unwritten_sync: convert XFS_IOC_FREESP64 to ftruncate
authorDarrick J. Wong <djwong@kernel.org>
Fri, 14 Jan 2022 22:38:32 +0000 (14:38 -0800)
committerEryu Guan <guaneryu@gmail.com>
Sun, 16 Jan 2022 07:02:33 +0000 (15:02 +0800)
This ioctl will be dropped soon, so port the program to use ftruncate,
which does the same thing.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
src/unwritten_sync.c

index ebdc8248bff7c60a7e3244fb9a01ed97b2598fa5..45ac7df9709be0b5d98c0b0be68c3f0c8809d247 100644 (file)
@@ -92,10 +92,11 @@ main(int argc, char *argv[])
 
                print_getbmapx(file, fd, 0, 0);
 
-               flock.l_whence = 0;
-               flock.l_start= 0;
-               flock.l_len = 0;
-               xfsctl(file, fd, XFS_IOC_FREESP64, &flock);
+               if (ftruncate(fd, 0)) {
+                       perror("ftruncate");
+                       exit(1);
+               }
+
                print_getbmapx(file, fd, 0, 0);
                close(fd);
        }