From: Amir Goldstein Date: Fri, 7 Apr 2017 09:15:39 +0000 (+0300) Subject: src/t_immutable: add ftruncate to append only tests X-Git-Tag: v2022.05.01~2097 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a589a208405d61215c52987c7d522e33b1321d34;p=users%2Fhch%2Fxfstests-dev.git src/t_immutable: add ftruncate to append only tests The truncate and ftruncate syscalls check the IS_APPEND() flag in 2 different vfs code paths and I had to fix both in order to fix overlayfs IS_APPEND() violations. Add the ftruncate test to t_immutable, so overlay/030 can verify the fix. Signed-off-by: Amir Goldstein Reviewed-by: Eryu Guan Signed-off-by: Eryu Guan --- diff --git a/src/t_immutable.c b/src/t_immutable.c index 8a12d2c30..7a7195e43 100644 --- a/src/t_immutable.c +++ b/src/t_immutable.c @@ -891,6 +891,21 @@ static int test_append(const char *dir) fail++; } + errno = 0; + if ((fd = open(path, O_RDWR|O_APPEND)) == -1) { + fprintf(stderr, "open(%s, O_RDWR|O_APPEND) failed: %s\n", path, strerror(errno)); + fail++; + } else { + if (ftruncate(fd, 0) != -1) { + fprintf(stderr, "ftruncate(%s, 0) did not fail\n", path); + fail++; + } else if (errno != EPERM) { + fprintf(stderr, "ftruncate(%s, 0) did not set errno == EPERM\n", path); + fail++; + } + close(fd); + } + errno = 0; if (truncate(path, 0) != -1) { fprintf(stderr, "truncate(%s, 0) did not fail\n", path);