Show vol free in help

This commit is contained in:
Arun Prakash Jana 2017-08-12 01:42:55 +05:30
parent 054f037bd2
commit f178004b13
No known key found for this signature in database
GPG key ID: A75979F35C080412

94
nnn.c
View file

@ -1421,6 +1421,50 @@ show_stats(char *fpath, char *fname, struct stat *sb)
return 0;
}
static int
getorder(size_t size)
{
switch (size) {
case 4096:
return 12;
case 512:
return 9;
case 8192:
return 13;
case 16384:
return 14;
case 32768:
return 15;
case 65536:
return 16;
case 131072:
return 17;
case 262144:
return 18;
case 524288:
return 19;
case 1048576:
return 20;
case 2048:
return 11;
case 1024:
return 10;
default:
return 0;
}
}
static void
update_fs_free(char *path)
{
static struct statvfs svb;
if (statvfs(path, &svb) == -1)
fs_free = 0;
else
fs_free = svb.f_bavail << getorder(svb.f_bsize);
}
static int
show_mediainfo(char *fpath, char *arg)
{
@ -1434,7 +1478,7 @@ show_mediainfo(char *fpath, char *arg)
}
static int
show_help(void)
show_help(char *path)
{
char tmp[] = "/tmp/nnnXXXXXX";
static char helpstr[] = ("\
@ -1485,7 +1529,7 @@ Home, g, ^, ^A | Jump to first entry\n\
dprintf(fd, "BOOKMARKS\n");
for (; i < MAX_BM; ++i)
if (bookmark[i].key)
dprintf(fd, "\t%s: %s\n",
dprintf(fd, " %s: %s\n",
bookmark[i].key, bookmark[i].loc);
else
break;
@ -1504,6 +1548,9 @@ Home, g, ^, ^A | Jump to first entry\n\
if (copier)
dprintf(fd, "NNN_COPIER: %s\n", copier);
update_fs_free(path);
dprintf(fd, "\nVolume: %s free\n", coolsize(fs_free));
dprintf(fd, "\n");
close(fd);
@ -1525,39 +1572,6 @@ sum_bsizes(const char *fpath, const struct stat *sb,
return 0;
}
static int
getorder(size_t size)
{
switch (size) {
case 4096:
return 12;
case 512:
return 9;
case 8192:
return 13;
case 16384:
return 14;
case 32768:
return 15;
case 65536:
return 16;
case 131072:
return 17;
case 262144:
return 18;
case 524288:
return 19;
case 1048576:
return 20;
case 2048:
return 11;
case 1024:
return 10;
default:
return 0;
}
}
static int
dentfill(char *path, struct entry **dents,
int (*filter)(regex_t *, char *), regex_t *re)
@ -1578,15 +1592,9 @@ dentfill(char *path, struct entry **dents,
n = 0;
if (cfg.blkorder) {
static struct statvfs svb;
if (statvfs(path, &svb) == -1)
fs_free = 0;
else
fs_free = svb.f_bavail << getorder(svb.f_bsize);
num_files = 0;
dir_blocks = 0;
update_fs_free(path);
}
while ((dp = readdir(dirp)) != NULL) {
@ -2413,7 +2421,7 @@ nochange:
printmsg("NNN_COPIER is not set");
goto nochange;
case SEL_HELP:
show_help();
show_help(path);
break;
case SEL_RUN:
run = xgetenv(env, run);