* [PATCH] generic/791: don't run if kernel misses FANOTIFY
@ 2026-05-20 13:37 Andrey Albershteyn
2026-05-20 14:55 ` Darrick J. Wong
0 siblings, 1 reply; 2+ messages in thread
From: Andrey Albershteyn @ 2026-05-20 13:37 UTC (permalink / raw)
To: djwong, fstests; +Cc: Andrey Albershteyn
If FANOTIFY=no in the kernel, then fs-monitor will fail to start. Fix
fs-monitor error codes to detect and skip the test on "Function not
implemented" code.
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
---
src/fs-monitor.c | 9 ++++++---
tests/generic/791 | 10 +++++++++-
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/fs-monitor.c b/src/fs-monitor.c
index 0cf09677a3ef..28436ec2336f 100644
--- a/src/fs-monitor.c
+++ b/src/fs-monitor.c
@@ -117,6 +117,7 @@ next_event:
int main(int argc, char **argv)
{
int fd;
+ int error;
char buffer[BUFSIZ];
@@ -126,15 +127,17 @@ int main(int argc, char **argv)
}
fd = fanotify_init(FAN_CLASS_NOTIF|FAN_REPORT_FID, O_RDONLY);
+ error = errno;
if (fd < 0) {
perror("fanotify_init");
- errx(1, "fanotify_init");
+ errx(error, "fanotify_init");
}
if (fanotify_mark(fd, FAN_MARK_ADD|FAN_MARK_FILESYSTEM,
FAN_FS_ERROR, AT_FDCWD, argv[1])) {
+ error = errno;
perror("fanotify_mark");
- errx(1, "fanotify_mark");
+ errx(errno, "fanotify_mark");
}
printf("fanotify active\n");
@@ -144,7 +147,7 @@ int main(int argc, char **argv)
int n = read(fd, buffer, BUFSIZ);
if (n < 0)
- errx(1, "read");
+ errx(errno, "read");
handle_notifications(buffer, n);
}
diff --git a/tests/generic/791 b/tests/generic/791
index 90242292cba2..1d3a6c181011 100755
--- a/tests/generic/791
+++ b/tests/generic/791
@@ -123,10 +123,18 @@ fi
_dmerror_unmount
_dmerror_mount
-$here/src/fs-monitor $SCRATCH_MNT > $tmp.fsmonitor &
+$here/src/fs-monitor $SCRATCH_MNT > $tmp.fsmonitor 2>&1 &
fsmonitor_pid=$!
sleep 1
+if ! kill -0 $fsmonitor_pid 2>/dev/null; then
+ wait $fsmonitor_pid
+ # Function not implemented
+ if [ $? -eq 38 ]; then
+ _notrun "Kernel doesn't support fanotify"
+ fi
+fi
+
_dmerror_mark_range_bad $bad_sector $bad_len
cat >> $seqres.full << ENDL
--
2.51.2
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] generic/791: don't run if kernel misses FANOTIFY
2026-05-20 13:37 [PATCH] generic/791: don't run if kernel misses FANOTIFY Andrey Albershteyn
@ 2026-05-20 14:55 ` Darrick J. Wong
0 siblings, 0 replies; 2+ messages in thread
From: Darrick J. Wong @ 2026-05-20 14:55 UTC (permalink / raw)
To: Andrey Albershteyn; +Cc: fstests
On Wed, May 20, 2026 at 03:37:15PM +0200, Andrey Albershteyn wrote:
> If FANOTIFY=no in the kernel, then fs-monitor will fail to start. Fix
> fs-monitor error codes to detect and skip the test on "Function not
> implemented" code.
>
> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
> ---
> src/fs-monitor.c | 9 ++++++---
> tests/generic/791 | 10 +++++++++-
> 2 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/src/fs-monitor.c b/src/fs-monitor.c
> index 0cf09677a3ef..28436ec2336f 100644
> --- a/src/fs-monitor.c
> +++ b/src/fs-monitor.c
> @@ -117,6 +117,7 @@ next_event:
> int main(int argc, char **argv)
> {
> int fd;
> + int error;
>
> char buffer[BUFSIZ];
>
> @@ -126,15 +127,17 @@ int main(int argc, char **argv)
> }
>
> fd = fanotify_init(FAN_CLASS_NOTIF|FAN_REPORT_FID, O_RDONLY);
> + error = errno;
> if (fd < 0) {
> perror("fanotify_init");
> - errx(1, "fanotify_init");
> + errx(error, "fanotify_init");
> }
>
> if (fanotify_mark(fd, FAN_MARK_ADD|FAN_MARK_FILESYSTEM,
> FAN_FS_ERROR, AT_FDCWD, argv[1])) {
> + error = errno;
> perror("fanotify_mark");
> - errx(1, "fanotify_mark");
> + errx(errno, "fanotify_mark");
> }
>
> printf("fanotify active\n");
> @@ -144,7 +147,7 @@ int main(int argc, char **argv)
> int n = read(fd, buffer, BUFSIZ);
>
> if (n < 0)
> - errx(1, "read");
> + errx(errno, "read");
>
> handle_notifications(buffer, n);
> }
> diff --git a/tests/generic/791 b/tests/generic/791
> index 90242292cba2..1d3a6c181011 100755
> --- a/tests/generic/791
> +++ b/tests/generic/791
> @@ -123,10 +123,18 @@ fi
> _dmerror_unmount
> _dmerror_mount
>
> -$here/src/fs-monitor $SCRATCH_MNT > $tmp.fsmonitor &
> +$here/src/fs-monitor $SCRATCH_MNT > $tmp.fsmonitor 2>&1 &
> fsmonitor_pid=$!
> sleep 1
>
> +if ! kill -0 $fsmonitor_pid 2>/dev/null; then
> + wait $fsmonitor_pid
> + # Function not implemented
> + if [ $? -eq 38 ]; then
error numbers aren't the same across architectures, so you generally
have to strerror/perror and grep for that in the output.
Alternately we could add a getopt loop to main() so that you could pass
in a --check that would do the setup and exit(0) just before the while
loop; and then you could add:
$here/src/fs-monitor $SCRATCH_MNT --check &> /dev/null || \
_notrun "fanotify too old"
--D
> + _notrun "Kernel doesn't support fanotify"
> + fi
> +fi
> +
> _dmerror_mark_range_bad $bad_sector $bad_len
>
> cat >> $seqres.full << ENDL
> --
> 2.51.2
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-20 14:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-20 13:37 [PATCH] generic/791: don't run if kernel misses FANOTIFY Andrey Albershteyn
2026-05-20 14:55 ` Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox