--- src/coreutils-8.21/lib/mountlist.c.orig 2013-02-07 20:44:47.000000000 +0400 +++ src/coreutils-8.21/lib/mountlist.c 2013-06-29 22:19:56.000000000 +0400 @@ -167,15 +167,48 @@ /* for Irix 6.5 */ \ || strcmp (Fs_type, "ignore") == 0) +/* Search MNT->mnt_opts for an option matching OPT. + Returns the address of the substring, or null if none found. */ +char * +hasmntopt (const struct mntent *mnt, const char *opt) +{ + const size_t optlen = strlen (opt); + char *rest = mnt->mnt_opts, *p; + + while ((p = strstr (rest, opt)) != NULL) + { + if (p == rest + || (p[-1] == ',' + && (p[optlen] == '\0' || + p[optlen] == '=' || + p[optlen] == ','))) + return p; + + rest = strchr (rest, ','); + if (rest == NULL) + break; + ++rest; + } + + return NULL; +} +#define HAVE_HASMNTOPT + /* Historically, we have marked as "dummy" any file system of type "none", but now that programs like du need to know about bind-mounted directories, we grant an exception to any with "bind" in its list of mount options. I.e., those are *not* dummy entries. */ -#ifdef MOUNTED_GETMNTENT1 -# define ME_DUMMY(Fs_name, Fs_type, Fs_ent) \ - (ME_DUMMY_0 (Fs_name, Fs_type) \ - || (strcmp (Fs_type, "none") == 0 \ - && !hasmntopt (Fs_ent, "bind"))) +#if defined MOUNTED_GETMNTENT1 && defined HAVE_HASMNTOPT +# if defined HAVE_HASMNTOPT +# define ME_DUMMY(Fs_name, Fs_type, Fs_ent) \ + (ME_DUMMY_0 (Fs_name, Fs_type) \ + || (strcmp (Fs_type, "none") == 0 \ + && !hasmntopt (Fs_ent, "bind"))) +# else +# define ME_DUMMY(Fs_name, Fs_type, Fs_ent) \ + (ME_DUMMY_0 (Fs_name, Fs_type) \ + || (strcmp (Fs_type, "none") == 0)) +# endif #else # define ME_DUMMY(Fs_name, Fs_type) \ (ME_DUMMY_0 (Fs_name, Fs_type) || strcmp (Fs_type, "none") == 0)