From abeb59fe302b2277c7e001af245abada05778991 Mon Sep 17 00:00:00 2001
From: yorhel <yorhel@ce56bc8d-f834-0410-b703-f827bd498a76>
Date: Fri, 2 Nov 2007 11:44:18 +0000
Subject: [PATCH] Bugfix for systems that don't have an S_BLKSIZE of 512

git-svn-id: svn://blicky.net/ncdu/trunk@29 ce56bc8d-f834-0410-b703-f827bd498a76
---
 src/calc.c | 4 ++--
 src/ncdu.h | 5 +++++
 2 files changed, 7 insertions(+), 2 deletions(-)

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 <sys/time.h>
 #include <dirent.h>
 
+/* 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
-- 
GitLab