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