ストレージの表示

このコミットが含まれているのは:
守矢諏訪子 2024-06-21 22:14:36 +09:00
コミット 56870db1ad
3個のファイルの変更30行の追加1行の削除

10
main.c
ファイルの表示

@ -20,6 +20,7 @@
#include "src/cpu.h"
#include "src/gpu.h"
#include "src/memory.h"
#include "src/storage.h"
const char *sofname = "farfetch";
const char *version = "0.0.1";
@ -239,13 +240,20 @@ int main(int argc, char *argv[]) {
printf("\n");
lc++;
const char *storage = display_storage();
if (storage) {
printf("%s ", LOGO[lc]);
printf("%sStorage%s: %s\n", color, reset, storage);
lc++;
free((void *)storage);
}
for (size_t i = lc; i < ls; i++) {
printf("%s\n", LOGO[i]);
}
// TODO:
// * 端末
// * ストレージ
return 0;
}

15
src/storage.c ノーマルファイル
ファイルの表示

@ -0,0 +1,15 @@
#include "storage.h"
#include "common.h"
#include <string.h>
const char *display_storage() {
const char *iszfs = run_command_s("LC_ALL=C zpool list 2>&1");
if (strstr(iszfs, "command not found: zpool")) {
return run_command_s("zpool list | awk 'NR>1 {print $1 \": \" $3 \" / \" $2}' | "
"sed ':a;N;$!ba;s//, /g'");
}
return run_command_s("df -h | awk 'NR>1 {print $1 \": \" $3 \" / \" $2}' | "
"sed ':a;N;$!ba;s/\\n/, /g'");
}

6
src/storage.h ノーマルファイル
ファイルの表示

@ -0,0 +1,6 @@
#ifndef STORAGE_H
#define STORAGE_H
const char *display_storage();
#endif