You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
df: rows appear in different order on each execution, but shouldn't #3086
Running df with no other arguments results in a different order of rows on each execution. In contrast, the GNU version of df seems to produce rows in the same order on each execution.
GNU df:
$ df | head -n 5
Filesystem 1K-blocks Used Available Use% Mounted on
udev 3858028 0 3858028 0% /dev
tmpfs 782624 2112 780512 1% /run
/dev/mapper/vgubuntu-root 242791844 93491652 136897300 41% /
tmpfs 3913120 0 3913120 0% /dev/shm
$ df | head -n 5
Filesystem 1K-blocks Used Available Use% Mounted on
udev 3858028 0 3858028 0% /dev
tmpfs 782624 2112 780512 1% /run
/dev/mapper/vgubuntu-root 242791844 93491652 136897300 41% /
tmpfs 3913120 0 3913120 0% /dev/shm
uutils df:
$ ./target/debug/df | head -n 5
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/loop5 56885248 56885248 0 100% /snap/snap-store/558
/dev/nvme0n1p1 535805952 32583680 503222272 6% /boot/efi
/dev/loop1 58327040 58327040 0 100% /snap/core18/2284
tmpfs 801406976 73728 801333248 0% /run/user/1000
$ ./target/debug/df | head -n 5
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/loop4 65011712 65011712 0 100% /snap/core20/1270
tmpfs 4007034880 0 4007034880 0% /sys/fs/cgroup
tmpfs 4007034880 0 4007034880 0% /dev/shm
/dev/loop0 58195968 58195968 0 100% /snap/core18/2253
On my Linux machine, It seems like it is based on the order given in /proc/mounts or /etc/mtab. The uucore::fsext::read_fs_list() function reads those:
Activity
tertsdiepraam commentedon Feb 6, 2022
Do you have any idea what GNU's order is based on?
jfinkels commentedon Feb 7, 2022
On my Linux machine, It seems like it is based on the order given in
/proc/mountsor/etc/mtab. Theuucore::fsext::read_fs_list()function reads those:coreutils/src/uucore/src/lib/features/fsext.rs
Lines 403 to 406 in 1f7c08d
df::filter_mount_list()collects them into aHashMap:coreutils/src/uu/df/src/df.rs
Line 187 in 1f7c08d
tertsdiepraam commentedon Feb 7, 2022
Good to know! Thanks!