[0895bdb] | 1 | /* |
---|
| 2 | * This test exercises stat() via fstat() and generates as many of the |
---|
| 3 | * path evaluation cases as possible. |
---|
| 4 | * |
---|
[c40d3c4b] | 5 | * This test also exercises lstat() and lchown() when symlinks are |
---|
| 6 | * involved. |
---|
| 7 | * |
---|
[947015f] | 8 | * COPYRIGHT (c) 1989-2010. |
---|
[0895bdb] | 9 | * On-Line Applications Research Corporation (OAR). |
---|
| 10 | * |
---|
| 11 | * The license and distribution terms for this file may be |
---|
| 12 | * found in the file LICENSE in this distribution or at |
---|
[3c48599] | 13 | * http://www.rtems.com/license/LICENSE. |
---|
[0895bdb] | 14 | * |
---|
| 15 | * $Id$ |
---|
| 16 | */ |
---|
| 17 | |
---|
[cafefbf] | 18 | #ifdef HAVE_CONFIG_H |
---|
| 19 | #include "config.h" |
---|
| 20 | #endif |
---|
| 21 | |
---|
[0895bdb] | 22 | #include <tmacros.h> |
---|
| 23 | #include <sys/stat.h> |
---|
| 24 | #include <fcntl.h> |
---|
| 25 | #include <limits.h> |
---|
| 26 | #include <stdio.h> |
---|
| 27 | #include <unistd.h> |
---|
| 28 | #include <errno.h> |
---|
| 29 | #include <string.h> |
---|
[947015f] | 30 | #include <reent.h> |
---|
[0895bdb] | 31 | #include <rtems.h> |
---|
| 32 | #include <rtems/libio.h> |
---|
[0fdaca2] | 33 | #include <rtems/imfs.h> |
---|
[d802489] | 34 | #include <pmacros.h> |
---|
[0895bdb] | 35 | |
---|
| 36 | #define MAXSYMLINK 5 /* There needs to be a better way of getting this. */ |
---|
[c9460e1] | 37 | #define TIMEOUT_VALUE ( 5 * rtems_clock_get_ticks_per_second() ) |
---|
[0895bdb] | 38 | |
---|
[947015f] | 39 | int _lstat_r(struct _reent *, const char *, struct stat *); |
---|
[eaf0e8eb] | 40 | |
---|
[0895bdb] | 41 | /* |
---|
| 42 | * List of files which should exist. |
---|
| 43 | */ |
---|
| 44 | |
---|
| 45 | char *Files[] = { |
---|
[2e3ce06] | 46 | "/////my_mount_point/dir1/\\//file1\\\\//", |
---|
| 47 | "/my_mount_point/dir1/file2", |
---|
| 48 | "/my_mount_point/dir1/file3", |
---|
| 49 | "/my_mount_point/dir1/file4", |
---|
| 50 | "/my_mount_point/dir1/dir1/file1", |
---|
| 51 | "../../..//my_mount_point/dir1/./././dir1/ file1", |
---|
[0895bdb] | 52 | "main.c", |
---|
| 53 | 0 |
---|
| 54 | }; |
---|
| 55 | |
---|
| 56 | /* |
---|
| 57 | * List of directories which should exist. |
---|
| 58 | */ |
---|
| 59 | |
---|
| 60 | char *Directories[] = { |
---|
[2e3ce06] | 61 | "/my_mount_point/dir1", |
---|
| 62 | "/my_mount_point/dir2", |
---|
| 63 | "/my_mount_point/dir3", |
---|
| 64 | "/my_mount_point/dir4", |
---|
| 65 | "/my_mount_point/dir1/dir1", |
---|
| 66 | "/./././my_mount_point/dir1/ dir1", |
---|
[1b4f2b30] | 67 | "/./././my_mount_point/links", |
---|
[2e3ce06] | 68 | "///my_mount_point/dir1/dir1/../../dir1/../symlinks/////", |
---|
[0895bdb] | 69 | 0 |
---|
| 70 | }; |
---|
| 71 | |
---|
| 72 | char *Links_to_Dirs[]= { |
---|
| 73 | "dir1/dir1/../../links/dir1", |
---|
| 74 | "links/dir2", |
---|
| 75 | "links/dir3", |
---|
| 76 | "links/dir4", |
---|
| 77 | "links/dir1_dir1", |
---|
| 78 | "links/dir1_ dir1", |
---|
| 79 | "links/../links/../links/links", |
---|
| 80 | 0 |
---|
| 81 | }; |
---|
| 82 | |
---|
| 83 | char *Links_to_Files[]= { |
---|
| 84 | "links/dir1_file1", |
---|
| 85 | "links/dir1_file2", |
---|
| 86 | "links/dir1_file3", |
---|
| 87 | "links/dir1_file4", |
---|
| 88 | "links/dir1_dir1_f1", |
---|
| 89 | "links/dir1_dir1 f1", |
---|
| 90 | 0 |
---|
| 91 | }; |
---|
| 92 | |
---|
| 93 | char *Links_to_dirlinks[]= { |
---|
| 94 | "links/links/links/links_dir1", |
---|
| 95 | "links//links_dir2", |
---|
| 96 | "links//links_dir3", |
---|
| 97 | "links//links_dir4", |
---|
| 98 | "links//links_dir1_d1", |
---|
| 99 | "links//links_dir1 d1", |
---|
| 100 | "links//links_links", |
---|
| 101 | 0 |
---|
| 102 | }; |
---|
| 103 | |
---|
| 104 | char *Links_to_filelinks[]= { |
---|
| 105 | "links///links_d1_file1", |
---|
| 106 | "links///links_d1_file2", |
---|
| 107 | "links///links_d1_file3", |
---|
| 108 | "links///links_d1_file4", |
---|
| 109 | "links///links_d1_d1_f1", |
---|
| 110 | "links///links_r1_d1 f1", |
---|
| 111 | 0 |
---|
| 112 | }; |
---|
| 113 | |
---|
| 114 | char *SymLinks[]= { |
---|
[2e3ce06] | 115 | "/my_mount_point/symlinks/a_file_symlink", |
---|
| 116 | "/my_mount_point/symlinks/a_dir_symlink", |
---|
| 117 | "/my_mount_point/symlinks/a_link_symlink", |
---|
[0895bdb] | 118 | "../symlinks/no_file", |
---|
[2e3ce06] | 119 | "/my_mount_point/symlinks/a_dir_symlink/a_file_symlink", |
---|
[0895bdb] | 120 | 0 |
---|
| 121 | }; |
---|
| 122 | |
---|
| 123 | /* |
---|
| 124 | * List of absolute paths to stat. |
---|
| 125 | */ |
---|
| 126 | |
---|
| 127 | char *Good_absolute_paths[] = { |
---|
[2e3ce06] | 128 | "/my_mount_point/dev", |
---|
| 129 | "////my_mount_point/dir1/\\//file1\\\\//", |
---|
| 130 | "/my_mount_point/dir1/\\\\/file2", |
---|
| 131 | "/my_mount_point/dir1/file3/////\\\\\\", |
---|
| 132 | "/my_mount_point/dir1/file4", |
---|
| 133 | "/my_mount_point/dir1/dir1/file1", |
---|
| 134 | "/my_mount_point/dir1/dir1/ file1", |
---|
| 135 | "/my_mount_point/dir1", |
---|
| 136 | "/my_mount_point/dir2//////\\", |
---|
| 137 | "/my_mount_point/dir3", |
---|
| 138 | "/my_mount_point/dir4", |
---|
| 139 | "/my_mount_point/dir1/dir1", |
---|
| 140 | "/my_mount_point/dir1/ dir1///\\\\", |
---|
| 141 | "/my_mount_point/\\/\\/\\/\\/\\/\\/links\\/\\/\\/\\/\\/\\", |
---|
[0895bdb] | 142 | 0 |
---|
| 143 | }; |
---|
| 144 | |
---|
| 145 | |
---|
| 146 | char *Bad_paths[] = { |
---|
[2e3ce06] | 147 | "/my_mount_point/links/ENAMETOOLONG__________________________", |
---|
| 148 | "/my_mount_point/dir1/file4/NOTADIR", |
---|
| 149 | "/my_mount_point/dir1/dir1/EACCES__", |
---|
[0895bdb] | 150 | 0 |
---|
| 151 | }; |
---|
| 152 | |
---|
| 153 | /* |
---|
| 154 | * List of relative paths to stat. |
---|
| 155 | */ |
---|
| 156 | |
---|
| 157 | char *Good_relative_paths[] = { |
---|
| 158 | "dev", |
---|
| 159 | "dir1/\\//file1\\\\//", |
---|
| 160 | "dir1/\\\\/file2", |
---|
| 161 | "dir1/file3/////\\\\\\", |
---|
| 162 | "dir1/file4", |
---|
| 163 | "dir1/dir1/file1", |
---|
| 164 | "dir1/dir1/ file1", |
---|
| 165 | "dir1", |
---|
| 166 | "dir2//////\\", |
---|
| 167 | "dir3", |
---|
| 168 | "dir4", |
---|
| 169 | "dir1/dir1", |
---|
| 170 | "dir1/ dir1///\\\\", |
---|
| 171 | "main.c", |
---|
| 172 | 0 |
---|
| 173 | }; |
---|
| 174 | |
---|
| 175 | /* |
---|
[c40d3c4b] | 176 | * Do a stat/lstat on a single file and report the status. |
---|
[0895bdb] | 177 | */ |
---|
| 178 | |
---|
[c40d3c4b] | 179 | void stat_a_file_helper( |
---|
| 180 | const char *file, |
---|
| 181 | int follow_link |
---|
[0895bdb] | 182 | ) |
---|
| 183 | { |
---|
| 184 | int status; |
---|
| 185 | struct stat statbuf; |
---|
| 186 | int major1; |
---|
| 187 | int minor1; |
---|
| 188 | int major2; |
---|
| 189 | int minor2; |
---|
| 190 | |
---|
| 191 | |
---|
[2317457] | 192 | rtems_test_assert( file ); |
---|
[0895bdb] | 193 | |
---|
[c40d3c4b] | 194 | if ( follow_link ) { |
---|
| 195 | printf( "stat( %s ) returned ", file ); |
---|
| 196 | fflush( stdout ); |
---|
| 197 | status = stat( file, &statbuf ); |
---|
| 198 | } else { |
---|
| 199 | printf( "lstat( %s ) returned ", file ); |
---|
| 200 | fflush( stdout ); |
---|
| 201 | status = lstat( file, &statbuf ); |
---|
| 202 | } |
---|
[0895bdb] | 203 | |
---|
| 204 | if ( status == -1 ) { |
---|
| 205 | printf( ": %s\n", strerror( errno ) ); |
---|
| 206 | } else { |
---|
| 207 | |
---|
| 208 | rtems_filesystem_split_dev_t( statbuf.st_dev, major1, minor1 ); |
---|
| 209 | rtems_filesystem_split_dev_t( statbuf.st_rdev, major2, minor2 ); |
---|
| 210 | |
---|
| 211 | |
---|
[1fbd283c] | 212 | printf("\n...st_dev (0x%x:0x%x)\n", major1, minor1 ); |
---|
[7a20394] | 213 | printf( "...st_ino %" PRIxino_t "\n", statbuf.st_ino ); |
---|
[3c0c898] | 214 | printf( "...st_mode %o\n", (unsigned int) statbuf.st_mode ); |
---|
[9060699] | 215 | printf( "...st_nlink %x\n", statbuf.st_nlink ); |
---|
| 216 | printf( "...st_uid %d\n", statbuf.st_uid ); |
---|
| 217 | printf( "...st_gid %d\n", statbuf.st_gid ); |
---|
| 218 | printf( "...st_rdev (0x%x:0x%x)\n", major2, minor2 ); |
---|
[7a20394] | 219 | printf( "...st_size %" PRIdoff_t "\n", statbuf.st_size ); |
---|
[9060699] | 220 | printf( "...st_atime %s", ctime( &statbuf.st_atime ) ); |
---|
| 221 | printf( "...st_mtime %s", ctime( &statbuf.st_mtime ) ); |
---|
| 222 | printf( "...st_ctime %s", ctime( &statbuf.st_ctime ) ); |
---|
[7a20394] | 223 | printf( "...st_blksize %" PRIxblksize_t "\n", statbuf.st_blksize ); |
---|
| 224 | printf( "...st_blocks %" PRIxblkcnt_t "\n", statbuf.st_blocks ); |
---|
[0895bdb] | 225 | } |
---|
| 226 | } |
---|
| 227 | |
---|
[c40d3c4b] | 228 | /* |
---|
| 229 | * Do a stat on a single file and report the status. |
---|
| 230 | */ |
---|
| 231 | void stat_a_file( |
---|
| 232 | const char *file |
---|
| 233 | ) |
---|
| 234 | { |
---|
| 235 | stat_a_file_helper( file, true ); |
---|
| 236 | } |
---|
| 237 | |
---|
| 238 | /* |
---|
| 239 | * Do a lstat on a single file and report the status. |
---|
| 240 | */ |
---|
| 241 | void lstat_a_file( |
---|
| 242 | const char *file |
---|
| 243 | ) |
---|
| 244 | { |
---|
| 245 | stat_a_file_helper( file, false ); |
---|
| 246 | } |
---|
| 247 | |
---|
[0895bdb] | 248 | /* |
---|
| 249 | * stat() multiple files at a time |
---|
| 250 | */ |
---|
| 251 | |
---|
| 252 | void stat_multiple_files( |
---|
| 253 | char **files |
---|
| 254 | ) |
---|
| 255 | { |
---|
| 256 | int i; |
---|
| 257 | |
---|
| 258 | i = 0; |
---|
| 259 | while ( files[i] ) { |
---|
| 260 | stat_a_file( files[i] ); |
---|
| 261 | i++; |
---|
| 262 | } |
---|
| 263 | } |
---|
| 264 | |
---|
| 265 | /* |
---|
[c40d3c4b] | 266 | * chown()/lchown() multiple files at a time |
---|
[0895bdb] | 267 | */ |
---|
[c40d3c4b] | 268 | void chown_multiple_files_helper( |
---|
| 269 | char **files, |
---|
| 270 | int follow_link |
---|
[0895bdb] | 271 | ) |
---|
| 272 | { |
---|
| 273 | int i; |
---|
| 274 | uid_t st_uid; |
---|
| 275 | gid_t st_gid; |
---|
| 276 | |
---|
| 277 | st_uid = geteuid(); |
---|
| 278 | st_gid = getegid(); |
---|
| 279 | |
---|
| 280 | i = 0; |
---|
| 281 | while ( files[i] ) { |
---|
| 282 | printf("Change group of %s\n", files[i]); |
---|
[c40d3c4b] | 283 | if ( follow_link ) { |
---|
| 284 | chown( files[i], st_uid, (st_gid+1) ); |
---|
| 285 | stat_a_file( files[i] ); |
---|
| 286 | } else { |
---|
| 287 | lchown( files[i], st_uid, (st_gid+1) ); |
---|
| 288 | lstat_a_file( files[i] ); |
---|
| 289 | } |
---|
[0895bdb] | 290 | |
---|
| 291 | printf("Change owner of %s\n", files[i]); |
---|
[c40d3c4b] | 292 | if ( follow_link ) { |
---|
| 293 | chown( files[i], (st_uid+1), st_gid ); |
---|
| 294 | stat_a_file( files[i] ); |
---|
| 295 | } else { |
---|
| 296 | lchown( files[i], (st_uid+1), st_gid ); |
---|
| 297 | lstat_a_file( files[i] ); |
---|
| 298 | } |
---|
[0895bdb] | 299 | i++; |
---|
| 300 | } |
---|
| 301 | |
---|
| 302 | } |
---|
| 303 | |
---|
[c40d3c4b] | 304 | /* |
---|
| 305 | * chown() multiple files at a time |
---|
| 306 | */ |
---|
| 307 | void chown_multiple_files( |
---|
| 308 | char **files |
---|
| 309 | ) |
---|
| 310 | { |
---|
| 311 | chown_multiple_files_helper( files, true ); |
---|
| 312 | } |
---|
[0895bdb] | 313 | |
---|
[c40d3c4b] | 314 | /* |
---|
| 315 | * lchown() multiple files at a time |
---|
| 316 | */ |
---|
| 317 | void lchown_multiple_files( |
---|
| 318 | char **files |
---|
| 319 | ) |
---|
| 320 | { |
---|
| 321 | chown_multiple_files_helper( files, false ); |
---|
| 322 | } |
---|
[0895bdb] | 323 | |
---|
| 324 | /* |
---|
| 325 | * mknod() multiple files at a time |
---|
| 326 | */ |
---|
| 327 | |
---|
| 328 | void make_multiple_files( |
---|
| 329 | char **files |
---|
| 330 | ) |
---|
| 331 | { |
---|
| 332 | int i; |
---|
| 333 | int status; |
---|
| 334 | |
---|
| 335 | i = 0; |
---|
| 336 | while ( files[i] ) { |
---|
| 337 | printf( "Making file %s\n", files[i] ); |
---|
| 338 | status = mknod( files[i], ( S_IFREG | S_IROTH|S_IWOTH ), 0LL ); |
---|
[2317457] | 339 | rtems_test_assert( !status ); |
---|
[0895bdb] | 340 | i++; |
---|
| 341 | } |
---|
| 342 | puts( "" ); |
---|
| 343 | } |
---|
| 344 | |
---|
| 345 | void make_multiple_bad_files( |
---|
| 346 | char **files |
---|
| 347 | ) |
---|
| 348 | { |
---|
| 349 | int i; |
---|
| 350 | int status; |
---|
| 351 | |
---|
| 352 | i = 0; |
---|
| 353 | while ( files[i] ) { |
---|
| 354 | printf( "Making file %s ", files[i] ); |
---|
| 355 | status = mknod( files[i], ( S_IFREG | S_IROTH|S_IWOTH ), 0LL ); |
---|
[2317457] | 356 | rtems_test_assert( status ); |
---|
[0895bdb] | 357 | printf( ": %s\n", strerror( errno ) ); |
---|
| 358 | i++; |
---|
| 359 | } |
---|
| 360 | puts( "" ); |
---|
| 361 | } |
---|
| 362 | |
---|
| 363 | void make_multiple_links( |
---|
| 364 | char **existing, |
---|
| 365 | char **new |
---|
| 366 | ) |
---|
| 367 | { |
---|
| 368 | int i; |
---|
| 369 | int status; |
---|
| 370 | |
---|
| 371 | i = 0; |
---|
| 372 | while ( new[i] && existing[i] ) { |
---|
| 373 | printf( "Making file %s\n", new[i] ); |
---|
| 374 | status = link( existing[i], new[i] ); |
---|
[2317457] | 375 | rtems_test_assert( !status ); |
---|
[0895bdb] | 376 | i++; |
---|
| 377 | } |
---|
| 378 | puts( "" ); |
---|
| 379 | |
---|
| 380 | status = link( "fred", "bob" ); |
---|
[2317457] | 381 | rtems_test_assert( status == -1 ); |
---|
[0895bdb] | 382 | |
---|
| 383 | status = link( existing[1], "doug/bob" ); |
---|
[2317457] | 384 | rtems_test_assert( status == -1 ); |
---|
[0895bdb] | 385 | } |
---|
| 386 | |
---|
| 387 | |
---|
[b6912c40] | 388 | void make_too_many_links(void) |
---|
[0895bdb] | 389 | { |
---|
| 390 | int i; |
---|
| 391 | int status; |
---|
| 392 | char name [20]; |
---|
| 393 | |
---|
| 394 | status = mkdir("/dummy", S_IRWXU ); |
---|
[2317457] | 395 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 396 | |
---|
| 397 | for (i=1; i<= LINK_MAX; i++) { |
---|
| 398 | |
---|
| 399 | sprintf(name,"/LinkName%d",i); |
---|
| 400 | printf( "Making file %s\n", name ); |
---|
| 401 | status = link("/dummy" , name ); |
---|
| 402 | if( i < LINK_MAX ) |
---|
[2317457] | 403 | rtems_test_assert( !status ); |
---|
[0895bdb] | 404 | else |
---|
[2317457] | 405 | rtems_test_assert( status == -1 ); |
---|
[0895bdb] | 406 | |
---|
| 407 | } |
---|
| 408 | } |
---|
| 409 | |
---|
| 410 | |
---|
| 411 | void make_a_symlink( |
---|
| 412 | char *existing, |
---|
| 413 | char *new |
---|
| 414 | ) |
---|
| 415 | { |
---|
| 416 | int status; |
---|
| 417 | char buf[100]; |
---|
| 418 | int len; |
---|
| 419 | |
---|
| 420 | memset( buf, 0, 100 ); |
---|
| 421 | |
---|
| 422 | printf( "Making file %s\n", new ); |
---|
| 423 | status = symlink( existing, new ); |
---|
[2317457] | 424 | rtems_test_assert( !status ); |
---|
[0895bdb] | 425 | |
---|
| 426 | printf( "Verify with readlink\n"); |
---|
| 427 | status = readlink( new, buf, 100 ); |
---|
| 428 | len = strlen( existing ); |
---|
[2317457] | 429 | rtems_test_assert ( status == len ); |
---|
[0895bdb] | 430 | |
---|
| 431 | status = readlink( new, buf, 3 ); |
---|
| 432 | len = strlen( existing ); |
---|
| 433 | if (len < 3 ) |
---|
[2317457] | 434 | rtems_test_assert( status == len ); |
---|
[0895bdb] | 435 | else |
---|
[2317457] | 436 | rtems_test_assert( status == 3 ); |
---|
[0895bdb] | 437 | |
---|
| 438 | status = strcmp( existing, buf ); |
---|
[2317457] | 439 | rtems_test_assert( !status ); |
---|
[0895bdb] | 440 | } |
---|
| 441 | |
---|
[b6912c40] | 442 | void make_multiple_symlinks(void) |
---|
[0895bdb] | 443 | { |
---|
[c40d3c4b] | 444 | int status, i; |
---|
[0895bdb] | 445 | |
---|
| 446 | make_a_symlink( Files[0], SymLinks[0] ); |
---|
| 447 | make_a_symlink( Directories[0], SymLinks[1] ); |
---|
| 448 | make_a_symlink( Links_to_dirlinks[0], SymLinks[2] ); |
---|
| 449 | make_a_symlink( "No_File", SymLinks[3] ); |
---|
| 450 | make_a_symlink( SymLinks[1], SymLinks[4] ); |
---|
[2e3ce06] | 451 | make_a_symlink( "//my_mount_point/links","/my_mount_point/symlinks/links" ); |
---|
[0895bdb] | 452 | |
---|
[c40d3c4b] | 453 | for (i = 0; i < 5; i++) { |
---|
| 454 | stat_a_file( SymLinks[i] ); |
---|
| 455 | lstat_a_file( SymLinks[i] ); |
---|
| 456 | } |
---|
[0895bdb] | 457 | |
---|
| 458 | status = symlink( "//links", "bob/frank" ); |
---|
[2317457] | 459 | rtems_test_assert (status == -1); |
---|
[0895bdb] | 460 | |
---|
| 461 | } |
---|
| 462 | /* |
---|
| 463 | void make_too_many_symlinks() |
---|
| 464 | { |
---|
| 465 | int i, status; |
---|
| 466 | char name1[8]; |
---|
| 467 | |
---|
| 468 | for (i=1; i <= MAXSYMLINK; i++) { |
---|
| 469 | sprintf( name1, "SymLink%d", i ); |
---|
| 470 | status = symlink( "/dummy", name1 ); |
---|
| 471 | if( i < MAXSYMLINK ) |
---|
[2317457] | 472 | rtems_test_assert( !status ); |
---|
[0895bdb] | 473 | else |
---|
[2317457] | 474 | rtems_test_assert( status == -1 ); |
---|
[0895bdb] | 475 | } |
---|
| 476 | } |
---|
| 477 | */ |
---|
| 478 | void make_many_symlinks( |
---|
| 479 | char *real_file, |
---|
| 480 | int link_count |
---|
| 481 | ) |
---|
| 482 | { |
---|
| 483 | int i; |
---|
| 484 | char name1[5]; |
---|
| 485 | char name2[5]; |
---|
| 486 | char *link_file; |
---|
| 487 | |
---|
| 488 | link_file = real_file; |
---|
| 489 | for (i=1; i < link_count; i++) { |
---|
| 490 | sprintf( name1, "%d", i ); |
---|
| 491 | make_a_symlink( link_file, name1 ); |
---|
| 492 | strcpy( name2, name1 ); |
---|
| 493 | link_file = name2; |
---|
| 494 | } |
---|
| 495 | |
---|
| 496 | for (i=1; i < link_count; i++) { |
---|
| 497 | sprintf( name1, "%d", i ); |
---|
| 498 | stat_a_file( name1 ); |
---|
[c40d3c4b] | 499 | lstat_a_file( name1 ); |
---|
[0895bdb] | 500 | } |
---|
| 501 | |
---|
| 502 | } |
---|
| 503 | |
---|
| 504 | /* |
---|
| 505 | * mkdir() multiple directories at a time |
---|
| 506 | */ |
---|
[1b4f2b30] | 507 | |
---|
[0895bdb] | 508 | void make_multiple_directories( |
---|
| 509 | char **files |
---|
[1b4f2b30] | 510 | ) |
---|
[0895bdb] | 511 | { |
---|
| 512 | int i; |
---|
| 513 | int status; |
---|
| 514 | |
---|
[1b4f2b30] | 515 | i = 0; |
---|
[0895bdb] | 516 | while ( files[i] ) { |
---|
| 517 | printf( "Making directory %s\n", files[i] ); |
---|
| 518 | status = mkdir( files[i], S_IRWXU ); |
---|
[2317457] | 519 | rtems_test_assert( !status ); |
---|
[0895bdb] | 520 | i++; |
---|
| 521 | } |
---|
| 522 | puts( "" ); |
---|
[1b4f2b30] | 523 | } |
---|
[0895bdb] | 524 | |
---|
| 525 | /* |
---|
| 526 | * Cause faults. |
---|
| 527 | */ |
---|
| 528 | |
---|
| 529 | |
---|
[b6912c40] | 530 | void Cause_faults(void) |
---|
[0895bdb] | 531 | { |
---|
| 532 | int fd; |
---|
| 533 | int status; |
---|
| 534 | char longer_name[100]; |
---|
| 535 | |
---|
| 536 | /* |
---|
| 537 | * Verify chmod with an invalid type. |
---|
| 538 | */ |
---|
| 539 | |
---|
[cbbc55ef] | 540 | #if 0 |
---|
[0895bdb] | 541 | printf("\n\nPass an invalid mode to chmod should fail with EPERM \n" ); |
---|
| 542 | status = chmod( Files[0], S_IFREG ); |
---|
[2317457] | 543 | rtems_test_assert( status == -1 ); |
---|
| 544 | rtems_test_assert( errno == EPERM ); |
---|
[cbbc55ef] | 545 | #endif |
---|
[0895bdb] | 546 | |
---|
| 547 | /* |
---|
[1b4f2b30] | 548 | * Change file to executable then try to chdir to it. |
---|
[0895bdb] | 549 | */ |
---|
| 550 | |
---|
[f2278a8] | 551 | status = chmod( Files[0], S_IXUSR ); |
---|
[2317457] | 552 | rtems_test_assert( status != -1 ); |
---|
[f2278a8] | 553 | |
---|
[0895bdb] | 554 | printf("chdir to a file should fail with ENOTDIR\n"); |
---|
| 555 | status = chdir( Files[0] ); |
---|
[2317457] | 556 | rtems_test_assert( status == -1 ); |
---|
| 557 | rtems_test_assert( errno == ENOTDIR ); |
---|
[0895bdb] | 558 | |
---|
| 559 | /* |
---|
| 560 | * Change mode to read/write on a directory. |
---|
| 561 | * Verify directory works properly. |
---|
| 562 | */ |
---|
| 563 | |
---|
| 564 | printf("Verify RWX permission on %s via access\n", Directories[0]); |
---|
| 565 | status = access( Directories[0], ( R_OK | W_OK | X_OK ) ); |
---|
[2317457] | 566 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 567 | |
---|
| 568 | printf( "chmod of %s to Read/Write\n", Directories[0] ); |
---|
| 569 | status = chmod( Directories[0], (S_IXGRP | S_IXOTH) ); |
---|
[2317457] | 570 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 571 | |
---|
| 572 | printf( "chmod fred should fail with ENOENT\n" ); |
---|
| 573 | status = chmod( "fred", (S_IXGRP | S_IXOTH) ); |
---|
[2317457] | 574 | rtems_test_assert( status == -1 ); |
---|
| 575 | rtems_test_assert( errno == ENOENT ); |
---|
[0895bdb] | 576 | |
---|
| 577 | strcpy(longer_name, Directories[0] ); |
---|
| 578 | strcat(longer_name, "/BADNAME" ); |
---|
| 579 | printf( "Create under %s should fail with EACCES\n", Directories[0] ); |
---|
| 580 | status = mkdir( longer_name , S_IRWXU ); |
---|
[2317457] | 581 | rtems_test_assert( status == -1 ); |
---|
| 582 | rtems_test_assert( errno == EACCES ); |
---|
[0895bdb] | 583 | |
---|
| 584 | printf("chdir to %s should fail with EACCES\n", Directories[4] ); |
---|
| 585 | status = chdir( Directories[4] ); |
---|
[2317457] | 586 | rtems_test_assert( status == -1 ); |
---|
| 587 | rtems_test_assert( errno == EACCES ); |
---|
[0895bdb] | 588 | |
---|
[1b4f2b30] | 589 | /* |
---|
[0895bdb] | 590 | * Check stat with a NULL buffer. |
---|
| 591 | */ |
---|
| 592 | |
---|
| 593 | printf("Stat with a NULL buffer should fail with EFAULT\n"); |
---|
| 594 | status = stat( Directories[0], NULL ); |
---|
[2317457] | 595 | rtems_test_assert( status == -1 ); |
---|
| 596 | rtems_test_assert( errno == EFAULT ); |
---|
[0895bdb] | 597 | |
---|
| 598 | /* |
---|
| 599 | * Set current to a directory with no owner permissions. |
---|
| 600 | * Verify it works properly. |
---|
| 601 | */ |
---|
| 602 | |
---|
| 603 | printf( "\n\nchmod of %s to Read/Write\n", Directories[0] ); |
---|
| 604 | status = chmod( Directories[0], (S_IXGRP | S_IXOTH) ); |
---|
[2317457] | 605 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 606 | |
---|
| 607 | printf("mkdir %s should fail with EACCESS\n", longer_name ); |
---|
| 608 | status = mkdir( longer_name , S_IRWXU ); |
---|
[2317457] | 609 | rtems_test_assert( status == -1 ); |
---|
| 610 | rtems_test_assert( errno == EACCES ); |
---|
[0895bdb] | 611 | |
---|
| 612 | printf("\n%s Should exist ( access )\n",Directories[0] ); |
---|
| 613 | status = access( Directories[0], F_OK ); |
---|
[2317457] | 614 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 615 | printf("\n%s Should have read permission( access )\n",Directories[0] ); |
---|
| 616 | status = access( Directories[0], R_OK ); |
---|
[2317457] | 617 | rtems_test_assert( status != 0 ); |
---|
[0895bdb] | 618 | printf("\n%s Should have write permission( access )\n",Directories[0] ); |
---|
| 619 | status = access( Directories[0], W_OK ); |
---|
[2317457] | 620 | rtems_test_assert( status != 0 ); |
---|
[0895bdb] | 621 | printf("\n%s Should not have execute permission( access )\n",Directories[0] ); |
---|
| 622 | status = access( Directories[0], X_OK ); |
---|
[2317457] | 623 | rtems_test_assert( status != 0 ); |
---|
[1b4f2b30] | 624 | |
---|
[0895bdb] | 625 | printf("\nRestore %s to RWX\n",Directories[0] ); |
---|
| 626 | status = chmod( Directories[0], S_IRWXU ); |
---|
[2317457] | 627 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 628 | |
---|
[2e3ce06] | 629 | printf("chdir to /my_mount_point \n"); |
---|
| 630 | status = chdir( "/my_mount_point" ); |
---|
[2317457] | 631 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 632 | |
---|
| 633 | /* |
---|
| 634 | * Remove one of the directories. |
---|
| 635 | * Verify links to the removed directory still work. |
---|
| 636 | */ |
---|
| 637 | |
---|
| 638 | printf( "Remove %s\n", Directories[5] ); |
---|
| 639 | status = rmdir( Directories[5] ); |
---|
[2317457] | 640 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 641 | |
---|
| 642 | stat_a_file( Directories[5] ); |
---|
| 643 | status = access( Directories[5], F_OK ); |
---|
[2317457] | 644 | rtems_test_assert( status != 0 ); |
---|
[0895bdb] | 645 | |
---|
| 646 | stat_a_file( Links_to_Dirs[5] ); |
---|
| 647 | status = readlink( Links_to_Dirs[5], longer_name, 3 ); |
---|
[2317457] | 648 | rtems_test_assert( status == -1 ); |
---|
| 649 | rtems_test_assert( errno == EINVAL ); |
---|
[0895bdb] | 650 | |
---|
| 651 | stat_a_file( Links_to_dirlinks[5] ); |
---|
| 652 | printf("Chdir to %s\n", Links_to_Dirs[5] ); |
---|
| 653 | status = chdir( Links_to_Dirs[5] ); |
---|
[2317457] | 654 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 655 | |
---|
| 656 | /* |
---|
| 657 | * Verify we cannot move up from a node with no parent node. |
---|
| 658 | */ |
---|
| 659 | |
---|
| 660 | printf("Chdir to .. should fail with ENOENT\n" ); |
---|
| 661 | status = chdir( ".." ); |
---|
[2317457] | 662 | rtems_test_assert( status == -1 ); |
---|
| 663 | rtems_test_assert( errno == ENOENT ); |
---|
[0895bdb] | 664 | |
---|
| 665 | /* |
---|
| 666 | * Create a subdirectory under the dangling node. |
---|
| 667 | */ |
---|
| 668 | |
---|
| 669 | printf("mkdir ../t should fail with ENOENT\n" ); |
---|
| 670 | status = mkdir( "../t" , S_IRWXU ); |
---|
[2317457] | 671 | rtems_test_assert( status == -1 ); |
---|
| 672 | rtems_test_assert( errno == ENOENT ); |
---|
[0895bdb] | 673 | |
---|
| 674 | printf("mkdir t\n"); |
---|
| 675 | status = mkdir( "t" , S_IRWXU ); |
---|
[2317457] | 676 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 677 | |
---|
[2e3ce06] | 678 | printf("chdir to /my_mount_point\n"); |
---|
| 679 | status = chdir( "/my_mount_point" ); |
---|
[2317457] | 680 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 681 | |
---|
| 682 | /* |
---|
| 683 | * Check rmdir, rmnod, and unlink |
---|
| 684 | */ |
---|
| 685 | |
---|
| 686 | printf("rmdir %s should fail with ENOTDIR\n", Links_to_Dirs[5] ); |
---|
| 687 | status = rmdir( Links_to_Dirs[5] ); |
---|
[2317457] | 688 | rtems_test_assert( status == -1 ); |
---|
| 689 | rtems_test_assert( errno == ENOTDIR ); |
---|
[0895bdb] | 690 | |
---|
| 691 | printf("unlink %s\n", Links_to_Dirs[5] ); |
---|
| 692 | status = unlink( Links_to_Dirs[5] ); |
---|
[2317457] | 693 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 694 | |
---|
| 695 | printf("unlink %s should fail with ENOTEMPTY\n", Links_to_dirlinks[5] ); |
---|
| 696 | status = unlink( Links_to_dirlinks[5] ); |
---|
[2317457] | 697 | rtems_test_assert( status == -1 ); |
---|
| 698 | rtems_test_assert( errno == ENOTEMPTY ); |
---|
[0895bdb] | 699 | |
---|
| 700 | strcpy( longer_name, Links_to_dirlinks[5] ); |
---|
| 701 | strcat( longer_name, "/t"); |
---|
| 702 | printf("rmdir %s\n", longer_name ); |
---|
| 703 | status = rmdir( longer_name ); |
---|
[2317457] | 704 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 705 | |
---|
| 706 | printf("unlink %s\n", Links_to_Dirs[5]); |
---|
| 707 | status = unlink( Links_to_dirlinks[5] ); |
---|
[2317457] | 708 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 709 | |
---|
| 710 | status = chdir( Directories[0] ); |
---|
| 711 | status = mkdir ( "my_mount_point", S_IRWXU ); |
---|
[2317457] | 712 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 713 | |
---|
| 714 | printf("Attempting to mount IMFS file system at /dir1/my_mount_point \n"); |
---|
| 715 | status = mount( |
---|
[042a442] | 716 | "null", |
---|
| 717 | "/my_mount_point/dir1/my_mount_point", |
---|
| 718 | "imfs", |
---|
[10794a7] | 719 | RTEMS_FILESYSTEM_READ_WRITE, |
---|
[042a442] | 720 | NULL ); |
---|
[2317457] | 721 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 722 | |
---|
| 723 | printf("rmdir /dir1/my_mount_point should fail with EBUSY\n"); |
---|
[2e3ce06] | 724 | status = rmdir ("/my_mount_point/dir1/my_mount_point" ); |
---|
[2317457] | 725 | rtems_test_assert( status == -1 ); |
---|
| 726 | rtems_test_assert( errno == EBUSY ); |
---|
[0895bdb] | 727 | |
---|
[2e3ce06] | 728 | printf( "Unmount /my_mount_point/dir1/my_mount_point\n"); |
---|
| 729 | status = unmount( "/my_mount_point/dir1/my_mount_point" ); |
---|
[2317457] | 730 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 731 | |
---|
| 732 | /* |
---|
| 733 | * Verify write permission is checked. |
---|
| 734 | */ |
---|
| 735 | |
---|
| 736 | printf("chmod of %s to group and other execute\n", Files[0] ); |
---|
| 737 | status = chmod (Files[0], (S_IXGRP | S_IXOTH) ); |
---|
[2317457] | 738 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 739 | |
---|
| 740 | printf("Open %s for write should fail with EACCES\n", Files[0] ); |
---|
[1b4f2b30] | 741 | fd = open (Files[0], O_WRONLY); |
---|
[2317457] | 742 | rtems_test_assert( fd == -1 ); |
---|
| 743 | rtems_test_assert( errno == EACCES ); |
---|
[0895bdb] | 744 | |
---|
| 745 | printf("chmod of %s to User Execute and Read\n", Directories[3] ); |
---|
| 746 | status = chmod (Directories[3], (S_IXUSR | S_IRUSR) ); |
---|
[2317457] | 747 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 748 | strcpy(longer_name, Directories[3] ); |
---|
| 749 | strcat(longer_name, "/NewFile" ); |
---|
| 750 | printf("Mkdir of %s should fail with EACCES\n",longer_name ); |
---|
| 751 | status = mkdir( longer_name, S_IRWXU ); |
---|
[2317457] | 752 | rtems_test_assert( status != 0 ); |
---|
| 753 | rtems_test_assert( errno == EACCES ); |
---|
[0895bdb] | 754 | |
---|
[1fbd283c] | 755 | printf("Making too many hard links.\n" ); |
---|
[0895bdb] | 756 | make_too_many_links( ); |
---|
| 757 | |
---|
| 758 | printf( "pass fstat a null pointer should fail with EFAULT\n"); |
---|
| 759 | status = fstat( fd, NULL ); |
---|
[2317457] | 760 | rtems_test_assert( status == -1 ); |
---|
| 761 | rtems_test_assert( errno == EFAULT); |
---|
[0895bdb] | 762 | |
---|
| 763 | /* |
---|
| 764 | * The current directory MUST be restored at the end of this test. |
---|
| 765 | */ |
---|
| 766 | |
---|
[2e3ce06] | 767 | printf("chdir to /my_mount_point \n"); |
---|
| 768 | status = chdir( "/my_mount_point" ); |
---|
[2317457] | 769 | rtems_test_assert( status == 0 ); |
---|
[0895bdb] | 770 | |
---|
| 771 | } |
---|
| 772 | |
---|
[b6912c40] | 773 | void Show_Time(void) |
---|
[0895bdb] | 774 | { |
---|
[a3ca5f36] | 775 | rtems_status_code sc; |
---|
[0895bdb] | 776 | rtems_time_of_day time; |
---|
| 777 | |
---|
[a3ca5f36] | 778 | sc = rtems_clock_get_tod( &time ); |
---|
| 779 | rtems_test_assert( sc == RTEMS_SUCCESSFUL ); |
---|
[17004308] | 780 | printf("--->Current Time: "); |
---|
[78076a2c] | 781 | print_time( " - rtems_clock_get_tod - ", &time, "\n" ); |
---|
[0895bdb] | 782 | } |
---|
| 783 | |
---|
[b05cc32] | 784 | void test_statvfs( void ) |
---|
| 785 | { |
---|
| 786 | |
---|
| 787 | int status = 0; |
---|
| 788 | struct statvfs stat; |
---|
| 789 | |
---|
[d0ef58a] | 790 | puts( "statvfs, with invalid path - expect ENOTSUP" ); |
---|
| 791 | status = statvfs( "" , &stat ); |
---|
[b05cc32] | 792 | rtems_test_assert( status == -1 ); |
---|
[d0ef58a] | 793 | rtems_test_assert( errno == ENOTSUP ); |
---|
[b05cc32] | 794 | |
---|
| 795 | puts( "create /tmp -- OK" ); |
---|
| 796 | status = mkdir( "/tmp", 0777 ); |
---|
| 797 | rtems_test_assert( status == 0 ); |
---|
| 798 | |
---|
| 799 | puts( "statvfs, with valid path - expect ENOTSUP" ); |
---|
| 800 | status = statvfs( "/tmp", &stat ); |
---|
| 801 | rtems_test_assert( status == -1 ); |
---|
| 802 | rtems_test_assert( errno == ENOTSUP ); |
---|
| 803 | |
---|
| 804 | puts( "statvfs tested!" ); |
---|
| 805 | } |
---|
| 806 | |
---|
[0895bdb] | 807 | /* |
---|
| 808 | * main entry point to the test |
---|
| 809 | */ |
---|
| 810 | |
---|
| 811 | #if defined(__rtems__) |
---|
| 812 | int test_main(void) |
---|
| 813 | #else |
---|
| 814 | int main( |
---|
| 815 | int argc, |
---|
| 816 | char **argv |
---|
| 817 | ) |
---|
| 818 | #endif |
---|
| 819 | { |
---|
[a3ca5f36] | 820 | rtems_status_code sc; |
---|
[042a442] | 821 | rtems_time_of_day time; |
---|
[15478c95] | 822 | int status; |
---|
[0895bdb] | 823 | |
---|
| 824 | puts( "\n\n*** STAT TEST 01 ***" ); |
---|
| 825 | |
---|
| 826 | build_time( &time, 12, 31, 1988, 9, 0, 0, 0 ); |
---|
[a3ca5f36] | 827 | sc = rtems_clock_set( &time ); |
---|
[2e3ce06] | 828 | Show_Time(); |
---|
| 829 | |
---|
| 830 | /* |
---|
| 831 | * Create and mount another version of the filesyste. |
---|
| 832 | * This allows expected node id's to be consistant across |
---|
| 833 | * platforms and bsp's. |
---|
| 834 | */ |
---|
| 835 | |
---|
| 836 | status = mkdir("/my_mount_point", S_IRWXU ); |
---|
[2317457] | 837 | rtems_test_assert( status == 0 ); |
---|
[2e3ce06] | 838 | status = mount( |
---|
[042a442] | 839 | "null", |
---|
| 840 | "my_mount_point", |
---|
| 841 | "imfs", |
---|
[2e3ce06] | 842 | RTEMS_FILESYSTEM_READ_WRITE, |
---|
[042a442] | 843 | NULL ); |
---|
[2317457] | 844 | rtems_test_assert( status == 0 ); |
---|
[2e3ce06] | 845 | status = chdir( "/my_mount_point" ); |
---|
[2317457] | 846 | rtems_test_assert( status == 0 ); |
---|
[2e3ce06] | 847 | status = mkdir("dev", S_IRWXU ); |
---|
[2317457] | 848 | rtems_test_assert( status == 0 ); |
---|
[2e3ce06] | 849 | |
---|
[0895bdb] | 850 | |
---|
| 851 | /* |
---|
| 852 | * Create the files and directories for the test. |
---|
| 853 | */ |
---|
| 854 | |
---|
| 855 | make_multiple_directories( Directories ); |
---|
| 856 | make_multiple_files( Files ); |
---|
| 857 | make_multiple_links( Directories, Links_to_Dirs ); |
---|
| 858 | make_multiple_links( Files, Links_to_Files ); |
---|
| 859 | |
---|
[a3ca5f36] | 860 | sc = rtems_task_wake_after( TIMEOUT_VALUE ); |
---|
| 861 | rtems_test_assert( sc == RTEMS_SUCCESSFUL ); |
---|
[0895bdb] | 862 | make_multiple_links( Links_to_Dirs, Links_to_dirlinks ); |
---|
[a3ca5f36] | 863 | sc = rtems_task_wake_after( TIMEOUT_VALUE ); |
---|
| 864 | rtems_test_assert( sc == RTEMS_SUCCESSFUL ); |
---|
[0895bdb] | 865 | make_multiple_links( Links_to_Files, Links_to_filelinks ); |
---|
| 866 | |
---|
[a3ca5f36] | 867 | sc = rtems_task_wake_after( TIMEOUT_VALUE ); |
---|
| 868 | rtems_test_assert( sc == RTEMS_SUCCESSFUL ); |
---|
[0895bdb] | 869 | |
---|
| 870 | /* |
---|
| 871 | * Now go through all the absolute path. |
---|
| 872 | */ |
---|
| 873 | |
---|
| 874 | puts( "Doing the stat() on all the good absolute paths" ); |
---|
| 875 | stat_multiple_files( Good_absolute_paths ); |
---|
| 876 | |
---|
| 877 | /* |
---|
| 878 | * run through the relative paths. |
---|
| 879 | */ |
---|
| 880 | |
---|
| 881 | puts( "\nDoing the stat() on all the good relative paths" ); |
---|
| 882 | stat_multiple_files( Good_relative_paths ); |
---|
| 883 | |
---|
| 884 | /* |
---|
| 885 | * Change directory and releative paths are now bad. |
---|
| 886 | */ |
---|
| 887 | |
---|
| 888 | puts("\nchdir to dev"); |
---|
| 889 | chdir("dev"); |
---|
| 890 | puts("\nstat relative paths that are now bad"); |
---|
| 891 | stat_multiple_files( Good_relative_paths ); |
---|
| 892 | |
---|
| 893 | /* |
---|
| 894 | * Change directory to the link directory and follow links. |
---|
| 895 | */ |
---|
| 896 | |
---|
| 897 | puts("\nchdir to ../links"); |
---|
| 898 | chdir("../links"); |
---|
| 899 | puts("Doing the stat() on good links\n"); |
---|
| 900 | stat_multiple_files( Links_to_Dirs ); |
---|
| 901 | stat_multiple_files( Links_to_Files ); |
---|
| 902 | stat_multiple_files( Links_to_dirlinks ); |
---|
| 903 | stat_multiple_files( Links_to_filelinks ); |
---|
[1b4f2b30] | 904 | |
---|
[0895bdb] | 905 | /* |
---|
| 906 | * Chmod on dir1/dir1. This allows the error path to be hit. |
---|
| 907 | */ |
---|
| 908 | |
---|
| 909 | printf( "chmod of %s to Read/Write\n", Directories[4] ); |
---|
| 910 | chmod( Directories[4], (S_IROTH|S_IWOTH) ); |
---|
| 911 | puts( "\nDoing the stat() on all the bad paths" ); |
---|
| 912 | |
---|
| 913 | stat_multiple_files( Bad_paths ); |
---|
| 914 | make_multiple_bad_files( Bad_paths ); |
---|
| 915 | |
---|
| 916 | printf( "Return %s to RWX\n", Directories[4] ); |
---|
| 917 | chmod( Directories[4], S_IRWXU ); |
---|
| 918 | |
---|
| 919 | |
---|
| 920 | /* |
---|
| 921 | * Check out symbolic links. |
---|
| 922 | */ |
---|
| 923 | |
---|
| 924 | make_multiple_symlinks(); |
---|
| 925 | make_many_symlinks( "/symlinks", 10 ); |
---|
| 926 | |
---|
[a3ca5f36] | 927 | sc = rtems_task_wake_after( TIMEOUT_VALUE ); |
---|
| 928 | rtems_test_assert( sc == RTEMS_SUCCESSFUL ); |
---|
[0895bdb] | 929 | Cause_faults(); |
---|
| 930 | |
---|
[a3ca5f36] | 931 | sc = rtems_task_wake_after( TIMEOUT_VALUE ); |
---|
| 932 | rtems_test_assert( sc == RTEMS_SUCCESSFUL ); |
---|
[0895bdb] | 933 | chown_multiple_files( Files ); |
---|
| 934 | |
---|
[a3ca5f36] | 935 | sc = rtems_task_wake_after( TIMEOUT_VALUE ); |
---|
| 936 | rtems_test_assert( sc == RTEMS_SUCCESSFUL ); |
---|
[0895bdb] | 937 | chown_multiple_files( Links_to_Dirs ); |
---|
[1b4f2b30] | 938 | |
---|
[a3ca5f36] | 939 | sc = rtems_task_wake_after( TIMEOUT_VALUE ); |
---|
| 940 | rtems_test_assert( sc == RTEMS_SUCCESSFUL ); |
---|
[c40d3c4b] | 941 | lchown_multiple_files( SymLinks ); |
---|
| 942 | |
---|
[b05cc32] | 943 | test_statvfs(); |
---|
| 944 | |
---|
[947015f] | 945 | puts( "Exercise the reentrant version - _stat_r - expect EFAULT" ); |
---|
| 946 | status = _stat_r( NULL, NULL, NULL ); |
---|
| 947 | rtems_test_assert( status == -1 ); |
---|
| 948 | rtems_test_assert( errno == EFAULT ); |
---|
| 949 | |
---|
| 950 | puts( "Exercise the reentrant version - _lstat_r - expect EFAULT" ); |
---|
| 951 | status = _lstat_r( NULL, NULL, NULL ); |
---|
| 952 | rtems_test_assert( status == -1 ); |
---|
| 953 | rtems_test_assert( errno == EFAULT ); |
---|
| 954 | |
---|
[efdc6987] | 955 | puts( "Try readlink with a bad buffer - expect EFAULT" ); |
---|
| 956 | status = readlink( "/tmp", NULL, 0 ); |
---|
| 957 | rtems_test_assert( status == -1 ); |
---|
| 958 | rtems_test_assert( errno == EFAULT ); |
---|
| 959 | |
---|
[0895bdb] | 960 | puts( "\n\n*** END OF STAT TEST 01 ***" ); |
---|
[d802489] | 961 | rtems_test_exit(0); |
---|
[0895bdb] | 962 | } |
---|