Skip to content

df: don't show entries previously considered best#12071

Open
Gelbpunkt wants to merge 1 commit intouutils:mainfrom
Gelbpunkt:df-no-duplicate-best
Open

df: don't show entries previously considered best#12071
Gelbpunkt wants to merge 1 commit intouutils:mainfrom
Gelbpunkt:df-no-duplicate-best

Conversation

@Gelbpunkt
Copy link
Copy Markdown

We would go over all the mountpoints and only display those considered the "best" for a device. However, if we found a new "best" entry for a device, we would still display the entry previously considered "best". Fix this by removing all previous entries for the same device before adding a new one.

Previously with the following mounts:

/ # cat /proc/mounts
tmpfs /dev tmpfs rw,noexec,relatime,size=1024k 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev,noexec,relatime 0 0
devpts /dev/pts devpts rw,relatime,mode=600,ptmxmode=666 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
/dev/nvme0n1p2 /var/cache/apk ext4 rw,relatime 0 0
/dev/nvme0n1p2 /mnt/appstream-data ext4 rw,relatime 0 0
/dev/nvme0n1p2 /mnt/pmbootstrap/ccache ext4 rw,relatime 0 0
/dev/nvme0n1p2 /var/cache/distfiles ext4 rw,relatime 0 0
/dev/nvme0n1p2 /mnt/pmbootstrap/git ext4 rw,relatime 0 0
/dev/nvme0n1p2 /mnt/pmbootstrap/go ext4 rw,relatime 0 0
/dev/nvme0n1p2 /mnt/pmbootstrap/rust ext4 rw,relatime 0 0
/dev/nvme0n1p2 /mnt/pmbootstrap/abuild-config ext4 rw,relatime 0 0
/dev/nvme0n1p2 /etc/apk/keys ext4 rw,relatime 0 0
/dev/nvme0n1p2 /mnt/pmbootstrap/sccache ext4 rw,relatime 0 0
/dev/nvme0n1p2 /mnt/pmbootstrap/netboot ext4 rw,relatime 0 0
/dev/nvme0n1p2 /mnt/pmbootstrap/packages ext4 rw,relatime 0 0

/var/cache/apk is the first entry that was seen and it was considered best, and it remains the best entry until /etc/apk/keys is encountered, which is considered the new best entry. Currently, this would result in both being printed:

/ # /tmp/coreutils df
Filesystem     1K-blocks      Used Available Use% Mounted on
tmpfs               1024         0      1024   0% /dev
tmpfs            7771112         0   7771112   0% /dev/shm
/dev/nvme0n1p2 490150872 162018872 303160276  35% /var/cache/apk
/dev/nvme0n1p2 490150872 162018872 303160276  35% /etc/apk/keys

After this change, finding a new best would get rid of any entry previously considered best, resulting in

/ # /tmp/coreutils df
Filesystem     1K-blocks      Used Available Use% Mounted on
tmpfs               1024         0      1024   0% /dev
tmpfs            7771112         0   7771112   0% /dev/shm
/dev/nvme0n1p2 490150872 162141416 303037732  35% /etc/apk/keys

which matches GNU coreutils:

/ # df
Filesystem     1K-blocks      Used Available Use% Mounted on
tmpfs               1024         0      1024   0% /dev
tmpfs            7771112         0   7771112   0% /dev/shm
/dev/nvme0n1p2 490150872 161206736 303972412  35% /etc/apk/keys

We would go over all the mountpoints and only display those
considered the "best" for a device. However, if we found a new
"best" entry for a device, we would still display the entry
previously considered "best". Fix this by removing all previous
entries for the same device before adding a new one.
@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/tail/tail-n0f is now being skipped but was previously passing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant