2022-08-07 23:18:33 +00:00
|
|
|
#if 0
|
|
|
|
/*─────────────────────────────────────────────────────────────────╗
|
|
|
|
│ To the extent possible under law, Justine Tunney has waived │
|
|
|
|
│ all copyright and related or neighboring rights to this file, │
|
|
|
|
│ as it is written in the following disclaimers: │
|
|
|
|
│ • http://unlicense.org/ │
|
|
|
|
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
|
|
|
╚─────────────────────────────────────────────────────────────────*/
|
|
|
|
#endif
|
|
|
|
#include "libc/calls/struct/statfs.h"
|
2022-08-17 20:41:21 +00:00
|
|
|
#include "libc/fmt/conv.h"
|
2022-08-07 23:18:33 +00:00
|
|
|
#include "libc/log/check.h"
|
|
|
|
#include "libc/stdio/stdio.h"
|
2022-08-17 20:41:21 +00:00
|
|
|
#include "libc/sysv/consts/st.h"
|
2022-08-07 23:18:33 +00:00
|
|
|
|
2022-08-17 20:41:21 +00:00
|
|
|
dontinline void ShowIt(const char *path) {
|
|
|
|
char ibuf[21];
|
2022-08-07 23:18:33 +00:00
|
|
|
struct statfs sf = {0};
|
|
|
|
CHECK_NE(-1, statfs(path, &sf));
|
|
|
|
|
|
|
|
printf("filesystem %s\n", path);
|
2022-08-17 20:41:21 +00:00
|
|
|
printf("f_type = %#x (%s)\n", sf.f_type, sf.f_fstypename);
|
|
|
|
sizefmt(ibuf, sf.f_bsize, 1024);
|
|
|
|
printf("f_bsize = %,zu (%sb %s)\n", sf.f_bsize, ibuf,
|
|
|
|
"optimal transfer block size");
|
|
|
|
sizefmt(ibuf, sf.f_frsize, 1024);
|
|
|
|
printf("f_frsize = %,zu (%sb %s)\n", sf.f_frsize, ibuf, "fragment size");
|
|
|
|
sizefmt(ibuf, sf.f_blocks * sf.f_bsize, 1024);
|
|
|
|
printf("f_blocks = %,zu (%sb %s)\n", sf.f_blocks, ibuf,
|
2022-08-07 23:18:33 +00:00
|
|
|
"total data blocks in filesystem");
|
2022-08-17 20:41:21 +00:00
|
|
|
sizefmt(ibuf, sf.f_bfree * sf.f_bsize, 1024);
|
|
|
|
printf("f_bfree = %,zu (%sb %s)\n", sf.f_bfree, ibuf,
|
|
|
|
"free blocks in filesystem");
|
|
|
|
sizefmt(ibuf, sf.f_bavail * sf.f_bsize, 1024);
|
|
|
|
printf("f_bavail = %,zu (%sb %s)\n", sf.f_bavail, ibuf,
|
|
|
|
"free blocks available to use");
|
|
|
|
printf("f_files = %,zu (%s)\n", sf.f_files,
|
2022-08-07 23:18:33 +00:00
|
|
|
"total file nodes in filesystem");
|
2022-08-17 20:41:21 +00:00
|
|
|
printf("f_ffree = %,zu (%s)\n", sf.f_ffree,
|
2022-08-07 23:18:33 +00:00
|
|
|
"free file nodes in filesystem");
|
2022-08-17 20:41:21 +00:00
|
|
|
printf("f_fsid = %#lx (%s)\n", sf.f_fsid, "filesystem id");
|
|
|
|
printf("f_owner = %#lx (%s)\n", sf.f_owner, "user that created mount");
|
|
|
|
printf("f_namelen = %,zu (%s)\n", sf.f_namelen,
|
2022-08-07 23:18:33 +00:00
|
|
|
"maximum length of filenames");
|
|
|
|
|
|
|
|
printf("f_flags = %#x", sf.f_flags);
|
2022-08-17 20:41:21 +00:00
|
|
|
if (ST_RDONLY && (sf.f_flags & ST_RDONLY)) {
|
|
|
|
printf(" ST_RDONLY");
|
|
|
|
}
|
|
|
|
if (ST_NOSUID && (sf.f_flags & ST_NOSUID)) {
|
|
|
|
printf(" ST_NOSUID");
|
|
|
|
}
|
|
|
|
if (ST_NODEV && (sf.f_flags & ST_NODEV)) {
|
|
|
|
printf(" ST_NODEV");
|
|
|
|
}
|
|
|
|
if (ST_NOEXEC && (sf.f_flags & ST_NOEXEC)) {
|
|
|
|
printf(" ST_NOEXEC");
|
|
|
|
}
|
|
|
|
if (ST_SYNCHRONOUS && (sf.f_flags & ST_SYNCHRONOUS)) {
|
|
|
|
printf(" ST_SYNCHRONOUS");
|
|
|
|
}
|
|
|
|
if (ST_MANDLOCK && (sf.f_flags & ST_MANDLOCK)) {
|
|
|
|
printf(" ST_MANDLOCK");
|
|
|
|
}
|
|
|
|
if (ST_WRITE && (sf.f_flags & ST_WRITE)) {
|
|
|
|
printf(" ST_WRITE");
|
|
|
|
}
|
|
|
|
if (ST_APPEND && (sf.f_flags & ST_APPEND)) {
|
|
|
|
printf(" ST_APPEND");
|
|
|
|
}
|
|
|
|
if (ST_IMMUTABLE && (sf.f_flags & ST_IMMUTABLE)) {
|
|
|
|
printf(" ST_IMMUTABLE");
|
|
|
|
}
|
|
|
|
if (ST_NOATIME && (sf.f_flags & ST_NOATIME)) {
|
|
|
|
printf(" ST_NOATIME");
|
|
|
|
}
|
|
|
|
if (ST_NODIRATIME && (sf.f_flags & ST_NODIRATIME)) {
|
|
|
|
printf(" ST_NODIRATIME");
|
|
|
|
}
|
|
|
|
if (ST_RELATIME && (sf.f_flags & ST_RELATIME)) {
|
|
|
|
printf(" ST_RELATIME");
|
|
|
|
}
|
2022-08-07 23:18:33 +00:00
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
2022-08-17 20:41:21 +00:00
|
|
|
if (argc <= 1) {
|
|
|
|
ShowIt("/");
|
|
|
|
} else {
|
|
|
|
for (int i = 1; i < argc; ++i) {
|
|
|
|
ShowIt(argv[i]);
|
|
|
|
}
|
|
|
|
}
|
2022-08-07 23:18:33 +00:00
|
|
|
}
|