tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c- Extension
.c- Size
- 11617 bytes
- Lines
- 529
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
fcntl.hsched.hstdio.hstring.hsys/stat.hsys/mount.hunistd.hsys/syscall.hsys/fanotify.hkselftest_harness.h../statmount/statmount.h../utils.h
Detected Declarations
function expect_notifyfunction expect_notify_nfunction expect_notify_maskfunction expect_notify_mask_nfunction verify_mount_idsfunction check_mountedfunction setup_mount_tree
Annotated Snippet
if (i > 0) {
// Groups 1,2 should get EAGAIN
ASSERT_EQ(len, -1);
ASSERT_EQ(errno, EAGAIN);
} else {
// Group 0 should get events
ASSERT_GT(len, 0);
}
}
self->rem = len;
self->next = (void *) self->buf;
}
meta = self->next;
ASSERT_TRUE(FAN_EVENT_OK(meta, self->rem));
thislen = meta->event_len;
self->rem -= thislen;
self->next += thislen;
*mask = meta->mask;
thislen -= sizeof(*meta);
mnt = ((void *) meta) + meta->event_len - thislen;
ASSERT_EQ(thislen, sizeof(*mnt));
return mnt->mnt_id;
}
static void expect_notify_n(struct __test_metadata *const _metadata,
FIXTURE_DATA(fanotify) *self,
unsigned int n, uint64_t mask[], uint64_t mnts[])
{
unsigned int i;
for (i = 0; i < n; i++)
mnts[i] = expect_notify(_metadata, self, &mask[i]);
}
static uint64_t expect_notify_mask(struct __test_metadata *const _metadata,
FIXTURE_DATA(fanotify) *self,
uint64_t expect_mask)
{
uint64_t mntid, mask;
mntid = expect_notify(_metadata, self, &mask);
ASSERT_EQ(expect_mask, mask);
return mntid;
}
static void expect_notify_mask_n(struct __test_metadata *const _metadata,
FIXTURE_DATA(fanotify) *self,
uint64_t mask, unsigned int n, uint64_t mnts[])
{
unsigned int i;
for (i = 0; i < n; i++)
mnts[i] = expect_notify_mask(_metadata, self, mask);
}
static void verify_mount_ids(struct __test_metadata *const _metadata,
const uint64_t list1[], const uint64_t list2[],
size_t num)
{
unsigned int i, j;
// Check that neither list has any duplicates
for (i = 0; i < num; i++) {
for (j = 0; j < num; j++) {
if (i != j) {
ASSERT_NE(list1[i], list1[j]);
ASSERT_NE(list2[i], list2[j]);
}
}
}
// Check that all list1 memebers can be found in list2. Together with
// the above it means that the list1 and list2 represent the same sets.
for (i = 0; i < num; i++) {
for (j = 0; j < num; j++) {
if (list1[i] == list2[j])
break;
}
ASSERT_NE(j, num);
}
}
Annotation
- Immediate include surface: `fcntl.h`, `sched.h`, `stdio.h`, `string.h`, `sys/stat.h`, `sys/mount.h`, `unistd.h`, `sys/syscall.h`.
- Detected declarations: `function expect_notify`, `function expect_notify_n`, `function expect_notify_mask`, `function expect_notify_mask_n`, `function verify_mount_ids`, `function check_mounted`, `function setup_mount_tree`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.