syscalls/fallocate05: Add missing FALLOC_FL_KEEP_SIZE flag

Message ID 1528339200-15655-1-git-send-email-yangx.jy@cn.fujitsu.com
State New
Headers show
Series
  • syscalls/fallocate05: Add missing FALLOC_FL_KEEP_SIZE flag
Related show

Commit Message

Xiao Yang June 7, 2018, 2:40 a.m.
According to fallocate(2) manpage and kernel source code, if fallocate(2)
only specify FALLOC_FL_PUNCH_HOLE flag, it always gets EOPNOTSUPP.  We
should specify both FALLOC_FL_PUNCH_HOLE and FALLOC_FL_KEEP_SIZE.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
 testcases/kernel/syscalls/fallocate/fallocate05.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jan Stancek June 19, 2018, 12:34 p.m. | #1
----- Original Message -----
> According to fallocate(2) manpage and kernel source code, if fallocate(2)
> only specify FALLOC_FL_PUNCH_HOLE flag, it always gets EOPNOTSUPP.  We
> should specify both FALLOC_FL_PUNCH_HOLE and FALLOC_FL_KEEP_SIZE.
> 
> Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>

Pushed.

Thanks,
Jan

Patch

diff --git a/testcases/kernel/syscalls/fallocate/fallocate05.c b/testcases/kernel/syscalls/fallocate/fallocate05.c
index 1fac26a..a358e67 100644
--- a/testcases/kernel/syscalls/fallocate/fallocate05.c
+++ b/testcases/kernel/syscalls/fallocate/fallocate05.c
@@ -69,7 +69,7 @@  static void run(void)
 
 	tst_res(TPASS | TERRNO, "fallocate() on full FS");
 
-	ret = fallocate(fd, FALLOC_FL_PUNCH_HOLE, 0, FALLOCATE_SIZE);
+	ret = fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, FALLOCATE_SIZE);
 	if (ret == -1) {
 		if (errno == EOPNOTSUPP)
 			tst_brk(TCONF, "fallocate(FALLOC_FL_PUNCH_HOLE)");