17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 568a94df1Scf46844 * Common Development and Distribution License (the "License"). 668a94df1Scf46844 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*ba3594baSGarrett D'Amore * Copyright 2014 Garrett D'Amore <garrett@damore.org> 23*ba3594baSGarrett D'Amore * 2468a94df1Scf46844 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 257c478bd9Sstevel@tonic-gate * Use is subject to license terms. 267c478bd9Sstevel@tonic-gate */ 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */ 297c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #ifndef _FTW_H 337c478bd9Sstevel@tonic-gate #define _FTW_H 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h> 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #include <sys/types.h> 387c478bd9Sstevel@tonic-gate #include <sys/stat.h> 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #ifdef __cplusplus 417c478bd9Sstevel@tonic-gate extern "C" { 427c478bd9Sstevel@tonic-gate #endif 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate /* 4568a94df1Scf46844 * Codes for the third argument to the user-supplied function. 467c478bd9Sstevel@tonic-gate */ 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate #define FTW_F 0 /* file */ 497c478bd9Sstevel@tonic-gate #define FTW_D 1 /* directory */ 507c478bd9Sstevel@tonic-gate #define FTW_DNR 2 /* directory without read permission */ 517c478bd9Sstevel@tonic-gate #define FTW_NS 3 /* unknown type, stat failed */ 527c478bd9Sstevel@tonic-gate #define FTW_SL 4 /* symbolic link */ 537c478bd9Sstevel@tonic-gate #define FTW_DP 6 /* directory */ 547c478bd9Sstevel@tonic-gate #define FTW_SLN 7 /* symbolic link that points to nonexistent file */ 5568a94df1Scf46844 #define FTW_DL 8 /* private interface for find utility */ 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate /* 5868a94df1Scf46844 * Codes for the fourth argument to nftw. You can specify the 597c478bd9Sstevel@tonic-gate * union of these flags. 607c478bd9Sstevel@tonic-gate */ 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate #define FTW_PHYS 01 /* use lstat instead of stat */ 637c478bd9Sstevel@tonic-gate #define FTW_MOUNT 02 /* do not cross a mount point */ 647c478bd9Sstevel@tonic-gate #define FTW_CHDIR 04 /* chdir to each directory before reading */ 657c478bd9Sstevel@tonic-gate #define FTW_DEPTH 010 /* call descendents before calling the parent */ 667c478bd9Sstevel@tonic-gate #define FTW_ANYERR 020 /* return FTW_NS on any stat failure */ 677c478bd9Sstevel@tonic-gate #define FTW_HOPTION 040 /* private interface for find utility */ 6868a94df1Scf46844 #define FTW_NOLOOP 0100 /* private interface for find utility */ 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) || defined(_XPG4_2) 717c478bd9Sstevel@tonic-gate struct FTW 727c478bd9Sstevel@tonic-gate { 737c478bd9Sstevel@tonic-gate #if defined(_XPG4_2) 747c478bd9Sstevel@tonic-gate int __quit; 757c478bd9Sstevel@tonic-gate #else 767c478bd9Sstevel@tonic-gate int quit; 777c478bd9Sstevel@tonic-gate #endif 787c478bd9Sstevel@tonic-gate int base; 797c478bd9Sstevel@tonic-gate int level; 807c478bd9Sstevel@tonic-gate }; 817c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) ... */ 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate /* 847c478bd9Sstevel@tonic-gate * legal values for quit 857c478bd9Sstevel@tonic-gate */ 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate #define FTW_SKD 1 887c478bd9Sstevel@tonic-gate #define FTW_FOLLOW 2 897c478bd9Sstevel@tonic-gate #define FTW_PRUNE 4 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* large file compilation environment setup */ 927c478bd9Sstevel@tonic-gate #if !defined(_LP64) && _FILE_OFFSET_BITS == 64 937c478bd9Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME 947c478bd9Sstevel@tonic-gate #pragma redefine_extname _xftw _xftw64 957c478bd9Sstevel@tonic-gate #pragma redefine_extname _ftw _ftw64 967c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(_XPG5) 977c478bd9Sstevel@tonic-gate #pragma redefine_extname nftw nftw64 987c478bd9Sstevel@tonic-gate #endif 997c478bd9Sstevel@tonic-gate #else /* __PRAGMA_REDEFINE_EXTNAME */ 1007c478bd9Sstevel@tonic-gate #define _xftw _xftw64 1017c478bd9Sstevel@tonic-gate #define _ftw _ftw64 1027c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(_XPG5) 1037c478bd9Sstevel@tonic-gate #define nftw nftw64 1047c478bd9Sstevel@tonic-gate #endif 1057c478bd9Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */ 1067c478bd9Sstevel@tonic-gate #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate /* In the LP64 compilation environment, all APIs are already large file */ 1097c478bd9Sstevel@tonic-gate #if defined(_LP64) && defined(_LARGEFILE64_SOURCE) 1107c478bd9Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME 1117c478bd9Sstevel@tonic-gate #pragma redefine_extname _xftw64 _xftw 1127c478bd9Sstevel@tonic-gate #pragma redefine_extname _ftw64 _ftw 1137c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(_XPG5) 1147c478bd9Sstevel@tonic-gate #pragma redefine_extname nftw64 nftw 1157c478bd9Sstevel@tonic-gate #endif 1167c478bd9Sstevel@tonic-gate #else /* __PRAGMA_REDEFINE_EXTNAME */ 1177c478bd9Sstevel@tonic-gate #define _xftw64 _xftw 1187c478bd9Sstevel@tonic-gate #define _ftw64 _ftw 1197c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) || defined(_XPG5) 1207c478bd9Sstevel@tonic-gate #define nftw64 nftw 1217c478bd9Sstevel@tonic-gate #endif 1227c478bd9Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */ 1237c478bd9Sstevel@tonic-gate #endif /* _LP64 && _LARGEFILE64_SOURCE */ 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate extern int ftw(const char *, 1267c478bd9Sstevel@tonic-gate int (*)(const char *, const struct stat *, int), int); 1277c478bd9Sstevel@tonic-gate extern int _xftw(int, const char *, 1287c478bd9Sstevel@tonic-gate int (*)(const char *, const struct stat *, int), int); 1297c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) || defined(_XPG4_2) 1307c478bd9Sstevel@tonic-gate extern int nftw(const char *, 1317c478bd9Sstevel@tonic-gate int (*)(const char *, const struct stat *, int, struct FTW *), 1327c478bd9Sstevel@tonic-gate int, int); 1337c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(_XOPEN_SOURCE) ... */ 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate /* 1367c478bd9Sstevel@tonic-gate * transitional large file interface versions 1377c478bd9Sstevel@tonic-gate */ 1387c478bd9Sstevel@tonic-gate #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ 1397c478bd9Sstevel@tonic-gate !defined(__PRAGMA_REDEFINE_EXTNAME)) 1407c478bd9Sstevel@tonic-gate extern int ftw64(const char *, 1417c478bd9Sstevel@tonic-gate int (*)(const char *, const struct stat64 *, int), int); 1427c478bd9Sstevel@tonic-gate extern int _xftw64(int, const char *, 1437c478bd9Sstevel@tonic-gate int (*)(const char *, const struct stat64 *, int), int); 1447c478bd9Sstevel@tonic-gate #if !defined(_XOPEN_SOURCE) 1457c478bd9Sstevel@tonic-gate extern int nftw64(const char *, 1467c478bd9Sstevel@tonic-gate int (*)(const char *, const struct stat64 *, int, struct FTW *), 1477c478bd9Sstevel@tonic-gate int, int); 1487c478bd9Sstevel@tonic-gate #endif /* !defined(_XOPEN_SOURCE) */ 1497c478bd9Sstevel@tonic-gate #endif /* _LARGEFILE64_SOURCE .. */ 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate #define _XFTWVER 2 /* version of file tree walk */ 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate #define ftw(path, fn, depth) _xftw(_XFTWVER, (path), (fn), (depth)) 1547c478bd9Sstevel@tonic-gate 1557c478bd9Sstevel@tonic-gate #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ 1567c478bd9Sstevel@tonic-gate !defined(__PRAGMA_REDEFINE_EXTNAME)) 1577c478bd9Sstevel@tonic-gate #define ftw64(path, fn, depth) _xftw64(_XFTWVER, (path), (fn), (depth)) 1587c478bd9Sstevel@tonic-gate #endif 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1617c478bd9Sstevel@tonic-gate } 1627c478bd9Sstevel@tonic-gate #endif 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate #endif /* _FTW_H */ 165