Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP5:GA
coreutils.669
coreutils-use_the_last_device_name_provided_by_...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File coreutils-use_the_last_device_name_provided_by_the_system.patch of Package coreutils.669
commit 25a2c948b24163ce0e0e9e52f6a5fef33d7d7842 Author: Pádraig Brady <P@draigBrady.com> Date: Thu May 29 15:30:46 2014 +0100 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. --- NEWS | 4 +++- src/df.c | 22 +++++++++++++++++++--- tests/df/skip-duplicates.sh | 13 +++++++++---- 3 files changed, 31 insertions(+), 8 deletions(-) Index: coreutils-8.22/NEWS =================================================================== --- coreutils-8.22.orig/NEWS 2014-07-26 00:00:59.716631657 +0200 +++ coreutils-8.22/NEWS 2014-07-26 00:01:35.008190452 +0200 @@ -2,7 +2,9 @@ GNU coreutils NEWS Changes done after the release of 8.22 - df now correctly elides duplicates for virtual file systems like tmpfs. + df now elides duplicates for virtual file systems like tmpfs, and will + display the correct device name for directories mounted multiple times. + [These bugs were present in "the beginning".] Noteworthy changes in release 8.22 (2013-12-13) [stable] Index: coreutils-8.22/src/df.c =================================================================== --- coreutils-8.22.orig/src/df.c 2014-07-26 00:00:59.711631720 +0200 +++ coreutils-8.22/src/df.c 2014-07-26 00:00:59.716631657 +0200 @@ -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); + } + } + } } Index: coreutils-8.22/tests/df/skip-duplicates.sh =================================================================== --- coreutils-8.22.orig/tests/df/skip-duplicates.sh 2014-07-26 00:00:59.706631782 +0200 +++ coreutils-8.22/tests/df/skip-duplicates.sh 2014-07-26 00:00:59.716631657 +0200 @@ -55,7 +55,7 @@ struct mntent *getmntent (FILE *fp) {.mnt_fsname="/fsname", .mnt_dir="/."}, {.mnt_fsname="/fsname", .mnt_dir="/"}, {.mnt_fsname="virtfs", .mnt_dir="/NONROOT"}, - {.mnt_fsname="virtfs", .mnt_dir="/NONROOT"}, + {.mnt_fsname="virtfs2", .mnt_dir="/NONROOT"}, {.mnt_fsname="netns", .mnt_dir="net:[1234567]"}, }; @@ -100,9 +100,14 @@ LD_PRELOAD=./k.so CU_TEST_DUPE_INVALID=1 test $(wc -l <out) -eq $(expr 1 + $unique_entries) || { fail=1; cat out; } # df should also prefer "/fsname" over "fsname" -test $(grep -c '/fsname' <out) -eq 1 || { fail=1; cat out; } -# ... and "/fsname" with '/' as Mounted on over '/.' -test $(grep -cF '/.' <out) -eq 0 || { fail=1; cat out; } +if test "$unique_entries" = 2; then + test $(grep -c '/fsname' <out) -eq 1 || { fail=1; cat out; } + # ... and "/fsname" with '/' as Mounted on over '/.' + test $(grep -cF '/.' <out) -eq 0 || { fail=1; cat out; } +fi + +# df should use the last seen devname (mnt_fsname) +test $(grep -c 'virtfs2' <out) -eq 1 || { fail=1; cat out; } # Ensure that filtering duplicates does not affect -a processing. LD_PRELOAD=./k.so df -a >out || fail=1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor