|
@@ -169,6 +169,7 @@ static char *editor; |
|
|
static char *desktop_manager; |
|
|
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 size_t fs_free; |
|
|
static size_t fs_free; |
|
|
static uint open_max; |
|
|
static uint open_max; |
|
|
static bm bookmark[MAX_BM]; |
|
|
static bm bookmark[MAX_BM]; |
|
@@ -1431,6 +1432,7 @@ sum_bsizes(const char *fpath, const struct stat *sb, |
|
|
if (sb->st_blocks && (typeflag == FTW_F || typeflag == FTW_D)) |
|
|
if (sb->st_blocks && (typeflag == FTW_F || typeflag == FTW_D)) |
|
|
ent_blocks += sb->st_blocks; |
|
|
ent_blocks += sb->st_blocks; |
|
|
|
|
|
|
|
|
|
|
|
++num_files; |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -1479,8 +1481,10 @@ dentfill(char *path, struct entry **dents, |
|
|
|
|
|
|
|
|
n = 0; |
|
|
n = 0; |
|
|
|
|
|
|
|
|
if (cfg.blkorder) |
|
|
|
|
|
|
|
|
if (cfg.blkorder) { |
|
|
|
|
|
num_files = 0; |
|
|
dir_blocks = 0; |
|
|
dir_blocks = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
dirp = opendir(path); |
|
|
dirp = opendir(path); |
|
|
if (dirp == NULL) |
|
|
if (dirp == NULL) |
|
@@ -1492,18 +1496,14 @@ dentfill(char *path, struct entry **dents, |
|
|
(dp->d_name[1] == '.' && dp->d_name[2] == '\0')))) |
|
|
(dp->d_name[1] == '.' && dp->d_name[2] == '\0')))) |
|
|
continue; |
|
|
continue; |
|
|
|
|
|
|
|
|
mkpath(path, dp->d_name, newpath, PATH_MAX); |
|
|
|
|
|
if (lstat(newpath, &sb) == -1) { |
|
|
|
|
|
continue; |
|
|
|
|
|
/* if (*dents) |
|
|
|
|
|
free(*dents); |
|
|
|
|
|
printerr(1, "lstat"); */ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (filter(re, dp->d_name) == 0) { |
|
|
if (filter(re, dp->d_name) == 0) { |
|
|
if (!cfg.blkorder) |
|
|
if (!cfg.blkorder) |
|
|
continue; |
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
mkpath(path, dp->d_name, newpath, PATH_MAX); |
|
|
|
|
|
if (lstat(newpath, &sb) == -1) |
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
if (S_ISDIR(sb.st_mode)) { |
|
|
if (S_ISDIR(sb.st_mode)) { |
|
|
ent_blocks = 0; |
|
|
ent_blocks = 0; |
|
|
if (nftw(newpath, sum_bsizes, open_max, |
|
|
if (nftw(newpath, sum_bsizes, open_max, |
|
@@ -1512,12 +1512,23 @@ dentfill(char *path, struct entry **dents, |
|
|
dir_blocks += sb.st_blocks; |
|
|
dir_blocks += sb.st_blocks; |
|
|
} else |
|
|
} else |
|
|
dir_blocks += ent_blocks; |
|
|
dir_blocks += ent_blocks; |
|
|
} else if (sb.st_blocks) |
|
|
|
|
|
dir_blocks += sb.st_blocks; |
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
if (sb.st_blocks) |
|
|
|
|
|
dir_blocks += sb.st_blocks; |
|
|
|
|
|
|
|
|
|
|
|
++num_files; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mkpath(path, dp->d_name, newpath, PATH_MAX); |
|
|
|
|
|
if (lstat(newpath, &sb) == -1) { |
|
|
|
|
|
if (*dents) |
|
|
|
|
|
free(*dents); |
|
|
|
|
|
printerr(1, "lstat"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (n == total_dents) { |
|
|
if (n == total_dents) { |
|
|
total_dents += 64; |
|
|
total_dents += 64; |
|
|
*dents = realloc(*dents, total_dents * sizeof(**dents)); |
|
|
*dents = realloc(*dents, total_dents * sizeof(**dents)); |
|
@@ -1540,8 +1551,10 @@ dentfill(char *path, struct entry **dents, |
|
|
(*dents)[n].blocks = sb.st_blocks; |
|
|
(*dents)[n].blocks = sb.st_blocks; |
|
|
} else |
|
|
} else |
|
|
(*dents)[n].blocks = ent_blocks; |
|
|
(*dents)[n].blocks = ent_blocks; |
|
|
} else |
|
|
|
|
|
|
|
|
} else { |
|
|
(*dents)[n].blocks = sb.st_blocks; |
|
|
(*dents)[n].blocks = sb.st_blocks; |
|
|
|
|
|
++num_files; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if ((*dents)[n].blocks) |
|
|
if ((*dents)[n].blocks) |
|
|
dir_blocks += (*dents)[n].blocks; |
|
|
dir_blocks += (*dents)[n].blocks; |
|
@@ -1695,9 +1708,9 @@ redraw(char *path) |
|
|
sprintf(g_buf, "total %d %s[%s%s]", ndents, sort, |
|
|
sprintf(g_buf, "total %d %s[%s%s]", ndents, sort, |
|
|
replace_escape(dents[cur].name), ind); |
|
|
replace_escape(dents[cur].name), ind); |
|
|
else { |
|
|
else { |
|
|
i = sprintf(g_buf, "du: %s in dir, ", |
|
|
|
|
|
coolsize(dir_blocks << 9)); |
|
|
|
|
|
sprintf(g_buf + i, "%s free [%s%s]", coolsize(fs_free), |
|
|
|
|
|
|
|
|
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), |
|
|
replace_escape(dents[cur].name), ind); |
|
|
replace_escape(dents[cur].name), ind); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|