cosmopolitan icon indicating copy to clipboard operation
cosmopolitan copied to clipboard

Bug: `df` cannot read table of mounted file systems on macos

Open bjornbm opened this issue 10 months ago • 4 comments

Contact Details

[email protected]

What happened?

Using cosmos df:

~ $ uname -a
Darwin Narcissus.local 24.1.0 Cosmopolitan 4.0.1 MODE=aarch64; Darwin Kernel Version 24.1.0: Thu Oct 10 21:03:15 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6000 arm64 GNU/Linux
~ $ df
df: cannot read table of mounted file systems: No such file or directory

Expected (using system df):

~ $ /bin/df
Filesystem     512-blocks      Used Available Capacity iused     ifree %iused  Mounted on
/dev/disk3s1s1  965595304  20981648 151801776    13%  408310 759008880    0%   /
devfs                 402       402         0   100%     696         0  100%   /dev
/dev/disk3s6    965595304   8391592 151801776     6%       4 759008880    0%   /System/Volumes/VM
/dev/disk3s2    965595304  12693752 151801776     8%    1098 759008880    0%   /System/Volumes/Preboot
/dev/disk3s4    965595304      6872 151801776     1%      50 759008880    0%   /System/Volumes/Update
/dev/disk1s2      1024000     12328    984904     2%       1   4924520    0%   /System/Volumes/xarts
/dev/disk1s1      1024000     11016    984904     2%      29   4924520    0%   /System/Volumes/iSCPreboot
/dev/disk1s3      1024000      6032    984904     1%      75   4924520    0%   /System/Volumes/Hardware
/dev/disk3s5    965595304 769499056 151801776    84% 1764505 759008880    0%   /System/Volumes/Data
map auto_home           0         0         0   100%       0         0     -   /System/Volumes/Data/home

Version

df (GNU coreutils) 9.4
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Torbjörn Granlund, David MacKenzie, and Paul Eggert.

Downloaded 2025-01-21 from https://cosmo.zip/pub/cosmos/bin/

What operating system are you seeing the problem on?

Mac

Relevant log output


bjornbm avatar Jan 21 '25 12:01 bjornbm

Mujhay shaman ma nahi aaya

On Tue, 21 Jan, 2025, 5:44 pm Björn Buckwalter, @.***> wrote:

Contact Details

@.*** What happened?

Using cosmos df:

~ $ uname -a Darwin Narcissus.local 24.1.0 Cosmopolitan 4.0.1 MODE=aarch64; Darwin Kernel Version 24.1.0: Thu Oct 10 21:03:15 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6000 arm64 GNU/Linux ~ $ df df: cannot read table of mounted file systems: No such file or directory

Expected (using system df):

~ $ /bin/df Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on /dev/disk3s1s1 965595304 20981648 151801776 13% 408310 759008880 0% / devfs 402 402 0 100% 696 0 100% /dev /dev/disk3s6 965595304 8391592 151801776 6% 4 759008880 0% /System/Volumes/VM /dev/disk3s2 965595304 12693752 151801776 8% 1098 759008880 0% /System/Volumes/Preboot /dev/disk3s4 965595304 6872 151801776 1% 50 759008880 0% /System/Volumes/Update /dev/disk1s2 1024000 12328 984904 2% 1 4924520 0% /System/Volumes/xarts /dev/disk1s1 1024000 11016 984904 2% 29 4924520 0% /System/Volumes/iSCPreboot /dev/disk1s3 1024000 6032 984904 1% 75 4924520 0% /System/Volumes/Hardware /dev/disk3s5 965595304 769499056 151801776 84% 1764505 759008880 0% /System/Volumes/Data map auto_home 0 0 0 100% 0 0 - /System/Volumes/Data/home

Version

df (GNU coreutils) 9.4 Copyright (C) 2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later https://gnu.org/licenses/gpl.html. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Written by Torbjörn Granlund, David MacKenzie, and Paul Eggert.

Downloaded 2025-01-21 from https://cosmo.zip/pub/cosmos/bin/ What operating system are you seeing the problem on?

Mac Relevant log output

— Reply to this email directly, view it on GitHub https://github.com/jart/cosmopolitan/issues/1356, or unsubscribe https://github.com/notifications/unsubscribe-auth/BFAZ52DJISDVUZSGEKBH2RT2LY2Z5AVCNFSM6AAAAABVSL4BPGVHI2DSMVQWIX3LMV43ASLTON2WKOZSHAYDCNRXGA4DQMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

954681 avatar Jan 21 '25 14:01 954681

We would most likely need to emulate the /proc filesystem to implement this feature. It wouldn't be trivial. An easier solution I would propose is that we simply write our own df command, and then have our program plug into all the relevant platform-specific APIs, since obviously this kind of thing isn't standardized by POSIX. We do however have a nice statfs() implementation, that works on all platforms. If you crawl the file system maybe 2-3 layers deep, breadth first, then you might be able to create something similar to df without getting into the platform-specific hairiness. Contributions welcome.

jart avatar Jan 25 '25 01:01 jart

Thanks. Sorry but I don't see myself making this contribution (time/skill limitations).

To provide context: I don't “need” df to work. What I've done is put everything from https://cosmo.zip/pub/cosmos/bin/ on my $PATH, mostly as an experiment. Sometimes I notice things don't work (#1340 is another example) and report it because I assume you would want to know. In the meantime I fall back to using the system df.

bjornbm avatar Jan 25 '25 11:01 bjornbm

df could use the output of /usr/sbin/diskutil list -plist which outputs XML.

dolmen avatar Mar 02 '25 13:03 dolmen