mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
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 <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
committed by
Dave Chinner
parent
004197958e
commit
f9ff240882
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user