From 83c5db2eae3d86072ab3ed6b4b64b10b2bd9e3a5 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Sat, 23 Jun 2012 14:14:16 +0200 Subject: [PATCH] find(1): Revert back to using statfs.f_type again for fstype comparison. It was breaking the weekly locate database update. More investigation is needed here. While here, also bring back 00a0ead88e3b856b49bc34aa4c3d8b0d80940600 which was accidentally removed. --- usr.bin/find/function.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index 82fb4ce28d..4d65780909 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * @(#)function.c 8.10 (Berkeley) 5/4/95 - * $FreeBSD: src/usr.bin/find/function.c,v 1.71 2011/06/13 05:22:07 avatar Exp $ + * $FreeBSD: src/usr.bin/find/function.c,v 1.70 2010/12/11 08:32:16 joel Exp $ */ #include @@ -772,8 +772,7 @@ f_fstype(PLAN *plan, FTSENT *entry) static dev_t curdev; /* need a guaranteed illegal dev value */ static int first = 1; struct statfs sb; - static int val_flags; - static char fstype[sizeof(sb.f_fstypename)]; + static int val_type, val_flags; char *p, save[2] = {0,0}; if ((plan->flags & F_MTMASK) == F_MTUNKNOWN) @@ -800,8 +799,10 @@ f_fstype(PLAN *plan, FTSENT *entry) } else p = NULL; - if (statfs(entry->fts_accpath, &sb)) - err(1, "%s", entry->fts_accpath); + if (statfs(entry->fts_accpath, &sb)) { + warn("%s", entry->fts_accpath); + return 0; + } if (p) { p[0] = save[0]; @@ -815,13 +816,13 @@ f_fstype(PLAN *plan, FTSENT *entry) * always copy both of them. */ val_flags = sb.f_flags; - strlcpy(fstype, sb.f_fstypename, sizeof(fstype)); + val_type = sb.f_type; } switch (plan->flags & F_MTMASK) { case F_MTFLAG: return val_flags & plan->mt_data; case F_MTTYPE: - return (strncmp(fstype, plan->c_data, sizeof(fstype)) == 0); + return val_type == plan->mt_data; default: abort(); } @@ -832,11 +833,22 @@ c_fstype(OPTION *option, char ***argvp) { char *fsname; PLAN *new; + struct vfsconf vfc; fsname = nextarg(option, argvp); ftsoptions &= ~FTS_NOSTAT; new = palloc(option); + + /* + * Check first for a filesystem name. + */ + if (getvfsbyname(fsname, &vfc) == 0) { + new->flags |= F_MTTYPE; + new->mt_data = vfc.vfc_typenum; + return new; + } + switch (*fsname) { case 'l': if (!strcmp(fsname, "local")) { @@ -854,8 +866,12 @@ c_fstype(OPTION *option, char ***argvp) break; } - new->flags |= F_MTTYPE; - new->c_data = fsname; + /* + * We need to make filesystem checks for filesystems + * that exists but aren't in the kernel work. + */ + fprintf(stderr, "Warning: Unknown filesystem type %s\n", fsname); + new->flags |= F_MTUNKNOWN; return new; } -- 2.41.0