aboutsummaryrefslogtreecommitdiffstats
path: root/src/nnn.c
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-02-27 00:37:00 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-02-27 00:38:30 +0530
commit05f3d5fdbeffb48ea530fb603da5c129b47f8c97 (patch)
tree528bf84c091796fab6380c2b3ec2ffbfe4abbeae /src/nnn.c
parentf12bf0a2eeb348513c38f598c103f5b4d5fcef75 (diff)
downloadnnn-05f3d5fdbeffb48ea530fb603da5c129b47f8c97.tar.gz
Hash inodes with lesser number of bits
Diffstat (limited to 'src/nnn.c')
-rw-r--r--src/nnn.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/nnn.c b/src/nnn.c
index ea37f2b..0e15806 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -165,7 +165,7 @@
#define BLK_SHIFT_512 9
/* Detect hardlinks in du */
-#define HASH_BITS (0xFFFFFF)
+#define HASH_BITS (0xFFFF)
#define HASH_OCTETS (HASH_BITS >> 6) /* 2^6 = 64 */
/* Program return codes */
@@ -702,6 +702,7 @@ static char *xitoa(uint val)
*/
static bool test_set_bit(ull nr)
{
+ nr &= HASH_BITS;
ull *m = ((ull *)ihashbmp) + (nr >> 6);
if (*m & (1 << (nr & 63)))
@@ -4179,7 +4180,7 @@ static void launch_app(const char *path, char *newpath)
static int sum_bsize(const char *UNUSED(fpath), const struct stat *sb, int typeflag, struct FTW *UNUSED(ftwbuf))
{
if (sb->st_blocks && (typeflag == FTW_F || typeflag == FTW_D)
- && (sb->st_nlink <= 1 || test_set_bit((ull)sb->st_ino)))
+ && (sb->st_nlink <= 1 || test_set_bit((ull)sb->st_ino + (ull)sb->st_size)))
ent_blocks += sb->st_blocks;
++num_files;
@@ -4189,7 +4190,7 @@ static int sum_bsize(const char *UNUSED(fpath), const struct stat *sb, int typef
static int sum_asize(const char *UNUSED(fpath), const struct stat *sb, int typeflag, struct FTW *UNUSED(ftwbuf))
{
if (sb->st_size && (typeflag == FTW_F || typeflag == FTW_D)
- && (sb->st_nlink <= 1 || test_set_bit((ull)sb->st_ino)))
+ && (sb->st_nlink <= 1 || test_set_bit((ull)sb->st_ino + (ull)sb->st_size)))
ent_blocks += sb->st_size;
++num_files;
@@ -4309,7 +4310,8 @@ static int dentfill(char *path, struct entry **dents)
}
} else {
/* Do not recount hard links */
- if (sb.st_nlink <= 1 || test_set_bit((ull)sb.st_ino))
+ if (sb.st_nlink <= 1
+ || test_set_bit((ull)sb.st_ino + (ull)sb.st_size))
dir_blocks += (cfg.apparentsz ? sb.st_size : sb.st_blocks);
++num_files;
}
@@ -4406,7 +4408,8 @@ static int dentfill(char *path, struct entry **dents)
} else {
dentp->blocks = (cfg.apparentsz ? sb.st_size : sb.st_blocks);
/* Do not recount hard links */
- if (sb.st_nlink <= 1 || test_set_bit((ull)sb.st_ino))
+ if (sb.st_nlink <= 1
+ || test_set_bit((ull)sb.st_ino + (ull)sb.st_size))
dir_blocks += dentp->blocks;
++num_files;
}