summaryrefslogtreecommitdiff
path: root/src/storage.c
blob: 5471a6211fddb414fdbd3f1f95e8c27202221828 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#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 {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'");
}