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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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
31 void setup(void);
32 void blenter(void);
33 void blexit(void);
34 void anyfail(void);
35
36 char progname[] = "nftw64.c";
37
38 /** LTP Port **/
39 #define FAILED 0
40 #define PASSED 1
41
42 int local_flag = PASSED;
43 int block_number;
44
45 FILE *temp;
46 char *TCID = "nftw6401";
47 int TST_TOTAL = 10;
48
49 struct passwd *ltpuser; /* password struct for ltpuser */
50 /**************/
51
52 /* Used for error return for some library routines */
53 int s2;
54
55 /* error messages formatted here. */
56 char ebuf[ERR_BUF_SIZ];
57
58 /*
59 * Local data declarations.
60 */
61 char *dirlist[NDIRLISTENTS];
62
63 int visit;
64 int next_fd[4];
65
66 pathdata 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
215 char *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
225 struct 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
237 struct 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
247 int npathdats, ngoods, nbads, nmnem;
248
249 /*--------------------------------------------------------------*/
main(void)250 int main(void)
251 {
252 setup(); /* temp file is now open */
253
254 npathdats = ARRAY_SIZE(pathdat);
255 ngoods = ARRAY_SIZE(goodlist);
256 nbads = ARRAY_SIZE(badlist);
257 nmnem = ARRAY_SIZE(mnem);
258
259 setup_path();
260
261 /*---------------- ENTER BLOCK 0 --------------------------------*/
262 blenter();
263 #ifdef DEBUG
264 fprintf(temp,
265 "A call to int nftw64(const char *path, int (*fn)(const\n");
266 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
267 fprintf(temp, "depth, int flags) shall recursively descend the\n");
268 fprintf(temp, "directory hierarchy rooted in path until it has\n");
269 fprintf(temp,
270 "traversed the whole tree, calling the function fn for\n");
271 fprintf(temp, "each object in the directory tree, and return 0.\n\n");
272 #endif
273 test1A();
274 blexit();
275 /*--------------- EXIT BLOCK 0 ---------------------------------*/
276
277 /*---------------- ENTER BLOCK 1 --------------------------------*/
278 blenter();
279 #ifdef DEBUG
280 fprintf(temp,
281 "A call to int nftw64(const char *path, int (*fn)(const\n");
282 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
283 fprintf(temp, "depth, int flags) when flags contains FTW_PHYS shall\n");
284 fprintf(temp, "not traverse symbolic links.\n\n");
285 #endif
286 test2A();
287 blexit();
288 /*--------------- EXIT BLOCK 1 ---------------------------------*/
289
290 /*---------------- ENTER BLOCK 2 --------------------------------*/
291 blenter();
292 #ifdef DEBUG
293 fprintf(temp,
294 "A call to int nftw64(const char *path, int (*fn)(const\n");
295 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
296 fprintf(temp,
297 "depth, int flags) when flags does not contain FTW_PHYS\n");
298 fprintf(temp,
299 "shall follow links instead of reporting them and shall\n");
300 fprintf(temp, "not report the same file twice.\n\n");
301 #endif
302 test3A();
303 blexit();
304 /*--------------- EXIT BLOCK 2 ---------------------------------*/
305
306 /*---------------- ENTER BLOCK 3 --------------------------------*/
307 blenter();
308 #ifdef DEBUG
309 fprintf(temp,
310 "A call to int nftw64(const char *path, int (*fn)(const\n");
311 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
312 fprintf(temp,
313 "depth, int flags) when flags contains FTW_DEPTH shall\n");
314 fprintf(temp, "report all files in a directory before reporting the\n");
315 fprintf(temp, "directory.\n\n");
316 #endif
317 test4A();
318 blexit();
319 /*--------------- EXIT BLOCK 3 ---------------------------------*/
320
321 /*---------------- ENTER BLOCK 4 --------------------------------*/
322 blenter();
323 #ifdef DEBUG
324 fprintf(temp,
325 "A call to int nftw64(const char *path, int (*fn)(const\n");
326 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
327 fprintf(temp, "depth, int flags) when flags does not contain\n");
328 fprintf(temp, "FTW_DEPTH shall report a directory before reporting\n");
329 fprintf(temp, "the files in that directory.\n\n");
330 #endif
331 test5A();
332 blexit();
333 /*--------------- EXIT BLOCK 4 ---------------------------------*/
334
335 /*---------------- ENTER BLOCK 5 --------------------------------*/
336 blenter();
337 #ifdef DEBUG
338 fprintf(temp,
339 "A call to int nftw64(const char *path, int (*fn)(const\n");
340 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
341 fprintf(temp,
342 "depth, int flags) when flags contains FTW_CHDIR shall\n");
343 fprintf(temp,
344 "change the current working directory to each directory\n");
345 fprintf(temp, "as it reports files in that directory.\n\n");
346 #endif
347 test6A();
348 blexit();
349 /*--------------- EXIT BLOCK 5 ---------------------------------*/
350
351 /*---------------- ENTER BLOCK 6 --------------------------------*/
352 blenter();
353 #ifdef DEBUG
354 fprintf(temp,
355 "A call to int nftw64(const char *path, int (*fn)(const\n");
356 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
357 fprintf(temp, "depth, int flags) shall pass the path-name of the\n");
358 fprintf(temp, "current object as the first argument of the function\n");
359 fprintf(temp, "fn.\n\n");
360 #endif
361 test7A();
362 blexit();
363 /*--------------- EXIT BLOCK 6 ---------------------------------*/
364
365 /*---------------- ENTER BLOCK 7 --------------------------------*/
366 blenter();
367 #ifdef DEBUG
368 fprintf(temp,
369 "A call to int nftw64(const char *path, int (*fn)(const\n");
370 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
371 fprintf(temp, "depth, int flags) shall pass a pointer to a stat\n");
372 fprintf(temp, "structure containing information about the current\n");
373 fprintf(temp, "object as the second argument to fn.\n\n");
374 #endif
375 test8A();
376 blexit();
377 /*--------------- EXIT BLOCK 7 ---------------------------------*/
378
379 /*---------------- ENTER BLOCK 8 --------------------------------*/
380 blenter();
381 #ifdef DEBUG
382 fprintf(temp,
383 "A call to int nftw64(const char *path, int (*fn)(const\n");
384 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
385 fprintf(temp, "depth, int flags) shall pass FTW_F as the third\n");
386 fprintf(temp,
387 "argument of the function fn when the object is a file.\n\n");
388 #endif
389 test9A();
390 blexit();
391 /*--------------- EXIT BLOCK 8 ---------------------------------*/
392
393 /*---------------- ENTER BLOCK 9 --------------------------------*/
394 blenter();
395 #ifdef DEBUG
396 fprintf(temp,
397 "A call to int nftw64(const char *path, int (*fn)(const\n");
398 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
399 fprintf(temp, "depth, int flags) shall pass FTW_D as the third\n");
400 fprintf(temp, "argument of the function fn when the object is a\n");
401 fprintf(temp, "directory.\n\n");
402 #endif
403 test10A();
404 blexit();
405 /*--------------- EXIT BLOCK 9 ---------------------------------*/
406
407 /*---------------- ENTER BLOCK 10 --------------------------------*/
408 blenter();
409 #ifdef DEBUG
410 fprintf(temp,
411 "A call to int nftw64(const char *path, int (*fn)(const\n");
412 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
413 fprintf(temp, "depth, int flags) shall pass FTW_DP as the third\n");
414 fprintf(temp, "argument of the function fn when the object is a\n");
415 fprintf(temp, "directory and subdirectories have been visited.\n\n");
416 #endif
417 test11A();
418 blexit();
419 /*--------------- EXIT BLOCK 10 ---------------------------------*/
420
421 /*---------------- ENTER BLOCK 11 --------------------------------*/
422 blenter();
423 #ifdef DEBUG
424 fprintf(temp,
425 "A call to int nftw64(const char *path, int (*fn)(const\n");
426 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
427 fprintf(temp, "depth, int flags) shall pass FTW_SL as the third\n");
428 fprintf(temp, "argument of the function fn when the object is a\n");
429 fprintf(temp, "symbolic link.\n\n");
430 #endif
431 test12A();
432 blexit();
433 /*--------------- EXIT BLOCK 11 ---------------------------------*/
434
435 /*---------------- ENTER BLOCK 12 --------------------------------*/
436 blenter();
437 #ifdef DEBUG
438 fprintf(temp,
439 "A call to int nftw64(const char *path, int (*fn)(const\n");
440 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
441 fprintf(temp, "depth, int flags) shall pass FTW_SLN as the third\n");
442 fprintf(temp, "argument of the function fn when the object is a\n");
443 fprintf(temp, "symbolic link that does not name an existing file.\n\n");
444 #endif
445 test13A();
446 blexit();
447 /*--------------- EXIT BLOCK 12 ---------------------------------*/
448
449 /*---------------- ENTER BLOCK 13 --------------------------------*/
450 blenter();
451 #ifdef DEBUG
452 fprintf(temp,
453 "A call to int nftw64(const char *path, int (*fn)(const\n");
454 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
455 fprintf(temp, "depth, int flags) shall pass FTW_DNR as the third\n");
456 fprintf(temp, "argument of the function fn when the object is a\n");
457 fprintf(temp, "directory that cannot be read.\n\n");
458 #endif
459 test14A();
460 blexit();
461 /*--------------- EXIT BLOCK 13 ---------------------------------*/
462
463 /*---------------- ENTER BLOCK 14 --------------------------------*/
464 blenter();
465 #ifdef DEBUG
466 fprintf(temp,
467 "A call to int nftw64(const char *path, int (*fn)(const\n");
468 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
469 fprintf(temp, "depth, int flags) shall pass FTW_NS as the third\n");
470 fprintf(temp,
471 "argument of the function fn when stat() failed on the\n");
472 fprintf(temp, "object because of lack of appropriate permission.\n\n");
473 #endif
474 test15A();
475 blexit();
476 /*--------------- EXIT BLOCK 14 ---------------------------------*/
477
478 /*---------------- ENTER BLOCK 15 --------------------------------*/
479 blenter();
480 #ifdef DEBUG
481 fprintf(temp,
482 "A call to int nftw64(const char *path, int (*fn)(const\n");
483 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
484 fprintf(temp, "depth, int flags) shall pass a structure which\n");
485 fprintf(temp, "contains the offset into the pathname of the object\n");
486 fprintf(temp, "and the depth relative to the root of the walk\n");
487 fprintf(temp,
488 "starting from 0 as the fourth argument of the function\n");
489 fprintf(temp, "fn.\n\n");
490 #endif
491 test16A();
492 blexit();
493 /*--------------- EXIT BLOCK 15 ---------------------------------*/
494
495 /*---------------- ENTER BLOCK 16 --------------------------------*/
496 blenter();
497 #ifdef DEBUG
498 fprintf(temp,
499 "A call to int nftw64(const char *path, int (*fn)(const\n");
500 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
501 fprintf(temp, "depth, int flags) shall pass FTW_SL as the third\n");
502 fprintf(temp, "argument to the function fn if and only if the\n");
503 fprintf(temp, "FTW_PHYS flag is included in flags.\n\n");
504 #endif
505 test17A();
506 blexit();
507 /*--------------- EXIT BLOCK 16 ---------------------------------*/
508
509 /*---------------- ENTER BLOCK 17 --------------------------------*/
510 blenter();
511 #ifdef DEBUG
512 fprintf(temp,
513 "A call to int nftw64(const char *path, int (*fn)(const\n");
514 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
515 fprintf(temp, "depth, int flags) shall pass FTW_SLN as the third\n");
516 fprintf(temp, "argument to the function fn if and only if the\n");
517 fprintf(temp, "FTW_PHYS flag is not included in flags.\n\n");
518 #endif
519 test18A();
520 blexit();
521 /*--------------- EXIT BLOCK 17 ---------------------------------*/
522
523 /*---------------- ENTER BLOCK 18 --------------------------------*/
524 blenter();
525 #ifdef DEBUG
526 fprintf(temp, "On a call to int nftw64(const char *path, int\n");
527 fprintf(temp, "(*fn)(const char *, const struct stat *, int, struct\n");
528 fprintf(temp,
529 "FTW *), int depth, int flags) when the third argument\n");
530 fprintf(temp, "passed to the function fn is FTW_DNR then the\n");
531 fprintf(temp,
532 "descendants of the directory shall not be processed.\n\n");
533 #endif
534 test19A();
535 blexit();
536 /*--------------- EXIT BLOCK 18 ---------------------------------*/
537
538 /*---------------- ENTER BLOCK 19 --------------------------------*/
539 blenter();
540 #ifdef DEBUG
541 fprintf(temp,
542 "A call to int nftw64(const char *path, int (*fn)(const\n");
543 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
544 fprintf(temp,
545 "depth, int flags) shall close any file descriptors or\n");
546 fprintf(temp,
547 "directory streams used to traverse the directory tree.\n\n");
548 #endif
549 test20A();
550 blexit();
551 /*--------------- EXIT BLOCK 19 ---------------------------------*/
552
553 /*---------------- ENTER BLOCK 20 --------------------------------*/
554 blenter();
555 #ifdef DEBUG
556 fprintf(temp, "On a call to int nftw64(const char *path, int\n");
557 fprintf(temp, "(*fn)(const char *, const struct stat *, int, struct\n");
558 fprintf(temp, "FTW *), int depth, int flags) depth shall be the\n");
559 fprintf(temp,
560 "maximum number of file descriptors used for the search.\n\n");
561 #endif
562 test21A();
563 blexit();
564 /*--------------- EXIT BLOCK 20 ---------------------------------*/
565
566 /*---------------- ENTER BLOCK 21 --------------------------------*/
567 blenter();
568 #ifdef DEBUG
569 fprintf(temp,
570 "A call to int nftw64(const char *path, int (*fn)(const\n");
571 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
572 fprintf(temp, "depth, int flags) shall use at most one file\n");
573 fprintf(temp, "descriptor for each directory level.\n\n");
574 #endif
575 test22A();
576 blexit();
577 /*--------------- EXIT BLOCK 21 ---------------------------------*/
578
579 /*---------------- ENTER BLOCK 22 --------------------------------*/
580 blenter();
581 #ifdef DEBUG
582 fprintf(temp,
583 "A call to int nftw64(const char *path, int (*fn)(const\n");
584 fprintf(temp, "char *, const struct stat *, int, struct FTW *), int\n");
585 fprintf(temp, "depth, int flags) when the function fn returns a\n");
586 fprintf(temp, "non-zero value shall stop and return the value\n");
587 fprintf(temp, "returned by fn.\n\n");
588 #endif
589 test23A();
590 blexit();
591 /*--------------- EXIT BLOCK 22 ---------------------------------*/
592
593 /*---------------- ENTER BLOCK 23 --------------------------------*/
594 blenter();
595 #ifdef DEBUG
596 fprintf(temp, "ENAMETOOLONG in errno and return -1 on a call to int\n");
597 fprintf(temp,
598 "nftw64(const char *path, int (*fn)(const char *, const\n");
599 fprintf(temp, "struct stat *, int, struct FTW *), int depth, int\n");
600 fprintf(temp, "flags) when the length of path exceeds PATH_MAX.\n\n");
601 #endif
602 test24A();
603 blexit();
604 /*--------------- EXIT BLOCK 23 ---------------------------------*/
605
606 /*---------------- ENTER BLOCK 24 --------------------------------*/
607 blenter();
608 #ifdef DEBUG
609 fprintf(temp, "ENAMETOOLONG in errno and return -1 on a call to int\n");
610 fprintf(temp,
611 "nftw64(const char *path, int (*fn)(const char *, const\n");
612 fprintf(temp, "struct stat *, int, struct FTW *), int depth, int\n");
613 fprintf(temp, "flags) when a component of path exceeds NAME_MAX.\n\n");
614 #endif
615 test25A();
616 blexit();
617 /*--------------- EXIT BLOCK 24 ---------------------------------*/
618
619 /*---------------- ENTER BLOCK 25 --------------------------------*/
620 blenter();
621 #ifdef DEBUG
622 fprintf(temp, "ENOENT in errno and return -1 on a call to int\n");
623 fprintf(temp,
624 "nftw64(const char *path, int (*fn)(const char *, const\n");
625 fprintf(temp, "struct stat *, int, struct FTW *), int depth, int\n");
626 fprintf(temp,
627 "flags) when path points to a file which does not exist.\n\n");
628 #endif
629 test26A();
630 blexit();
631 /*--------------- EXIT BLOCK 25 ---------------------------------*/
632
633 /*---------------- ENTER BLOCK 26 --------------------------------*/
634 blenter();
635 #ifdef DEBUG
636 fprintf(temp, "ENOENT in errno and return -1 on a call to int\n");
637 fprintf(temp,
638 "nftw64(const char *path, int (*fn)(const char *, const\n");
639 fprintf(temp, "struct stat *, int, struct FTW *), int depth, int\n");
640 fprintf(temp, "flags) when path points to an empty string.\n\n");
641 #endif
642 test27A();
643 blexit();
644 /*--------------- EXIT BLOCK 26 ---------------------------------*/
645
646 /*---------------- ENTER BLOCK 27 --------------------------------*/
647 blenter();
648 #ifdef DEBUG
649 fprintf(temp, "ENOTDIR in errno and return -1 on a call to int\n");
650 fprintf(temp,
651 "nftw64(const char *path, int (*fn)(const char *, const\n");
652 fprintf(temp, "struct stat *, int, struct FTW *), int depth, int\n");
653 fprintf(temp, "flags) when path is not a directory.\n\n");
654 #endif
655 test28A();
656 blexit();
657 /*--------------- EXIT BLOCK 27 ---------------------------------*/
658
659 /*---------------- ENTER BLOCK 28 --------------------------------*/
660 blenter();
661 #ifdef DEBUG
662 fprintf(temp, "EACCES in errno and return -1 on a call to int\n");
663 fprintf(temp,
664 "nftw64(const char *path, int (*fn)(const char *, const\n");
665 fprintf(temp, "struct stat *, int, struct FTW *), int depth, int\n");
666 fprintf(temp, "flags) when search permission is denied for any\n");
667 fprintf(temp, "component of path.\n\n");
668 #endif
669 test29A();
670 blexit();
671 /*--------------- EXIT BLOCK 28 ---------------------------------*/
672
673 /*---------------- ENTER BLOCK 29 --------------------------------*/
674 blenter();
675 #ifdef DEBUG
676 fprintf(temp, "EACCES in errno and return -1 on a call to int\n");
677 fprintf(temp,
678 "nftw64(const char *path, int (*fn)(const char *, const\n");
679 fprintf(temp, "struct stat *, int, struct FTW *), int depth, int\n");
680 fprintf(temp, "flags) when read permission is denied for path.\n\n");
681 #endif
682 test30A();
683 blexit();
684 /*--------------- EXIT BLOCK 29 ---------------------------------*/
685
686 cleanup_function();
687
688 anyfail(); /* THIS CALL DOES NOT RETURN - EXITS!! */
689
690 tst_exit();
691 }
692
693 /*--------------------------------------------------------------*/
694
695 /** LTP Port **/
696 /*
697 * setup
698 *
699 * Do set up - here its a dummy function
700 */
setup(void)701 void setup(void)
702 {
703 /* Direct debug output to stderr */
704 temp = stderr;
705
706 /* Get the user id "nobody" */
707 if ((ltpuser = getpwnam("nobody")) == NULL) {
708 perror("change_owner: nobody not found in /etc/passwd");
709 exit(1);
710 }
711
712 /* Switch to "nobody" */
713 setuid(ltpuser->pw_uid);
714
715 tst_tmpdir();
716 }
717
718 /*
719 * Function: blenter()
720 *
721 * Description: Print message on entering a new block
722 */
blenter(void)723 void blenter(void)
724 {
725 local_flag = PASSED;
726 return;
727 }
728
729 /*
730 * Function: blexit()
731 *
732 * Description: This function will exit a block, a block may be a logical unit
733 * of a test. It will report the status if the test ie fail or
734 * pass.
735 */
blexit(void)736 void blexit(void)
737 {
738 (local_flag == PASSED) ? tst_resm(TPASS, "Test block %d", block_number)
739 : tst_resm(TFAIL, "Test block %d", block_number);
740 block_number++;
741 return;
742 }
743
744 /*
745 *
746 * Function: anyfail()
747 *
748 * Description: Exit a test.
749 */
anyfail(void)750 void anyfail(void)
751 {
752 (local_flag == FAILED) ? tst_resm(TFAIL, "Test failed")
753 : tst_resm(TPASS, "Test passed");
754 tst_rmdir();
755 tst_exit();
756 }
757
758 /**************/
759