nftw64.c revision 1569799abe4296fc5ca50ede305c1eb2ac482422
1/* 2 * 3 * Copyright (c) International Business Machines Corp., 2002 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 13 * the GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 */ 19 20/* 10/31/2002 Port to LTP robbiew@us.ibm.com */ 21/* 06/30/2001 Port to Linux nsharoff@us.ibm.com */ 22 23/* 24 * NAME 25 * nftw64.c - Test of nftw64() 26 */ 27 28#include <pwd.h> 29#include "nftw64.h" 30 31void setup(void); 32void blenter(void); 33void blexit(void); 34void anyfail(void); 35 36char progname[] = "nftw64.c"; 37 38/** LTP Port **/ 39#define FAILED 0 40#define PASSED 1 41 42int local_flag = PASSED; 43int block_number; 44 45FILE *temp; 46char *TCID = "nftw6401"; /* Test program identifier. */ 47int TST_TOTAL = 10; /* Total number of test cases. */ 48 49struct passwd *ltpuser; /* password struct for ltpuser */ 50/**************/ 51 52/* Used for error return for some library routines */ 53int s2; 54 55/* error messages formatted here. */ 56char ebuf[ERR_BUF_SIZ]; 57 58/* 59 * Local data declarations. 60 */ 61char *dirlist[NDIRLISTENTS]; 62 63int visit; 64int next_fd[4]; 65 66pathdata pathdat[] = { 67 { 68 "./tmp/data", 69 S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH, 70 DIR, ""}, { 71 "./tmp/byebye", 72 S_IRWXU | S_IRWXG | S_IROTH | S_IWOTH, 73 REG, "byebye!\n"}, { 74 "./tmp/data/d333", 75 S_IRWXU | S_IRWXG | S_IRWXO, 76 DIR, ""}, { 77 "./tmp/data/d666", 78 S_IRWXU | S_IRWXG | S_IRWXO, 79 DIR, ""}, { 80 "./tmp/data/d777", 81 S_IRWXU | S_IRWXG 82 | S_IRWXO, 83 DIR, ""}, { 84 "./tmp/data/dirg", 85 S_IRWXU 86 | 87 S_IRWXG 88 | 89 S_IROTH 90 | 91 S_IWOTH, 92 DIR, 93 ""}, { 94 "./tmp/data/dirh", 95 S_IRWXU 96 | 97 S_IRWXG 98 | 99 S_IROTH 100 | 101 S_IWOTH, 102 DIR, 103 ""}, 104 { 105 "./tmp/data/dirl", 106 S_IRWXU | S_IRWXG | S_IROTH | S_IWOTH, 107 DIR, ""}, { 108 "./tmp/data/d333/errs", 109 S_IRWXU | S_IRWXG | S_IROTH | S_IWOTH, 110 REG, "Do not eat yellow snow!\n"}, { 111 "./tmp/data/d666/errs", 112 S_IRWXU | S_IRWXG | 113 S_IROTH | S_IWOTH, 114 REG, 115 "Do not eat yellow snow!\n"}, 116 { 117 "./tmp/data/d777/errs", 118 S_IRWXU | S_IRWXG | S_IROTH | S_IWOTH, 119 REG, "Do not eat yellow snow!\n"}, { 120 "./tmp/data/dirg/filebad", 121 S_IRUSR | S_IWUSR | S_IRGRP | 122 S_IROTH, 123 REG, ""}, { 124 "./tmp/data/dirg/fileok", 125 S_IRUSR | S_IWUSR | 126 S_IRGRP | S_IROTH, 127 REG, ""}, { 128 "./tmp/data/dirg/symlink", 129 S_IRWXU | 130 S_IRWXG | 131 S_IRWXO, 132 SYM, 133 "../../byebye"}, 134 { 135 "./tmp/data/dirg/dir_left.1", 136 S_IRWXU | S_IRWXG | S_IROTH | S_IWOTH, 137 DIR, ""}, { 138 "./tmp/data/dirg/dir_left.1/dir_left.2", 139 S_IRWXU | S_IRWXG | S_IROTH | S_IWOTH, 140 DIR, ""}, { 141 "./tmp/data/dirg/dir_right.1", 142 S_IRWXU | S_IRWXG | S_IRWXO, 143 DIR, ""}, { 144 "./tmp/data/dirg/dir_left.1/dir_left.2/left.3", 145 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP 146 | S_IROTH, 147 REG, ""}, { 148 "./tmp/data/dirh/dir_left.1", 149 S_IRWXU | S_IRWXG | S_IROTH 150 | S_IWOTH, 151 DIR, ""}, { 152 "./tmp/data/dirh/dir_right.1", 153 S_IRWXU | 154 S_IRWXG | 155 S_IROTH | 156 S_IWOTH, 157 DIR, ""}, { 158 "./tmp/data/dirh/dir_left.1/dir_left.2", 159 S_IRWXU 160 | 161 S_IRWXG 162 | 163 S_IROTH 164 | 165 S_IWOTH, 166 DIR, 167 ""}, 168 { 169 "./tmp/data/dirh/dir_left.1/dir_left.2/left.3", 170 S_IRWXU | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, 171 REG, "left leaf\n"}, { 172 "./tmp/data/dirh/dir_right.1/dir_right.2", 173 S_IRWXU | S_IRWXG | S_IROTH | S_IWOTH, 174 DIR, ""}, { 175 "./tmp/data/dirh/dir_right.1/dir_right.2/right.3", 176 S_IRWXU | S_IRGRP | S_IWGRP | S_IROTH 177 | S_IWOTH, 178 REG, "right leaf\n"}, { 179 "./tmp/data/dirl/dir_left.1", 180 S_IRWXU | 181 S_IRWXG | 182 S_IROTH | 183 S_IWOTH, 184 DIR, ""}, { 185 "./tmp/data/dirl/dir_left.1/dir_left.2", 186 S_IRWXU 187 | 188 S_IRWXG 189 | 190 S_IROTH 191 | 192 S_IWOTH, 193 DIR, 194 ""}, 195 { 196 "./tmp/data/dirl/dir_left.1/dir_left.2/left.3", 197 0, 198 SYM, "../../../dirh"}, { 199 "./tmp/data/dirl/dir_right.1", 200 S_IRWXU | S_IRWXG | S_IROTH | S_IWOTH, 201 DIR, ""}, { 202 "./tmp/data/dirl/dir_right.1/dir_right.2", 203 S_IRWXU | S_IRWXG | S_IROTH | 204 S_IWOTH, 205 DIR, ""}, { 206 "./tmp/data/dirl/dir_right.1/dir_right.2/right.3", 207 0, 208 SYM, "../dir_right.2"}, { 209 "./tmp/data/loop", 210 0, 211 SYM, 212 "./loop"} 213}; 214 215char *goodlist[] = { 216 "/dirh", 217 "/dirh/dir_left.1", 218 "/dirh/dir_right.1", 219 "/dirh/dir_left.1/dir_left.2", 220 "/dirh/dir_right.1/dir_right.2", 221 "/dirh/dir_left.1/dir_left.2/left.3", 222 "/dirh/dir_right.1/dir_right.2/right.3" 223}; 224 225struct list badlist[] = { 226 {"/dirg", FTW_D}, 227 {"/dirg/dir_left.1", FTW_D}, 228 /* not FTW_NS in following since stat can't fail if file exists */ 229 {"/dirg/filebad", FTW_F}, 230 {"/dirg/fileok", FTW_F}, 231 {"/dirg/symlink", FTW_SL}, 232 {"/dirg/dir_right.1", FTW_DNR}, 233 {"/dirg/dir_left.1/dir_left.2", FTW_D}, 234 {"/dirg/dir_left.1/dir_left.2/left.3", FTW_F}, 235}; 236 237struct list mnem[] = { 238 {"FTW_F", FTW_F}, 239 {"FTW_D", FTW_D}, 240 {"FTW_DNR", FTW_DNR}, 241 {"FTW_NS", FTW_NS}, 242 {"FTW_SL", FTW_SL}, 243 {"FTW_DP", FTW_DP}, 244 {"FTW_SLN", FTW_SLN}, 245}; 246 247int npathdats, ngoods, nbads, nmnem; 248 249/*--------------------------------------------------------------*/ 250int 251main(void) 252{ 253 setup(); /* temp file is now open */ 254 255 npathdats = (sizeof(pathdat) / sizeof(pathdat[0])); 256 ngoods = (sizeof(goodlist) / sizeof(goodlist[0])); 257 nbads = (sizeof(badlist) / sizeof(badlist[0])); 258 nmnem = (sizeof(mnem) / sizeof(mnem[0])); 259 260 setup_path(); 261 262/*---------------- ENTER BLOCK 0 --------------------------------*/ 263 blenter(); 264#ifdef DEBUG 265 fprintf(temp, 266 "A call to int nftw64(const char *path, int (*fn)(const\n"); 267 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 268 fprintf(temp, "depth, int flags) shall recursively descend the\n"); 269 fprintf(temp, "directory hierarchy rooted in path until it has\n"); 270 fprintf(temp, 271 "traversed the whole tree, calling the function fn for\n"); 272 fprintf(temp, "each object in the directory tree, and return 0.\n\n"); 273#endif 274 test1A(); 275 blexit(); 276/*--------------- EXIT BLOCK 0 ---------------------------------*/ 277 278/*---------------- ENTER BLOCK 1 --------------------------------*/ 279 blenter(); 280#ifdef DEBUG 281 fprintf(temp, 282 "A call to int nftw64(const char *path, int (*fn)(const\n"); 283 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 284 fprintf(temp, "depth, int flags) when flags contains FTW_PHYS shall\n"); 285 fprintf(temp, "not traverse symbolic links.\n\n"); 286#endif 287 test2A(); 288 blexit(); 289/*--------------- EXIT BLOCK 1 ---------------------------------*/ 290 291/*---------------- ENTER BLOCK 2 --------------------------------*/ 292 blenter(); 293#ifdef DEBUG 294 fprintf(temp, 295 "A call to int nftw64(const char *path, int (*fn)(const\n"); 296 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 297 fprintf(temp, 298 "depth, int flags) when flags does not contain FTW_PHYS\n"); 299 fprintf(temp, 300 "shall follow links instead of reporting them and shall\n"); 301 fprintf(temp, "not report the same file twice.\n\n"); 302#endif 303 test3A(); 304 blexit(); 305/*--------------- EXIT BLOCK 2 ---------------------------------*/ 306 307/*---------------- ENTER BLOCK 3 --------------------------------*/ 308 blenter(); 309#ifdef DEBUG 310 fprintf(temp, 311 "A call to int nftw64(const char *path, int (*fn)(const\n"); 312 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 313 fprintf(temp, 314 "depth, int flags) when flags contains FTW_DEPTH shall\n"); 315 fprintf(temp, "report all files in a directory before reporting the\n"); 316 fprintf(temp, "directory.\n\n"); 317#endif 318 test4A(); 319 blexit(); 320/*--------------- EXIT BLOCK 3 ---------------------------------*/ 321 322/*---------------- ENTER BLOCK 4 --------------------------------*/ 323 blenter(); 324#ifdef DEBUG 325 fprintf(temp, 326 "A call to int nftw64(const char *path, int (*fn)(const\n"); 327 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 328 fprintf(temp, "depth, int flags) when flags does not contain\n"); 329 fprintf(temp, "FTW_DEPTH shall report a directory before reporting\n"); 330 fprintf(temp, "the files in that directory.\n\n"); 331#endif 332 test5A(); 333 blexit(); 334/*--------------- EXIT BLOCK 4 ---------------------------------*/ 335 336/*---------------- ENTER BLOCK 5 --------------------------------*/ 337 blenter(); 338#ifdef DEBUG 339 fprintf(temp, 340 "A call to int nftw64(const char *path, int (*fn)(const\n"); 341 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 342 fprintf(temp, 343 "depth, int flags) when flags contains FTW_CHDIR shall\n"); 344 fprintf(temp, 345 "change the current working directory to each directory\n"); 346 fprintf(temp, "as it reports files in that directory.\n\n"); 347#endif 348 test6A(); 349 blexit(); 350/*--------------- EXIT BLOCK 5 ---------------------------------*/ 351 352/*---------------- ENTER BLOCK 6 --------------------------------*/ 353 blenter(); 354#ifdef DEBUG 355 fprintf(temp, 356 "A call to int nftw64(const char *path, int (*fn)(const\n"); 357 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 358 fprintf(temp, "depth, int flags) shall pass the path-name of the\n"); 359 fprintf(temp, "current object as the first argument of the function\n"); 360 fprintf(temp, "fn.\n\n"); 361#endif 362 test7A(); 363 blexit(); 364/*--------------- EXIT BLOCK 6 ---------------------------------*/ 365 366/*---------------- ENTER BLOCK 7 --------------------------------*/ 367 blenter(); 368#ifdef DEBUG 369 fprintf(temp, 370 "A call to int nftw64(const char *path, int (*fn)(const\n"); 371 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 372 fprintf(temp, "depth, int flags) shall pass a pointer to a stat\n"); 373 fprintf(temp, "structure containing information about the current\n"); 374 fprintf(temp, "object as the second argument to fn.\n\n"); 375#endif 376 test8A(); 377 blexit(); 378/*--------------- EXIT BLOCK 7 ---------------------------------*/ 379 380/*---------------- ENTER BLOCK 8 --------------------------------*/ 381 blenter(); 382#ifdef DEBUG 383 fprintf(temp, 384 "A call to int nftw64(const char *path, int (*fn)(const\n"); 385 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 386 fprintf(temp, "depth, int flags) shall pass FTW_F as the third\n"); 387 fprintf(temp, 388 "argument of the function fn when the object is a file.\n\n"); 389#endif 390 test9A(); 391 blexit(); 392/*--------------- EXIT BLOCK 8 ---------------------------------*/ 393 394/*---------------- ENTER BLOCK 9 --------------------------------*/ 395 blenter(); 396#ifdef DEBUG 397 fprintf(temp, 398 "A call to int nftw64(const char *path, int (*fn)(const\n"); 399 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 400 fprintf(temp, "depth, int flags) shall pass FTW_D as the third\n"); 401 fprintf(temp, "argument of the function fn when the object is a\n"); 402 fprintf(temp, "directory.\n\n"); 403#endif 404 test10A(); 405 blexit(); 406/*--------------- EXIT BLOCK 9 ---------------------------------*/ 407 408/*---------------- ENTER BLOCK 10 --------------------------------*/ 409 blenter(); 410#ifdef DEBUG 411 fprintf(temp, 412 "A call to int nftw64(const char *path, int (*fn)(const\n"); 413 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 414 fprintf(temp, "depth, int flags) shall pass FTW_DP as the third\n"); 415 fprintf(temp, "argument of the function fn when the object is a\n"); 416 fprintf(temp, "directory and subdirectories have been visited.\n\n"); 417#endif 418 test11A(); 419 blexit(); 420/*--------------- EXIT BLOCK 10 ---------------------------------*/ 421 422/*---------------- ENTER BLOCK 11 --------------------------------*/ 423 blenter(); 424#ifdef DEBUG 425 fprintf(temp, 426 "A call to int nftw64(const char *path, int (*fn)(const\n"); 427 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 428 fprintf(temp, "depth, int flags) shall pass FTW_SL as the third\n"); 429 fprintf(temp, "argument of the function fn when the object is a\n"); 430 fprintf(temp, "symbolic link.\n\n"); 431#endif 432 test12A(); 433 blexit(); 434/*--------------- EXIT BLOCK 11 ---------------------------------*/ 435 436/*---------------- ENTER BLOCK 12 --------------------------------*/ 437 blenter(); 438#ifdef DEBUG 439 fprintf(temp, 440 "A call to int nftw64(const char *path, int (*fn)(const\n"); 441 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 442 fprintf(temp, "depth, int flags) shall pass FTW_SLN as the third\n"); 443 fprintf(temp, "argument of the function fn when the object is a\n"); 444 fprintf(temp, "symbolic link that does not name an existing file.\n\n"); 445#endif 446 test13A(); 447 blexit(); 448/*--------------- EXIT BLOCK 12 ---------------------------------*/ 449 450/*---------------- ENTER BLOCK 13 --------------------------------*/ 451 blenter(); 452#ifdef DEBUG 453 fprintf(temp, 454 "A call to int nftw64(const char *path, int (*fn)(const\n"); 455 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 456 fprintf(temp, "depth, int flags) shall pass FTW_DNR as the third\n"); 457 fprintf(temp, "argument of the function fn when the object is a\n"); 458 fprintf(temp, "directory that cannot be read.\n\n"); 459#endif 460 test14A(); 461 blexit(); 462/*--------------- EXIT BLOCK 13 ---------------------------------*/ 463 464/*---------------- ENTER BLOCK 14 --------------------------------*/ 465 blenter(); 466#ifdef DEBUG 467 fprintf(temp, 468 "A call to int nftw64(const char *path, int (*fn)(const\n"); 469 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 470 fprintf(temp, "depth, int flags) shall pass FTW_NS as the third\n"); 471 fprintf(temp, 472 "argument of the function fn when stat() failed on the\n"); 473 fprintf(temp, "object because of lack of appropriate permission.\n\n"); 474#endif 475 test15A(); 476 blexit(); 477/*--------------- EXIT BLOCK 14 ---------------------------------*/ 478 479/*---------------- ENTER BLOCK 15 --------------------------------*/ 480 blenter(); 481#ifdef DEBUG 482 fprintf(temp, 483 "A call to int nftw64(const char *path, int (*fn)(const\n"); 484 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 485 fprintf(temp, "depth, int flags) shall pass a structure which\n"); 486 fprintf(temp, "contains the offset into the pathname of the object\n"); 487 fprintf(temp, "and the depth relative to the root of the walk\n"); 488 fprintf(temp, 489 "starting from 0 as the fourth argument of the function\n"); 490 fprintf(temp, "fn.\n\n"); 491#endif 492 test16A(); 493 blexit(); 494/*--------------- EXIT BLOCK 15 ---------------------------------*/ 495 496/*---------------- ENTER BLOCK 16 --------------------------------*/ 497 blenter(); 498#ifdef DEBUG 499 fprintf(temp, 500 "A call to int nftw64(const char *path, int (*fn)(const\n"); 501 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 502 fprintf(temp, "depth, int flags) shall pass FTW_SL as the third\n"); 503 fprintf(temp, "argument to the function fn if and only if the\n"); 504 fprintf(temp, "FTW_PHYS flag is included in flags.\n\n"); 505#endif 506 test17A(); 507 blexit(); 508/*--------------- EXIT BLOCK 16 ---------------------------------*/ 509 510/*---------------- ENTER BLOCK 17 --------------------------------*/ 511 blenter(); 512#ifdef DEBUG 513 fprintf(temp, 514 "A call to int nftw64(const char *path, int (*fn)(const\n"); 515 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 516 fprintf(temp, "depth, int flags) shall pass FTW_SLN as the third\n"); 517 fprintf(temp, "argument to the function fn if and only if the\n"); 518 fprintf(temp, "FTW_PHYS flag is not included in flags.\n\n"); 519#endif 520 test18A(); 521 blexit(); 522/*--------------- EXIT BLOCK 17 ---------------------------------*/ 523 524/*---------------- ENTER BLOCK 18 --------------------------------*/ 525 blenter(); 526#ifdef DEBUG 527 fprintf(temp, "On a call to int nftw64(const char *path, int\n"); 528 fprintf(temp, "(*fn)(const char *, const struct stat *, int, struct\n"); 529 fprintf(temp, 530 "FTW *), int depth, int flags) when the third argument\n"); 531 fprintf(temp, "passed to the function fn is FTW_DNR then the\n"); 532 fprintf(temp, 533 "descendants of the directory shall not be processed.\n\n"); 534#endif 535 test19A(); 536 blexit(); 537/*--------------- EXIT BLOCK 18 ---------------------------------*/ 538 539/*---------------- ENTER BLOCK 19 --------------------------------*/ 540 blenter(); 541#ifdef DEBUG 542 fprintf(temp, 543 "A call to int nftw64(const char *path, int (*fn)(const\n"); 544 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 545 fprintf(temp, 546 "depth, int flags) shall close any file descriptors or\n"); 547 fprintf(temp, 548 "directory streams used to traverse the directory tree.\n\n"); 549#endif 550 test20A(); 551 blexit(); 552/*--------------- EXIT BLOCK 19 ---------------------------------*/ 553 554/*---------------- ENTER BLOCK 20 --------------------------------*/ 555 blenter(); 556#ifdef DEBUG 557 fprintf(temp, "On a call to int nftw64(const char *path, int\n"); 558 fprintf(temp, "(*fn)(const char *, const struct stat *, int, struct\n"); 559 fprintf(temp, "FTW *), int depth, int flags) depth shall be the\n"); 560 fprintf(temp, 561 "maximum number of file descriptors used for the search.\n\n"); 562#endif 563 test21A(); 564 blexit(); 565/*--------------- EXIT BLOCK 20 ---------------------------------*/ 566 567/*---------------- ENTER BLOCK 21 --------------------------------*/ 568 blenter(); 569#ifdef DEBUG 570 fprintf(temp, 571 "A call to int nftw64(const char *path, int (*fn)(const\n"); 572 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 573 fprintf(temp, "depth, int flags) shall use at most one file\n"); 574 fprintf(temp, "descriptor for each directory level.\n\n"); 575#endif 576 test22A(); 577 blexit(); 578/*--------------- EXIT BLOCK 21 ---------------------------------*/ 579 580/*---------------- ENTER BLOCK 22 --------------------------------*/ 581 blenter(); 582#ifdef DEBUG 583 fprintf(temp, 584 "A call to int nftw64(const char *path, int (*fn)(const\n"); 585 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n"); 586 fprintf(temp, "depth, int flags) when the function fn returns a\n"); 587 fprintf(temp, "non-zero value shall stop and return the value\n"); 588 fprintf(temp, "returned by fn.\n\n"); 589#endif 590 test23A(); 591 blexit(); 592/*--------------- EXIT BLOCK 22 ---------------------------------*/ 593 594/*---------------- ENTER BLOCK 23 --------------------------------*/ 595 blenter(); 596#ifdef DEBUG 597 fprintf(temp, "ENAMETOOLONG in errno and return -1 on a call to int\n"); 598 fprintf(temp, 599 "nftw64(const char *path, int (*fn)(const char *, const\n"); 600 fprintf(temp, "struct stat *, int, struct FTW *), int depth, int\n"); 601 fprintf(temp, "flags) when the length of path exceeds PATH_MAX.\n\n"); 602#endif 603 test24A(); 604 blexit(); 605/*--------------- EXIT BLOCK 23 ---------------------------------*/ 606 607/*---------------- ENTER BLOCK 24 --------------------------------*/ 608 blenter(); 609#ifdef DEBUG 610 fprintf(temp, "ENAMETOOLONG in errno and return -1 on a call to int\n"); 611 fprintf(temp, 612 "nftw64(const char *path, int (*fn)(const char *, const\n"); 613 fprintf(temp, "struct stat *, int, struct FTW *), int depth, int\n"); 614 fprintf(temp, "flags) when a component of path exceeds NAME_MAX.\n\n"); 615#endif 616 test25A(); 617 blexit(); 618/*--------------- EXIT BLOCK 24 ---------------------------------*/ 619 620/*---------------- ENTER BLOCK 25 --------------------------------*/ 621 blenter(); 622#ifdef DEBUG 623 fprintf(temp, "ENOENT in errno and return -1 on a call to int\n"); 624 fprintf(temp, 625 "nftw64(const char *path, int (*fn)(const char *, const\n"); 626 fprintf(temp, "struct stat *, int, struct FTW *), int depth, int\n"); 627 fprintf(temp, 628 "flags) when path points to a file which does not exist.\n\n"); 629#endif 630 test26A(); 631 blexit(); 632/*--------------- EXIT BLOCK 25 ---------------------------------*/ 633 634/*---------------- ENTER BLOCK 26 --------------------------------*/ 635 blenter(); 636#ifdef DEBUG 637 fprintf(temp, "ENOENT in errno and return -1 on a call to int\n"); 638 fprintf(temp, 639 "nftw64(const char *path, int (*fn)(const char *, const\n"); 640 fprintf(temp, "struct stat *, int, struct FTW *), int depth, int\n"); 641 fprintf(temp, "flags) when path points to an empty string.\n\n"); 642#endif 643 test27A(); 644 blexit(); 645/*--------------- EXIT BLOCK 26 ---------------------------------*/ 646 647/*---------------- ENTER BLOCK 27 --------------------------------*/ 648 blenter(); 649#ifdef DEBUG 650 fprintf(temp, "ENOTDIR in errno and return -1 on a call to int\n"); 651 fprintf(temp, 652 "nftw64(const char *path, int (*fn)(const char *, const\n"); 653 fprintf(temp, "struct stat *, int, struct FTW *), int depth, int\n"); 654 fprintf(temp, "flags) when path is not a directory.\n\n"); 655#endif 656 test28A(); 657 blexit(); 658/*--------------- EXIT BLOCK 27 ---------------------------------*/ 659 660/*---------------- ENTER BLOCK 28 --------------------------------*/ 661 blenter(); 662#ifdef DEBUG 663 fprintf(temp, "EACCES in errno and return -1 on a call to int\n"); 664 fprintf(temp, 665 "nftw64(const char *path, int (*fn)(const char *, const\n"); 666 fprintf(temp, "struct stat *, int, struct FTW *), int depth, int\n"); 667 fprintf(temp, "flags) when search permission is denied for any\n"); 668 fprintf(temp, "component of path.\n\n"); 669#endif 670 test29A(); 671 blexit(); 672/*--------------- EXIT BLOCK 28 ---------------------------------*/ 673 674/*---------------- ENTER BLOCK 29 --------------------------------*/ 675 blenter(); 676#ifdef DEBUG 677 fprintf(temp, "EACCES in errno and return -1 on a call to int\n"); 678 fprintf(temp, 679 "nftw64(const char *path, int (*fn)(const char *, const\n"); 680 fprintf(temp, "struct stat *, int, struct FTW *), int depth, int\n"); 681 fprintf(temp, "flags) when read permission is denied for path.\n\n"); 682#endif 683 test30A(); 684 blexit(); 685/*--------------- EXIT BLOCK 29 ---------------------------------*/ 686 687 cleanup_function(); 688 689 anyfail(); /* THIS CALL DOES NOT RETURN - EXITS!! */ 690 691 tst_exit(); 692} 693 694/*--------------------------------------------------------------*/ 695 696/** LTP Port **/ 697/* 698 * setup 699 * 700 * Do set up - here its a dummy function 701 */ 702void setup() 703{ 704 /* Direct debug output to stderr */ 705 temp = stderr; 706 707 /* Get the user id "nobody" */ 708 if ((ltpuser = getpwnam("nobody")) == NULL) { 709 perror("change_owner: nobody not found in /etc/passwd"); 710 exit(1); 711 } 712 713 /* Switch to "nobody" */ 714 setuid(ltpuser->pw_uid); 715 716 tst_tmpdir(); 717} 718 719/* 720 * Function: blenter() 721 * 722 * Description: Print message on entering a new block 723 */ 724void blenter() 725{ 726 local_flag = PASSED; 727 return; 728} 729 730/* 731 * Function: blexit() 732 * 733 * Description: This function will exit a block, a block may be a logical unit 734 * of a test. It will report the status if the test ie fail or 735 * pass. 736 */ 737void blexit() 738{ 739 (local_flag == PASSED) ? tst_resm(TPASS, "Test block %d", block_number) 740 : tst_resm(TFAIL, "Test block %d", block_number); 741 block_number++; 742 return; 743} 744 745/* 746 * 747 * Function: anyfail() 748 * 749 * Description: Exit a test. 750 */ 751void anyfail() 752{ 753 (local_flag == FAILED) ? tst_resm(TFAIL, "Test failed") 754 : tst_resm(TPASS, "Test passed"); 755 tst_rmdir(); 756 tst_exit(); 757} 758 759/**************/