diff options
author | haturatu <taro@eyes4you.org> | 2024-06-27 22:11:27 +0900 |
---|---|---|
committer | haturatu <taro@eyes4you.org> | 2024-06-27 22:11:27 +0900 |
commit | 7bfe462e5412a7157a570cefabfd303a7664a7b9 (patch) | |
tree | 28cd9a31a1c35c8f46a9b7109dc7a5cf947ba8f8 /src/storage.c | |
parent | b4307fffd9ef76efc612699a783e76368291f882 (diff) |
fixmaster
Diffstat (limited to 'src/storage.c')
-rw-r--r-- | src/storage.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/src/storage.c b/src/storage.c index 5500e93..909f477 100644 --- a/src/storage.c +++ b/src/storage.c @@ -2,28 +2,19 @@ #include "common.h" #include <string.h> +#include <stdlib.h> const char *display_storage() { - const char *excode = run_command_s("LC_ALL=C zpool list 2>/dev/null || echo $?"); + const char *excode = run_command_s("zpool list 2>/dev/null || echo $?"); + if ( excode != NULL && (strncmp(excode, "127", strlen("127")) == 0)) { + free((void *)excode); + return run_command_s("df -h | " + "awk '/^\\/dev\\// {printf \"%s: %s / %s, \", $1, $3, $2}' | " + "awk '{sub(/, $/, \"\"); print}'"); + } - if (excode != NULL && strcmp(excode, "127") == 0) { - return run_command_s("df -h | " - "awk '/^\\/dev\\// {printf \"%s: %s / %s, \", $1, $3, $2}' | " - "awk '{sub(/, $/, \"\"); print}'"); - } else { - const char *iszfs = run_command_s("LC_ALL=C zpool list 2>&1"); - if ( - strncmp(iszfs, "sh: zpool: not found", strlen("sh: zpool: not found")) == 0 || - strncmp(iszfs, "sh: 1: zpool: not found", strlen("sh: 1: zpool: not found")) == 0 - ) { - return run_command_s("df -h | " - "awk '/^\\/dev\\// {printf \"%s: %s / %s, \", $1, $3, $2}' | " - "awk '{sub(/, $/, \"\"); print}'"); - } else { - return run_command_s("zpool list | " - "awk 'NR>1 {printf \"%s: %s / %s, \", $1, $3, $2}' | " - "awk '{sub(/, $/, \"\"); print}'"); - } - } + free((void *)excode); + return run_command_s("zpool list | " + "awk 'NR>1 {printf \"%s: %s / %s, \", $1, $3, $2}' | " + "awk '{sub(/, $/, \"\"); print}'"); } - |