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