Index: usr.bin/find/Makefile =================================================================== --- usr.bin/find/Makefile +++ usr.bin/find/Makefile @@ -5,6 +5,8 @@ SRCS= find.c function.c ls.c main.c misc.c operator.c option.c \ getdate.y YFLAGS= +CFLAGS+= -DHAVE_STRUCT_STAT_BIRTHTIME=1 -DHAVE_STRUCT_STAT_ST_FLAGS=1 \ + -DHAVE_STRUCT_STATFS_F_FSTYPENAME=1 NO_WMISSING_VARIABLE_DECLARATIONS= Index: usr.bin/find/find.h =================================================================== --- usr.bin/find/find.h +++ usr.bin/find/find.h @@ -35,6 +35,10 @@ * $FreeBSD$ */ +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include /* forward declarations */ @@ -70,8 +74,10 @@ #define F_IGNCASE 0x00010000 /* iname ipath iregex */ #define F_EXACTTIME F_IGNCASE /* -[acm]time units syntax */ #define F_EXECPLUS 0x00020000 /* -exec ... {} + */ +#if HAVE_STRUCT_STAT_BIRTHTIME #define F_TIME_B 0x00040000 /* one of -Btime, -Bnewer, -newerB* */ #define F_TIME2_B 0x00080000 /* one of -newer?B */ +#endif #define F_LINK 0x00100000 /* lname or ilname */ /* node definition */ Index: usr.bin/find/function.c =================================================================== --- usr.bin/find/function.c +++ usr.bin/find/function.c @@ -42,12 +42,17 @@ __FBSDID("$FreeBSD$"); #include +#if defined(__FreeBSD__) || __has_include() #include +#endif #include #include #include #include #include +#if defined(__FreeBSD__) || __has_include() +#include +#endif #include #include @@ -261,9 +266,11 @@ } else if (plan->flags & F_TIME_A) { COMPARE((now - entry->fts_statp->st_atime + 60 - 1) / 60, plan->t_data.tv_sec); +#if HAVE_STRUCT_STAT_BIRTHTIME } else if (plan->flags & F_TIME_B) { COMPARE((now - entry->fts_statp->st_birthtime + 60 - 1) / 60, plan->t_data.tv_sec); +#endif } else { COMPARE((now - entry->fts_statp->st_mtime + 60 - 1) / 60, plan->t_data.tv_sec); @@ -304,8 +311,10 @@ if (plan->flags & F_TIME_A) xtime = entry->fts_statp->st_atime; +#if HAVE_STRUCT_STAT_BIRTHTIME else if (plan->flags & F_TIME_B) xtime = entry->fts_statp->st_birthtime; +#endif else if (plan->flags & F_TIME_C) xtime = entry->fts_statp->st_ctime; else @@ -362,6 +371,7 @@ return new; } +#ifdef ACL_TYPE_NFS4 /* * -acl function -- * @@ -412,6 +422,7 @@ return (0); return (1); } +#endif /* defined(ACL_TYPE_NFS4) */ PLAN * c_acl(OPTION *option, char ***argvp __unused) @@ -448,12 +459,14 @@ errx(1, "-delete: %s: relative path potentially not safe", entry->fts_accpath); +#if HAVE_STRUCT_STAT_ST_FLAGS /* Turn off user immutable bits if running as root */ if ((entry->fts_statp->st_flags & (UF_APPEND|UF_IMMUTABLE)) && !(entry->fts_statp->st_flags & (SF_APPEND|SF_IMMUTABLE)) && geteuid() == 0) lchflags(entry->fts_accpath, entry->fts_statp->st_flags &= ~(UF_APPEND|UF_IMMUTABLE)); +#endif /* rmdir directories, unlink everything else */ if (S_ISDIR(entry->fts_statp->st_mode)) { @@ -806,6 +819,7 @@ } } +#if HAVE_STRUCT_STAT_ST_FLAGS int f_flags(PLAN *plan, FTSENT *entry) { @@ -849,6 +863,7 @@ new->fl_notflags = notflags; return new; } +#endif /* defined(HAVE_STRUCT_STAT_ST_FLAGS) */ /* * -follow functions -- @@ -865,6 +880,7 @@ return palloc(option); } +#if HAVE_STRUCT_STATFS_F_FSTYPENAME /* * -fstype functions -- * @@ -967,6 +983,7 @@ new->c_data = fsname; return new; } +#endif /* defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) */ /* * -group gname functions -- @@ -1184,10 +1201,12 @@ if (plan->flags & F_TIME_C) ft = entry->fts_statp->st_ctim; +#if HAVE_STRUCT_STAT_BIRTHTIME else if (plan->flags & F_TIME_A) ft = entry->fts_statp->st_atim; else if (plan->flags & F_TIME_B) ft = entry->fts_statp->st_birthtim; +#endif else ft = entry->fts_statp->st_mtim; return (ft.tv_sec > plan->t_data.tv_sec || @@ -1220,8 +1239,10 @@ new->t_data = sb.st_ctim; else if (option->flags & F_TIME2_A) new->t_data = sb.st_atim; +#if HAVE_STRUCT_STAT_BIRTHTIME else if (option->flags & F_TIME2_B) new->t_data = sb.st_birthtim; +#endif else new->t_data = sb.st_mtim; } @@ -1605,7 +1626,7 @@ case 's': mask = S_IFSOCK; break; -#ifdef FTS_WHITEOUT +#if defined(FTS_WHITEOUT) && defined(S_IFWHT) case 'w': mask = S_IFWHT; ftsoptions |= FTS_WHITEOUT; Index: usr.bin/find/ls.c =================================================================== --- usr.bin/find/ls.c +++ usr.bin/find/ls.c @@ -91,8 +91,10 @@ const char *format; static int d_first = -1; +#ifdef D_MD_ORDER if (d_first < 0) d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); +#endif if (lnow == 0) lnow = time(NULL); Index: usr.bin/find/option.c =================================================================== --- usr.bin/find/option.c +++ usr.bin/find/option.c @@ -61,11 +61,15 @@ { "!", c_simple, f_not, 0 }, { "(", c_simple, f_openparen, 0 }, { ")", c_simple, f_closeparen, 0 }, +#if HAVE_STRUCT_STAT_BIRTHTIME { "-Bmin", c_Xmin, f_Xmin, F_TIME_B }, { "-Bnewer", c_newer, f_newer, F_TIME_B }, { "-Btime", c_Xtime, f_Xtime, F_TIME_B }, +#endif { "-a", c_and, NULL, 0 }, +#ifdef ACL_TYPE_NFS4 { "-acl", c_acl, f_acl, 0 }, +#endif { "-amin", c_Xmin, f_Xmin, F_TIME_A }, { "-and", c_and, NULL, 0 }, { "-anewer", c_newer, f_newer, F_TIME_A }, @@ -81,13 +85,17 @@ { "-exec", c_exec, f_exec, 0 }, { "-execdir", c_exec, f_exec, F_EXECDIR }, { "-false", c_simple, f_false, 0 }, +#if HAVE_STRUCT_STAT_ST_FLAGS { "-flags", c_flags, f_flags, 0 }, +#endif // -fls { "-follow", c_follow, f_always_true, 0 }, // -fprint // -fprint0 // -fprintf +#if HAVE_STRUCT_STATFS_F_FSTYPENAME { "-fstype", c_fstype, f_fstype, 0 }, +#endif { "-gid", c_group, f_group, 0 }, { "-group", c_group, f_group, 0 }, { "-ignore_readdir_race",c_ignore_readdir_race, f_always_true,0 }, @@ -108,22 +116,28 @@ { "-mtime", c_Xtime, f_Xtime, 0 }, { "-name", c_name, f_name, 0 }, { "-newer", c_newer, f_newer, 0 }, +#if HAVE_STRUCT_STAT_BIRTHTIME { "-newerBB", c_newer, f_newer, F_TIME_B | F_TIME2_B }, { "-newerBa", c_newer, f_newer, F_TIME_B | F_TIME2_A }, { "-newerBc", c_newer, f_newer, F_TIME_B | F_TIME2_C }, { "-newerBm", c_newer, f_newer, F_TIME_B }, { "-newerBt", c_newer, f_newer, F_TIME_B | F_TIME2_T }, { "-neweraB", c_newer, f_newer, F_TIME_A | F_TIME2_B }, +#endif { "-neweraa", c_newer, f_newer, F_TIME_A | F_TIME2_A }, { "-newerac", c_newer, f_newer, F_TIME_A | F_TIME2_C }, { "-neweram", c_newer, f_newer, F_TIME_A }, { "-newerat", c_newer, f_newer, F_TIME_A | F_TIME2_T }, +#if HAVE_STRUCT_STAT_BIRTHTIME { "-newercB", c_newer, f_newer, F_TIME_C | F_TIME2_B }, +#endif { "-newerca", c_newer, f_newer, F_TIME_C | F_TIME2_A }, { "-newercc", c_newer, f_newer, F_TIME_C | F_TIME2_C }, { "-newercm", c_newer, f_newer, F_TIME_C }, { "-newerct", c_newer, f_newer, F_TIME_C | F_TIME2_T }, +#if HAVE_STRUCT_STAT_BIRTHTIME { "-newermB", c_newer, f_newer, F_TIME2_B }, +#endif { "-newerma", c_newer, f_newer, F_TIME2_A }, { "-newermc", c_newer, f_newer, F_TIME2_C }, { "-newermm", c_newer, f_newer, 0 },