1d45662739871a315e75b7d85a424531eb583cf79robbiew/*
2d45662739871a315e75b7d85a424531eb583cf79robbiew *
3d45662739871a315e75b7d85a424531eb583cf79robbiew *   Copyright (c) International Business Machines  Corp., 2002
4d45662739871a315e75b7d85a424531eb583cf79robbiew *
5d45662739871a315e75b7d85a424531eb583cf79robbiew *   This program is free software;  you can redistribute it and/or modify
6d45662739871a315e75b7d85a424531eb583cf79robbiew *   it under the terms of the GNU General Public License as published by
7d45662739871a315e75b7d85a424531eb583cf79robbiew *   the Free Software Foundation; either version 2 of the License, or
8d45662739871a315e75b7d85a424531eb583cf79robbiew *   (at your option) any later version.
9d45662739871a315e75b7d85a424531eb583cf79robbiew *
10d45662739871a315e75b7d85a424531eb583cf79robbiew *   This program is distributed in the hope that it will be useful,
11d45662739871a315e75b7d85a424531eb583cf79robbiew *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
12d45662739871a315e75b7d85a424531eb583cf79robbiew *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
13d45662739871a315e75b7d85a424531eb583cf79robbiew *   the GNU General Public License for more details.
14d45662739871a315e75b7d85a424531eb583cf79robbiew *
15d45662739871a315e75b7d85a424531eb583cf79robbiew *   You should have received a copy of the GNU General Public License
16d45662739871a315e75b7d85a424531eb583cf79robbiew *   along with this program;  if not, write to the Free Software
174548c6cf9bcdd96d8303caa4130ab638b61f8a30Wanlong Gao *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18d45662739871a315e75b7d85a424531eb583cf79robbiew */
19d45662739871a315e75b7d85a424531eb583cf79robbiew
20d45662739871a315e75b7d85a424531eb583cf79robbiew/* 10/31/2002   Port to LTP     robbiew@us.ibm.com */
21d45662739871a315e75b7d85a424531eb583cf79robbiew/* 06/30/2001   Port to Linux   nsharoff@us.ibm.com */
22d45662739871a315e75b7d85a424531eb583cf79robbiew
23d45662739871a315e75b7d85a424531eb583cf79robbiew
24d45662739871a315e75b7d85a424531eb583cf79robbiew/*
25d45662739871a315e75b7d85a424531eb583cf79robbiew * NAME
26d45662739871a315e75b7d85a424531eb583cf79robbiew *	nftw.h - Header file for nftw.c
27d45662739871a315e75b7d85a424531eb583cf79robbiew */
2837550cf5a86c7ca7424a2a318dd64e550f13f5dfChris Dearman
29d45662739871a315e75b7d85a424531eb583cf79robbiew
30d45662739871a315e75b7d85a424531eb583cf79robbiew#ifndef _NFTW_H_
31d45662739871a315e75b7d85a424531eb583cf79robbiew#define _NFTW_H_
32d45662739871a315e75b7d85a424531eb583cf79robbiew
33d45662739871a315e75b7d85a424531eb583cf79robbiew#include <stdlib.h>
34d45662739871a315e75b7d85a424531eb583cf79robbiew#include <ftw.h>
35d45662739871a315e75b7d85a424531eb583cf79robbiew#include <unistd.h>
36d45662739871a315e75b7d85a424531eb583cf79robbiew#include <fcntl.h>
37d45662739871a315e75b7d85a424531eb583cf79robbiew#include <string.h>
38d45662739871a315e75b7d85a424531eb583cf79robbiew#include <dirent.h>
39d45662739871a315e75b7d85a424531eb583cf79robbiew#include <sys/stat.h>
40d45662739871a315e75b7d85a424531eb583cf79robbiew#include <sys/wait.h>
41d45662739871a315e75b7d85a424531eb583cf79robbiew#include <sys/types.h>
42d45662739871a315e75b7d85a424531eb583cf79robbiew#include <limits.h>
43d45662739871a315e75b7d85a424531eb583cf79robbiew#include <errno.h>
44d45662739871a315e75b7d85a424531eb583cf79robbiew#include <setjmp.h>
45d45662739871a315e75b7d85a424531eb583cf79robbiew#include <stdio.h>
46d45662739871a315e75b7d85a424531eb583cf79robbiew#include <linux/limits.h>
47d45662739871a315e75b7d85a424531eb583cf79robbiew
48d45662739871a315e75b7d85a424531eb583cf79robbiew#include "test.h"
49d45662739871a315e75b7d85a424531eb583cf79robbiew
50d45662739871a315e75b7d85a424531eb583cf79robbiew#define STRLEN          512
51d45662739871a315e75b7d85a424531eb583cf79robbiew#define MAX_FD          20
52d45662739871a315e75b7d85a424531eb583cf79robbiew#define MAXOPENDIRS     1024    /* max opendirs to try to exhaust dir streams */
53d45662739871a315e75b7d85a424531eb583cf79robbiew#define NUM_2_VISIT     4
54d45662739871a315e75b7d85a424531eb583cf79robbiew#define RET_VAL         666
55d45662739871a315e75b7d85a424531eb583cf79robbiew#define NDIRLISTENTS    100
56d45662739871a315e75b7d85a424531eb583cf79robbiew#define ERR_BUF_SIZ	4096
57d45662739871a315e75b7d85a424531eb583cf79robbiew#define NFTW            "./tmp/data"
58d45662739871a315e75b7d85a424531eb583cf79robbiew#define NFTW2           "/tmp/data"
59d45662739871a315e75b7d85a424531eb583cf79robbiew#define LINK_CNT        13
60d45662739871a315e75b7d85a424531eb583cf79robbiew#define NO_LINK_CNT     7
61d45662739871a315e75b7d85a424531eb583cf79robbiew#define DIR             0
62d45662739871a315e75b7d85a424531eb583cf79robbiew#define REG             1
63d45662739871a315e75b7d85a424531eb583cf79robbiew#define SYM             2
64d45662739871a315e75b7d85a424531eb583cf79robbiew
65d45662739871a315e75b7d85a424531eb583cf79robbiewtypedef struct pathdata {
66d45662739871a315e75b7d85a424531eb583cf79robbiew        char    name[PATH_MAX];
67d45662739871a315e75b7d85a424531eb583cf79robbiew        mode_t  mode;
68d45662739871a315e75b7d85a424531eb583cf79robbiew        int     type;
69d45662739871a315e75b7d85a424531eb583cf79robbiew        char    contents[STRLEN];
70d45662739871a315e75b7d85a424531eb583cf79robbiew} pathdata;
71d45662739871a315e75b7d85a424531eb583cf79robbiew
72d45662739871a315e75b7d85a424531eb583cf79robbiewstruct list {
73d45662739871a315e75b7d85a424531eb583cf79robbiew	char	*s;
74d45662739871a315e75b7d85a424531eb583cf79robbiew	int	 i;
75d45662739871a315e75b7d85a424531eb583cf79robbiew};
76d45662739871a315e75b7d85a424531eb583cf79robbiew
77ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void fail_exit(void);
78d45662739871a315e75b7d85a424531eb583cf79robbiew
79d45662739871a315e75b7d85a424531eb583cf79robbiew/* These functions are found in test.c */
80ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test1A(void);
81ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test2A(void);
82ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test3A(void);
83ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test4A(void);
84ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test5A(void);
85ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test6A(void);
86ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test7A(void);
87ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test8A(void);
88ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test9A(void);
89ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test10A(void);
90ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test11A(void);
91ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test12A(void);
92ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test13A(void);
93ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test14A(void);
94ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test15A(void);
95ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test16A(void);
96ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test17A(void);
97ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test18A(void);
98ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test19A(void);
99ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test20A(void);
100ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test21A(void);
101ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test22A(void);
102ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test23A(void);
103ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test24A(void);
104ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test25A(void);
105ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test26A(void);
106ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test27A(void);
107ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test28A(void);
108ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test29A(void);
109ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test30A(void);
110d45662739871a315e75b7d85a424531eb583cf79robbiew
111d45662739871a315e75b7d85a424531eb583cf79robbiew/* These functions are found in test_func.c */
112ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func1(const char *, const struct stat *, int, struct FTW *);
113ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func3(const char *, const struct stat *, int, struct FTW *);
114ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func4(const char *, const struct stat *, int, struct FTW *);
115ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func5(const char *, const struct stat *, int, struct FTW *);
116ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func7(const char *, const struct stat *, int, struct FTW *);
117ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func8(const char *, const struct stat *, int, struct FTW *);
118ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func9(const char *, const struct stat *, int, struct FTW *);
119ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func10(const char *, const struct stat *, int, struct FTW *);
120ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func11(const char *, const struct stat *, int, struct FTW *);
121ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func12(const char *, const struct stat *, int, struct FTW *);
122ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func13(const char *, const struct stat *, int, struct FTW *);
123ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func14(const char *, const struct stat *, int, struct FTW *);
124ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func15(const char *, const struct stat *, int, struct FTW *);
125ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func16(const char *, const struct stat *, int, struct FTW *);
126ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func17(const char *, const struct stat *, int, struct FTW *);
127ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func18(const char *, const struct stat *, int, struct FTW *);
128ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func19(const char *, const struct stat *, int, struct FTW *);
129ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func20(const char *, const struct stat *, int, struct FTW *);
130ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func21(const char *, const struct stat *, int, struct FTW *);
131ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func22(const char *, const struct stat *, int, struct FTW *);
132ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int test_func23(const char *, const struct stat *, int, struct FTW *);
133d45662739871a315e75b7d85a424531eb583cf79robbiew
134d45662739871a315e75b7d85a424531eb583cf79robbiew/* These functions are found in tools.c */
135ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void cleanup_function(void);
136ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void setup_path(void);
137ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int nftw_fn(const char *, const struct stat *, int, struct FTW *);
138ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis char * ftw_mnemonic(int);
139ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int getbase(const char *);
140ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis int getlev(const char *);
141ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void do_info(const char *);
142d45662739871a315e75b7d85a424531eb583cf79robbiew
143d45662739871a315e75b7d85a424531eb583cf79robbiew/* These functions are found in lib.c */
144ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void remove_test_ENOTDIR_files(void);
145ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void remove_test_ENOENT_files(void);
146ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test_ENAMETOOLONG_path(char *, int (*)(const char *), int);
147ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test_ENAMETOOLONG_name(char *, int (*)(const char *), int);
148ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test_ENOENT_empty(char *, int (*)(const char *), int);
149ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test_ENOTDIR(char *, int (*)(const char *), int);
150ae1e1d2ff360b437bb0a9fcdce938f581061d65fCyril Hrubis void test_ENOENT_nofile(char *, int (*)(const char *), int);
151d45662739871a315e75b7d85a424531eb583cf79robbiew
152d45662739871a315e75b7d85a424531eb583cf79robbiew#endif	/* _NFTW_H_ */
153