* [LTP] [PATCH 0/2] Fix inotify{07,08} TBROK where it should TFAIL
@ 2026-05-26 8:34 Cyril Hrubis
2026-05-26 8:34 ` [LTP] [PATCH v2 1/2] safe_macros: Add SAFE_READ_ANY_EAGAIN Cyril Hrubis
2026-05-26 8:34 ` [LTP] [PATCH v2 2/2] syscalls/inotify{07, 08}: Fix TBROK on older kernels Cyril Hrubis
0 siblings, 2 replies; 12+ messages in thread
From: Cyril Hrubis @ 2026-05-26 8:34 UTC (permalink / raw)
To: ltp
Fixes regression cause by deda021818a4 ('inotify: modernize with SAFE_ wrappers')
v2: Fix all the typos
Cyril Hrubis (2):
safe_macros: Add SAFE_READ_ANY_EAGAIN
syscalls/inotify{07,08}: Fix TBROK on older kernels
include/safe_macros_fn.h | 16 ++++++++++++++--
lib/safe_macros.c | 10 +++++++---
testcases/kernel/syscalls/inotify/inotify07.c | 2 +-
testcases/kernel/syscalls/inotify/inotify08.c | 2 +-
4 files changed, 23 insertions(+), 7 deletions(-)
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread
* [LTP] [PATCH v2 1/2] safe_macros: Add SAFE_READ_ANY_EAGAIN
2026-05-26 8:34 [LTP] [PATCH 0/2] Fix inotify{07,08} TBROK where it should TFAIL Cyril Hrubis
@ 2026-05-26 8:34 ` Cyril Hrubis
2026-05-26 11:56 ` Avinesh Kumar via ltp
2026-05-26 13:39 ` Petr Vorel
2026-05-26 8:34 ` [LTP] [PATCH v2 2/2] syscalls/inotify{07, 08}: Fix TBROK on older kernels Cyril Hrubis
1 sibling, 2 replies; 12+ messages in thread
From: Cyril Hrubis @ 2026-05-26 8:34 UTC (permalink / raw)
To: ltp
Similarly to the safe_write() this turns the len_strict into three way
switch with the new value SAFE_READ_ANY_EAGAIN=2 that turns EAGAIN into
a read with a zero length.
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
include/safe_macros_fn.h | 16 ++++++++++++++--
lib/safe_macros.c | 10 +++++++---
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/include/safe_macros_fn.h b/include/safe_macros_fn.h
index 9a09c4922..e8dc02539 100644
--- a/include/safe_macros_fn.h
+++ b/include/safe_macros_fn.h
@@ -36,6 +36,18 @@ enum safe_write_opts {
SAFE_WRITE_RETRY = 2,
};
+/* supported values for safe_read() len_strict parameter */
+enum safe_read_opts {
+ /* no length strictness, short reads are ok */
+ SAFE_READ_ANY = 0,
+
+ /* strict length, short reads trigger TBROK */
+ SAFE_READ_ALL = 1,
+
+ /* converts EAGAIN to read that returns 0 */
+ SAFE_READ_ANY_EAGAIN = 2,
+};
+
char* safe_basename(const char *file, const int lineno,
void (*cleanup_fn)(void), char *path);
@@ -80,8 +92,8 @@ int safe_pipe(const char *file, const int lineno,
void (*cleanup_fn)(void), int fildes[2]);
ssize_t safe_read(const char *file, const int lineno,
- void (*cleanup_fn)(void), char len_strict, int fildes,
- void *buf, size_t nbyte);
+ void (*cleanup_fn)(void), enum safe_read_opts len_strict,
+ int fildes, void *buf, size_t nbyte);
int safe_setegid(const char *file, const int lineno,
void (*cleanup_fn)(void), gid_t egid);
diff --git a/lib/safe_macros.c b/lib/safe_macros.c
index 68b8747b4..f95c5fdc5 100644
--- a/lib/safe_macros.c
+++ b/lib/safe_macros.c
@@ -286,14 +286,18 @@ int safe_pipe(const char *file, const int lineno, void (*cleanup_fn) (void),
return rval;
}
-ssize_t safe_read(const char *file, const int lineno, void (*cleanup_fn) (void),
- char len_strict, int fildes, void *buf, size_t nbyte)
+ssize_t safe_read(const char *file, const int lineno,
+ void (*cleanup_fn) (void), enum safe_read_opts len_strict,
+ int fildes, void *buf, size_t nbyte)
{
ssize_t rval;
rval = read(fildes, buf, nbyte);
if (rval == -1) {
+ if (len_strict == SAFE_READ_ANY_EAGAIN && errno == EAGAIN)
+ return 0;
+
tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
"read(%d,%p,%zu) failed, returned %zd", fildes, buf,
nbyte, rval);
@@ -301,7 +305,7 @@ ssize_t safe_read(const char *file, const int lineno, void (*cleanup_fn) (void),
tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
"Invalid read(%d,%p,%zu) return value %zd", fildes,
buf, nbyte, rval);
- } else if (len_strict && (size_t)rval != nbyte) {
+ } else if (len_strict == SAFE_READ_ALL && (size_t)rval != nbyte) {
tst_brkm_(file, lineno, TBROK, cleanup_fn,
"Short read(%d,%p,%zu) returned only %zd",
fildes, buf, nbyte, rval);
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [LTP] [PATCH v2 2/2] syscalls/inotify{07, 08}: Fix TBROK on older kernels
2026-05-26 8:34 [LTP] [PATCH 0/2] Fix inotify{07,08} TBROK where it should TFAIL Cyril Hrubis
2026-05-26 8:34 ` [LTP] [PATCH v2 1/2] safe_macros: Add SAFE_READ_ANY_EAGAIN Cyril Hrubis
@ 2026-05-26 8:34 ` Cyril Hrubis
2026-05-26 8:44 ` Martin Doucha
2026-05-26 13:45 ` Petr Vorel
1 sibling, 2 replies; 12+ messages in thread
From: Cyril Hrubis @ 2026-05-26 8:34 UTC (permalink / raw)
To: ltp
When kernel fails to generate events the read returns EAGAIN and since
we switched to SAFE_READ() the tests now TBROK when kernel does not
generate events. Fix this by passing the newly introduced
SAFE_READ_ANY_EAGAIN flag to the SAFE_READ().
Fixes: deda021818a4 ('inotify: modernize with SAFE_ wrappers')
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
testcases/kernel/syscalls/inotify/inotify07.c | 2 +-
testcases/kernel/syscalls/inotify/inotify08.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/inotify/inotify07.c b/testcases/kernel/syscalls/inotify/inotify07.c
index b4000f353..9cadbf656 100644
--- a/testcases/kernel/syscalls/inotify/inotify07.c
+++ b/testcases/kernel/syscalls/inotify/inotify07.c
@@ -88,7 +88,7 @@ void verify_inotify(void)
strcpy(event_set[test_cnt].name, FILE_NAME);
test_cnt++;
- int len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
+ int len = SAFE_READ(SAFE_READ_ANY_EAGAIN, fd_notify, event_buf, EVENT_BUF_LEN);
int i = 0, test_num = 0;
while (i < len) {
diff --git a/testcases/kernel/syscalls/inotify/inotify08.c b/testcases/kernel/syscalls/inotify/inotify08.c
index e0837cac3..23d3c5a65 100644
--- a/testcases/kernel/syscalls/inotify/inotify08.c
+++ b/testcases/kernel/syscalls/inotify/inotify08.c
@@ -86,7 +86,7 @@ void verify_inotify(void)
SAFE_TOUCH(OVL_LOWER"/"FILE_NAME, 0644, NULL);
SAFE_TOUCH(OVL_UPPER"/"FILE_NAME, 0644, NULL);
- int len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
+ int len = SAFE_READ(SAFE_READ_ANY_EAGAIN, fd_notify, event_buf, EVENT_BUF_LEN);
int i = 0, test_num = 0;
while (i < len) {
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH v2 2/2] syscalls/inotify{07, 08}: Fix TBROK on older kernels
2026-05-26 8:34 ` [LTP] [PATCH v2 2/2] syscalls/inotify{07, 08}: Fix TBROK on older kernels Cyril Hrubis
@ 2026-05-26 8:44 ` Martin Doucha
2026-05-26 13:45 ` Petr Vorel
1 sibling, 0 replies; 12+ messages in thread
From: Martin Doucha @ 2026-05-26 8:44 UTC (permalink / raw)
To: Cyril Hrubis, ltp
Hi,
for both patches:
Reviewed-by: Martin Doucha <mdoucha@suse.cz>
On 5/26/26 10:34, Cyril Hrubis wrote:
> When kernel fails to generate events the read returns EAGAIN and since
> we switched to SAFE_READ() the tests now TBROK when kernel does not
> generate events. Fix this by passing the newly introduced
> SAFE_READ_ANY_EAGAIN flag to the SAFE_READ().
>
> Fixes: deda021818a4 ('inotify: modernize with SAFE_ wrappers')
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---
> testcases/kernel/syscalls/inotify/inotify07.c | 2 +-
> testcases/kernel/syscalls/inotify/inotify08.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/inotify/inotify07.c b/testcases/kernel/syscalls/inotify/inotify07.c
> index b4000f353..9cadbf656 100644
> --- a/testcases/kernel/syscalls/inotify/inotify07.c
> +++ b/testcases/kernel/syscalls/inotify/inotify07.c
> @@ -88,7 +88,7 @@ void verify_inotify(void)
> strcpy(event_set[test_cnt].name, FILE_NAME);
> test_cnt++;
>
> - int len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
> + int len = SAFE_READ(SAFE_READ_ANY_EAGAIN, fd_notify, event_buf, EVENT_BUF_LEN);
>
> int i = 0, test_num = 0;
> while (i < len) {
> diff --git a/testcases/kernel/syscalls/inotify/inotify08.c b/testcases/kernel/syscalls/inotify/inotify08.c
> index e0837cac3..23d3c5a65 100644
> --- a/testcases/kernel/syscalls/inotify/inotify08.c
> +++ b/testcases/kernel/syscalls/inotify/inotify08.c
> @@ -86,7 +86,7 @@ void verify_inotify(void)
> SAFE_TOUCH(OVL_LOWER"/"FILE_NAME, 0644, NULL);
> SAFE_TOUCH(OVL_UPPER"/"FILE_NAME, 0644, NULL);
>
> - int len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
> + int len = SAFE_READ(SAFE_READ_ANY_EAGAIN, fd_notify, event_buf, EVENT_BUF_LEN);
>
> int i = 0, test_num = 0;
> while (i < len) {
--
Martin Doucha mdoucha@suse.cz
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH v2 1/2] safe_macros: Add SAFE_READ_ANY_EAGAIN
2026-05-26 8:34 ` [LTP] [PATCH v2 1/2] safe_macros: Add SAFE_READ_ANY_EAGAIN Cyril Hrubis
@ 2026-05-26 11:56 ` Avinesh Kumar via ltp
2026-05-26 13:39 ` Petr Vorel
1 sibling, 0 replies; 12+ messages in thread
From: Avinesh Kumar via ltp @ 2026-05-26 11:56 UTC (permalink / raw)
To: Cyril Hrubis, ltp
Hi,
Reviewed-by: Avinesh Kumar <avinesh.kumar@suse.com>
for both patches.
Thanks,
Avinesh
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH v2 1/2] safe_macros: Add SAFE_READ_ANY_EAGAIN
2026-05-26 8:34 ` [LTP] [PATCH v2 1/2] safe_macros: Add SAFE_READ_ANY_EAGAIN Cyril Hrubis
2026-05-26 11:56 ` Avinesh Kumar via ltp
@ 2026-05-26 13:39 ` Petr Vorel
2026-05-26 14:02 ` Cyril Hrubis
1 sibling, 1 reply; 12+ messages in thread
From: Petr Vorel @ 2026-05-26 13:39 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
Hi Cyril,
...
> +/* supported values for safe_read() len_strict parameter */
Could we have kerneldoc (ok to fix before merge).
/**
* enum safe_read_opts - supported values for safe_read() len_strict parameter */
*
* @SAFE_READ_ANY: no length strictness, short reads are ok.
* @SAFE_READ_ALL: strict length, short reads trigger :c:enum:`TBROK <tst_res_flags>`.
* @SAFE_READ_ANY_EAGAIN: converts EAGAIN to read that returns 0.
*/
Otherwise LGTM, thanks for spotting the error.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
> +enum safe_read_opts {
> + /* no length strictness, short reads are ok */
> + SAFE_READ_ANY = 0,
> +
> + /* strict length, short reads trigger TBROK */
> + SAFE_READ_ALL = 1,
> +
> + /* converts EAGAIN to read that returns 0 */
> + SAFE_READ_ANY_EAGAIN = 2,
> +};
...
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH v2 2/2] syscalls/inotify{07, 08}: Fix TBROK on older kernels
2026-05-26 8:34 ` [LTP] [PATCH v2 2/2] syscalls/inotify{07, 08}: Fix TBROK on older kernels Cyril Hrubis
2026-05-26 8:44 ` Martin Doucha
@ 2026-05-26 13:45 ` Petr Vorel
2026-05-26 13:59 ` Cyril Hrubis
1 sibling, 1 reply; 12+ messages in thread
From: Petr Vorel @ 2026-05-26 13:45 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
Hi Cyril,
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Thanks for fixing it!
> - int len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
> + int len = SAFE_READ(SAFE_READ_ANY_EAGAIN, fd_notify, event_buf, EVENT_BUF_LEN);
Maybe later after the release we could think about about shorten this with
definitions. I'm ok if you consider this as not useful.
Kind regards,
Petr
+++ include/tst_safe_macros.h
@@ -117,6 +117,15 @@ int safe_pipe2(const char *file, const int lineno, int fildes[2], int flags);
#define SAFE_READ(len_strict, fildes, buf, nbyte) \
safe_read(__FILE__, __LINE__, NULL, (len_strict), (fildes), (buf), (nbyte))
+#define SAFE_READ_ANY(fildes, buf, nbyte) \
+ SAFE_READ(SAFE_READ_ANY, fildes, buf, nbyte)
+
+#define SAFE_READ_ALL(fildes, buf, nbyte) \
+ SAFE_READ(SAFE_READ_ALL, fildes, buf, nbyte)
+
+#define SAFE_READ_ANY_EAGAIN(fildes, buf, nbyte) \
+ SAFE_READ(SAFE_READ_ANY_EAGAIN, fildes, buf, nbyte)
+
#define SAFE_SETEGID(egid) \
safe_setegid(__FILE__, __LINE__, NULL, (egid))
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH v2 2/2] syscalls/inotify{07, 08}: Fix TBROK on older kernels
2026-05-26 13:45 ` Petr Vorel
@ 2026-05-26 13:59 ` Cyril Hrubis
2026-05-26 14:16 ` Petr Vorel
0 siblings, 1 reply; 12+ messages in thread
From: Cyril Hrubis @ 2026-05-26 13:59 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi!
> Maybe later after the release we could think about about shorten this with
> definitions. I'm ok if you consider this as not useful.
I was thinking about this, but I wanted to have minimal fix before the
release. We can rethink the SAFE_WRITE and SAFE_READ API later on.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH v2 1/2] safe_macros: Add SAFE_READ_ANY_EAGAIN
2026-05-26 13:39 ` Petr Vorel
@ 2026-05-26 14:02 ` Cyril Hrubis
2026-05-26 14:15 ` Petr Vorel
0 siblings, 1 reply; 12+ messages in thread
From: Cyril Hrubis @ 2026-05-26 14:02 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi!
> ...
> > +/* supported values for safe_read() len_strict parameter */
> Could we have kerneldoc (ok to fix before merge).
>
> /**
> * enum safe_read_opts - supported values for safe_read() len_strict parameter */
> *
> * @SAFE_READ_ANY: no length strictness, short reads are ok.
> * @SAFE_READ_ALL: strict length, short reads trigger :c:enum:`TBROK <tst_res_flags>`.
> * @SAFE_READ_ANY_EAGAIN: converts EAGAIN to read that returns 0.
> */
>
> Otherwise LGTM, thanks for spotting the error.
I would avoid that for now, since we are likely going to change the API
after the release. Is that okay?
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH v2 1/2] safe_macros: Add SAFE_READ_ANY_EAGAIN
2026-05-26 14:02 ` Cyril Hrubis
@ 2026-05-26 14:15 ` Petr Vorel
0 siblings, 0 replies; 12+ messages in thread
From: Petr Vorel @ 2026-05-26 14:15 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
> Hi!
> > ...
> > > +/* supported values for safe_read() len_strict parameter */
> > Could we have kerneldoc (ok to fix before merge).
> > /**
> > * enum safe_read_opts - supported values for safe_read() len_strict parameter */
> > *
> > * @SAFE_READ_ANY: no length strictness, short reads are ok.
> > * @SAFE_READ_ALL: strict length, short reads trigger :c:enum:`TBROK <tst_res_flags>`.
> > * @SAFE_READ_ANY_EAGAIN: converts EAGAIN to read that returns 0.
> > */
> > Otherwise LGTM, thanks for spotting the error.
> I would avoid that for now, since we are likely going to change the API
> after the release. Is that okay?
Sure, I'm sorry I overlooked expected API change.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH v2 2/2] syscalls/inotify{07, 08}: Fix TBROK on older kernels
2026-05-26 13:59 ` Cyril Hrubis
@ 2026-05-26 14:16 ` Petr Vorel
2026-05-26 15:03 ` Cyril Hrubis
0 siblings, 1 reply; 12+ messages in thread
From: Petr Vorel @ 2026-05-26 14:16 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
> Hi!
> > Maybe later after the release we could think about about shorten this with
> > definitions. I'm ok if you consider this as not useful.
> I was thinking about this, but I wanted to have minimal fix before the
> release. We can rethink the SAFE_WRITE and SAFE_READ API later on.
Good. Sure I agree with minimal changes as these are pre-release fixes.
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [LTP] [PATCH v2 2/2] syscalls/inotify{07, 08}: Fix TBROK on older kernels
2026-05-26 14:16 ` Petr Vorel
@ 2026-05-26 15:03 ` Cyril Hrubis
0 siblings, 0 replies; 12+ messages in thread
From: Cyril Hrubis @ 2026-05-26 15:03 UTC (permalink / raw)
To: Petr Vorel; +Cc: ltp
Hi!
> Good. Sure I agree with minimal changes as these are pre-release fixes.
Pushed.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-05-26 15:04 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-26 8:34 [LTP] [PATCH 0/2] Fix inotify{07,08} TBROK where it should TFAIL Cyril Hrubis
2026-05-26 8:34 ` [LTP] [PATCH v2 1/2] safe_macros: Add SAFE_READ_ANY_EAGAIN Cyril Hrubis
2026-05-26 11:56 ` Avinesh Kumar via ltp
2026-05-26 13:39 ` Petr Vorel
2026-05-26 14:02 ` Cyril Hrubis
2026-05-26 14:15 ` Petr Vorel
2026-05-26 8:34 ` [LTP] [PATCH v2 2/2] syscalls/inotify{07, 08}: Fix TBROK on older kernels Cyril Hrubis
2026-05-26 8:44 ` Martin Doucha
2026-05-26 13:45 ` Petr Vorel
2026-05-26 13:59 ` Cyril Hrubis
2026-05-26 14:16 ` Petr Vorel
2026-05-26 15:03 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox