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

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