diff options
| author | Julian Hurst <julian.hurst@digdash.com> | 2024-10-24 18:17:26 +0200 |
|---|---|---|
| committer | Julian Hurst <julian.hurst@digdash.com> | 2024-10-24 18:17:26 +0200 |
| commit | efff8af1d69de8424d0cc6338497aed3bb1cd6d5 (patch) | |
| tree | 1946c3b0359c4878a529358ab3c007aa3d63acf8 | |
| parent | 1bb0ea153abd99d470659b2ee018f341774238f9 (diff) | |
| download | statusdaemon-disk.tar.gz | |
add statfs structdisk
| -rw-r--r-- | cmd/statusdaemon/disk.ha | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/cmd/statusdaemon/disk.ha b/cmd/statusdaemon/disk.ha index 19367a1..913b227 100644 --- a/cmd/statusdaemon/disk.ha +++ b/cmd/statusdaemon/disk.ha @@ -25,16 +25,44 @@ fn builddisk(mounts: str...) disk = { return d; }; +type statfs = struct { + // type of filesystem + f_type: u64, + // optimal transfer block size + f_bsize: u64, + // total data blocks in filesystem + f_blocks: u64, + // free blocks in filesystem + f_bfree: u64, + // free blocks available to unprivileged user + f_bavail: u64, + + // total inodes in filesystem + f_files: u64, + // free inodes in filesystem + f_ffree: u64, + // filesystem id + f_fsid: u64, + // maximum length of filenames + f_fnamelen: u64, + // fragment size (since Linux 2.6) + f_frsize: u64, + // mount flags of filesystem (since Linux 2.6.36) + f_flags: u64, + + f_spare: [4]u64, +}; + fn updatedisk(d: *disk) void = { const stream = memio::dynamic(); defer io::close(&stream)!; for (const mount .. d.mounts) { memio::concat(&stream, mount, ": ")!; - let c = rt::st { + let c = statfs { ... }; rt::syscall(rt::SYS_statfs, &mount: uintptr: u64, &c: uintptr: u64); - log::println(c.blocks); + log::println(c.f_blocks); match (os::stat(mount)) { case let st: fs::filestat => memio::concat(&stream, strconv::ztos(st.sz))!; |
