浏览代码

Show volume capacity in help

master
Arun Prakash Jana 7 年前
父节点
当前提交
2f40eb5efc
找不到此签名对应的密钥 GPG 密钥 ID: A75979F35C080412
共有 1 个文件被更改,包括 18 次插入9 次删除
  1. +18
    -9
      nnn.c

+ 18
- 9
nnn.c 查看文件

@@ -196,7 +196,6 @@ static char *desktop_manager;
static blkcnt_t ent_blocks; static blkcnt_t ent_blocks;
static blkcnt_t dir_blocks; static blkcnt_t dir_blocks;
static ulong num_files; static ulong num_files;
static size_t fs_free;
static uint open_max; static uint open_max;
static bm bookmark[BM_MAX]; static bm bookmark[BM_MAX];
static const double div_2_pow_10 = 1.0 / 1024.0; static const double div_2_pow_10 = 1.0 / 1024.0;
@@ -1587,15 +1586,26 @@ getorder(size_t size)
} }
} }


static void static size_t
update_fs_free(char *path) get_fs_free(char *path)
{ {
static struct statvfs svb; static struct statvfs svb;


if (statvfs(path, &svb) == -1) if (statvfs(path, &svb) == -1)
fs_free = 0; return 0;
else
return svb.f_bavail << getorder(svb.f_frsize);
}

static size_t
get_fs_capacity(char *path)
{
struct statvfs svb;

if (statvfs(path, &svb) == -1)
return 0;
else else
fs_free = svb.f_bavail << getorder(svb.f_bsize); return svb.f_blocks << getorder(svb.f_bsize);
} }


static int static int
@@ -1706,8 +1716,8 @@ show_help(char *path)
if (copier) if (copier)
dprintf(fd, "NNN_COPIER: %s\n", copier); dprintf(fd, "NNN_COPIER: %s\n", copier);


update_fs_free(path); dprintf(fd, "\nVolume: %s of ", coolsize(get_fs_free(path)));
dprintf(fd, "\nVolume: %s free\n", coolsize(fs_free)); dprintf(fd, "%s free\n", coolsize(get_fs_capacity(path)));


dprintf(fd, "\n"); dprintf(fd, "\n");
close(fd); close(fd);
@@ -1753,7 +1763,6 @@ dentfill(char *path, struct entry **dents,
if (cfg.blkorder) { if (cfg.blkorder) {
num_files = 0; num_files = 0;
dir_blocks = 0; dir_blocks = 0;
update_fs_free(path);


if (fstatat(fd, ".", &sb_path, 0) == -1) { if (fstatat(fd, ".", &sb_path, 0) == -1) {
printwarn(); printwarn();
@@ -2006,7 +2015,7 @@ redraw(char *path)
sprintf(g_buf, "total %d %s[%s%s]", ndents, sort, unescape(dents[cur].name), ind); sprintf(g_buf, "total %d %s[%s%s]", ndents, sort, unescape(dents[cur].name), ind);
else { else {
i = sprintf(g_buf, "du: %s (%lu files) ", coolsize(dir_blocks << 9), num_files); i = sprintf(g_buf, "du: %s (%lu files) ", coolsize(dir_blocks << 9), num_files);
sprintf(g_buf + i, "vol: %s free [%s%s]", coolsize(fs_free), unescape(dents[cur].name), ind); sprintf(g_buf + i, "vol: %s free [%s%s]", coolsize(get_fs_free(path)), unescape(dents[cur].name), ind);
} }


printmsg(g_buf); printmsg(g_buf);


||||||
x
 
000:0
正在加载...
取消
保存