Skip to content

Commit

Permalink
fanotify{01,09,10}: Check for report fid support with mount mark
Browse files Browse the repository at this point in the history
There are now filesystems other than overlayfs (e.g. fuse) that do not
support filesystem and mount marks with FAN_REPORT_FID.

Adapt tests to runs correctly on those filesystems (tested with ntfs-3g).

Link: https://lore.kernel.org/ltp/CAOQ4uxjMiPG5E5=jirxT_D=NDxdUfA2Vp8u1yNZ=YH_SxC0S8Q@mail.gmail.com/
Reviewed-by: Petr Vorel <[email protected]>
Signed-off-by: Amir Goldstein <[email protected]>
  • Loading branch information
amir73il authored and pevik committed Jan 25, 2024
1 parent 3626124 commit bae8ec9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
14 changes: 12 additions & 2 deletions testcases/kernel/syscalls/fanotify/fanotify01.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ static char fname[BUF_SIZE];
static char buf[BUF_SIZE];
static int fd_notify;
static int fan_report_fid_unsupported;
static int mount_mark_fid_unsupported;
static int filesystem_mark_unsupported;

static unsigned long long event_set[EVENT_MAX];
Expand All @@ -88,16 +89,22 @@ static void test_fanotify(unsigned int n)
struct fanotify_mark_type *mark = &tc->mark;
int fd, ret, len, i = 0, test_num = 0;
int tst_count = 0;
int report_fid = (tc->init_flags & FAN_REPORT_FID);

tst_res(TINFO, "Test #%d: %s", n, tc->tname);

if (fan_report_fid_unsupported && (tc->init_flags & FAN_REPORT_FID)) {
if (fan_report_fid_unsupported && report_fid) {
FANOTIFY_INIT_FLAGS_ERR_MSG(FAN_REPORT_FID, fan_report_fid_unsupported);
return;
}

if (filesystem_mark_unsupported && mark->flag == FAN_MARK_FILESYSTEM) {
tst_res(TCONF, "FAN_MARK_FILESYSTEM not supported in kernel?");
FANOTIFY_MARK_FLAGS_ERR_MSG(mark, filesystem_mark_unsupported);
return;
}

if (mount_mark_fid_unsupported && report_fid && mark->flag != FAN_MARK_INODE) {
FANOTIFY_MARK_FLAGS_ERR_MSG(mark, mount_mark_fid_unsupported);
return;
}

Expand Down Expand Up @@ -342,6 +349,9 @@ static void setup(void)

fan_report_fid_unsupported = fanotify_init_flags_supported_on_fs(FAN_REPORT_FID, fname);
filesystem_mark_unsupported = fanotify_mark_supported_on_fs(FAN_MARK_FILESYSTEM, fname);
mount_mark_fid_unsupported = fanotify_flags_supported_on_fs(FAN_REPORT_FID,
FAN_MARK_MOUNT,
FAN_OPEN, fname);
}

static void cleanup(void)
Expand Down
5 changes: 3 additions & 2 deletions testcases/kernel/syscalls/fanotify/fanotify09.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,9 @@ static void test_fanotify(unsigned int n)

static void setup(void)
{
fan_report_dfid_unsupported = fanotify_init_flags_supported_on_fs(FAN_REPORT_DFID_NAME,
MOUNT_PATH);
fan_report_dfid_unsupported = fanotify_flags_supported_on_fs(FAN_REPORT_DFID_NAME,
FAN_MARK_MOUNT,
FAN_OPEN, MOUNT_PATH);
ignore_mark_unsupported = fanotify_mark_supported_on_fs(FAN_MARK_IGNORE_SURV,
MOUNT_PATH);

Expand Down
5 changes: 3 additions & 2 deletions testcases/kernel/syscalls/fanotify/fanotify10.c
Original file line number Diff line number Diff line change
Expand Up @@ -882,8 +882,9 @@ static void setup(void)
MOUNT_PATH);
ignore_mark_unsupported = fanotify_mark_supported_on_fs(FAN_MARK_IGNORE_SURV,
MOUNT_PATH);
fan_report_dfid_unsupported = fanotify_init_flags_supported_on_fs(FAN_REPORT_DFID_NAME,
MOUNT_PATH);
fan_report_dfid_unsupported = fanotify_flags_supported_on_fs(FAN_REPORT_DFID_NAME,
FAN_MARK_MOUNT,
FAN_OPEN, MOUNT_PATH);
if (fan_report_dfid_unsupported) {
FANOTIFY_INIT_FLAGS_ERR_MSG(FAN_REPORT_DFID_NAME, fan_report_dfid_unsupported);
/* Limit tests to legacy priority classes */
Expand Down

0 comments on commit bae8ec9

Please sign in to comment.