All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 4/4] syscalls/fanotify15: verify fid for dirent events
Date: Tue, 16 Apr 2019 16:29:59 +0200	[thread overview]
Message-ID: <20190416142959.GC20437@rei> (raw)
In-Reply-To: <2934be190caaaf4bb75caffd731d34711fbf1c61.1554197461.git.mbobrowski@mbobrowski.org>

Hi!
This one misses runtest entry as well.

> +#define BUF_SIZE 256
> +#define EVENT_MAX 256 
> +
> +#define MOUNT_POINT "mntpoint"
> +#define TEST_DIR MOUNT_POINT"/test_dir"
> +#define DIR1 TEST_DIR"/dir1"
> +#define DIR2 TEST_DIR"/dir2"
> +#define FILE1 TEST_DIR"/file1"
> +#define FILE2 TEST_DIR"/file2"
> +
> +struct event_t {
> +	unsigned long long mask;
> +	__kernel_fsid_t fsid;
> +	struct file_handle handle;
> +	char buf[MAX_HANDLE_SZ];
> +};
> +
> +static int fanotify_fd;
> +static char events_buf[BUF_SIZE];
> +static struct event_t event_set[EVENT_MAX];
> +
> +static void do_setup(void)
> +{
> +	int fd;
> +
> +	/* Check kernel for fanotify support */
> +	fd = SAFE_FANOTIFY_INIT(FAN_CLASS_NOTIF, O_RDONLY);
> +	SAFE_CLOSE(fd);
> +
> +	fanotify_fd = fanotify_init(FAN_REPORT_FID, O_RDONLY);
> +	if (fanotify_fd == -1) {
> +		if (errno == EINVAL)
> +			tst_brk(TCONF,
> +				"FAN_REPORT_FID not supported in kernel");
> +		tst_brk(TBROK | TERRNO,
> +			"fanotify_init(FAN_REPORT_FID, O_RDONLY) failed");
> +	}
> +
> +	SAFE_MKDIR(TEST_DIR, 0755);
> +}
> +
> +static void get_fid_data(int i, const char *path)
> +{
> +	int mount_id;
> +	struct statfs stats;
> +
> +	if (statfs(path, &stats) == -1)
> +		tst_brk(TBROK | TERRNO,
> +			"statfs(%s, ...) failed", path);
> +	memcpy(&event_set[i].fsid, &stats.f_fsid, sizeof(stats.f_fsid));
> +
> +	event_set[i].handle.handle_bytes = MAX_HANDLE_SZ;
> +	if (name_to_handle_at(AT_FDCWD, path, &event_set[i].handle,
> +				&mount_id, 0) == -1) {
> +		if (errno == EOPNOTSUPP) {
> +			tst_brk(TCONF,
> +				"filesystem %s does not support file handles",
> +				tst_device->fs_type);
> +		}
> +		tst_brk(TBROK | TERRNO,
> +			"name_to_handle_at(AT_FDCWD, %s, ...) failed",
> +			path);
> +	}
> +}

Can put this code into an header in the fanotify/ directory along with
the event_t structure definiton so that we do not carry two copies of
nearly identical code.

If we passed a pointer to the event_t structure instead of the index we
can call this function in a loop in the get_object_stats() in
fanotify13, right?

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2019-04-16 14:29 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-02 10:01 [LTP] [PATCH 0/4] fanotify: FAN_REPORT_FID and Directory Modification Events Matthew Bobrowski
2019-04-02 10:01 ` [LTP] [PATCH 1/4] syscalls/fanotify01: add FAN_REPORT_FID test cases Amir Goldstein
2019-04-15 15:18   ` Cyril Hrubis
2019-04-02 10:02 ` [LTP] [PATCH 2/4] syscalls/fanotify13: new test to verify FAN_REPORT_FID functionality Matthew Bobrowski
2019-04-16 13:41   ` Cyril Hrubis
2019-04-16 14:23     ` Amir Goldstein
2019-04-19  8:37       ` Matthew Bobrowski
2019-04-19  9:07         ` Amir Goldstein
2019-04-02 10:02 ` [LTP] [PATCH 3/4] syscalls/fanotify14: new test to validate FAN_REPORT_FID interface return values Matthew Bobrowski
2019-04-16 14:04   ` Cyril Hrubis
2019-04-19  8:38     ` Matthew Bobrowski
2019-04-02 10:02 ` [LTP] [PATCH 4/4] syscalls/fanotify15: verify fid for dirent events Matthew Bobrowski
2019-04-16 14:29   ` Cyril Hrubis [this message]
2019-04-16 14:59     ` Amir Goldstein
2019-04-16 15:00       ` Cyril Hrubis
2019-04-18 18:36         ` Amir Goldstein
2019-04-18 18:58           ` Cyril Hrubis
2019-04-18 19:10             ` Amir Goldstein
2019-04-18 19:42               ` Cyril Hrubis
2019-04-19  7:18                 ` Amir Goldstein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190416142959.GC20437@rei \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.