From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 1/3] syscalls/fanotify13: new test to verify FAN_REPORT_FID functionality
Date: Fri, 26 Apr 2019 17:27:48 +0200 [thread overview]
Message-ID: <20190426152748.GA31769@rei.lan> (raw)
In-Reply-To: <6639dd7a9ff9929ce79f4f353f3e1db075594ea2.1555763787.git.mbobrowski@mbobrowski.org>
Hi!
I've tried these tests on buildservice to check that there are no
problems on slightly older distributions and found two.
The first one is that we do define fallback definitions in fanotify.h
but then ifdef the whole test code in #if defined(HAVE_SYS_FANOTIFY_H)
so that it's efectively disabled on older distros even with fallback
definitions in place. Also it's TST_TEST_TCONF() but that is just easy
to fix typo. I guess that we can remove the ifdef and sys/fanotify.h
include from the test sources since we conditionally include the
sys/fanotify.h in the local fanotify.h already.
The second one is that we fail to compile on older distributions because
of missing name_to_handle_at() so we need configure check for that
syscall and fallback definition in lapi/ header, or at least configure
check and ifdef in the fanotify_get_fid() function. Which should be as
easy as adding a name_to_handle_at line to AC_CHECK_FUNCS() in the
configure.ac and using the macro from config.h.
> diff --git a/runtest/syscalls b/runtest/syscalls
> index 2b8ca71..dfdc6cb 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -537,6 +537,7 @@ fanotify09 fanotify09
> fanotify10 fanotify10
> fanotify11 fanotify11
> fanotify12 fanotify12
> +fanotify13 fanotify13
>
> ioperm01 ioperm01
> ioperm02 ioperm02
> diff --git a/testcases/kernel/syscalls/fanotify/.gitignore b/testcases/kernel/syscalls/fanotify/.gitignore
> index 4256b8c..16bdd99 100644
> --- a/testcases/kernel/syscalls/fanotify/.gitignore
> +++ b/testcases/kernel/syscalls/fanotify/.gitignore
> @@ -10,4 +10,5 @@
> /fanotify10
> /fanotify11
> /fanotify12
> +/fanotify13
> /fanotify_child
> diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h
> index 14654b7..e9b23cc 100644
> --- a/testcases/kernel/syscalls/fanotify/fanotify.h
> +++ b/testcases/kernel/syscalls/fanotify/fanotify.h
> @@ -29,6 +29,11 @@
> #define __FANOTIFY_H__
>
> #include "config.h"
> +#include <sys/statfs.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <errno.h>
> +#include <fcntl.h>
>
> #if defined(HAVE_SYS_FANOTIFY_H)
>
> @@ -57,9 +62,6 @@ static long fanotify_mark(int fd, unsigned int flags, uint64_t mask,
> #ifndef FAN_REPORT_TID
> #define FAN_REPORT_TID 0x00000100
> #endif
> -#ifndef FAN_REPORT_FID
> -#define FAN_REPORT_FID 0x00000200
> -#endif
>
> #ifndef FAN_MARK_INODE
> #define FAN_MARK_INODE 0
> @@ -89,6 +91,50 @@ struct fanotify_mark_type {
> const char * name;
> };
>
> +#ifndef FAN_REPORT_FID
> +#define FAN_REPORT_FID 0x00000200
> +
> +struct fanotify_event_info_header {
> + uint8_t info_type;
> + uint8_t pad;
> + uint16_t len;
> +};
> +
> +struct fanotify_event_info_fid {
> + struct fanotify_event_info_header hdr;
> + __kernel_fsid_t fsid;
> + unsigned char handle[0];
> +};
> +
> +/*
> + * Helper function used to obtain __kernel_fsid_t and file_handle objects
> + * for a given path. Used by test files correlated to FAN_REPORT_FID
> + * functionality.
> + */
> +static inline void fanotify_get_fid(const char *path, __kernel_fsid_t *fsid,
> + struct file_handle *handle)
> +{
> + int mount_id;
> + struct statfs stats;
> +
> + if (statfs(path, &stats) == -1)
> + tst_brk(TBROK | TERRNO,
> + "statfs(%s, ...) failed", path);
> + memcpy(fsid, &stats.f_fsid, sizeof(stats.f_fsid));
> +
> + if (name_to_handle_at(AT_FDCWD, path, handle, &mount_id, 0) == -1) {
> + if (errno == EOPNOTSUPP) {
> + tst_res(TCONF,
> + "filesystem %s does not support file handles",
> + tst_device->fs_type);
Btw, here the tst_res() does not make much sense sice the code will
continue and we will exit the test with the tst_brk() below. Shouldn't
we use tst_brk() here as well?
> + }
> + tst_brk(TBROK | TERRNO,
> + "name_to_handle_at(AT_FDCWD, %s, ...) failed", path);
> + }
> +}
> +
> +#endif
> +
> #define INIT_FANOTIFY_MARK_TYPE(t) \
> { FAN_MARK_ ## t, "FAN_MARK_" #t }
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2019-04-26 15:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-20 12:49 [LTP] [PATCH v2 0/3] FAN_REPORT_FID and Directory Modification Events Matthew Bobrowski
2019-04-20 12:49 ` [LTP] [PATCH v2 1/3] syscalls/fanotify13: new test to verify FAN_REPORT_FID functionality Matthew Bobrowski
2019-04-26 15:27 ` Cyril Hrubis [this message]
2019-04-27 4:53 ` Matthew Bobrowski
2019-05-07 7:40 ` Matthew Bobrowski
2019-05-15 14:50 ` Amir Goldstein
2019-05-19 4:39 ` Matthew Bobrowski
2019-04-20 12:50 ` [LTP] [PATCH v2 2/3] syscalls/fanotify14: new test to validate FAN_REPORT_FID interface return values Matthew Bobrowski
2019-04-20 12:50 ` [LTP] [PATCH v2 3/3] syscalls/fanotify15: verify fid for dirent events Matthew Bobrowski
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=20190426152748.GA31769@rei.lan \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox