SimpleOS

LXR

Navigation



Site hébergé par : enix

The LXR Cross Referencer for SOS

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Article:1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 6.5 ] [ 7 ] [ 7.5 ] [ 8 ] [ 9 ] [ 9.5 ]

Diff markup

Differences between /userland/fstest.c (Article 9.5) and /userland/fstest.c (Article 9)


001 /* Copyright (C) 2005 David Decotigny             001 /* Copyright (C) 2005 David Decotigny
002                                                   002 
003    This program is free software; you can redi    003    This program is free software; you can redistribute it and/or
004    modify it under the terms of the GNU Genera    004    modify it under the terms of the GNU General Public License
005    as published by the Free Software Foundatio    005    as published by the Free Software Foundation; either version 2
006    of the License, or (at your option) any lat    006    of the License, or (at your option) any later version.
007                                                   007    
008    This program is distributed in the hope tha    008    This program is distributed in the hope that it will be useful,
009    but WITHOUT ANY WARRANTY; without even the     009    but WITHOUT ANY WARRANTY; without even the implied warranty of
010    MERCHANTABILITY or FITNESS FOR A PARTICULAR    010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
011    GNU General Public License for more details    011    GNU General Public License for more details.
012                                                   012    
013    You should have received a copy of the GNU     013    You should have received a copy of the GNU General Public License
014    along with this program; if not, write to t    014    along with this program; if not, write to the Free Software
015    Foundation, Inc., 59 Temple Place - Suite 3    015    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
016    USA.                                           016    USA. 
017 */                                                017 */
018                                                   018 
019 #include <crt.h>                                  019 #include <crt.h>
020 #include <libc.h>                                 020 #include <libc.h>
021 #include <stdarg.h>                               021 #include <stdarg.h>
022 #include <string.h>                               022 #include <string.h>
023 #include <debug.h>                                023 #include <debug.h>
024                                                   024 
025 #include "fstest_utils.h"                         025 #include "fstest_utils.h"
026                                                   026 
027 #define OPEN_BASE_FD 3                            027 #define OPEN_BASE_FD 3
028                                                   028 
029 /**                                               029 /**
030  * @file fstest.c                                 030  * @file fstest.c
031  *                                                031  *
032  * File-system tests                              032  * File-system tests
033  */                                               033  */
034                                                   034 
035 int main(void)                                 !! 035 int main()
036 {                                                 036 {
037   int fd, len;                                    037   int fd, len;
038   char buff[256];                                 038   char buff[256];
039                                                   039 
040   bochs_printf("Hi from fstest\n");               040   bochs_printf("Hi from fstest\n");
041                                                   041   
042   ls("/", 1, 1);                                  042   ls("/", 1, 1);
043   ls(".", 1, 1);                                  043   ls(".", 1, 1);
044   ls("", 1, 1);                                   044   ls("", 1, 1);
045   ls(0, 1, 1);                                    045   ls(0, 1, 1);
046                                                   046 
047   TEST_EXPECT_CONDITION(fd = open("", 0),         047   TEST_EXPECT_CONDITION(fd = open("", 0),
048                         RETVAL < 0);              048                         RETVAL < 0);
049                                                   049 
050   TEST_EXPECT_CONDITION(fd = open(0, 0),          050   TEST_EXPECT_CONDITION(fd = open(0, 0),
051                         RETVAL < 0);              051                         RETVAL < 0);
052                                                   052 
053   TEST_EXPECT_CONDITION(fd = open("/", O_RDWR)    053   TEST_EXPECT_CONDITION(fd = open("/", O_RDWR),
054                         RETVAL == OPEN_BASE_FD    054                         RETVAL == OPEN_BASE_FD + 0);
055                                                   055 
056   TEST_EXPECT_CONDITION(fd = open("/", O_RDONL    056   TEST_EXPECT_CONDITION(fd = open("/", O_RDONLY),
057                         RETVAL == OPEN_BASE_FD    057                         RETVAL == OPEN_BASE_FD + 1);
058                                                   058 
059   TEST_EXPECT_CONDITION(fd = open("/", O_WRONL    059   TEST_EXPECT_CONDITION(fd = open("/", O_WRONLY),
060                         RETVAL == OPEN_BASE_FD    060                         RETVAL == OPEN_BASE_FD + 2);
061                                                   061 
062   TEST_EXPECT_CONDITION(close(OPEN_BASE_FD + 1    062   TEST_EXPECT_CONDITION(close(OPEN_BASE_FD + 1),
063                         RETVAL == 0);             063                         RETVAL == 0);
064                                                   064   
065   TEST_EXPECT_CONDITION(fd = open("/", O_WRONL    065   TEST_EXPECT_CONDITION(fd = open("/", O_WRONLY),
066                         RETVAL == OPEN_BASE_FD    066                         RETVAL == OPEN_BASE_FD + 1);
067                                                   067 
068   TEST_EXPECT_CONDITION(fd = open("//", O_WRON    068   TEST_EXPECT_CONDITION(fd = open("//", O_WRONLY),
069                         RETVAL == OPEN_BASE_FD    069                         RETVAL == OPEN_BASE_FD + 3);
070                                                   070 
071   TEST_EXPECT_CONDITION(fd = open("////////",     071   TEST_EXPECT_CONDITION(fd = open("////////", O_WRONLY),
072                         RETVAL == OPEN_BASE_FD    072                         RETVAL == OPEN_BASE_FD + 4);
073                                                   073 
074   TEST_EXPECT_CONDITION(fd = open("/does not e    074   TEST_EXPECT_CONDITION(fd = open("/does not exist", O_WRONLY),
075                         RETVAL < 0);              075                         RETVAL < 0);
076                                                   076 
077   TEST_EXPECT_CONDITION(fd = open("////does no    077   TEST_EXPECT_CONDITION(fd = open("////does not exist", O_WRONLY),
078                         RETVAL < 0);              078                         RETVAL < 0);
079                                                   079 
080   TEST_EXPECT_CONDITION(fd = open("/does not e    080   TEST_EXPECT_CONDITION(fd = open("/does not exist/", O_WRONLY),
081                         RETVAL < 0);              081                         RETVAL < 0);
082                                                   082 
083   TEST_EXPECT_CONDITION(fd = open("////does no    083   TEST_EXPECT_CONDITION(fd = open("////does not exist/", O_WRONLY),
084                         RETVAL < 0);              084                         RETVAL < 0);
085                                                   085 
086   TEST_EXPECT_CONDITION(fd = open("/does not e    086   TEST_EXPECT_CONDITION(fd = open("/does not exist////", O_WRONLY),
087                         RETVAL < 0);              087                         RETVAL < 0);
088                                                   088 
089   TEST_EXPECT_CONDITION(fd = open("////does no    089   TEST_EXPECT_CONDITION(fd = open("////does not exist/////", O_WRONLY),
090                         RETVAL < 0);              090                         RETVAL < 0);
091                                                   091 
092   TEST_EXPECT_CONDITION(fd = open("does not ex    092   TEST_EXPECT_CONDITION(fd = open("does not exist", O_WRONLY),
093                         RETVAL < 0);              093                         RETVAL < 0);
094                                                   094 
095   TEST_EXPECT_CONDITION(fd = open("does not ex    095   TEST_EXPECT_CONDITION(fd = open("does not exist/", O_WRONLY),
096                         RETVAL < 0);              096                         RETVAL < 0);
097                                                   097 
098   TEST_EXPECT_CONDITION(fd = open("does not ex    098   TEST_EXPECT_CONDITION(fd = open("does not exist////", O_WRONLY),
099                         RETVAL);                  099                         RETVAL);
100                                                   100 
101   TEST_EXPECT_CONDITION(fd = open("/does not e    101   TEST_EXPECT_CONDITION(fd = open("/does not exist/ab c d", O_WRONLY),
102                         RETVAL < 0);              102                         RETVAL < 0);
103                                                   103 
104   TEST_EXPECT_CONDITION(fd = open("////does no    104   TEST_EXPECT_CONDITION(fd = open("////does not exist/ab c d", O_WRONLY),
105                         RETVAL < 0);              105                         RETVAL < 0);
106                                                   106 
107   TEST_EXPECT_CONDITION(fd = open("/does not e    107   TEST_EXPECT_CONDITION(fd = open("/does not exist////ab c d", O_WRONLY),
108                         RETVAL < 0);              108                         RETVAL < 0);
109                                                   109 
110   TEST_EXPECT_CONDITION(fd = open("////does no    110   TEST_EXPECT_CONDITION(fd = open("////does not exist/////ab c d", O_WRONLY),
111                         RETVAL < 0);              111                         RETVAL < 0);
112                                                   112 
113   TEST_EXPECT_CONDITION(fd = open("does not ex    113   TEST_EXPECT_CONDITION(fd = open("does not exist", O_WRONLY),
114                         RETVAL < 0);              114                         RETVAL < 0);
115                                                   115 
116   TEST_EXPECT_CONDITION(fd = open("does not ex    116   TEST_EXPECT_CONDITION(fd = open("does not exist/ab c d", O_WRONLY),
117                         RETVAL < 0);              117                         RETVAL < 0);
118                                                   118 
119   TEST_EXPECT_CONDITION(fd = open("does not ex    119   TEST_EXPECT_CONDITION(fd = open("does not exist////ab c d", O_WRONLY),
120                         RETVAL < 0);              120                         RETVAL < 0);
121                                                   121 
122   TEST_EXPECT_CONDITION(fd = open("/", O_RDWR)    122   TEST_EXPECT_CONDITION(fd = open("/", O_RDWR),
123                         RETVAL == OPEN_BASE_FD    123                         RETVAL == OPEN_BASE_FD + 5);
124                                                   124 
125   TEST_EXPECT_CONDITION(fd = open("/tutu.txt",    125   TEST_EXPECT_CONDITION(fd = open("/tutu.txt", O_RDWR),
126                         RETVAL < 0);              126                         RETVAL < 0);
127                                                   127 
128   ls("/", 1, 1);                                  128   ls("/", 1, 1);
129                                                   129 
130   TEST_EXPECT_CONDITION(fd = open("/tutu.txt",    130   TEST_EXPECT_CONDITION(fd = open("/tutu.txt", O_RDWR | O_CREAT,
131                                   S_IRUSR | S_    131                                   S_IRUSR | S_IWUSR),
132                         RETVAL == OPEN_BASE_FD    132                         RETVAL == OPEN_BASE_FD + 6);
133                                                   133   
134   ls("/", 1, 1);                                  134   ls("/", 1, 1);
135                                                   135 
136   TEST_EXPECT_CONDITION(fd = open("tutu.txt",     136   TEST_EXPECT_CONDITION(fd = open("tutu.txt", O_RDWR | O_CREAT),
137                         RETVAL == OPEN_BASE_FD    137                         RETVAL == OPEN_BASE_FD + 7);
138                                                   138 
139   /* O_EXCL with an already-existing file */      139   /* O_EXCL with an already-existing file */
140   TEST_EXPECT_CONDITION(fd = open("tutu.txt",     140   TEST_EXPECT_CONDITION(fd = open("tutu.txt", O_RDWR | O_CREAT | O_EXCL),
141                         RETVAL < 0);              141                         RETVAL < 0);
142                                                   142 
143   TEST_EXPECT_CONDITION(fd = open("/toto.txt",    143   TEST_EXPECT_CONDITION(fd = open("/toto.txt", O_RDWR | O_CREAT | O_EXCL,
144                                   S_IRWXALL),     144                                   S_IRWXALL),
145                         RETVAL == OPEN_BASE_FD    145                         RETVAL == OPEN_BASE_FD + 8);
146                                                   146 
147   /* O_EXCL with an already-existing file */      147   /* O_EXCL with an already-existing file */
148   TEST_EXPECT_CONDITION(fd = open("toto.txt",     148   TEST_EXPECT_CONDITION(fd = open("toto.txt", O_RDWR | O_CREAT | O_EXCL),
149                         RETVAL < 0);              149                         RETVAL < 0);
150                                                   150 
151   TEST_EXPECT_CONDITION(fd = open("toto.txt",     151   TEST_EXPECT_CONDITION(fd = open("toto.txt", O_RDWR | O_CREAT,
152                                   S_IRUSR | S_    152                                   S_IRUSR | S_IWUSR),
153                         RETVAL == OPEN_BASE_FD    153                         RETVAL == OPEN_BASE_FD + 9);
154                                                   154 
155   /* Trailing slash on non-dir entries */         155   /* Trailing slash on non-dir entries */
156   TEST_EXPECT_CONDITION(fd = open("toto.txt/",    156   TEST_EXPECT_CONDITION(fd = open("toto.txt/", O_RDWR), RETVAL < 0);
157   TEST_EXPECT_CONDITION(fd = open("notdir/", O    157   TEST_EXPECT_CONDITION(fd = open("notdir/", O_RDWR | O_CREAT, S_IRWXALL),
158                         RETVAL < 0);              158                         RETVAL < 0);
159   TEST_EXPECT_CONDITION(fd = open("notdir/", O    159   TEST_EXPECT_CONDITION(fd = open("notdir/", O_RDWR), RETVAL < 0);
160                                                   160 
161   /* Substring match */                           161   /* Substring match */
162   TEST_EXPECT_CONDITION(fd = open("toto1.txt",    162   TEST_EXPECT_CONDITION(fd = open("toto1.txt", O_RDWR),
163                         RETVAL < 0);              163                         RETVAL < 0);
164   TEST_EXPECT_CONDITION(fd = open("toto1.tx",     164   TEST_EXPECT_CONDITION(fd = open("toto1.tx", O_RDWR | O_CREAT, S_IWUSR),
165                         RETVAL == OPEN_BASE_FD    165                         RETVAL == OPEN_BASE_FD + 10);
166                                                   166 
167   /* Substring match */                           167   /* Substring match */
168   TEST_EXPECT_CONDITION(fd = open("toto.tx", O    168   TEST_EXPECT_CONDITION(fd = open("toto.tx", O_RDWR),
169                         RETVAL < 0);              169                         RETVAL < 0);
170   TEST_EXPECT_CONDITION(fd = open("toto.tx", O    170   TEST_EXPECT_CONDITION(fd = open("toto.tx", O_RDWR | O_CREAT,
171                                   S_IRUSR | S_    171                                   S_IRUSR | S_IWUSR),
172                         RETVAL == OPEN_BASE_FD    172                         RETVAL == OPEN_BASE_FD + 11);
173                                                   173 
174   /*                                              174   /*
175    * read/write/seek                              175    * read/write/seek
176    */                                             176    */
177                                                   177 
178   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    178   TEST_EXPECT_CONDITION(len = read(fd, buff, 256),
179                         RETVAL == 0);             179                         RETVAL == 0);
180                                                   180 
181   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    181   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET),
182                         RETVAL == 0);             182                         RETVAL == 0);
183                                                   183 
184   strzcpy(buff, "Bonjour !", 256);                184   strzcpy(buff, "Bonjour !", 256);
185   TEST_EXPECT_CONDITION(len = write(fd, buff,     185   TEST_EXPECT_CONDITION(len = write(fd, buff, 10),
186                         RETVAL == 10);            186                         RETVAL == 10);
187                                                   187 
188   ls("/", 1, 1);                                  188   ls("/", 1, 1);
189                                                   189 
190   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    190   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET),
191                         RETVAL == 0);             191                         RETVAL == 0);
192                                                   192 
193   strzcpy(buff, "Garbage garbage garbage", 256    193   strzcpy(buff, "Garbage garbage garbage", 256);
194   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    194   TEST_EXPECT_CONDITION(len = read(fd, buff, 256),
195                         RETVAL == 10);            195                         RETVAL == 10);
196   bochs_printf("read s='%s'\n", buff);            196   bochs_printf("read s='%s'\n", buff);
197   TEST_EXPECT_CONDITION(strcmp("Bonjour !", bu    197   TEST_EXPECT_CONDITION(strcmp("Bonjour !", buff), RETVAL ==0);
198   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_CUR)    198   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_CUR), RETVAL == 10);
199                                                   199 
200   /*                                              200   /*
201    * truncate                                     201    * truncate
202    */                                             202    */
203                                                   203 
204   TEST_EXPECT_CONDITION(ftruncate(fd, 3), RETV    204   TEST_EXPECT_CONDITION(ftruncate(fd, 3), RETVAL == 0);
205                                                   205   
206   /* The current position should not have chan    206   /* The current position should not have changed */
207   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_CUR)    207   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_CUR), RETVAL == 10);
208                                                   208 
209   /* Make sure we cannot read anything because    209   /* Make sure we cannot read anything because we get past the end of
210      the file */                                  210      the file */
211   strzcpy(buff, "Garbage garbage garbage", 256    211   strzcpy(buff, "Garbage garbage garbage", 256);
212   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    212   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 0);
213                                                   213 
214   /* Now get back at the begining of the file     214   /* Now get back at the begining of the file */
215   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    215   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);
216                                                   216 
217   /* Make sure that we can read something with    217   /* Make sure that we can read something with the correct first 3
218      characters */                                218      characters */
219   strzcpy(buff, "Garbage garbage garbage", 256    219   strzcpy(buff, "Garbage garbage garbage", 256);
220   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    220   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 3);
221   bochs_printf("read s='%s'\n", buff);            221   bochs_printf("read s='%s'\n", buff);
222   TEST_EXPECT_CONDITION(strncmp("Bon", buff, l    222   TEST_EXPECT_CONDITION(strncmp("Bon", buff, len), RETVAL == 0);
223                                                   223 
224   /*                                              224   /*
225    * open mode                                    225    * open mode
226    */                                             226    */
227                                                   227 
228   ls("/", 1, 1);                                  228   ls("/", 1, 1);
229                                                   229 
230                                                   230 
231   /* Open r/w, create read-only */                231   /* Open r/w, create read-only */
232                                                   232 
233   TEST_EXPECT_CONDITION(fd = open("toto2.txt",    233   TEST_EXPECT_CONDITION(fd = open("toto2.txt", O_RDWR | O_CREAT, S_IRUSR),
234                         RETVAL == OPEN_BASE_FD    234                         RETVAL == OPEN_BASE_FD + 12);
235                                                   235 
236   strzcpy(buff, "Garbage garbage garbage", 256    236   strzcpy(buff, "Garbage garbage garbage", 256);
237   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    237   TEST_EXPECT_CONDITION(len = read(fd, buff, 256),
238                         RETVAL == 0);             238                         RETVAL == 0);
239                                                   239 
240   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    240   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);
241                                                   241 
242   strzcpy(buff, "Permission denied", 256);        242   strzcpy(buff, "Permission denied", 256);
243   TEST_EXPECT_CONDITION(len = write(fd, buff,     243   TEST_EXPECT_CONDITION(len = write(fd, buff, 10),
244                         RETVAL < 0); /* Permis    244                         RETVAL < 0); /* Permission denied ! */
245                                                   245 
246   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    246   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);
247                                                   247 
248   strzcpy(buff, "Garbage garbage garbage", 256    248   strzcpy(buff, "Garbage garbage garbage", 256);
249   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    249   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 0);
250                                                   250 
251   /* Open read-only, create r/w */                251   /* Open read-only, create r/w */
252                                                   252 
253   TEST_EXPECT_CONDITION(fd = open("toto3.txt",    253   TEST_EXPECT_CONDITION(fd = open("toto3.txt", O_RDONLY | O_CREAT,
254                                   S_IRUSR | S_    254                                   S_IRUSR | S_IWUSR),
255                         RETVAL == OPEN_BASE_FD    255                         RETVAL == OPEN_BASE_FD + 13);
256                                                   256 
257   strzcpy(buff, "Garbage garbage garbage", 256    257   strzcpy(buff, "Garbage garbage garbage", 256);
258   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    258   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 0);
259                                                   259 
260   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    260   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
261                                                   261 
262   strzcpy(buff, "Permission denied 2", 256);      262   strzcpy(buff, "Permission denied 2", 256);
263   TEST_EXPECT_CONDITION(len = write(fd, buff,     263   TEST_EXPECT_CONDITION(len = write(fd, buff, 10),
264                         RETVAL < 0); /* Permis    264                         RETVAL < 0); /* Permission denied ! */
265                                                   265 
266   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    266   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
267                                                   267 
268   strzcpy(buff, "Garbage garbage garbage", 256    268   strzcpy(buff, "Garbage garbage garbage", 256);
269   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    269   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 0);
270                                                   270 
271   /* Create another process that chdirs in it     271   /* Create another process that chdirs in it */
272   if (fork() == 0)                                272   if (fork() == 0)
273     {                                             273     {
274       bochs_printf("Hello from child\n");         274       bochs_printf("Hello from child\n");
275       TEST_EXPECT_CONDITION(fd = open("shrd.tx    275       TEST_EXPECT_CONDITION(fd = open("shrd.txt", O_RDWR | O_CREAT, S_IRWXALL),
276                             RETVAL == OPEN_BAS    276                             RETVAL == OPEN_BASE_FD + 14);
277       strzcpy(buff, "Hello from child !", 256)    277       strzcpy(buff, "Hello from child !", 256);
278       TEST_EXPECT_CONDITION(len = write(fd, bu    278       TEST_EXPECT_CONDITION(len = write(fd, buff, 19),
279                             RETVAL == 19);        279                             RETVAL == 19);
280       TEST_EXPECT_CONDITION(close(fd), RETVAL     280       TEST_EXPECT_CONDITION(close(fd), RETVAL == 0);
281       bochs_printf("Bye from child\n");           281       bochs_printf("Bye from child\n");
282       return 0;                                   282       return 0;
283     }                                             283     }
284                                                   284 
285   bochs_printf("Father sleeping\n");              285   bochs_printf("Father sleeping\n");
286   nanosleep(1, 0);                                286   nanosleep(1, 0);
287   ls("/", 1, 1);                                  287   ls("/", 1, 1);
288   TEST_EXPECT_CONDITION(fd = open("shrd.txt",     288   TEST_EXPECT_CONDITION(fd = open("shrd.txt", O_RDONLY),
289                         RETVAL == OPEN_BASE_FD    289                         RETVAL == OPEN_BASE_FD + 14);
290   strzcpy(buff, "Garbage garbage garbage", 256    290   strzcpy(buff, "Garbage garbage garbage", 256);
291   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    291   TEST_EXPECT_CONDITION(len = read(fd, buff, 256),
292                         RETVAL == 19);            292                         RETVAL == 19);
293   bochs_printf("read s='%s'\n", buff);            293   bochs_printf("read s='%s'\n", buff);
294   TEST_EXPECT_CONDITION(strncmp("Hello from ch    294   TEST_EXPECT_CONDITION(strncmp("Hello from child !", buff, len),
295                         RETVAL == 0);             295                         RETVAL == 0);
296   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0    296   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0);
297   TEST_EXPECT_CONDITION(unlink("shrd.txt"), RE    297   TEST_EXPECT_CONDITION(unlink("shrd.txt"), RETVAL == 0);
298   ls("/", 1, 1);                                  298   ls("/", 1, 1);
299                                                   299 
300   /*                                              300   /*
301    * ioctl / fcntl                                301    * ioctl / fcntl
302    */                                             302    */
303                                                   303 
304   TEST_EXPECT_CONDITION(fcntl(fd, 2, 3), RETVA    304   TEST_EXPECT_CONDITION(fcntl(fd, 2, 3), RETVAL < 0); /* Not supported
305                                                   305                                                          by virtfs */
306   TEST_EXPECT_CONDITION(ioctl(fd, 2, 3), RETVA    306   TEST_EXPECT_CONDITION(ioctl(fd, 2, 3), RETVAL < 0); /* Not supported
307                                                   307                                                          by virtfs */
308                                                   308 
309   ls("/", 1, 1);                                  309   ls("/", 1, 1);
310                                                   310 
311   /*                                              311   /*
312    * creat/link/unlink/symlink                    312    * creat/link/unlink/symlink
313    */                                             313    */
314   TEST_EXPECT_CONDITION(creat("toto4.txt", S_I    314   TEST_EXPECT_CONDITION(creat("toto4.txt", S_IRUSR), RETVAL == 0);
315   TEST_EXPECT_CONDITION(creat("toto4.txt", S_I    315   TEST_EXPECT_CONDITION(creat("toto4.txt", S_IRWXALL), RETVAL < 0); /*EEXIST*/
316   TEST_EXPECT_CONDITION(link("toto4.txt", "tot    316   TEST_EXPECT_CONDITION(link("toto4.txt", "toto5.txt"), RETVAL == 0);
317   TEST_EXPECT_CONDITION(link("toto4.txt", "tot    317   TEST_EXPECT_CONDITION(link("toto4.txt", "toto5.txt"), RETVAL < 0); /*EEXIST*/
318   TEST_EXPECT_CONDITION(link("toto4.txt", "tot    318   TEST_EXPECT_CONDITION(link("toto4.txt", "toto.txt"), RETVAL < 0); /*EEXIST*/
319   ls("/", 1, 1);                                  319   ls("/", 1, 1);
320   TEST_EXPECT_CONDITION(chmod("toto5.txt", S_I    320   TEST_EXPECT_CONDITION(chmod("toto5.txt", S_IRUSR | S_IWUSR), RETVAL == 0);
321   ls("/", 1, 1);                                  321   ls("/", 1, 1);
322                                                   322 
323   TEST_EXPECT_CONDITION(fd = open("toto5.txt",    323   TEST_EXPECT_CONDITION(fd = open("toto5.txt", O_RDWR),
324                         RETVAL == OPEN_BASE_FD    324                         RETVAL == OPEN_BASE_FD + 14);
325   strzcpy(buff, "Garbage garbage garbage", 256    325   strzcpy(buff, "Garbage garbage garbage", 256);
326   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    326   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 0);
327                                                   327 
328   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    328   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
329                                                   329 
330   strzcpy(buff, "Hello world from toto5", 256)    330   strzcpy(buff, "Hello world from toto5", 256);
331   TEST_EXPECT_CONDITION(len = write(fd, buff,     331   TEST_EXPECT_CONDITION(len = write(fd, buff, 24), RETVAL == 24);
332                                                   332 
333   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    333   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
334                                                   334 
335   strzcpy(buff, "Garbage garbage garbage", 256    335   strzcpy(buff, "Garbage garbage garbage", 256);
336   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    336   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 24);
337   bochs_printf("read s='%s'\n", buff);            337   bochs_printf("read s='%s'\n", buff);
338                                                   338 
339   TEST_EXPECT_CONDITION(fd = open("toto4.txt",    339   TEST_EXPECT_CONDITION(fd = open("toto4.txt", O_RDWR),
340                         RETVAL == OPEN_BASE_FD    340                         RETVAL == OPEN_BASE_FD + 15);
341   strzcpy(buff, "Garbage garbage garbage", 256    341   strzcpy(buff, "Garbage garbage garbage", 256);
342   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    342   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 24);
343   bochs_printf("read s='%s'\n", buff);            343   bochs_printf("read s='%s'\n", buff);
344                                                   344 
345   ls("/", 1, 1);                                  345   ls("/", 1, 1);
346                                                   346 
347   TEST_EXPECT_CONDITION(link("dangling", "toto    347   TEST_EXPECT_CONDITION(link("dangling", "toto42.txt"), RETVAL < 0); /*ENOENT*/
348   TEST_EXPECT_CONDITION(unlink("toto4.txt"), R    348   TEST_EXPECT_CONDITION(unlink("toto4.txt"), RETVAL == 0);
349   TEST_EXPECT_CONDITION(unlink("toto42.txt"),     349   TEST_EXPECT_CONDITION(unlink("toto42.txt"), RETVAL < 0); /* ENOENT */
350   TEST_EXPECT_CONDITION(unlink("toto4.txt"), R    350   TEST_EXPECT_CONDITION(unlink("toto4.txt"), RETVAL < 0); /* ENOENT */
351   TEST_EXPECT_CONDITION(creat("toto4.txt", S_I    351   TEST_EXPECT_CONDITION(creat("toto4.txt", S_IWUSR | S_IRUSR), RETVAL == 0);
352   TEST_EXPECT_CONDITION(unlink("toto5.txt/"),     352   TEST_EXPECT_CONDITION(unlink("toto5.txt/"), RETVAL < 0); /* EISDIR ? */
353   TEST_EXPECT_CONDITION(rmdir("toto5.txt/"), R    353   TEST_EXPECT_CONDITION(rmdir("toto5.txt/"), RETVAL < 0); /* ENOTDIR ? */
354   TEST_EXPECT_CONDITION(rmdir("toto5.txt"), RE    354   TEST_EXPECT_CONDITION(rmdir("toto5.txt"), RETVAL < 0); /* ENOTDIR ? */
355   TEST_EXPECT_CONDITION(unlink("toto5.txt"), R    355   TEST_EXPECT_CONDITION(unlink("toto5.txt"), RETVAL == 0);
356   TEST_EXPECT_CONDITION(unlink("toto5.txt"), R    356   TEST_EXPECT_CONDITION(unlink("toto5.txt"), RETVAL < 0); /* ENOENT */
357   TEST_EXPECT_CONDITION(creat("toto4.txt", S_I    357   TEST_EXPECT_CONDITION(creat("toto4.txt", S_IRWXALL), RETVAL < 0); /*EEXIST*/
358                                                   358 
359   ls("/", 1, 1);                                  359   ls("/", 1, 1);
360                                                   360 
361   /* Change symlinks */                           361   /* Change symlinks */
362   TEST_EXPECT_CONDITION(symlink("toto4.txt", "    362   TEST_EXPECT_CONDITION(symlink("toto4.txt", "toto5.txt"), RETVAL == 0);
363   TEST_EXPECT_CONDITION(symlink("toto4.txt", "    363   TEST_EXPECT_CONDITION(symlink("toto4.txt", "toto5.txt"), RETVAL < 0); /*EEXIST*/
364   TEST_EXPECT_CONDITION(symlink("toto4.txt", "    364   TEST_EXPECT_CONDITION(symlink("toto4.txt", "toto.txt"), RETVAL < 0); /*EEXIST*/
365                                                   365 
366   ls("/", 1, 1);                                  366   ls("/", 1, 1);
367                                                   367 
368   TEST_EXPECT_CONDITION(fd = open("toto5.txt",    368   TEST_EXPECT_CONDITION(fd = open("toto5.txt", O_RDWR),
369                         RETVAL == OPEN_BASE_FD    369                         RETVAL == OPEN_BASE_FD + 16);
370   strzcpy(buff, "Garbage garbage garbage", 256    370   strzcpy(buff, "Garbage garbage garbage", 256);
371   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    371   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 0);
372                                                   372 
373   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    373   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
374                                                   374 
375   strzcpy(buff, "Hello world from toto5", 256)    375   strzcpy(buff, "Hello world from toto5", 256);
376   TEST_EXPECT_CONDITION(len = write(fd, buff,     376   TEST_EXPECT_CONDITION(len = write(fd, buff, 24), RETVAL == 24);
377                                                   377 
378   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    378   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
379                                                   379 
380   strzcpy(buff, "Garbage garbage garbage", 256    380   strzcpy(buff, "Garbage garbage garbage", 256);
381   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    381   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 24);
382   bochs_printf("read s='%s'\n", buff);            382   bochs_printf("read s='%s'\n", buff);
383   TEST_EXPECT_CONDITION(strcmp(buff, "Hello wo    383   TEST_EXPECT_CONDITION(strcmp(buff, "Hello world from toto5"), RETVAL == 0);
384                                                   384 
385   TEST_EXPECT_CONDITION(fd = open("toto4.txt",    385   TEST_EXPECT_CONDITION(fd = open("toto4.txt", O_RDWR),
386                         RETVAL == OPEN_BASE_FD    386                         RETVAL == OPEN_BASE_FD + 17);
387   strzcpy(buff, "Garbage garbage garbage", 256    387   strzcpy(buff, "Garbage garbage garbage", 256);
388   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    388   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 24);
389   bochs_printf("read s='%s'\n", buff);            389   bochs_printf("read s='%s'\n", buff);
390   TEST_EXPECT_CONDITION(strcmp(buff, "Hello wo    390   TEST_EXPECT_CONDITION(strcmp(buff, "Hello world from toto5"), RETVAL == 0);
391                                                   391 
392                                                   392 
393   TEST_EXPECT_CONDITION(symlink("dangling", "t    393   TEST_EXPECT_CONDITION(symlink("dangling", "toto6.txt"), RETVAL == 0);
394   TEST_EXPECT_CONDITION(symlink("dangling", "t    394   TEST_EXPECT_CONDITION(symlink("dangling", "toto6.txt"), RETVAL < 0); /*EEXIST*/
395                                                   395 
396   TEST_EXPECT_CONDITION(fd = open("toto6.txt",    396   TEST_EXPECT_CONDITION(fd = open("toto6.txt", O_RDWR), RETVAL < 0);
397   TEST_EXPECT_CONDITION(fd = open("toto6.txt",    397   TEST_EXPECT_CONDITION(fd = open("toto6.txt", O_RDWR | O_NOFOLLOW),
398                         RETVAL == OPEN_BASE_FD    398                         RETVAL == OPEN_BASE_FD + 18);
399   strzcpy(buff, "Garbage garbage garbage", 256    399   strzcpy(buff, "Garbage garbage garbage", 256);
400   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    400   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 8);
401   bochs_printf("read s='%s'\n", buff);            401   bochs_printf("read s='%s'\n", buff);
402   TEST_EXPECT_CONDITION(strncmp(buff, "danglin    402   TEST_EXPECT_CONDITION(strncmp(buff, "dangling", len), RETVAL == 0);
403                                                   403 
404   ls("/", 1, 1);                                  404   ls("/", 1, 1);
405                                                   405 
406   /* mkdir/rmdir */                               406   /* mkdir/rmdir */
407                                                   407 
408   TEST_EXPECT_CONDITION(mkdir("yo1", S_IRUSR |    408   TEST_EXPECT_CONDITION(mkdir("yo1", S_IRUSR | S_IXUSR), RETVAL == 0);
409   TEST_EXPECT_CONDITION(mkdir("yo1", S_IRWXALL    409   TEST_EXPECT_CONDITION(mkdir("yo1", S_IRWXALL), RETVAL < 0); /*EEXIST*/
410                                                   410 
411   ls("/", 1, 1);                                  411   ls("/", 1, 1);
412                                                   412 
413   TEST_EXPECT_CONDITION(unlink("yo1"), RETVAL     413   TEST_EXPECT_CONDITION(unlink("yo1"), RETVAL < 0); /*EISDIR*/
414   TEST_EXPECT_CONDITION(unlink("yo1/"), RETVAL    414   TEST_EXPECT_CONDITION(unlink("yo1/"), RETVAL < 0); /*EISDIR*/
415   TEST_EXPECT_CONDITION(rmdir("yo1"), RETVAL =    415   TEST_EXPECT_CONDITION(rmdir("yo1"), RETVAL == 0);
416   TEST_EXPECT_CONDITION(rmdir("yo1"), RETVAL <    416   TEST_EXPECT_CONDITION(rmdir("yo1"), RETVAL < 0); /*ENOENT*/
417   TEST_EXPECT_CONDITION(rmdir("yoda"), RETVAL     417   TEST_EXPECT_CONDITION(rmdir("yoda"), RETVAL < 0); /*ENOENT*/
418                                                   418 
419   ls("/", 1, 1);                                  419   ls("/", 1, 1);
420                                                   420 
421   TEST_EXPECT_CONDITION(mkdir("yoplait1", S_IR    421   TEST_EXPECT_CONDITION(mkdir("yoplait1", S_IRWXALL), RETVAL == 0);
422   TEST_EXPECT_CONDITION(rename("yoplait1", "mo    422   TEST_EXPECT_CONDITION(rename("yoplait1", "mouf1"), RETVAL == 0);
423   TEST_EXPECT_CONDITION(fd = open("mouf1/a", O    423   TEST_EXPECT_CONDITION(fd = open("mouf1/a", O_RDWR | O_CREAT, S_IRWXALL),
424                         RETVAL == OPEN_BASE_FD    424                         RETVAL == OPEN_BASE_FD + 19);
425   TEST_EXPECT_CONDITION(unlink("mouf1/a"), RET    425   TEST_EXPECT_CONDITION(unlink("mouf1/a"), RETVAL == 0);
426   TEST_EXPECT_CONDITION(rmdir("mouf1"), RETVAL    426   TEST_EXPECT_CONDITION(rmdir("mouf1"), RETVAL == 0);
427                                                   427 
428   TEST_EXPECT_CONDITION(mkdir("yoplait2", S_IR    428   TEST_EXPECT_CONDITION(mkdir("yoplait2", S_IRWXALL), RETVAL == 0);
429   TEST_EXPECT_CONDITION(rename("yoplait2", "mo    429   TEST_EXPECT_CONDITION(rename("yoplait2", "mouf2"), RETVAL == 0);
430   TEST_EXPECT_CONDITION(fd = open("mouf2/a", O    430   TEST_EXPECT_CONDITION(fd = open("mouf2/a", O_RDWR | O_CREAT, S_IRWXALL),
431                         RETVAL == OPEN_BASE_FD    431                         RETVAL == OPEN_BASE_FD + 20);
432   TEST_EXPECT_CONDITION(rmdir("mouf2"), RETVAL    432   TEST_EXPECT_CONDITION(rmdir("mouf2"), RETVAL < 0);
433                                                   433 
434   TEST_EXPECT_CONDITION(mkdir("yoplait3", S_IR    434   TEST_EXPECT_CONDITION(mkdir("yoplait3", S_IRWXALL), RETVAL == 0);
435   TEST_EXPECT_CONDITION(rename("yoplait3", "mo    435   TEST_EXPECT_CONDITION(rename("yoplait3", "mouf3"), RETVAL == 0);
436   TEST_EXPECT_CONDITION(creat("mouf3/a", S_IRW    436   TEST_EXPECT_CONDITION(creat("mouf3/a", S_IRWXALL), RETVAL == 0);
437   TEST_EXPECT_CONDITION(unlink("mouf3/a"), RET    437   TEST_EXPECT_CONDITION(unlink("mouf3/a"), RETVAL == 0);
438   TEST_EXPECT_CONDITION(rmdir("mouf3"), RETVAL    438   TEST_EXPECT_CONDITION(rmdir("mouf3"), RETVAL == 0);
439                                                   439 
440   TEST_EXPECT_CONDITION(mkdir("yoplait4", S_IR    440   TEST_EXPECT_CONDITION(mkdir("yoplait4", S_IRWXALL), RETVAL == 0);
441   TEST_EXPECT_CONDITION(rename("yoplait4", "mo    441   TEST_EXPECT_CONDITION(rename("yoplait4", "mouf4"), RETVAL == 0);
442   TEST_EXPECT_CONDITION(creat("mouf4/a", S_IRW    442   TEST_EXPECT_CONDITION(creat("mouf4/a", S_IRWXALL), RETVAL == 0);
443   TEST_EXPECT_CONDITION(rmdir("mouf4"), RETVAL    443   TEST_EXPECT_CONDITION(rmdir("mouf4"), RETVAL < 0);
444                                                   444 
445   ls("/", 1, 1);                                  445   ls("/", 1, 1);
446                                                   446 
447   /* Not supported by virtfs */                   447   /* Not supported by virtfs */
448   TEST_EXPECT_CONDITION(mknod("dev1", S_IRWXAL    448   TEST_EXPECT_CONDITION(mknod("dev1", S_IRWXALL, S_IFCHR, 420, 268),
449                         RETVAL == 0);             449                         RETVAL == 0);
450   /* Make sure the device cannot be opened (no    450   /* Make sure the device cannot be opened (no device should be
451      associated to it */                          451      associated to it */
452   TEST_EXPECT_CONDITION(open("dev1", O_RDONLY)    452   TEST_EXPECT_CONDITION(open("dev1", O_RDONLY), RETVAL < 0);
453   TEST_EXPECT_CONDITION(unlink("dev1"), RETVAL    453   TEST_EXPECT_CONDITION(unlink("dev1"), RETVAL == 0);
454                                                   454 
455   ls("/", 1, 1);                                  455   ls("/", 1, 1);
456   ls("..", 1, 1);                                 456   ls("..", 1, 1);
457   ls("../", 1, 1);                                457   ls("../", 1, 1);
458   ls("/..", 1, 1);                                458   ls("/..", 1, 1);
459                                                   459 
460   /* subdirs */                                   460   /* subdirs */
461   TEST_EXPECT_CONDITION(fd = open("yo1/titi1.t    461   TEST_EXPECT_CONDITION(fd = open("yo1/titi1.txt", O_RDONLY), RETVAL < 0);
462   TEST_EXPECT_CONDITION(fd = open("yo1/titi1.t    462   TEST_EXPECT_CONDITION(fd = open("yo1/titi1.txt", O_RDONLY | O_CREAT,
463                                   S_IRUSR), RE    463                                   S_IRUSR), RETVAL < 0);
464                                                   464 
465   ls("/", 1, 1);                                  465   ls("/", 1, 1);
466   ls("/yo1", 1, 1);                               466   ls("/yo1", 1, 1);
467                                                   467 
468   TEST_EXPECT_CONDITION(mkdir("yo1", S_IRWXALL    468   TEST_EXPECT_CONDITION(mkdir("yo1", S_IRWXALL), RETVAL == 0);
469   TEST_EXPECT_CONDITION(fd = open("yo1/titi1.t    469   TEST_EXPECT_CONDITION(fd = open("yo1/titi1.txt", O_RDONLY), RETVAL < 0);
470   TEST_EXPECT_CONDITION(fd = open("yo1/titi1.t    470   TEST_EXPECT_CONDITION(fd = open("yo1/titi1.txt", O_RDONLY | O_CREAT,
471                                   S_IRUSR), RE    471                                   S_IRUSR), RETVAL == OPEN_BASE_FD + 21);
472                                                   472 
473   ls("/", 1, 1);                                  473   ls("/", 1, 1);
474   ls("/yo1", 1, 1);                               474   ls("/yo1", 1, 1);
475                                                   475 
476   TEST_EXPECT_CONDITION(mkdir("yo2", S_IRUSR |    476   TEST_EXPECT_CONDITION(mkdir("yo2", S_IRUSR | S_IXUSR), RETVAL == 0);
477   TEST_EXPECT_CONDITION(fd = open("yo2/titi1.t    477   TEST_EXPECT_CONDITION(fd = open("yo2/titi1.txt", O_RDONLY), RETVAL < 0);
478   TEST_EXPECT_CONDITION(fd = open("yo2/titi1.t    478   TEST_EXPECT_CONDITION(fd = open("yo2/titi1.txt", O_RDONLY | O_CREAT,
479                                   S_IRUSR), RE    479                                   S_IRUSR), RETVAL < 0);
480                                                   480 
481   ls("/", 1, 1);                                  481   ls("/", 1, 1);
482                                                   482 
483   TEST_EXPECT_CONDITION(mkdir("yo3", S_IWUSR |    483   TEST_EXPECT_CONDITION(mkdir("yo3", S_IWUSR | S_IXUSR), RETVAL == 0);
484   TEST_EXPECT_CONDITION(fd = open("yo3/titi1.t    484   TEST_EXPECT_CONDITION(fd = open("yo3/titi1.txt", O_RDONLY), RETVAL < 0);
485   TEST_EXPECT_CONDITION(fd = open("yo3/titi1.t    485   TEST_EXPECT_CONDITION(fd = open("yo3/titi1.txt", O_RDONLY | O_CREAT,
486                                   S_IRUSR), RE    486                                   S_IRUSR), RETVAL == OPEN_BASE_FD + 22);
487                                                   487 
488   ls("/", 1, 1);                                  488   ls("/", 1, 1);
489                                                   489 
490   TEST_EXPECT_CONDITION(mkdir("yo4", S_IWUSR),    490   TEST_EXPECT_CONDITION(mkdir("yo4", S_IWUSR), RETVAL == 0);
491   TEST_EXPECT_CONDITION(fd = open("yo4/titi1.t    491   TEST_EXPECT_CONDITION(fd = open("yo4/titi1.txt", O_RDONLY), RETVAL < 0);
492   TEST_EXPECT_CONDITION(fd = open("yo4/titi1.t    492   TEST_EXPECT_CONDITION(fd = open("yo4/titi1.txt", O_RDONLY | O_CREAT,
493                                   S_IRUSR), RE    493                                   S_IRUSR), RETVAL < 0);
494                                                   494 
495   ls("/", 1, 1);                                  495   ls("/", 1, 1);
496                                                   496 
497   TEST_EXPECT_CONDITION(chdir("nowhere"), RETV    497   TEST_EXPECT_CONDITION(chdir("nowhere"), RETVAL < 0);
498   TEST_EXPECT_CONDITION(chdir("yo1"), RETVAL =    498   TEST_EXPECT_CONDITION(chdir("yo1"), RETVAL == 0);
499                                                   499 
500   ls(".", 1, 1);                                  500   ls(".", 1, 1);
501   ls("/", 1, 1);                                  501   ls("/", 1, 1);
502   ls("..", 1, 1);                                 502   ls("..", 1, 1);
503   ls("../../../../", 1, 1);                       503   ls("../../../../", 1, 1);
504   ls("/../../../../", 1, 1);                      504   ls("/../../../../", 1, 1);
505                                                   505 
506   /* Test chroot */                               506   /* Test chroot */
507                                                   507 
508   TEST_EXPECT_CONDITION(chroot("nowhere"), RET    508   TEST_EXPECT_CONDITION(chroot("nowhere"), RETVAL < 0);
509   TEST_EXPECT_CONDITION(chroot("."), RETVAL ==    509   TEST_EXPECT_CONDITION(chroot("."), RETVAL == 0);
510   ls(".", 1, 1);                                  510   ls(".", 1, 1);
511   ls("/", 1, 1);                                  511   ls("/", 1, 1);
512   ls("..", 1, 1);                                 512   ls("..", 1, 1);
513   ls("../../../../", 1, 1);                       513   ls("../../../../", 1, 1);
514   ls("/../../../../", 1, 1);                      514   ls("/../../../../", 1, 1);
515                                                   515 
516   /* mount */                                     516   /* mount */
517   TEST_EXPECT_CONDITION(mount(NULL, "nowhere",    517   TEST_EXPECT_CONDITION(mount(NULL, "nowhere", NULL, 0, NULL), RETVAL < 0);
518   TEST_EXPECT_CONDITION(mount(NULL, "nowhere",    518   TEST_EXPECT_CONDITION(mount(NULL, "nowhere", "yoplait", 0, NULL), RETVAL < 0);
519   TEST_EXPECT_CONDITION(mount(NULL, "nowhere",    519   TEST_EXPECT_CONDITION(mount(NULL, "nowhere", "virtfs", 0, NULL), RETVAL < 0);
520                                                   520 
521   TEST_EXPECT_CONDITION(mkdir("mnt", S_IRWXALL    521   TEST_EXPECT_CONDITION(mkdir("mnt", S_IRWXALL), RETVAL == 0);
522   TEST_EXPECT_CONDITION(mkdir("mnt/subdir0", S    522   TEST_EXPECT_CONDITION(mkdir("mnt/subdir0", S_IRWXALL), RETVAL == 0);
523   ls("/", 1, 1);                                  523   ls("/", 1, 1);
524   TEST_EXPECT_CONDITION(mount(NULL, "mnt", "vi    524   TEST_EXPECT_CONDITION(mount(NULL, "mnt", "virtfs", 0, NULL), RETVAL == 0);
525   ls("/", 1, 1);                                  525   ls("/", 1, 1);
526   TEST_EXPECT_CONDITION(mkdir("mnt/subdir_moun    526   TEST_EXPECT_CONDITION(mkdir("mnt/subdir_mounted", S_IRWXALL), RETVAL == 0);
527   ls("/", 1, 1);                                  527   ls("/", 1, 1);
528                                                   528 
529   /* Make sure we cannot umount if the FS is i    529   /* Make sure we cannot umount if the FS is in use */
530   TEST_EXPECT_CONDITION(fd = open("mnt/subdir_    530   TEST_EXPECT_CONDITION(fd = open("mnt/subdir_mounted", O_DIRECTORY),
531                         RETVAL == OPEN_BASE_FD    531                         RETVAL == OPEN_BASE_FD + 23);
532   TEST_EXPECT_CONDITION(umount("mnt"), RETVAL     532   TEST_EXPECT_CONDITION(umount("mnt"), RETVAL < 0);
533   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0    533   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0);
534                                                   534 
535   /* Make sure we cannot umount if the FS is i    535   /* Make sure we cannot umount if the FS is in use */
536   TEST_EXPECT_CONDITION(chdir("mnt"), RETVAL =    536   TEST_EXPECT_CONDITION(chdir("mnt"), RETVAL == 0);
537   TEST_EXPECT_CONDITION(umount("/mnt"), RETVAL    537   TEST_EXPECT_CONDITION(umount("/mnt"), RETVAL < 0);
538   TEST_EXPECT_CONDITION(chdir(".."), RETVAL ==    538   TEST_EXPECT_CONDITION(chdir(".."), RETVAL == 0);
539   ls(".", 1, 1);                                  539   ls(".", 1, 1);
540                                                   540   
541   /* Create another process that chdirs in it     541   /* Create another process that chdirs in it */
542   if (fork() == 0)                                542   if (fork() == 0)
543     {                                             543     {
544       bochs_printf("Hello from child\n");         544       bochs_printf("Hello from child\n");
545       TEST_EXPECT_CONDITION(chdir("mnt"), RETV    545       TEST_EXPECT_CONDITION(chdir("mnt"), RETVAL == 0);
546       TEST_EXPECT_CONDITION(fd = open("subdir_    546       TEST_EXPECT_CONDITION(fd = open("subdir_mounted", O_DIRECTORY),
547                             RETVAL == OPEN_BAS    547                             RETVAL == OPEN_BASE_FD + 23);
548       bochs_printf("Child sleeping...\n");        548       bochs_printf("Child sleeping...\n");
549       nanosleep(2, 0);                            549       nanosleep(2, 0);
550       bochs_printf("Bye from child\n");           550       bochs_printf("Bye from child\n");
551       return 0;                                   551       return 0;
552     }                                             552     }
553   else                                            553   else
554     {                                             554     {
555       bochs_printf("Father sleeping\n");          555       bochs_printf("Father sleeping\n");
556       nanosleep(1, 0);                            556       nanosleep(1, 0);
557       bochs_printf("Father trying to umount, s    557       bochs_printf("Father trying to umount, should fail (a process chdir'ed in it)\n");
558       TEST_EXPECT_CONDITION(umount("mnt"), RET    558       TEST_EXPECT_CONDITION(umount("mnt"), RETVAL < 0);
559       bochs_printf("Father Resuming normal ope    559       bochs_printf("Father Resuming normal operation in 3s...\n");
560       nanosleep(3, 0);                            560       nanosleep(3, 0);
561     }                                             561     }
562                                                   562 
563   TEST_EXPECT_CONDITION(umount(NULL), RETVAL <    563   TEST_EXPECT_CONDITION(umount(NULL), RETVAL < 0);
564   TEST_EXPECT_CONDITION(umount("nowhere"), RET    564   TEST_EXPECT_CONDITION(umount("nowhere"), RETVAL < 0);
565   ls("/", 1, 1);                                  565   ls("/", 1, 1);
566   TEST_EXPECT_CONDITION(umount("mnt"), RETVAL     566   TEST_EXPECT_CONDITION(umount("mnt"), RETVAL == 0);
567   ls("/", 1, 1);                                  567   ls("/", 1, 1);
568   TEST_EXPECT_CONDITION(umount("mnt"), RETVAL     568   TEST_EXPECT_CONDITION(umount("mnt"), RETVAL < 0);
569                                                   569 
570   /*                                              570   /*
571    * Mountchain exploration                       571    * Mountchain exploration
572    */                                             572    */
573   TEST_EXPECT_CONDITION(mkdir("/mnt2", S_IRWXA    573   TEST_EXPECT_CONDITION(mkdir("/mnt2", S_IRWXALL), RETVAL == 0);
574   TEST_EXPECT_CONDITION(mkdir("/mnt2/nothing-m    574   TEST_EXPECT_CONDITION(mkdir("/mnt2/nothing-mounted", S_IRWXALL), RETVAL == 0);
575   TEST_EXPECT_CONDITION(mount(NULL, "mnt2", "v    575   TEST_EXPECT_CONDITION(mount(NULL, "mnt2", "virtfs", 0, NULL), RETVAL == 0);
576   TEST_EXPECT_CONDITION(mkdir("/mnt2/mountpoin    576   TEST_EXPECT_CONDITION(mkdir("/mnt2/mountpoint-1", S_IRWXALL), RETVAL == 0);
577   TEST_EXPECT_CONDITION(mount(NULL, "mnt2", "v    577   TEST_EXPECT_CONDITION(mount(NULL, "mnt2", "virtfs", 0, NULL), RETVAL == 0);
578   TEST_EXPECT_CONDITION(mkdir("/mnt2/mountpoin    578   TEST_EXPECT_CONDITION(mkdir("/mnt2/mountpoint-2", S_IRWXALL), RETVAL == 0);
579   ls("/", 1, 1);                                  579   ls("/", 1, 1);
580   TEST_EXPECT_CONDITION(umount("mnt2"), RETVAL    580   TEST_EXPECT_CONDITION(umount("mnt2"), RETVAL == 0);
581   ls("/", 1, 1);                                  581   ls("/", 1, 1);
582   TEST_EXPECT_CONDITION(umount("mnt2"), RETVAL    582   TEST_EXPECT_CONDITION(umount("mnt2"), RETVAL == 0);
583   ls("/", 1, 1);                                  583   ls("/", 1, 1);
584   TEST_EXPECT_CONDITION(umount("mnt2"), RETVAL    584   TEST_EXPECT_CONDITION(umount("mnt2"), RETVAL < 0);
585                                                   585 
586   /*                                              586   /*
587    * Erasing files while they are in use          587    * Erasing files while they are in use
588    */                                             588    */
589                                                   589 
590   TEST_EXPECT_CONDITION(fd = open("toto8.txt",    590   TEST_EXPECT_CONDITION(fd = open("toto8.txt", O_RDWR | O_CREAT,
591                                   S_IRUSR | S_    591                                   S_IRUSR | S_IWUSR),
592                         RETVAL == OPEN_BASE_FD    592                         RETVAL == OPEN_BASE_FD + 23);
593   ls("/", 1, 1);                                  593   ls("/", 1, 1);
594   TEST_EXPECT_CONDITION(unlink("toto8.txt"), R    594   TEST_EXPECT_CONDITION(unlink("toto8.txt"), RETVAL == 0);
595   ls("/", 1, 1);                                  595   ls("/", 1, 1);
596                                                   596 
597   strzcpy(buff, "Garbage garbage garbage", 256    597   strzcpy(buff, "Garbage garbage garbage", 256);
598   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    598   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 0);
599                                                   599 
600   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    600   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
601                                                   601 
602   strzcpy(buff, "Hello world from toto8", 256)    602   strzcpy(buff, "Hello world from toto8", 256);
603   TEST_EXPECT_CONDITION(len = write(fd, buff,     603   TEST_EXPECT_CONDITION(len = write(fd, buff, 24), RETVAL == 24);
604                                                   604 
605   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    605   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
606                                                   606 
607   strzcpy(buff, "Garbage garbage garbage", 256    607   strzcpy(buff, "Garbage garbage garbage", 256);
608   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    608   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 24);
609   bochs_printf("read s='%s'\n", buff);            609   bochs_printf("read s='%s'\n", buff);
610                                                   610 
611   /*                                              611   /*
612    * rmdir on still used dirs                     612    * rmdir on still used dirs
613    */                                             613    */
614   TEST_EXPECT_CONDITION(mkdir("plotch", S_IRWX    614   TEST_EXPECT_CONDITION(mkdir("plotch", S_IRWXALL), RETVAL == 0);
615   TEST_EXPECT_CONDITION(chdir("plotch"), RETVA    615   TEST_EXPECT_CONDITION(chdir("plotch"), RETVAL == 0);
616   TEST_EXPECT_CONDITION(rmdir("../plotch"), RE    616   TEST_EXPECT_CONDITION(rmdir("../plotch"), RETVAL < 0);
617   TEST_EXPECT_CONDITION(chdir(".."), RETVAL ==    617   TEST_EXPECT_CONDITION(chdir(".."), RETVAL == 0);
618   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVA    618   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVAL == 0);
619   ls("/", 1, 1);                                  619   ls("/", 1, 1);
620                                                   620 
621   TEST_EXPECT_CONDITION(mkdir("plotch", S_IRWX    621   TEST_EXPECT_CONDITION(mkdir("plotch", S_IRWXALL), RETVAL == 0);
622   TEST_EXPECT_CONDITION(creat("plotch/a", S_IR    622   TEST_EXPECT_CONDITION(creat("plotch/a", S_IRWXALL), RETVAL == 0);
623   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVA    623   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVAL < 0);
624   TEST_EXPECT_CONDITION(unlink("plotch/a"), RE    624   TEST_EXPECT_CONDITION(unlink("plotch/a"), RETVAL == 0);
625   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVA    625   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVAL == 0);
626   ls("/", 1, 1);                                  626   ls("/", 1, 1);
627                                                   627 
628   TEST_EXPECT_CONDITION(mkdir("plotch", S_IRWX    628   TEST_EXPECT_CONDITION(mkdir("plotch", S_IRWXALL), RETVAL == 0);
629   TEST_EXPECT_CONDITION(fd = open("plotch/a",     629   TEST_EXPECT_CONDITION(fd = open("plotch/a", O_RDWR | O_CREAT, S_IRWXALL),
630                         RETVAL == OPEN_BASE_FD    630                         RETVAL == OPEN_BASE_FD + 24);
631   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVA    631   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVAL < 0);
632   TEST_EXPECT_CONDITION(unlink("plotch/a"), RE    632   TEST_EXPECT_CONDITION(unlink("plotch/a"), RETVAL == 0);
633   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVA    633   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVAL == 0);
634   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0    634   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0);
635   ls("/", 1, 1);                                  635   ls("/", 1, 1);
636                                                   636 
637   TEST_EXPECT_CONDITION(mkdir("this is ", S_IR    637   TEST_EXPECT_CONDITION(mkdir("this is ", S_IRWXALL), RETVAL == 0);
638   TEST_EXPECT_CONDITION(mkdir("this is / a lon    638   TEST_EXPECT_CONDITION(mkdir("this is / a long path", S_IRWXALL), RETVAL == 0);
639   TEST_EXPECT_CONDITION(mkdir("this is / a lon    639   TEST_EXPECT_CONDITION(mkdir("this is / a long path/tothe", S_IRWXALL), RETVAL == 0);
640   TEST_EXPECT_CONDITION(mkdir("this is / a lon    640   TEST_EXPECT_CONDITION(mkdir("this is / a long path/tothe/destination ", S_IRWXALL), RETVAL == 0);
641   TEST_EXPECT_CONDITION(mkdir("this is / a lon    641   TEST_EXPECT_CONDITION(mkdir("this is / a long path/tothe/destination / directory", S_IRWXALL), RETVAL == 0);
642   TEST_EXPECT_CONDITION(fd = open("this is / a    642   TEST_EXPECT_CONDITION(fd = open("this is / a long path/tothe/destination / directory/a", O_RDWR | O_CREAT, S_IRWXALL),
643                         RETVAL == OPEN_BASE_FD    643                         RETVAL == OPEN_BASE_FD + 24);
644   TEST_EXPECT_CONDITION(rmdir("this is / a lon    644   TEST_EXPECT_CONDITION(rmdir("this is / a long path/tothe/destination / directory"), RETVAL < 0);
645   TEST_EXPECT_CONDITION(unlink("this is / a lo    645   TEST_EXPECT_CONDITION(unlink("this is / a long path/tothe/destination / directory/a"), RETVAL == 0);
646   TEST_EXPECT_CONDITION(rmdir("this is / a lon    646   TEST_EXPECT_CONDITION(rmdir("this is / a long path/tothe/destination / directory"), RETVAL == 0);
647   TEST_EXPECT_CONDITION(rmdir("this is / a lon    647   TEST_EXPECT_CONDITION(rmdir("this is / a long path/tothe/destination / directory/"), RETVAL < 0);
648   TEST_EXPECT_CONDITION(rmdir("this is / a lon    648   TEST_EXPECT_CONDITION(rmdir("this is / a long path/tothe/destination "), RETVAL == 0);
649   TEST_EXPECT_CONDITION(rmdir("this is / a lon    649   TEST_EXPECT_CONDITION(rmdir("this is / a long path/tothe/"), RETVAL == 0);
650   TEST_EXPECT_CONDITION(rmdir("this is / a lon    650   TEST_EXPECT_CONDITION(rmdir("this is / a long path"), RETVAL == 0);
651   TEST_EXPECT_CONDITION(rmdir("this is "), RET    651   TEST_EXPECT_CONDITION(rmdir("this is "), RETVAL == 0);
652   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0    652   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0);
653   ls("/", 1, 1);                                  653   ls("/", 1, 1);
654                                                   654 
655   /*                                              655   /*
656    * Unlink/link files while they are in use      656    * Unlink/link files while they are in use
657    */                                             657    */
658                                                   658 
659   TEST_EXPECT_CONDITION(fd = open("toto8.txt",    659   TEST_EXPECT_CONDITION(fd = open("toto8.txt", O_RDWR | O_CREAT,
660                                   S_IRUSR | S_    660                                   S_IRUSR | S_IWUSR),
661                         RETVAL == OPEN_BASE_FD    661                         RETVAL == OPEN_BASE_FD + 24);
662   ls("/", 1, 1);                                  662   ls("/", 1, 1);
663   TEST_EXPECT_CONDITION(link("toto8.txt", "tot    663   TEST_EXPECT_CONDITION(link("toto8.txt", "toto9.txt"), RETVAL == 0);
664   TEST_EXPECT_CONDITION(unlink("toto8.txt"), R    664   TEST_EXPECT_CONDITION(unlink("toto8.txt"), RETVAL == 0);
665   ls("/", 1, 1);                                  665   ls("/", 1, 1);
666                                                   666 
667   strzcpy(buff, "Garbage garbage garbage", 256    667   strzcpy(buff, "Garbage garbage garbage", 256);
668   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    668   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 0);
669                                                   669 
670   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    670   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
671                                                   671 
672   strzcpy(buff, "Hello world from toto8", 256)    672   strzcpy(buff, "Hello world from toto8", 256);
673   TEST_EXPECT_CONDITION(len = write(fd, buff,     673   TEST_EXPECT_CONDITION(len = write(fd, buff, 24), RETVAL == 24);
674                                                   674 
675   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    675   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
676                                                   676 
677   strzcpy(buff, "Garbage garbage garbage", 256    677   strzcpy(buff, "Garbage garbage garbage", 256);
678   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    678   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 24);
679   bochs_printf("read s='%s'\n", buff);            679   bochs_printf("read s='%s'\n", buff);
680                                                   680 
681   TEST_EXPECT_CONDITION(fd = open("toto8.txt",    681   TEST_EXPECT_CONDITION(fd = open("toto8.txt", O_RDWR), RETVAL < 0);
682   TEST_EXPECT_CONDITION(fd = open("toto9.txt",    682   TEST_EXPECT_CONDITION(fd = open("toto9.txt", O_RDWR),
683                         RETVAL == OPEN_BASE_FD    683                         RETVAL == OPEN_BASE_FD + 25);
684                                                   684 
685   strzcpy(buff, "Garbage garbage garbage", 256    685   strzcpy(buff, "Garbage garbage garbage", 256);
686   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    686   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 24);
687   bochs_printf("read s='%s'\n", buff);            687   bochs_printf("read s='%s'\n", buff);
688   TEST_EXPECT_CONDITION(unlink("toto9.txt"), R    688   TEST_EXPECT_CONDITION(unlink("toto9.txt"), RETVAL == 0);
689   ls("/", 1, 1);                                  689   ls("/", 1, 1);
690                                                   690 
691   /*                                              691   /*
692    * Rename files while they are in use           692    * Rename files while they are in use
693    */                                             693    */
694                                                   694 
695   TEST_EXPECT_CONDITION(fd = open("toto8.txt",    695   TEST_EXPECT_CONDITION(fd = open("toto8.txt", O_RDWR | O_CREAT,
696                                   S_IRUSR | S_    696                                   S_IRUSR | S_IWUSR),
697                         RETVAL == OPEN_BASE_FD    697                         RETVAL == OPEN_BASE_FD + 26);
698   ls("/", 1, 1);                                  698   ls("/", 1, 1);
699   TEST_EXPECT_CONDITION(rename("toto8.txt", "t    699   TEST_EXPECT_CONDITION(rename("toto8.txt", "toto9.txt"), RETVAL == 0);
700   ls("/", 1, 1);                                  700   ls("/", 1, 1);
701                                                   701 
702   strzcpy(buff, "Garbage garbage garbage", 256    702   strzcpy(buff, "Garbage garbage garbage", 256);
703   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    703   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 0);
704                                                   704 
705   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    705   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
706                                                   706 
707   strzcpy(buff, "Hello world from toto8", 256)    707   strzcpy(buff, "Hello world from toto8", 256);
708   TEST_EXPECT_CONDITION(len = write(fd, buff,     708   TEST_EXPECT_CONDITION(len = write(fd, buff, 24), RETVAL == 24);
709                                                   709 
710   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    710   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
711                                                   711 
712   strzcpy(buff, "Garbage garbage garbage", 256    712   strzcpy(buff, "Garbage garbage garbage", 256);
713   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    713   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 24);
714   bochs_printf("read s='%s'\n", buff);            714   bochs_printf("read s='%s'\n", buff);
715   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0    715   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0);
716                                                   716 
717   TEST_EXPECT_CONDITION(fd = open("toto8.txt",    717   TEST_EXPECT_CONDITION(fd = open("toto8.txt", O_RDWR), RETVAL < 0);
718   TEST_EXPECT_CONDITION(fd = open("toto9.txt",    718   TEST_EXPECT_CONDITION(fd = open("toto9.txt", O_RDWR),
719                         RETVAL == OPEN_BASE_FD    719                         RETVAL == OPEN_BASE_FD + 26);
720                                                   720 
721   strzcpy(buff, "Garbage garbage garbage", 256    721   strzcpy(buff, "Garbage garbage garbage", 256);
722   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    722   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 24);
723   bochs_printf("read s='%s'\n", buff);            723   bochs_printf("read s='%s'\n", buff);
724   TEST_EXPECT_CONDITION(unlink("toto9.txt"), R    724   TEST_EXPECT_CONDITION(unlink("toto9.txt"), RETVAL == 0);
725   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0    725   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0);
726                                                   726 
727   /* Rename */                                    727   /* Rename */
728   ls("/", 1, 1);                                  728   ls("/", 1, 1);
729   TEST_EXPECT_CONDITION(rename("/mnt/subdir0",    729   TEST_EXPECT_CONDITION(rename("/mnt/subdir0", "subdir42"), RETVAL == 0);
730   ls("/", 1, 1);                                  730   ls("/", 1, 1);
731   TEST_EXPECT_CONDITION(rename("titi1.txt", "s    731   TEST_EXPECT_CONDITION(rename("titi1.txt", "subdir42"), RETVAL < 0);
732   ls("/", 1, 1);                                  732   ls("/", 1, 1);
733   TEST_EXPECT_CONDITION(rename("titi1.txt", "s    733   TEST_EXPECT_CONDITION(rename("titi1.txt", "subdir42/titi.txt"), RETVAL == 0);
734                                                   734 
735   /* Rename a dir being used */                   735   /* Rename a dir being used */
736   TEST_EXPECT_CONDITION(chdir("subdir42"), RET    736   TEST_EXPECT_CONDITION(chdir("subdir42"), RETVAL == 0);
737   ls(".", 1, 1);                                  737   ls(".", 1, 1);
738   ls("..", 1, 1);                                 738   ls("..", 1, 1);
739   ls("/", 1, 1);                                  739   ls("/", 1, 1);
740   TEST_EXPECT_CONDITION(rename("../subdir42",     740   TEST_EXPECT_CONDITION(rename("../subdir42", "../subdir000"), RETVAL == 0);
741   ls(".", 1, 1);                                  741   ls(".", 1, 1);
742   ls("/", 1, 1);                                  742   ls("/", 1, 1);
743   ls("..", 1, 1);                                 743   ls("..", 1, 1);
744                                                   744 
745   /*                                              745   /*
746    * test mmap                                    746    * test mmap
747    */                                             747    */
748                                                   748 
749   /* Common use: shared file suppressed as soo    749   /* Common use: shared file suppressed as soon as possible */
750   TEST_EXPECT_CONDITION(fd = open("mmap.txt",     750   TEST_EXPECT_CONDITION(fd = open("mmap.txt", O_RDWR | O_CREAT,
751                                   S_IRUSR | S_    751                                   S_IRUSR | S_IWUSR),
752                         RETVAL == OPEN_BASE_FD    752                         RETVAL == OPEN_BASE_FD + 26);
753   if (fork() == 0)                                753   if (fork() == 0)
754     {                                             754     {
755       char *shrd;                                 755       char *shrd;
756       TEST_EXPECT_CONDITION(shrd = mmap(NULL,     756       TEST_EXPECT_CONDITION(shrd = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
757                                         MAP_SH    757                                         MAP_SHARED, fd, 4096),
758                             shrd != NULL);        758                             shrd != NULL);
759       nanosleep(1, 0);                            759       nanosleep(1, 0);
760       strzcpy(shrd, "Hello1 from the child (sh    760       strzcpy(shrd, "Hello1 from the child (shared mapping) !", 4096);
761       return 0;                                   761       return 0;
762     }                                             762     }
763   else                                            763   else
764     {                                             764     {
765       char *shrd;                                 765       char *shrd;
766       TEST_EXPECT_CONDITION(shrd = mmap(NULL,     766       TEST_EXPECT_CONDITION(shrd = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
767                                         MAP_SH    767                                         MAP_SHARED, fd, 4096),
768                             shrd != NULL);        768                             shrd != NULL);
769       strzcpy(shrd, "Garbage garbage garbage",    769       strzcpy(shrd, "Garbage garbage garbage", 256);
770       nanosleep(2, 0);                            770       nanosleep(2, 0);
771       bochs_printf("Father woken up\n");          771       bochs_printf("Father woken up\n");
772       bochs_printf("Read string from child: '%    772       bochs_printf("Read string from child: '%s'\n", shrd);
773       TEST_EXPECT_CONDITION(strcmp(shrd, "Hell    773       TEST_EXPECT_CONDITION(strcmp(shrd, "Hello1 from the child (shared mapping) !"),
774                             RETVAL == 0);         774                             RETVAL == 0);
775       munmap(shrd, 8192);                         775       munmap(shrd, 8192);
776     }                                             776     }
777   ls("/", 1, 1);                                  777   ls("/", 1, 1);
778   TEST_EXPECT_CONDITION(unlink("mmap.txt"), RE    778   TEST_EXPECT_CONDITION(unlink("mmap.txt"), RETVAL == 0);
779   ls("/", 1, 1);                                  779   ls("/", 1, 1);
780                                                   780 
781   /* Common use: shared file suppressed as soo    781   /* Common use: shared file suppressed as soon as possible */
782   TEST_EXPECT_CONDITION(fd = open("mmap.txt",     782   TEST_EXPECT_CONDITION(fd = open("mmap.txt", O_RDWR | O_CREAT,
783                                   S_IRUSR | S_    783                                   S_IRUSR | S_IWUSR),
784                         RETVAL == OPEN_BASE_FD    784                         RETVAL == OPEN_BASE_FD + 27);
785   TEST_EXPECT_CONDITION(unlink("mmap.txt"), RE    785   TEST_EXPECT_CONDITION(unlink("mmap.txt"), RETVAL == 0);
786   if (fork() == 0)                                786   if (fork() == 0)
787     {                                             787     {
788       char *shrd;                                 788       char *shrd;
789       TEST_EXPECT_CONDITION(shrd = mmap(NULL,     789       TEST_EXPECT_CONDITION(shrd = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
790                                         MAP_SH    790                                         MAP_SHARED, fd, 4096),
791                             shrd != NULL);        791                             shrd != NULL);
792       nanosleep(1, 0);                            792       nanosleep(1, 0);
793       strzcpy(shrd, "Hello2 from the child (sh    793       strzcpy(shrd, "Hello2 from the child (shared mapping) !", 4096);
794       return 0;                                   794       return 0;
795     }                                             795     }
796   else                                            796   else
797     {                                             797     {
798       char *shrd;                                 798       char *shrd;
799       TEST_EXPECT_CONDITION(shrd = mmap(NULL,     799       TEST_EXPECT_CONDITION(shrd = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
800                                         MAP_SH    800                                         MAP_SHARED, fd, 4096),
801                             shrd != NULL);        801                             shrd != NULL);
802       strzcpy(shrd, "Garbage garbage garbage",    802       strzcpy(shrd, "Garbage garbage garbage", 256);
803       nanosleep(2, 0);                            803       nanosleep(2, 0);
804       bochs_printf("Father woken up\n");          804       bochs_printf("Father woken up\n");
805       bochs_printf("Read string from child: '%    805       bochs_printf("Read string from child: '%s'\n", shrd);
806       TEST_EXPECT_CONDITION(strcmp(shrd, "Hell    806       TEST_EXPECT_CONDITION(strcmp(shrd, "Hello2 from the child (shared mapping) !"),
807                             RETVAL == 0);         807                             RETVAL == 0);
808     }                                             808     }
809   ls("/", 1, 1);                                  809   ls("/", 1, 1);
810                                                   810 
811   /* Basic use */                                 811   /* Basic use */
812   TEST_EXPECT_CONDITION(creat("mmap.txt", S_IR    812   TEST_EXPECT_CONDITION(creat("mmap.txt", S_IRUSR | S_IWUSR), RETVAL == 0);
813   if (fork() == 0)                                813   if (fork() == 0)
814     {                                             814     {
815       char *shrd;                                 815       char *shrd;
816       TEST_EXPECT_CONDITION(fd = open("mmap.tx    816       TEST_EXPECT_CONDITION(fd = open("mmap.txt", O_RDWR | O_CREAT,
817                                       S_IRUSR     817                                       S_IRUSR | S_IWUSR),
818                             RETVAL == OPEN_BAS    818                             RETVAL == OPEN_BASE_FD + 28);
819       TEST_EXPECT_CONDITION(shrd = mmap(NULL,     819       TEST_EXPECT_CONDITION(shrd = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
820                                         MAP_SH    820                                         MAP_SHARED, fd, 4096),
821                             shrd != NULL);        821                             shrd != NULL);
822       nanosleep(1, 0);                            822       nanosleep(1, 0);
823       strzcpy(shrd, "Hello3 from the child (sh    823       strzcpy(shrd, "Hello3 from the child (shared mapping) !", 4096);
824       return 0;                                   824       return 0;
825     }                                             825     }
826   else                                            826   else
827     {                                             827     {
828       char *shrd;                                 828       char *shrd;
829       TEST_EXPECT_CONDITION(fd = open("mmap.tx    829       TEST_EXPECT_CONDITION(fd = open("mmap.txt", O_RDWR | O_CREAT,
830                                       S_IRUSR     830                                       S_IRUSR | S_IWUSR),
831                             RETVAL == OPEN_BAS    831                             RETVAL == OPEN_BASE_FD + 28);
832       TEST_EXPECT_CONDITION(shrd = mmap(NULL,     832       TEST_EXPECT_CONDITION(shrd = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
833                                         MAP_SH    833                                         MAP_SHARED, fd, 4096),
834                             shrd != NULL);        834                             shrd != NULL);
835       strzcpy(shrd, "Garbage garbage garbage",    835       strzcpy(shrd, "Garbage garbage garbage", 256);
836       nanosleep(2, 0);                            836       nanosleep(2, 0);
837       bochs_printf("Father woken up\n");          837       bochs_printf("Father woken up\n");
838       bochs_printf("Read string from child: '%    838       bochs_printf("Read string from child: '%s'\n", shrd);
839       TEST_EXPECT_CONDITION(strcmp(shrd, "Hell    839       TEST_EXPECT_CONDITION(strcmp(shrd, "Hello3 from the child (shared mapping) !"),
840                             RETVAL == 0);         840                             RETVAL == 0);
841     }                                             841     }
842   ls("/", 1, 1);                                  842   ls("/", 1, 1);
843                                                   843   
844   bochs_printf("Bye from fstest\n");              844   bochs_printf("Bye from fstest\n");
845   ls("/", 1, 1);                                  845   ls("/", 1, 1);
846   return 0;                                       846   return 0;
847 }                                                 847 }
                                                      

source navigation ] diff markup ] identifier search ] general search ]