From 7bfe462e5412a7157a570cefabfd303a7664a7b9 Mon Sep 17 00:00:00 2001 From: haturatu Date: Thu, 27 Jun 2024 22:11:27 +0900 Subject: fix --- src/storage.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'src/storage.c') 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 +#include 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}'"); } - -- cgit v1.2.3