From: Darrick J. Wong Date: Thu, 18 Feb 2016 23:51:17 +0000 (+1100) Subject: punch-alternating: use the block size reported by the fs for punching X-Git-Tag: v2022.05.01~2598 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=f9ff240882ee1343828834a9265f64da605d4c9b;p=xfstests-dev.git punch-alternating: use the block size reported by the fs for punching When we're trying to punch alternating blocks out of a file, use the bsize reported by fstatfs so that we can punch out single blocks. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Dave Chinner --- diff --git a/src/punch-alternating.c b/src/punch-alternating.c index 95663108..4148622f 100644 --- a/src/punch-alternating.c +++ b/src/punch-alternating.c @@ -14,6 +14,7 @@ int main(int argc, char *argv[]) { struct stat s; + struct statfs sf; off_t offset; int fd; blksize_t blksz; @@ -35,8 +36,12 @@ int main(int argc, char *argv[]) if (error) goto err; + error = fstatfs(fd, &sf); + if (error) + goto err; + sz = s.st_size; - blksz = s.st_blksize; + blksz = sf.f_bsize; mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE; for (offset = 0; offset < sz; offset += blksz * 2) {