bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] mountlist: don't use libmount to decide on dummy/remote


From: Pádraig Brady
Subject: [PATCH] mountlist: don't use libmount to decide on dummy/remote
Date: Thu, 30 Oct 2014 09:34:47 +0000

* lib/mountlist.c (read_file_system_list): Don't use the libmount
routines to determine whether a file system is dummy or remote,
as they're not currently compatible.  For example the remoteness
is determined on file system type (for which the list seems incomplete),
rather than simply checking for a ':' in the device name.
Also libmount currently determines that 'tmpfs' is a dummy file system
even though it has associated storage.
---
 ChangeLog       |   11 +++++++++++
 lib/mountlist.c |   19 +++++++++++++------
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 93c95dc..0d6c285 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2014-10-30  Pádraig Brady  <address@hidden>
+
+       mountlist: don't use libmount to decide on dummy/remote
+       * lib/mountlist.c (read_file_system_list): Don't use the libmount
+       routines to determine whether a file system is dummy or remote,
+       as they're not currently compatible.  For example the remoteness
+       is determined on file system type (for which the list seems incomplete),
+       rather than simply checking for a ':' in the device name.
+       Also libmount currently determines that 'tmpfs' is a dummy file system
+       even though it has associated storage.
+
 2014-10-29  Paul Eggert  <address@hidden>
 
        obstack: prefer __alignof__ to alignof
diff --git a/lib/mountlist.c b/lib/mountlist.c
index 84dc2c8..a91dcae 100644
--- a/lib/mountlist.c
+++ b/lib/mountlist.c
@@ -183,10 +183,9 @@
    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)    \
+# define ME_DUMMY(Fs_name, Fs_type, Bind)      \
   (ME_DUMMY_0 (Fs_name, Fs_type)               \
-   || (strcmp (Fs_type, "none") == 0           \
-       && !hasmntopt (Fs_ent, "bind")))
+   || (strcmp (Fs_type, "none") == 0 && !Bind))
 #else
 # define ME_DUMMY(Fs_name, Fs_type)            \
   (ME_DUMMY_0 (Fs_name, Fs_type) || strcmp (Fs_type, "none") == 0)
@@ -456,8 +455,14 @@ read_file_system_list (bool need_fs_type)
             me->me_type = xstrdup (mnt_fs_get_fstype (fs));
             me->me_type_malloced = 1;
             me->me_dev = mnt_fs_get_devno (fs);
-            me->me_dummy = mnt_fs_is_pseudofs (fs);
-            me->me_remote = mnt_fs_is_netfs (fs);
+            /* Note we don't use mnt_fs_is_pseudofs() or mnt_fs_is_netfs() here
+               as libmount's classification is non-compatible currently.
+               Also we pass "false" for the "Bind" option as that's only
+               significant when the Fs_type is "none" which will not be
+               the case when parsing "/proc/self/mountinfo", and only
+               applies for static /etc/mtab files.  */
+            me->me_dummy = ME_DUMMY (me->me_devname, me->me_type, false);
+            me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
 
             /* Add to the linked list. */
             *mtail = me;
@@ -480,12 +485,14 @@ read_file_system_list (bool need_fs_type)
 
         while ((mnt = getmntent (fp)))
           {
+            bool bind = hasmntopt (mnt, "bind");
+
             me = xmalloc (sizeof *me);
             me->me_devname = xstrdup (mnt->mnt_fsname);
             me->me_mountdir = xstrdup (mnt->mnt_dir);
             me->me_type = xstrdup (mnt->mnt_type);
             me->me_type_malloced = 1;
-            me->me_dummy = ME_DUMMY (me->me_devname, me->me_type, mnt);
+            me->me_dummy = ME_DUMMY (me->me_devname, me->me_type, bind);
             me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
             me->me_dev = dev_from_mount_options (mnt->mnt_opts);
 
-- 
1.7.7.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]