Use macro for 512B sector size

This commit is contained in:
Arun Prakash Jana 2019-10-30 22:43:22 +05:30
parent a97e3ed5c4
commit 6eeab1af9f
No known key found for this signature in database
GPG key ID: A75979F35C080412

View file

@ -142,6 +142,7 @@
#define MIN_DISPLAY_COLS 10 #define MIN_DISPLAY_COLS 10
#define LONG_SIZE sizeof(ulong) #define LONG_SIZE sizeof(ulong)
#define ARCHIVE_CMD_LEN 16 #define ARCHIVE_CMD_LEN 16
#define BLK_SHIFT_512 9
/* Program return codes */ /* Program return codes */
#define _SUCCESS 0 #define _SUCCESS 0
@ -322,7 +323,7 @@ static ulong num_files;
static kv bookmark[BM_MAX]; static kv bookmark[BM_MAX];
static kv plug[PLUGIN_MAX]; static kv plug[PLUGIN_MAX];
static uchar g_tmpfplen; static uchar g_tmpfplen;
static uchar BLK_SHIFT = 9; static uchar blk_shift = BLK_SHIFT_512;
static bool interrupted = FALSE; static bool interrupted = FALSE;
/* Retain old signal handlers */ /* Retain old signal handlers */
@ -2639,14 +2640,14 @@ static void printent_long(const struct entry *ent, int sel, uint namecols)
case S_IFREG: case S_IFREG:
if (ent->mode & 0100) if (ent->mode & 0100)
printw("%c%-16.16s %s %8.8s* %s*\n", cp, timebuf, permbuf, printw("%c%-16.16s %s %8.8s* %s*\n", cp, timebuf, permbuf,
coolsize(cfg.blkorder ? ent->blocks << BLK_SHIFT : ent->size), pname); coolsize(cfg.blkorder ? ent->blocks << blk_shift : ent->size), pname);
else else
printw("%c%-16.16s %s %8.8s %s\n", cp, timebuf, permbuf, printw("%c%-16.16s %s %8.8s %s\n", cp, timebuf, permbuf,
coolsize(cfg.blkorder ? ent->blocks << BLK_SHIFT : ent->size), pname); coolsize(cfg.blkorder ? ent->blocks << blk_shift : ent->size), pname);
break; break;
case S_IFDIR: case S_IFDIR:
printw("%c%-16.16s %s %8.8s %s/\n", cp, timebuf, permbuf, printw("%c%-16.16s %s %8.8s %s/\n", cp, timebuf, permbuf,
coolsize(cfg.blkorder ? ent->blocks << BLK_SHIFT : ent->size), pname); coolsize(cfg.blkorder ? ent->blocks << blk_shift : ent->size), pname);
break; break;
case S_IFLNK: case S_IFLNK:
printw("%c%-16.16s %s @ %s@\n", cp, timebuf, permbuf, pname); printw("%c%-16.16s %s @ %s@\n", cp, timebuf, permbuf, pname);
@ -3924,7 +3925,7 @@ static void redraw(char *path)
ptr = "\b"; ptr = "\b";
if (cfg.blkorder) { /* du mode */ if (cfg.blkorder) { /* du mode */
xstrlcpy(buf, coolsize(dir_blocks << BLK_SHIFT), 12); xstrlcpy(buf, coolsize(dir_blocks << blk_shift), 12);
c = cfg.apparentsz ? 'a' : 'd'; c = cfg.apparentsz ? 'a' : 'd';
mvprintw(lastln, 0, "%d/%d (%d) %cu:%s free:%s files:%lu %s", mvprintw(lastln, 0, "%d/%d (%d) %cu:%s free:%s files:%lu %s",
@ -4019,7 +4020,7 @@ begin:
interrupted = FALSE; interrupted = FALSE;
cfg.apparentsz = 0; cfg.apparentsz = 0;
cfg.blkorder = 0; cfg.blkorder = 0;
BLK_SHIFT = 9; blk_shift = BLK_SHIFT_512;
presel = CONTROL('L'); presel = CONTROL('L');
} }
@ -4482,7 +4483,7 @@ nochange:
if (cfg.apparentsz) { if (cfg.apparentsz) {
nftw_fn = &sum_sizes; nftw_fn = &sum_sizes;
cfg.blkorder = 1; cfg.blkorder = 1;
BLK_SHIFT = 0; blk_shift = 0;
} else } else
cfg.blkorder = 0; // fallthrough cfg.blkorder = 0; // fallthrough
case SEL_BSIZE: case SEL_BSIZE:
@ -4491,7 +4492,7 @@ nochange:
cfg.blkorder ^= 1; cfg.blkorder ^= 1;
nftw_fn = &sum_bsizes; nftw_fn = &sum_bsizes;
cfg.apparentsz = 0; cfg.apparentsz = 0;
BLK_SHIFT = ffs(S_BLKSIZE) - 1; blk_shift = ffs(S_BLKSIZE) - 1;
} }
if (cfg.blkorder) { if (cfg.blkorder) {
@ -5334,7 +5335,7 @@ int main(int argc, char *argv[])
case 'S': case 'S':
cfg.blkorder = 1; cfg.blkorder = 1;
nftw_fn = sum_bsizes; nftw_fn = sum_bsizes;
BLK_SHIFT = ffs(S_BLKSIZE) - 1; // fallthrough blk_shift = ffs(S_BLKSIZE) - 1; // fallthrough
case 'd': case 'd':
cfg.showdetail = 1; cfg.showdetail = 1;
printptr = &printent_long; printptr = &printent_long;