Hi,

"W. Wesley Groleau (伟思礼)" <[email protected]> writes:

> I would like to replace my macOS closed-source "df" with one that has
> one or two features I am not skilled enough to code in C.

Actually, the 'df' implementation used by MacOS is not closed source. It
can be found on GitHub [1]. Most of their programs are imported from
FreeBSD and modified to varying degrees.

They annoying ship old GPLv2+ programs because they are alergic to
GPLv3+. For example /usr/bin/bison on MacOS 15 isn't enough to build
Coreutils from git.

> 1) needs to have apfs as one of the filesystem types for -T (Apple's version 
> does)

This is supported. See the following:

    $ ./src/df -T
    Filesystem     Type  1K-blocks      Used  Available Use% Mounted on
    /dev/disk3s1s1 apfs  239362496 205124268   34238228  86% /
    /dev/disk3s6   apfs  239362496 205124268   34238228  86% /System/Volumes/VM
    /dev/disk3s2   apfs  239362496 205124268   34238228  86% 
/System/Volumes/Preboot
    /dev/disk3s4   apfs  239362496 205124268   34238228  86% 
/System/Volumes/Update
    /dev/disk1s2   apfs     512000     18500     493500   4% 
/System/Volumes/xarts
    /dev/disk1s1   apfs     512000     18500     493500   4% 
/System/Volumes/iSCPreboot
    /dev/disk1s3   apfs     512000     18500     493500   4% 
/System/Volumes/Hardware
    /dev/disk7s1   apfs 1953309744 573040608 1380269136  30% /Volumes/STORAGE

This is MacOS 12.6, which is older than most should be using. I haven't
tested earlier versions.

> 2) needs to be able to exclude or "include only" certain strings in the 
> output using regex patterns.  Maybe -v, like egrep has, or -x for "eXclude" 
> (Apple's version doesn't)

The GNU version of 'df' already has the -x option to exclude file system
types. I can exclude apfs file systems like so (which is all of them on
this machine):

    $ ./src/df -x apfs
    df: no file systems processed

For other fields I think that 'df | grep -v text' works fine.

> 3) the column spacing should be computed on the filtered output.
>
> 4) these features should work on any locale, even utf-8 with characters 
> outside of ISOLatin1

The width of characters is computed using multibyte-aware functions.

Collin

[1] https://github.com/apple-oss-distributions/file_cmds/blob/main/df/df.c

Reply via email to