aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar fengyichui <fengyichui@gmail.com>2018-11-15 17:14:29 +0800
committerGravatar fengyichui <fengyichui@gmail.com>2018-11-15 17:14:29 +0800
commit7213b226d78032b18dd0b679894f346d534b0198 (patch)
treee49a22268d162640aee5aec05ee1a3150e7c207c /src
parentff0999b8018fe208ca1e49c47cec094fcc9a1e08 (diff)
downloadnnn-7213b226d78032b18dd0b679894f346d534b0198.tar.gz
Fix BLK_SHIFT may be wrong in some platforms #128
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 1bc9385..047c0ae 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -417,6 +417,18 @@ static uchar crc8fast(uchar const message[], size_t n)
return remainder;
}
+/* Get platform block shift */
+static int get_blk_shift(void)
+{
+ int shift;
+ for (shift = 0; shift < 32; ++shift)
+ {
+ if ((1<<shift) & S_BLKSIZE)
+ break;
+ }
+ return shift;
+}
+
/* Messages show up at the bottom */
static void printmsg(const char *msg)
{
@@ -2905,7 +2917,7 @@ nochange:
cfg.blkorder ^= 1;
nftw_fn = &sum_bsizes;
cfg.apparentsz = 0;
- BLK_SHIFT = 9;
+ BLK_SHIFT = get_blk_shift();
}
if (cfg.blkorder) {
@@ -3399,6 +3411,9 @@ int main(int argc, char *argv[])
char *ipath = NULL;
int opt;
+ // Get platform block shift
+ BLK_SHIFT = get_blk_shift();
+
/* Confirm we are in a terminal */
if (!isatty(0) || !isatty(1)) {
fprintf(stderr, "stdin or stdout is not a tty\n");