Use S_BLKSIZE when multiplying st_blocks.
authorWayne Davison <wayned@samba.org>
Sat, 15 Oct 2016 18:13:28 +0000 (11:13 -0700)
committerWayne Davison <wayned@samba.org>
Sat, 15 Oct 2016 18:33:07 +0000 (11:33 -0700)
syscall.c

index fa53b638159125ae3f15b3e3e48d2ffa41d3cfca..d89eacd57fb4de608ddc88aef21f4e145ac02a46 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -43,6 +43,16 @@ extern int preallocate_files;
 extern int preserve_perms;
 extern int preserve_executability;
 
+#ifndef S_BLKSIZE
+# if defined hpux || defined __hpux__ || defined __hpux
+#  define S_BLKSIZE 1024
+# elif defined _AIX && defined _I386
+#  define S_BLKSIZE 4096
+# else
+#  define S_BLKSIZE 512
+# endif
+#endif
+
 #define RETURN_ERROR_IF(x,e) \
        do { \
                if (x) { \
@@ -456,7 +466,7 @@ OFF_T do_fallocate(int fd, OFF_T offset, OFF_T length)
                STRUCT_STAT st;
                if (do_fstat(fd, &st) < 0)
                        return length;
-               return st.st_blocks * 512;
+               return st.st_blocks * S_BLKSIZE;
        }
        return 0;
 }