Explorar el Código

Show unprivileged free blocks in du mode

master
Arun Prakash Jana hace 8 años
padre
commit
b123985437
No se encontró ninguna clave conocida en la base de datos para esta firma ID de clave GPG: A75979F35C080412
Se han modificado 1 ficheros con 16 adiciones y 4 borrados
  1. +16
    -4
      nnn.c

+ 16
- 4
nnn.c Ver fichero

@@ -2,6 +2,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/statvfs.h>


#include <curses.h> #include <curses.h>
#include <dirent.h> #include <dirent.h>
@@ -929,6 +930,7 @@ show_help(void)
} }


off_t blk_size; off_t blk_size;
size_t fs_free = 0;


static int static int
sum_sizes(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf) sum_sizes(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf)
@@ -955,12 +957,19 @@ dentfill(char *path, struct entry **dents,
DIR *dirp; DIR *dirp;
struct dirent *dp; struct dirent *dp;
struct stat sb; struct stat sb;
struct statvfs svb;
int r, n = 0; int r, n = 0;


dirp = opendir(path); dirp = opendir(path);
if (dirp == NULL) if (dirp == NULL)
return 0; return 0;


r = statvfs(path, &svb);
if (r == -1)
fs_free = 0;
else
fs_free = svb.f_bsize * svb.f_bavail;

while ((dp = readdir(dirp)) != NULL) { while ((dp = readdir(dirp)) != NULL) {
/* Skip self and parent */ /* Skip self and parent */
if (strcmp(dp->d_name, ".") == 0 || if (strcmp(dp->d_name, ".") == 0 ||
@@ -1114,8 +1123,6 @@ redraw(char *path)
sprintf(sort, "by time "); sprintf(sort, "by time ");
else if (sizeorder) else if (sizeorder)
sprintf(sort, "by size "); sprintf(sort, "by size ");
else if (bsizeorder)
sprintf(sort, "by content size ");
else else
sort[0] = '\0'; sort[0] = '\0';


@@ -1132,8 +1139,13 @@ redraw(char *path)
else else
ind[0] = '\0'; ind[0] = '\0';


sprintf(cwd, "total %d %s[%s%s]", ndents, sort,
dents[cur].name, ind);
if (!bsizeorder)
sprintf(cwd, "total %d %s[%s%s]", ndents, sort,
dents[cur].name, ind);
else
sprintf(cwd, "total %d by disk usage, %s free [%s%s]",
ndents, coolsize(fs_free), dents[cur].name, ind);

printmsg(cwd); printmsg(cwd);
} else } else
printmsg("0 items"); printmsg("0 items");


Cargando…
Cancelar
Guardar