diff options
author | Yorhel <git@yorhel.nl> | 2020-06-07 10:01:31 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2020-06-07 10:03:11 +0200 |
commit | a389443c9a1f3b2b68fe9b9fccef1f0b6569b632 (patch) | |
tree | b0f56b045ff053cd7f6df410e34cbe1c7dad9470 | |
parent | c340980b80b9ef0c957fe832e93e5ef430b216ac (diff) |
Add --exclude-firmlinks and follow firmlinks by default
What a mess.
https://code.blicky.net/yorhel/ncdu/issues/153#issuecomment-764
-rw-r--r-- | doc/ncdu.pod | 12 | ||||
-rw-r--r-- | src/main.c | 18 |
2 files changed, 20 insertions, 10 deletions
diff --git a/doc/ncdu.pod b/doc/ncdu.pod index 56ae025..7fc04f5 100644 --- a/doc/ncdu.pod +++ b/doc/ncdu.pod @@ -179,12 +179,9 @@ this option will not follow symlinks to directories and will count each symlinked file as a unique file (i.e. unlike how hard links are handled). This is subject to change in later versions. -=item --follow-firmlinks +=item --exclude-firmlinks -(MacOS only) follow firmlinks. WARNING: This may cause directories to be -scanned and counted multiple times. Firmlink cycles are current (1.15) not -detected, so it may also cause ncdu to get stuck in an infinite loop and -eventually run out of memory. +(MacOS only) Exclude firmlinks. =item --exclude-kernfs @@ -429,6 +426,11 @@ Item counts are stored in a signed 32-bit integer without overflow detection. If you have a directory with more than 2 billion files, quite literally anything can happen. +On macOS 10.15 and later, running ncdu on the root directory without +`--exclude-firmlinks` may cause directories to be scanned and counted multiple +times. Firmlink cycles are currently (1.15.1) not detected, so it may also +cause ncdu to get stuck in an infinite loop and eventually run out of memory. + Please report any other bugs you may find at the bug tracker, which can be found on the web site at https://dev.yorhel.nl/ncdu @@ -42,7 +42,7 @@ long update_delay = 100; int cachedir_tags = 0; int extended_info = 0; int follow_symlinks = 0; -int follow_firmlinks = 0; +int follow_firmlinks = 1; int confirm_quit = 0; static int min_rows = 17, min_cols = 60; @@ -139,7 +139,8 @@ static void argv_parse(int argc, char **argv) { { 'L', 0, "-L,--follow-symlinks" }, { 'C', 0, "--exclude-caches" }, { 2, 0, "--exclude-kernfs" }, - { 3, 0, "--follow-firmlinks" }, + { 3, 0, "--follow-firmlinks" }, /* undocumented, this behavior is the current default */ + { 4, 0, "--exclude-firmlinks" }, { 's', 0, "--si" }, { 'Q', 0, "--confirm-quit" }, { 'c', 1, "--color" }, @@ -173,7 +174,7 @@ static void argv_parse(int argc, char **argv) { printf(" --exclude-kernfs Exclude Linux pseudo filesystems (procfs,sysfs,cgroup,...)\n"); #endif #if HAVE_SYS_ATTR_H && HAVE_GETATTRLIST && HAVE_DECL_ATTR_CMNEXT_NOFIRMLINKPATH - printf(" --follow-firmlinks Follow firmlinks on macOS\n"); + printf(" --exclude-firmlinks Exclude firmlinks on macOS\n"); #endif printf(" --confirm-quit Confirm quitting ncdu\n"); printf(" --color SCHEME Set color scheme (off/dark)\n"); @@ -204,20 +205,27 @@ static void argv_parse(int argc, char **argv) { cachedir_tags = 1; break; - case 2 : + case 2 : /* --exclude-kernfs */ #if HAVE_LINUX_MAGIC_H && HAVE_SYS_STATFS_H && HAVE_STATFS exclude_kernfs = 1; break; #else fprintf(stderr, "This feature is not supported on your platform\n"); exit(1); #endif - case 3 : + case 3 : /* --follow-firmlinks */ #if HAVE_SYS_ATTR_H && HAVE_GETATTRLIST && HAVE_DECL_ATTR_CMNEXT_NOFIRMLINKPATH follow_firmlinks = 1; break; #else fprintf(stderr, "This feature is not supported on your platform\n"); exit(1); #endif + case 4 : /* --exclude-firmlinks */ +#if HAVE_SYS_ATTR_H && HAVE_GETATTRLIST && HAVE_DECL_ATTR_CMNEXT_NOFIRMLINKPATH + follow_firmlinks = 0; break; +#else + fprintf(stderr, "This feature is not supported on your platform\n"); + exit(1); +#endif case 'c': if(strcmp(val, "off") == 0) { uic_theme = 0; } else if(strcmp(val, "dark") == 0) { uic_theme = 1; } |