what i want is something like this:
> df ~/todo
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 51290592 23633044 25019724 49% /home
> findmnt --target ~/todo
TARGET SOURCE FSTYPE OPTIONS
/home /dev/sda3 ext4 rw,relatime,lazytime,data=ordered
i found two ways to do that so far, but as i know little about c libs, i’m
still wondering if there are better or idiomatic ways.
after read the fstab struct in fstab.h, the mntent struct in mntent.h, i started to know they are merely a string parser, so i implemented the parser in pure zig, and used
/proc/mounts as the source.
If you can afford linking against libc (apparently you can, as you’re using
@cImport()) then you can use
getmntent(). That parses
/etc/fstab for you, but of course you can just parse it yourself if you want and skip the dependency
thanks for the reply! i think the “import mntent.h” approach is a bit of overkill.