diff options
author | Pádraig Brady <P@draigBrady.com> | 2014-05-29 15:30:46 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2014-05-29 16:01:30 +0100 |
commit | 25a2c948b24163ce0e0e9e52f6a5fef33d7d7842 (patch) | |
tree | 60ab5ff2fcd550420e8657ba3962ae5a6dab2687 /src | |
parent | e4314774fd44bf2230a64f26c7f07383ddf6aa4c (diff) | |
download | coreutils-25a2c948b24163ce0e0e9e52f6a5fef33d7d7842.tar.xz |
df: use the last device name provided by the system
The device name reported for a particular mount entry
may no longer be valid if the mount point was subsequently
mounted on a different device. Therefore honor the order
of the mount list returned by the system and use the last
reported device name.
* src/df.c (filter_mount_list): When discarding the current
mount entry, ensure that a new device name is not also discarded.
* tests/df/skip-duplicates.sh: Add a test case. Also fix
a false failure in the edge case of a system with only a
single file system.
* NEWS: Mention the fix.
Diffstat (limited to 'src')
-rw-r--r-- | src/df.c | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -604,7 +604,7 @@ excluded_fstype (const char *fstype) } /* Filter mount list by skipping duplicate entries. - In the case of duplicities - based on to the device number - the mount entry + In the case of duplicities - based on the device number - the mount entry with a '/' in its me_devname (i.e. not pseudo name like tmpfs) wins. If both have a real devname (e.g. bind mounts), then that with the shorter me_mountdir wins. */ @@ -638,17 +638,33 @@ filter_mount_list (void) if (devlist) { - discard_me = me; - /* ...let the shorter mountdir win. */ if ((strchr (me->me_devname, '/') && ! strchr (devlist->me->me_devname, '/')) || (strlen (devlist->me->me_mountdir) > strlen (me->me_mountdir))) { + /* Discard mount entry for existing device. */ discard_me = devlist->me; devlist->me = me; } + else + { + /* Discard mount entry currently being processed. */ + discard_me = me; + + /* We might still want the devname from this mount entry as + the dev_num might not correlate with st_dev if another + device is subsequently overmounted at mountdir, so honor + the order of the presented list and replace with the + latest devname encountered. */ + if (! STREQ (devlist->me->me_devname, me->me_devname)) + { + free (devlist->me->me_devname); + devlist->me->me_devname = xstrdup (me->me_devname); + } + } + } } |