[LTP] fanotify27: Test FAN_DELETE_SELF on unlinked hardlinked open file
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Fri Nov 13 19:18:28 CET 2026
Hi Amir,
On Fri Nov 13 18:51:18 2026 +0100, Amir Goldstein <amir73il@gmail.com> wrote:
> fanotify27: Test FAN_DELETE_SELF on unlinked hardlinked open file
> + * Before the fix, the unlink of the last link reported FAN_DELETE_SELF and
> + * removed all the inode marks of the still open inode, so the write to the
> + * open file did not report FAN_MODIFY. Closing the file then reported a
> + * second FAN_DELETE_SELF event.
> + */
Document why .needs_root = 1 is required in the /*\ ... */ comment block
(mounting the test filesystem and using FAN_MARK_FILESYSTEM).
> + while ((len = read(fanotify_fd, buf, sizeof(buf))) > 0) {
> + for (metadata = (struct fanotify_event_metadata *)buf;
> + FAN_EVENT_OK(metadata, len);
> + metadata = FAN_EVENT_NEXT(metadata, len)) {
> + if (!event_matches_victim(metadata))
> + continue;
> + if (metadata->mask & FAN_DELETE_SELF)
> + (*delete_self)++;
> + if (metadata->mask & FAN_MODIFY)
> + (*modify)++;
> + }
> + }
> +
> + if (len < 0 && errno != EAGAIN)
> + tst_brk(TBROK | TERRNO, "read(fanotify_fd) failed");
Use SAFE_READ(SAFE_READ_ANY_EAGAIN, fanotify_fd, buf, sizeof(buf)) in the
while condition and drop the manual errno != EAGAIN check.
> +static void cleanup(void)
> +{
> + if (file_fd >= 0)
> + SAFE_CLOSE(file_fd);
> + if (fanotify_fd >= 0)
> + SAFE_CLOSE(fanotify_fd);
> +}
Use file_fd != -1 and fanotify_fd != -1 to check file descriptor validity.
Verdict - Needs revision
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
More information about the ltp
mailing list