mirror of
https://github.com/jarun/nnn.git
synced 2024-12-01 02:49:44 +00:00
Do not follow mounted fs in du mode
This commit is contained in:
parent
96e9028226
commit
081cb3a3e8
20
nnn.c
20
nnn.c
|
@ -1665,9 +1665,10 @@ dentfill(char *path, struct entry **dents,
|
|||
{
|
||||
static DIR *dirp;
|
||||
static struct dirent *dp;
|
||||
static struct stat sb;
|
||||
static struct stat sb_path, sb;
|
||||
static int fd, n;
|
||||
static char *namep;
|
||||
static ulong num_saved;
|
||||
static struct entry *dentp;
|
||||
|
||||
dirp = opendir(path);
|
||||
|
@ -1682,6 +1683,11 @@ dentfill(char *path, struct entry **dents,
|
|||
num_files = 0;
|
||||
dir_blocks = 0;
|
||||
update_fs_free(path);
|
||||
|
||||
if (fstatat(fd, ".", &sb_path, 0) == -1) {
|
||||
printwarn();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
while ((dp = readdir(dirp)) != NULL) {
|
||||
|
@ -1701,6 +1707,7 @@ dentfill(char *path, struct entry **dents,
|
|||
continue;
|
||||
|
||||
if (S_ISDIR(sb.st_mode)) {
|
||||
if (sb_path.st_dev == sb.st_dev) {
|
||||
ent_blocks = 0;
|
||||
mkpath(path, namep, g_buf, PATH_MAX);
|
||||
|
||||
|
@ -1710,6 +1717,7 @@ dentfill(char *path, struct entry **dents,
|
|||
dir_blocks += sb.st_blocks;
|
||||
} else
|
||||
dir_blocks += ent_blocks;
|
||||
}
|
||||
} else {
|
||||
if (sb.st_blocks)
|
||||
dir_blocks += sb.st_blocks;
|
||||
|
@ -1748,6 +1756,7 @@ dentfill(char *path, struct entry **dents,
|
|||
if (cfg.blkorder) {
|
||||
if (S_ISDIR(sb.st_mode)) {
|
||||
ent_blocks = 0;
|
||||
num_saved = num_files + 1;
|
||||
mkpath(path, namep, g_buf, PATH_MAX);
|
||||
|
||||
if (nftw(g_buf, sum_bsizes, open_max,
|
||||
|
@ -1756,13 +1765,16 @@ dentfill(char *path, struct entry **dents,
|
|||
dentp->blocks = sb.st_blocks;
|
||||
} else
|
||||
dentp->blocks = ent_blocks;
|
||||
|
||||
if (sb_path.st_dev == sb.st_dev)
|
||||
dir_blocks += dentp->blocks;
|
||||
else
|
||||
num_files = num_saved;
|
||||
} else {
|
||||
dentp->blocks = sb.st_blocks;
|
||||
dir_blocks += dentp->blocks;
|
||||
++num_files;
|
||||
}
|
||||
|
||||
if (dentp->blocks)
|
||||
dir_blocks += dentp->blocks;
|
||||
}
|
||||
|
||||
++n;
|
||||
|
|
Loading…
Reference in a new issue