diff options
Diffstat (limited to 'usr.bin/find/function.c')
-rw-r--r-- | usr.bin/find/function.c | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index 1c813d9..de7f8b1 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -36,6 +36,7 @@ #ifndef lint static char sccsid[] = "@(#)function.c 8.10 (Berkeley) 5/4/95"; +static char rcsid[] = "$FreeBSD$"; #endif /* not lint */ #include <sys/param.h> @@ -57,6 +58,8 @@ static char sccsid[] = "@(#)function.c 8.10 (Berkeley) 5/4/95"; #include "find.h" +int string_to_flags __P((char **, u_long *, u_long *)); + #define COMPARE(a, b) { \ switch (plan->flags) { \ case F_EQUAL: \ @@ -945,7 +948,7 @@ c_perm(perm) } if ((set = setmode(perm)) == NULL) - err(1, "-perm: %s: illegal mode string", perm); + errx(1, "-perm: %s: illegal mode string", perm); new->m_data = getmode(set, 0); free(set); @@ -953,6 +956,60 @@ c_perm(perm) } /* + * -flags functions -- + * + * The flags argument is used to represent file flags bits. + */ +int +f_flags(plan, entry) + PLAN *plan; + FTSENT *entry; +{ + u_long flags; + + flags = entry->fts_statp->st_flags & + (UF_NODUMP | UF_IMMUTABLE | UF_APPEND | UF_OPAQUE | + SF_ARCHIVED | SF_IMMUTABLE | SF_APPEND); + if (plan->flags == F_ATLEAST) + /* note that plan->fl_flags always is a subset of + plan->fl_mask */ + return (flags & plan->fl_mask) == plan->fl_flags; + else + return flags == plan->fl_flags; + /* NOTREACHED */ +} + +PLAN * +c_flags(flags_str) + char *flags_str; +{ + PLAN *new; + u_long flags, notflags; + + ftsoptions &= ~FTS_NOSTAT; + + new = palloc(N_FLAGS, f_flags); + + if (*flags_str == '-') { + new->flags = F_ATLEAST; + flags_str++; + } + if (string_to_flags(&flags_str, &flags, ¬flags) == 1) + errx(1, "-flags: %s: illegal flags string", flags_str); + + new->fl_flags = flags; + new->fl_mask = flags | notflags; +#if 0 + printf("flags = %08x, mask = %08x (%08x, %08x)\n", + new->fl_flags, new->fl_mask, flags, notflags); +#endif + return new; +} + + /* + + +/* * -print functions -- * * Always true, causes the current pathame to be written to |