diff --git a/src/calc.c b/src/calc.c index 0a96a83..90b52b0 100644 --- a/src/calc.c +++ b/src/calc.c @@ -311,7 +311,7 @@ int calcDir(struct dir *dest, char *path) { /* count the size */ if(!(d->flags & FF_EXL || d->flags & FF_OTHFS)) { - d->size = fs.st_blocks * 512; + d->size = fs.st_blocks * S_BLKSIZE; d->asize = fs.st_size; for(t = dest; t != NULL; t = t->parent) { t->size += d->size; @@ -376,7 +376,7 @@ struct dir *showCalc(char *path) { return(NULL); } parent = calloc(sizeof(struct dir), 1); - parent->size = fs.st_blocks * 512; + parent->size = fs.st_blocks * S_BLKSIZE; parent->asize = fs.st_size; parent->flags |= FF_DIR; curdev = fs.st_dev; diff --git a/src/ncdu.h b/src/ncdu.h index dc5d0af..745f959 100644 --- a/src/ncdu.h +++ b/src/ncdu.h @@ -44,6 +44,11 @@ #include #include +/* set S_BLKSIZE if not defined already in sys/stat.h */ +#ifndef S_BLKSIZE +# define S_BLKSIZE 512 +#endif + /* PATH_MAX 260 on Cygwin is too small for /proc/registry */ #ifdef __CYGWIN__ # if PATH_MAX < 1024