From d1a1fec1340254926e17f5d83f848f7574286a33 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Sat, 15 Oct 2016 11:13:28 -0700 Subject: [PATCH] Use S_BLKSIZE when multiplying st_blocks. --- syscall.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/syscall.c b/syscall.c index fa53b638..d89eacd5 100644 --- 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; } -- 2.47.2