diff options
author | 諏訪子 <suwako@076.moe> | 2024-06-21 22:35:41 +0900 |
---|---|---|
committer | 諏訪子 <suwako@076.moe> | 2024-06-21 22:35:41 +0900 |
commit | 986d0d6002f90a8737f5037b7423e1ac8fba98f2 (patch) | |
tree | d44f5682f758f618e35b078e7bd66960cc94fc41 /src/storage.c | |
parent | 2fe1aa6de98d0f0c6c9e4a8dcf9192c6b3392883 (diff) |
ごめん
Diffstat (limited to 'src/storage.c')
-rw-r--r-- | src/storage.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/storage.c b/src/storage.c index 5471a62..976c810 100644 --- a/src/storage.c +++ b/src/storage.c @@ -5,16 +5,20 @@ const char *display_storage() { const char *iszfs = run_command_s("LC_ALL=C zpool list 2>&1"); - if (!strstr(iszfs, "command not found: zpool")) { + if ( + strncmp( + iszfs, + "sh: command not found: zpool", + strlen("sh: command not found: zpool") + ) != 0 || + strncmp(iszfs, "sh: zpool: not found", strlen("sh: zpool: not found") + ) == 0) { + return run_command_s("df -h | " + "awk '/^\\/dev\\// {printf \"%s: %s / %s, \", $1, $3, $2}' | " + "awk '{sub(/, $/, \"\"); print}'"); + } + return run_command_s("zpool list | " "awk 'NR>1 {printf \"%s: %s / %s, \", $1, $3, $2}' | " "awk '{sub(/, $/, \"\"); print}'"); - } - - return run_command_s("df -h | " - "awk '/^\\/dev\\// {printf \"%s: %s / %s, \", $1, $3, $2}' | " - "awk '{sub(/, $/, \"\"); print}'"); - - return run_command_s("df -h | awk 'NR>1 {print $1 \": \" $3 \" / \" $2}' | " - "sed ':a;N;$!ba;s/\\n/, /g'"); } |