* [LTP] [PATCH] inotify: cleanup - limit masks, use SAFE_ wrappers
@ 2026-02-14 17:52 Jinseok Kim
2026-02-16 10:20 ` Petr Vorel
2026-02-19 16:08 ` Cyril Hrubis
0 siblings, 2 replies; 13+ messages in thread
From: Jinseok Kim @ 2026-02-14 17:52 UTC (permalink / raw)
To: ltp
Replace IN_ALL_EVENTS with minimal relevant masks and manual read/write
with SAFE_READ/SAFE_WRITE for better stability and consistency.
inotify12.c intentionally unchanged: raw read() + manual EAGAIN handling
is required to treat missing second event as IN_IGNORED (normal case).
Signed-off-by: Jinseok Kim <always.starving0@gmail.com>
---
testcases/kernel/syscalls/inotify/inotify01.c | 21 ++++++-------------
testcases/kernel/syscalls/inotify/inotify02.c | 5 ++++-
testcases/kernel/syscalls/inotify/inotify03.c | 16 +++-----------
testcases/kernel/syscalls/inotify/inotify04.c | 10 ++++-----
testcases/kernel/syscalls/inotify/inotify05.c | 10 +++------
testcases/kernel/syscalls/inotify/inotify07.c | 10 +++------
testcases/kernel/syscalls/inotify/inotify08.c | 7 +------
testcases/kernel/syscalls/inotify/inotify10.c | 4 +---
8 files changed, 26 insertions(+), 57 deletions(-)
diff --git a/testcases/kernel/syscalls/inotify/inotify01.c b/testcases/kernel/syscalls/inotify/inotify01.c
index 8671b594a..f58784ffd 100644
--- a/testcases/kernel/syscalls/inotify/inotify01.c
+++ b/testcases/kernel/syscalls/inotify/inotify01.c
@@ -55,10 +55,7 @@ void verify_inotify(void)
event_set[test_cnt] = IN_OPEN;
test_cnt++;
- if (read(fd, buf, BUF_SIZE) == -1) {
- tst_brk(TBROK | TERRNO,
- "read(%d, buf, %d) failed", fd, BUF_SIZE);
- }
+ SAFE_READ(0, fd, buf, BUF_SIZE);
event_set[test_cnt] = IN_ACCESS;
test_cnt++;
@@ -70,10 +67,7 @@ void verify_inotify(void)
event_set[test_cnt] = IN_OPEN;
test_cnt++;
- if (write(fd, buf, BUF_SIZE) == -1) {
- tst_brk(TBROK,
- "write(%d, %s, %d) failed", fd, fname, BUF_SIZE);
- }
+ SAFE_WRITE(SAFE_WRITE_ALL, fd, buf, BUF_SIZE);
event_set[test_cnt] = IN_MODIFY;
test_cnt++;
@@ -85,12 +79,7 @@ void verify_inotify(void)
* get list of events
*/
int len, i = 0, test_num = 0;
- if ((len = read(fd_notify, event_buf, EVENT_BUF_LEN)) < 0) {
- tst_brk(TBROK,
- "read(%d, buf, %zu) failed",
- fd_notify, EVENT_BUF_LEN);
-
- }
+ len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
/*
* check events
@@ -143,7 +132,9 @@ static void setup(void)
fd_notify = SAFE_MYINOTIFY_INIT();
- wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, fname, IN_ALL_EVENTS);
+ wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, fname, IN_ATTRIB | IN_OPEN |
+ IN_ACCESS | IN_CLOSE_NOWRITE | IN_MODIFY |
+ IN_CLOSE_WRITE);
reap_wd = 1;
}
diff --git a/testcases/kernel/syscalls/inotify/inotify02.c b/testcases/kernel/syscalls/inotify/inotify02.c
index 314c1bd49..a842abeee 100644
--- a/testcases/kernel/syscalls/inotify/inotify02.c
+++ b/testcases/kernel/syscalls/inotify/inotify02.c
@@ -187,7 +187,10 @@ static void setup(void)
{
fd_notify = SAFE_MYINOTIFY_INIT();
- wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, ".", IN_ALL_EVENTS);
+ wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, ".", IN_ATTRIB | IN_CREATE |
+ IN_OPEN | IN_CLOSE_WRITE |
+ IN_MOVED_FROM | IN_MOVED_TO |
+ IN_MOVE_SELF | IN_DELETE);
reap_wd = 1;
}
diff --git a/testcases/kernel/syscalls/inotify/inotify03.c b/testcases/kernel/syscalls/inotify/inotify03.c
index 9bb95addb..5d141fbb5 100644
--- a/testcases/kernel/syscalls/inotify/inotify03.c
+++ b/testcases/kernel/syscalls/inotify/inotify03.c
@@ -55,7 +55,7 @@ void verify_inotify(void)
SAFE_MOUNT(tst_device->dev, mntpoint, tst_device->fs_type, 0, NULL);
mount_flag = 1;
- wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, fname, IN_ALL_EVENTS);
+ wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, fname, IN_UNMOUNT | IN_IGNORED);
event_set[test_cnt] = IN_UNMOUNT;
test_cnt++;
@@ -74,11 +74,7 @@ void verify_inotify(void)
}
mount_flag = 0;
- len = read(fd_notify, event_buf, EVENT_BUF_LEN);
- if (len < 0) {
- tst_brk(TBROK | TERRNO,
- "read(%d, buf, %zu) failed", fd_notify, EVENT_BUF_LEN);
- }
+ len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
/* check events */
test_num = 0;
@@ -125,8 +121,6 @@ void verify_inotify(void)
static void setup(void)
{
- int ret;
-
SAFE_MKDIR(mntpoint, DIR_MODE);
SAFE_MOUNT(tst_device->dev, mntpoint, tst_device->fs_type, 0, NULL);
@@ -135,11 +129,7 @@ static void setup(void)
sprintf(fname, "%s/tfile_%d", mntpoint, getpid());
fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0700);
- ret = write(fd, fname, 1);
- if (ret == -1) {
- tst_brk(TBROK | TERRNO,
- "write(%d, %s, 1) failed", fd, fname);
- }
+ SAFE_WRITE(SAFE_WRITE_ALL, fd, fname, 1);
/* close the file we have open */
SAFE_CLOSE(fd);
diff --git a/testcases/kernel/syscalls/inotify/inotify04.c b/testcases/kernel/syscalls/inotify/inotify04.c
index 1db38ddf2..1472bcff0 100644
--- a/testcases/kernel/syscalls/inotify/inotify04.c
+++ b/testcases/kernel/syscalls/inotify/inotify04.c
@@ -81,10 +81,12 @@ void verify_inotify(void)
SAFE_MKDIR(TEST_DIR, 00700);
close(SAFE_CREAT(TEST_FILE, 00600));
- wd_dir = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, TEST_DIR, IN_ALL_EVENTS);
+ wd_dir = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, TEST_DIR, IN_DELETE_SELF |
+ IN_ATTRIB | IN_IGNORED);
reap_wd_dir = 1;
- wd_file = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, TEST_FILE, IN_ALL_EVENTS);
+ wd_file = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, TEST_FILE, IN_DELETE_SELF |
+ IN_ATTRIB | IN_IGNORED);
reap_wd_file = 1;
SAFE_RMDIR(TEST_DIR);
@@ -118,9 +120,7 @@ void verify_inotify(void)
strcpy(event_set[test_cnt].name, "");
test_cnt++;
- len = read(fd_notify, event_buf, EVENT_BUF_LEN);
- if (len == -1)
- tst_brk(TBROK | TERRNO, "read failed");
+ len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
while (i < len) {
struct inotify_event *event;
diff --git a/testcases/kernel/syscalls/inotify/inotify05.c b/testcases/kernel/syscalls/inotify/inotify05.c
index d9bfb05f1..d1e35b735 100644
--- a/testcases/kernel/syscalls/inotify/inotify05.c
+++ b/testcases/kernel/syscalls/inotify/inotify05.c
@@ -60,12 +60,7 @@ void verify_inotify(void)
/*
* get list on events
*/
- len = read(fd_notify, event_buf, EVENT_BUF_LEN);
- if (len < 0) {
- tst_brk(TBROK | TERRNO,
- "read(%d, buf, %zu) failed",
- fd_notify, EVENT_BUF_LEN);
- }
+ len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
/*
* check events
@@ -128,7 +123,8 @@ static void setup(void)
fd_notify = SAFE_MYINOTIFY_INIT1(O_NONBLOCK);
- wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, fname, IN_ALL_EVENTS);
+ wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, fname, IN_ACCESS | IN_MODIFY |
+ IN_OPEN | IN_Q_OVERFLOW);
SAFE_FILE_SCANF("/proc/sys/fs/inotify/max_queued_events",
"%d", &max_events);
diff --git a/testcases/kernel/syscalls/inotify/inotify07.c b/testcases/kernel/syscalls/inotify/inotify07.c
index 66a2f4d37..55d03377c 100644
--- a/testcases/kernel/syscalls/inotify/inotify07.c
+++ b/testcases/kernel/syscalls/inotify/inotify07.c
@@ -88,12 +88,7 @@ void verify_inotify(void)
strcpy(event_set[test_cnt].name, FILE_NAME);
test_cnt++;
- int len = read(fd_notify, event_buf, EVENT_BUF_LEN);
- if (len == -1 && errno != EAGAIN) {
- tst_brk(TBROK | TERRNO,
- "read(%d, buf, %zu) failed",
- fd_notify, EVENT_BUF_LEN);
- }
+ int len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
int i = 0, test_num = 0;
while (i < len) {
@@ -151,7 +146,8 @@ static void setup(void)
fd_notify = SAFE_MYINOTIFY_INIT1(O_NONBLOCK);
/* Setup a watch on an overlayfs lower directory */
- wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, DIR_PATH, IN_ALL_EVENTS);
+ wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, DIR_PATH, IN_ATTRIB | IN_OPEN |
+ IN_CLOSE_WRITE);
reap_wd = 1;
SAFE_STAT(DIR_PATH, &buf);
diff --git a/testcases/kernel/syscalls/inotify/inotify08.c b/testcases/kernel/syscalls/inotify/inotify08.c
index 4cbb16ce0..e0837cac3 100644
--- a/testcases/kernel/syscalls/inotify/inotify08.c
+++ b/testcases/kernel/syscalls/inotify/inotify08.c
@@ -86,12 +86,7 @@ void verify_inotify(void)
SAFE_TOUCH(OVL_LOWER"/"FILE_NAME, 0644, NULL);
SAFE_TOUCH(OVL_UPPER"/"FILE_NAME, 0644, NULL);
- int len = read(fd_notify, event_buf, EVENT_BUF_LEN);
- if (len == -1 && errno != EAGAIN) {
- tst_brk(TBROK | TERRNO,
- "read(%d, buf, %zu) failed",
- fd_notify, EVENT_BUF_LEN);
- }
+ int len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
int i = 0, test_num = 0;
while (i < len) {
diff --git a/testcases/kernel/syscalls/inotify/inotify10.c b/testcases/kernel/syscalls/inotify/inotify10.c
index a78572dff..4c3a1d116 100644
--- a/testcases/kernel/syscalls/inotify/inotify10.c
+++ b/testcases/kernel/syscalls/inotify/inotify10.c
@@ -143,9 +143,7 @@ static void verify_inotify(unsigned int n)
test_cnt++;
}
- len = read(fd_notify, event_buf, EVENT_BUF_LEN);
- if (len == -1)
- tst_brk(TBROK | TERRNO, "read failed");
+ len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
while (i < len) {
struct event_t *expected = &event_set[test_num];
--
2.43.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [LTP] [PATCH] inotify: cleanup - limit masks, use SAFE_ wrappers
2026-02-14 17:52 [LTP] [PATCH] inotify: cleanup - limit masks, use SAFE_ wrappers Jinseok Kim
@ 2026-02-16 10:20 ` Petr Vorel
2026-02-16 16:50 ` Jinseok Kim
2026-02-19 16:08 ` Cyril Hrubis
1 sibling, 1 reply; 13+ messages in thread
From: Petr Vorel @ 2026-02-16 10:20 UTC (permalink / raw)
To: Jinseok Kim; +Cc: ltp
Hi Jinseok Kim,
> Replace IN_ALL_EVENTS with minimal relevant masks and manual read/write
> with SAFE_READ/SAFE_WRITE for better stability and consistency.
> inotify12.c intentionally unchanged: raw read() + manual EAGAIN handling
> is required to treat missing second event as IN_IGNORED (normal case).
...
> +++ b/testcases/kernel/syscalls/inotify/inotify07.c
> @@ -88,12 +88,7 @@ void verify_inotify(void)
> strcpy(event_set[test_cnt].name, FILE_NAME);
> test_cnt++;
> - int len = read(fd_notify, event_buf, EVENT_BUF_LEN);
> - if (len == -1 && errno != EAGAIN) {
> - tst_brk(TBROK | TERRNO,
> - "read(%d, buf, %zu) failed",
> - fd_notify, EVENT_BUF_LEN);
> - }
> + int len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
I suppose this should be also kept unchanged (similar to inotify12.c).
Or any reason why to skip?
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread
* [LTP] [PATCH] inotify: cleanup - limit masks, use SAFE_ wrappers
2026-02-16 10:20 ` Petr Vorel
@ 2026-02-16 16:50 ` Jinseok Kim
2026-02-17 13:29 ` Andrea Cervesato via ltp
0 siblings, 1 reply; 13+ messages in thread
From: Jinseok Kim @ 2026-02-16 16:50 UTC (permalink / raw)
To: pvorel, ltp
Hi Vorel,
Thanks for the review!
- inotify12.c needs read() because EAGAIN (“no second event”) is a
valid case that must be explicitly detected and treated as IN_IGNORED.
- inotify07.c does not require this distinction: SAFE_READ() is enough,
since EAGAIN just means end-of-events, while real errors are handled as
TBROK, matching the original test intent.
Best regards,
Jinseok.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [LTP] [PATCH] inotify: cleanup - limit masks, use SAFE_ wrappers
2026-02-16 16:50 ` Jinseok Kim
@ 2026-02-17 13:29 ` Andrea Cervesato via ltp
0 siblings, 0 replies; 13+ messages in thread
From: Andrea Cervesato via ltp @ 2026-02-17 13:29 UTC (permalink / raw)
To: Jinseok Kim, pvorel, ltp
On Mon Feb 16, 2026 at 5:50 PM CET, Jinseok Kim wrote:
> Hi Vorel,
>
> Thanks for the review!
>
> - inotify12.c needs read() because EAGAIN (“no second event”) is a
> valid case that must be explicitly detected and treated as IN_IGNORED.
>
> - inotify07.c does not require this distinction: SAFE_READ() is enough,
> since EAGAIN just means end-of-events, while real errors are handled as
> TBROK, matching the original test intent.
>
> Best regards,
> Jinseok.
LGTM
Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [LTP] [PATCH] inotify: cleanup - limit masks, use SAFE_ wrappers
2026-02-14 17:52 [LTP] [PATCH] inotify: cleanup - limit masks, use SAFE_ wrappers Jinseok Kim
2026-02-16 10:20 ` Petr Vorel
@ 2026-02-19 16:08 ` Cyril Hrubis
2026-02-19 18:04 ` [LTP] [PATCH v2] " Jinseok Kim
1 sibling, 1 reply; 13+ messages in thread
From: Cyril Hrubis @ 2026-02-19 16:08 UTC (permalink / raw)
To: Jinseok Kim; +Cc: ltp
Hi!
> - wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, fname, IN_ALL_EVENTS);
> + wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, fname, IN_ATTRIB | IN_OPEN |
> + IN_ACCESS | IN_CLOSE_NOWRITE | IN_MODIFY |
> + IN_CLOSE_WRITE);
I had a short discussion about this with Jan Kara and we agreed to keep
the IN_ALL_EVENTS here. The rationale is that if kernel starts sending
unexpected events we want the test to fail instead of filtering them
out.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread
* [LTP] [PATCH v2] inotify: cleanup - limit masks, use SAFE_ wrappers
2026-02-19 16:08 ` Cyril Hrubis
@ 2026-02-19 18:04 ` Jinseok Kim
2026-02-20 10:43 ` Cyril Hrubis
0 siblings, 1 reply; 13+ messages in thread
From: Jinseok Kim @ 2026-02-19 18:04 UTC (permalink / raw)
To: chrubis, ltp
Replace IN_ALL_EVENTS with minimal relevant masks and manual read/write
with SAFE_READ/SAFE_WRITE for better stability and consistency.
inotify12.c intentionally unchanged: raw read() + manual EAGAIN handling
is required to treat missing second event as IN_IGNORED (normal case).
Signed-off-by: Jinseok Kim <always.starving0@gmail.com>
---
testcases/kernel/syscalls/inotify/inotify01.c | 17 +++--------------
testcases/kernel/syscalls/inotify/inotify02.c | 5 ++++-
testcases/kernel/syscalls/inotify/inotify03.c | 16 +++-------------
testcases/kernel/syscalls/inotify/inotify04.c | 10 +++++-----
testcases/kernel/syscalls/inotify/inotify05.c | 10 +++-------
testcases/kernel/syscalls/inotify/inotify07.c | 10 +++-------
testcases/kernel/syscalls/inotify/inotify08.c | 7 +------
testcases/kernel/syscalls/inotify/inotify10.c | 4 +---
8 files changed, 23 insertions(+), 56 deletions(-)
diff --git a/testcases/kernel/syscalls/inotify/inotify01.c b/testcases/kernel/syscalls/inotify/inotify01.c
index 8671b594a..972b1025e 100644
--- a/testcases/kernel/syscalls/inotify/inotify01.c
+++ b/testcases/kernel/syscalls/inotify/inotify01.c
@@ -55,10 +55,7 @@ void verify_inotify(void)
event_set[test_cnt] = IN_OPEN;
test_cnt++;
- if (read(fd, buf, BUF_SIZE) == -1) {
- tst_brk(TBROK | TERRNO,
- "read(%d, buf, %d) failed", fd, BUF_SIZE);
- }
+ SAFE_READ(0, fd, buf, BUF_SIZE);
event_set[test_cnt] = IN_ACCESS;
test_cnt++;
@@ -70,10 +67,7 @@ void verify_inotify(void)
event_set[test_cnt] = IN_OPEN;
test_cnt++;
- if (write(fd, buf, BUF_SIZE) == -1) {
- tst_brk(TBROK,
- "write(%d, %s, %d) failed", fd, fname, BUF_SIZE);
- }
+ SAFE_WRITE(SAFE_WRITE_ALL, fd, buf, BUF_SIZE);
event_set[test_cnt] = IN_MODIFY;
test_cnt++;
@@ -85,12 +79,7 @@ void verify_inotify(void)
* get list of events
*/
int len, i = 0, test_num = 0;
- if ((len = read(fd_notify, event_buf, EVENT_BUF_LEN)) < 0) {
- tst_brk(TBROK,
- "read(%d, buf, %zu) failed",
- fd_notify, EVENT_BUF_LEN);
-
- }
+ len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
/*
* check events
diff --git a/testcases/kernel/syscalls/inotify/inotify02.c b/testcases/kernel/syscalls/inotify/inotify02.c
index 314c1bd49..a842abeee 100644
--- a/testcases/kernel/syscalls/inotify/inotify02.c
+++ b/testcases/kernel/syscalls/inotify/inotify02.c
@@ -187,7 +187,10 @@ static void setup(void)
{
fd_notify = SAFE_MYINOTIFY_INIT();
- wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, ".", IN_ALL_EVENTS);
+ wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, ".", IN_ATTRIB | IN_CREATE |
+ IN_OPEN | IN_CLOSE_WRITE |
+ IN_MOVED_FROM | IN_MOVED_TO |
+ IN_MOVE_SELF | IN_DELETE);
reap_wd = 1;
}
diff --git a/testcases/kernel/syscalls/inotify/inotify03.c b/testcases/kernel/syscalls/inotify/inotify03.c
index 9bb95addb..5d141fbb5 100644
--- a/testcases/kernel/syscalls/inotify/inotify03.c
+++ b/testcases/kernel/syscalls/inotify/inotify03.c
@@ -55,7 +55,7 @@ void verify_inotify(void)
SAFE_MOUNT(tst_device->dev, mntpoint, tst_device->fs_type, 0, NULL);
mount_flag = 1;
- wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, fname, IN_ALL_EVENTS);
+ wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, fname, IN_UNMOUNT | IN_IGNORED);
event_set[test_cnt] = IN_UNMOUNT;
test_cnt++;
@@ -74,11 +74,7 @@ void verify_inotify(void)
}
mount_flag = 0;
- len = read(fd_notify, event_buf, EVENT_BUF_LEN);
- if (len < 0) {
- tst_brk(TBROK | TERRNO,
- "read(%d, buf, %zu) failed", fd_notify, EVENT_BUF_LEN);
- }
+ len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
/* check events */
test_num = 0;
@@ -125,8 +121,6 @@ void verify_inotify(void)
static void setup(void)
{
- int ret;
-
SAFE_MKDIR(mntpoint, DIR_MODE);
SAFE_MOUNT(tst_device->dev, mntpoint, tst_device->fs_type, 0, NULL);
@@ -135,11 +129,7 @@ static void setup(void)
sprintf(fname, "%s/tfile_%d", mntpoint, getpid());
fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0700);
- ret = write(fd, fname, 1);
- if (ret == -1) {
- tst_brk(TBROK | TERRNO,
- "write(%d, %s, 1) failed", fd, fname);
- }
+ SAFE_WRITE(SAFE_WRITE_ALL, fd, fname, 1);
/* close the file we have open */
SAFE_CLOSE(fd);
diff --git a/testcases/kernel/syscalls/inotify/inotify04.c b/testcases/kernel/syscalls/inotify/inotify04.c
index 1db38ddf2..1472bcff0 100644
--- a/testcases/kernel/syscalls/inotify/inotify04.c
+++ b/testcases/kernel/syscalls/inotify/inotify04.c
@@ -81,10 +81,12 @@ void verify_inotify(void)
SAFE_MKDIR(TEST_DIR, 00700);
close(SAFE_CREAT(TEST_FILE, 00600));
- wd_dir = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, TEST_DIR, IN_ALL_EVENTS);
+ wd_dir = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, TEST_DIR, IN_DELETE_SELF |
+ IN_ATTRIB | IN_IGNORED);
reap_wd_dir = 1;
- wd_file = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, TEST_FILE, IN_ALL_EVENTS);
+ wd_file = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, TEST_FILE, IN_DELETE_SELF |
+ IN_ATTRIB | IN_IGNORED);
reap_wd_file = 1;
SAFE_RMDIR(TEST_DIR);
@@ -118,9 +120,7 @@ void verify_inotify(void)
strcpy(event_set[test_cnt].name, "");
test_cnt++;
- len = read(fd_notify, event_buf, EVENT_BUF_LEN);
- if (len == -1)
- tst_brk(TBROK | TERRNO, "read failed");
+ len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
while (i < len) {
struct inotify_event *event;
diff --git a/testcases/kernel/syscalls/inotify/inotify05.c b/testcases/kernel/syscalls/inotify/inotify05.c
index d9bfb05f1..d1e35b735 100644
--- a/testcases/kernel/syscalls/inotify/inotify05.c
+++ b/testcases/kernel/syscalls/inotify/inotify05.c
@@ -60,12 +60,7 @@ void verify_inotify(void)
/*
* get list on events
*/
- len = read(fd_notify, event_buf, EVENT_BUF_LEN);
- if (len < 0) {
- tst_brk(TBROK | TERRNO,
- "read(%d, buf, %zu) failed",
- fd_notify, EVENT_BUF_LEN);
- }
+ len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
/*
* check events
@@ -128,7 +123,8 @@ static void setup(void)
fd_notify = SAFE_MYINOTIFY_INIT1(O_NONBLOCK);
- wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, fname, IN_ALL_EVENTS);
+ wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, fname, IN_ACCESS | IN_MODIFY |
+ IN_OPEN | IN_Q_OVERFLOW);
SAFE_FILE_SCANF("/proc/sys/fs/inotify/max_queued_events",
"%d", &max_events);
diff --git a/testcases/kernel/syscalls/inotify/inotify07.c b/testcases/kernel/syscalls/inotify/inotify07.c
index 66a2f4d37..55d03377c 100644
--- a/testcases/kernel/syscalls/inotify/inotify07.c
+++ b/testcases/kernel/syscalls/inotify/inotify07.c
@@ -88,12 +88,7 @@ void verify_inotify(void)
strcpy(event_set[test_cnt].name, FILE_NAME);
test_cnt++;
- int len = read(fd_notify, event_buf, EVENT_BUF_LEN);
- if (len == -1 && errno != EAGAIN) {
- tst_brk(TBROK | TERRNO,
- "read(%d, buf, %zu) failed",
- fd_notify, EVENT_BUF_LEN);
- }
+ int len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
int i = 0, test_num = 0;
while (i < len) {
@@ -151,7 +146,8 @@ static void setup(void)
fd_notify = SAFE_MYINOTIFY_INIT1(O_NONBLOCK);
/* Setup a watch on an overlayfs lower directory */
- wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, DIR_PATH, IN_ALL_EVENTS);
+ wd = SAFE_MYINOTIFY_ADD_WATCH(fd_notify, DIR_PATH, IN_ATTRIB | IN_OPEN |
+ IN_CLOSE_WRITE);
reap_wd = 1;
SAFE_STAT(DIR_PATH, &buf);
diff --git a/testcases/kernel/syscalls/inotify/inotify08.c b/testcases/kernel/syscalls/inotify/inotify08.c
index 4cbb16ce0..e0837cac3 100644
--- a/testcases/kernel/syscalls/inotify/inotify08.c
+++ b/testcases/kernel/syscalls/inotify/inotify08.c
@@ -86,12 +86,7 @@ void verify_inotify(void)
SAFE_TOUCH(OVL_LOWER"/"FILE_NAME, 0644, NULL);
SAFE_TOUCH(OVL_UPPER"/"FILE_NAME, 0644, NULL);
- int len = read(fd_notify, event_buf, EVENT_BUF_LEN);
- if (len == -1 && errno != EAGAIN) {
- tst_brk(TBROK | TERRNO,
- "read(%d, buf, %zu) failed",
- fd_notify, EVENT_BUF_LEN);
- }
+ int len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
int i = 0, test_num = 0;
while (i < len) {
diff --git a/testcases/kernel/syscalls/inotify/inotify10.c b/testcases/kernel/syscalls/inotify/inotify10.c
index a78572dff..4c3a1d116 100644
--- a/testcases/kernel/syscalls/inotify/inotify10.c
+++ b/testcases/kernel/syscalls/inotify/inotify10.c
@@ -143,9 +143,7 @@ static void verify_inotify(unsigned int n)
test_cnt++;
}
- len = read(fd_notify, event_buf, EVENT_BUF_LEN);
- if (len == -1)
- tst_brk(TBROK | TERRNO, "read failed");
+ len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
while (i < len) {
struct event_t *expected = &event_set[test_num];
--
2.43.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [LTP] [PATCH v2] inotify: cleanup - limit masks, use SAFE_ wrappers
2026-02-19 18:04 ` [LTP] [PATCH v2] " Jinseok Kim
@ 2026-02-20 10:43 ` Cyril Hrubis
2026-02-20 14:08 ` Jinseok Kim
0 siblings, 1 reply; 13+ messages in thread
From: Cyril Hrubis @ 2026-02-20 10:43 UTC (permalink / raw)
To: Jinseok Kim; +Cc: ltp
Hi!
> Replace IN_ALL_EVENTS with minimal relevant masks
Please do not replace the IN_ALL_EVENTS since we decided we want to keep
IN_ALL_EVENTS in the tests.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread
* [LTP] [PATCH v2] inotify: cleanup - limit masks, use SAFE_ wrappers
2026-02-20 10:43 ` Cyril Hrubis
@ 2026-02-20 14:08 ` Jinseok Kim
2026-02-20 15:05 ` Cyril Hrubis
0 siblings, 1 reply; 13+ messages in thread
From: Jinseok Kim @ 2026-02-20 14:08 UTC (permalink / raw)
To: chrubis, ltp
Hi!
Thanks for the review.
So does this mean IN_ALL_EVENTS is used (and should stay) in all test
files, not just inotify01.c?
If so, do the test files that are currently not using IN_ALL_EVENTS
need to be updated to use it, or can they stay as-is?
Thanks.
Jinseok.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [LTP] [PATCH v2] inotify: cleanup - limit masks, use SAFE_ wrappers
2026-02-20 14:08 ` Jinseok Kim
@ 2026-02-20 15:05 ` Cyril Hrubis
2026-02-21 8:21 ` [LTP] [PATCH v3] inotify: modernize with " Jinseok Kim
0 siblings, 1 reply; 13+ messages in thread
From: Cyril Hrubis @ 2026-02-20 15:05 UTC (permalink / raw)
To: Jinseok Kim; +Cc: ltp
Hi!
> So does this mean IN_ALL_EVENTS is used (and should stay) in all test
> files, not just inotify01.c?
Yes, sorry for not being clear enough.
> If so, do the test files that are currently not using IN_ALL_EVENTS
> need to be updated to use it, or can they stay as-is?
That is completely different question. I would expect that tests that
actually test event filtering would set subset of the bits in the mask
and make sure events are filtered. This needs to be evaluated case by
case.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread
* [LTP] [PATCH v3] inotify: modernize with SAFE_ wrappers
2026-02-20 15:05 ` Cyril Hrubis
@ 2026-02-21 8:21 ` Jinseok Kim
2026-02-23 16:59 ` Cyril Hrubis
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Jinseok Kim @ 2026-02-21 8:21 UTC (permalink / raw)
To: chrubis, ltp
Replace manual read/write with SAFE_READ/SAFE_WRITE for better stability
and consistency.
inotify12.c intentionally unchanged: raw read() + manual EAGAIN handling
is required to treat missing second event as IN_IGNORED (normal case).
Signed-off-by: Jinseok Kim <always.starving0@gmail.com>
---
testcases/kernel/syscalls/inotify/inotify01.c | 17 +++--------------
testcases/kernel/syscalls/inotify/inotify03.c | 14 ++------------
testcases/kernel/syscalls/inotify/inotify04.c | 4 +---
testcases/kernel/syscalls/inotify/inotify05.c | 7 +------
testcases/kernel/syscalls/inotify/inotify07.c | 7 +------
testcases/kernel/syscalls/inotify/inotify08.c | 7 +------
testcases/kernel/syscalls/inotify/inotify10.c | 4 +---
7 files changed, 10 insertions(+), 50 deletions(-)
diff --git a/testcases/kernel/syscalls/inotify/inotify01.c b/testcases/kernel/syscalls/inotify/inotify01.c
index 8671b594a..972b1025e 100644
--- a/testcases/kernel/syscalls/inotify/inotify01.c
+++ b/testcases/kernel/syscalls/inotify/inotify01.c
@@ -55,10 +55,7 @@ void verify_inotify(void)
event_set[test_cnt] = IN_OPEN;
test_cnt++;
- if (read(fd, buf, BUF_SIZE) == -1) {
- tst_brk(TBROK | TERRNO,
- "read(%d, buf, %d) failed", fd, BUF_SIZE);
- }
+ SAFE_READ(0, fd, buf, BUF_SIZE);
event_set[test_cnt] = IN_ACCESS;
test_cnt++;
@@ -70,10 +67,7 @@ void verify_inotify(void)
event_set[test_cnt] = IN_OPEN;
test_cnt++;
- if (write(fd, buf, BUF_SIZE) == -1) {
- tst_brk(TBROK,
- "write(%d, %s, %d) failed", fd, fname, BUF_SIZE);
- }
+ SAFE_WRITE(SAFE_WRITE_ALL, fd, buf, BUF_SIZE);
event_set[test_cnt] = IN_MODIFY;
test_cnt++;
@@ -85,12 +79,7 @@ void verify_inotify(void)
* get list of events
*/
int len, i = 0, test_num = 0;
- if ((len = read(fd_notify, event_buf, EVENT_BUF_LEN)) < 0) {
- tst_brk(TBROK,
- "read(%d, buf, %zu) failed",
- fd_notify, EVENT_BUF_LEN);
-
- }
+ len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
/*
* check events
diff --git a/testcases/kernel/syscalls/inotify/inotify03.c b/testcases/kernel/syscalls/inotify/inotify03.c
index 9bb95addb..a7974dd57 100644
--- a/testcases/kernel/syscalls/inotify/inotify03.c
+++ b/testcases/kernel/syscalls/inotify/inotify03.c
@@ -74,11 +74,7 @@ void verify_inotify(void)
}
mount_flag = 0;
- len = read(fd_notify, event_buf, EVENT_BUF_LEN);
- if (len < 0) {
- tst_brk(TBROK | TERRNO,
- "read(%d, buf, %zu) failed", fd_notify, EVENT_BUF_LEN);
- }
+ len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
/* check events */
test_num = 0;
@@ -125,8 +121,6 @@ void verify_inotify(void)
static void setup(void)
{
- int ret;
-
SAFE_MKDIR(mntpoint, DIR_MODE);
SAFE_MOUNT(tst_device->dev, mntpoint, tst_device->fs_type, 0, NULL);
@@ -135,11 +129,7 @@ static void setup(void)
sprintf(fname, "%s/tfile_%d", mntpoint, getpid());
fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0700);
- ret = write(fd, fname, 1);
- if (ret == -1) {
- tst_brk(TBROK | TERRNO,
- "write(%d, %s, 1) failed", fd, fname);
- }
+ SAFE_WRITE(SAFE_WRITE_ALL, fd, fname, 1);
/* close the file we have open */
SAFE_CLOSE(fd);
diff --git a/testcases/kernel/syscalls/inotify/inotify04.c b/testcases/kernel/syscalls/inotify/inotify04.c
index 1db38ddf2..947623952 100644
--- a/testcases/kernel/syscalls/inotify/inotify04.c
+++ b/testcases/kernel/syscalls/inotify/inotify04.c
@@ -118,9 +118,7 @@ void verify_inotify(void)
strcpy(event_set[test_cnt].name, "");
test_cnt++;
- len = read(fd_notify, event_buf, EVENT_BUF_LEN);
- if (len == -1)
- tst_brk(TBROK | TERRNO, "read failed");
+ len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
while (i < len) {
struct inotify_event *event;
diff --git a/testcases/kernel/syscalls/inotify/inotify05.c b/testcases/kernel/syscalls/inotify/inotify05.c
index d9bfb05f1..82a4c7bdc 100644
--- a/testcases/kernel/syscalls/inotify/inotify05.c
+++ b/testcases/kernel/syscalls/inotify/inotify05.c
@@ -60,12 +60,7 @@ void verify_inotify(void)
/*
* get list on events
*/
- len = read(fd_notify, event_buf, EVENT_BUF_LEN);
- if (len < 0) {
- tst_brk(TBROK | TERRNO,
- "read(%d, buf, %zu) failed",
- fd_notify, EVENT_BUF_LEN);
- }
+ len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
/*
* check events
diff --git a/testcases/kernel/syscalls/inotify/inotify07.c b/testcases/kernel/syscalls/inotify/inotify07.c
index 66a2f4d37..b4000f353 100644
--- a/testcases/kernel/syscalls/inotify/inotify07.c
+++ b/testcases/kernel/syscalls/inotify/inotify07.c
@@ -88,12 +88,7 @@ void verify_inotify(void)
strcpy(event_set[test_cnt].name, FILE_NAME);
test_cnt++;
- int len = read(fd_notify, event_buf, EVENT_BUF_LEN);
- if (len == -1 && errno != EAGAIN) {
- tst_brk(TBROK | TERRNO,
- "read(%d, buf, %zu) failed",
- fd_notify, EVENT_BUF_LEN);
- }
+ int len = SAFE_READ(0, 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 4cbb16ce0..e0837cac3 100644
--- a/testcases/kernel/syscalls/inotify/inotify08.c
+++ b/testcases/kernel/syscalls/inotify/inotify08.c
@@ -86,12 +86,7 @@ void verify_inotify(void)
SAFE_TOUCH(OVL_LOWER"/"FILE_NAME, 0644, NULL);
SAFE_TOUCH(OVL_UPPER"/"FILE_NAME, 0644, NULL);
- int len = read(fd_notify, event_buf, EVENT_BUF_LEN);
- if (len == -1 && errno != EAGAIN) {
- tst_brk(TBROK | TERRNO,
- "read(%d, buf, %zu) failed",
- fd_notify, EVENT_BUF_LEN);
- }
+ int len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
int i = 0, test_num = 0;
while (i < len) {
diff --git a/testcases/kernel/syscalls/inotify/inotify10.c b/testcases/kernel/syscalls/inotify/inotify10.c
index a78572dff..4c3a1d116 100644
--- a/testcases/kernel/syscalls/inotify/inotify10.c
+++ b/testcases/kernel/syscalls/inotify/inotify10.c
@@ -143,9 +143,7 @@ static void verify_inotify(unsigned int n)
test_cnt++;
}
- len = read(fd_notify, event_buf, EVENT_BUF_LEN);
- if (len == -1)
- tst_brk(TBROK | TERRNO, "read failed");
+ len = SAFE_READ(0, fd_notify, event_buf, EVENT_BUF_LEN);
while (i < len) {
struct event_t *expected = &event_set[test_num];
--
2.43.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [LTP] [PATCH v3] inotify: modernize with SAFE_ wrappers
2026-02-21 8:21 ` [LTP] [PATCH v3] inotify: modernize with " Jinseok Kim
@ 2026-02-23 16:59 ` Cyril Hrubis
2026-02-24 13:32 ` Andrea Cervesato via ltp
2026-02-24 13:34 ` Andrea Cervesato via ltp
2 siblings, 0 replies; 13+ messages in thread
From: Cyril Hrubis @ 2026-02-23 16:59 UTC (permalink / raw)
To: Jinseok Kim; +Cc: ltp
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [LTP] [PATCH v3] inotify: modernize with SAFE_ wrappers
2026-02-21 8:21 ` [LTP] [PATCH v3] inotify: modernize with " Jinseok Kim
2026-02-23 16:59 ` Cyril Hrubis
@ 2026-02-24 13:32 ` Andrea Cervesato via ltp
2026-02-24 13:34 ` Andrea Cervesato via ltp
2 siblings, 0 replies; 13+ messages in thread
From: Andrea Cervesato via ltp @ 2026-02-24 13:32 UTC (permalink / raw)
To: Jinseok Kim, chrubis, ltp
Hi!
Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [LTP] [PATCH v3] inotify: modernize with SAFE_ wrappers
2026-02-21 8:21 ` [LTP] [PATCH v3] inotify: modernize with " Jinseok Kim
2026-02-23 16:59 ` Cyril Hrubis
2026-02-24 13:32 ` Andrea Cervesato via ltp
@ 2026-02-24 13:34 ` Andrea Cervesato via ltp
2 siblings, 0 replies; 13+ messages in thread
From: Andrea Cervesato via ltp @ 2026-02-24 13:34 UTC (permalink / raw)
To: Jinseok Kim, chrubis, ltp
Merged, thanks!
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-02-24 13:35 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-14 17:52 [LTP] [PATCH] inotify: cleanup - limit masks, use SAFE_ wrappers Jinseok Kim
2026-02-16 10:20 ` Petr Vorel
2026-02-16 16:50 ` Jinseok Kim
2026-02-17 13:29 ` Andrea Cervesato via ltp
2026-02-19 16:08 ` Cyril Hrubis
2026-02-19 18:04 ` [LTP] [PATCH v2] " Jinseok Kim
2026-02-20 10:43 ` Cyril Hrubis
2026-02-20 14:08 ` Jinseok Kim
2026-02-20 15:05 ` Cyril Hrubis
2026-02-21 8:21 ` [LTP] [PATCH v3] inotify: modernize with " Jinseok Kim
2026-02-23 16:59 ` Cyril Hrubis
2026-02-24 13:32 ` Andrea Cervesato via ltp
2026-02-24 13:34 ` Andrea Cervesato via ltp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox