Message ID | 20211026184239.151156-7-krisman@collabora.com |
---|---|
State | Not Applicable |
Headers | show |
Series | Test the new fanotify FAN_FS_ERROR event | expand |
On Tue, Oct 26, 2021 at 9:43 PM Gabriel Krisman Bertazi <krisman@collabora.com> wrote: > > In order to test FAN_FS_ERROR, we want to corrupt the filesystem. The > easiest way to do it is by using debugfs. Add a small helper to issue > debugfs requests. Since most likely this will be the only testcase to > need this, don't bother making it a proper helper for now. > > Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com> Reviewed-by: Amir Goldstein <amir73il@gmail.com> > --- > changes since v1: > - Add .needs_cmds to require debugfs > --- > testcases/kernel/syscalls/fanotify/fanotify20.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/testcases/kernel/syscalls/fanotify/fanotify20.c b/testcases/kernel/syscalls/fanotify/fanotify20.c > index 220cd51419e8..7c4b01720654 100644 > --- a/testcases/kernel/syscalls/fanotify/fanotify20.c > +++ b/testcases/kernel/syscalls/fanotify/fanotify20.c > @@ -47,6 +47,13 @@ int fd_notify; > /* These expected FIDs are common to multiple tests */ > static struct fanotify_fid_t null_fid; > > +static void do_debugfs_request(const char *dev, char *request) > +{ > + const char *cmd[] = {"debugfs", "-w", dev, "-R", request, NULL}; > + > + SAFE_CMD(cmd, NULL, NULL); > +} > + > static struct test_case { > char *name; > int error; > @@ -216,7 +223,11 @@ static struct tst_test test = { > .mntpoint = MOUNT_PATH, > .all_filesystems = 0, > .needs_root = 1, > - .dev_fs_type = "ext4" > + .dev_fs_type = "ext4", > + .needs_cmds = (const char *[]) { > + "debugfs", > + NULL > + } > }; > > #else > -- > 2.33.0 >
diff --git a/testcases/kernel/syscalls/fanotify/fanotify20.c b/testcases/kernel/syscalls/fanotify/fanotify20.c index 220cd51419e8..7c4b01720654 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify20.c +++ b/testcases/kernel/syscalls/fanotify/fanotify20.c @@ -47,6 +47,13 @@ int fd_notify; /* These expected FIDs are common to multiple tests */ static struct fanotify_fid_t null_fid; +static void do_debugfs_request(const char *dev, char *request) +{ + const char *cmd[] = {"debugfs", "-w", dev, "-R", request, NULL}; + + SAFE_CMD(cmd, NULL, NULL); +} + static struct test_case { char *name; int error; @@ -216,7 +223,11 @@ static struct tst_test test = { .mntpoint = MOUNT_PATH, .all_filesystems = 0, .needs_root = 1, - .dev_fs_type = "ext4" + .dev_fs_type = "ext4", + .needs_cmds = (const char *[]) { + "debugfs", + NULL + } }; #else
In order to test FAN_FS_ERROR, we want to corrupt the filesystem. The easiest way to do it is by using debugfs. Add a small helper to issue debugfs requests. Since most likely this will be the only testcase to need this, don't bother making it a proper helper for now. Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com> --- changes since v1: - Add .needs_cmds to require debugfs --- testcases/kernel/syscalls/fanotify/fanotify20.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)