From efff8af1d69de8424d0cc6338497aed3bb1cd6d5 Mon Sep 17 00:00:00 2001 From: Julian Hurst Date: Thu, 24 Oct 2024 18:17:26 +0200 Subject: add statfs struct --- cmd/statusdaemon/disk.ha | 32 ++++++++++++++++++++++++++++++-- 1 file 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))!; -- cgit v1.2.3