tools/testing/selftests/lsm/lsm_get_self_attr_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/lsm/lsm_get_self_attr_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/lsm/lsm_get_self_attr_test.c- Extension
.c- Size
- 6362 bytes
- Lines
- 276
- 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
linux/lsm.hfcntl.hstring.hstdio.hunistd.hsys/types.hkselftest_harness.hcommon.h
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
switch (syscall_lsms[i]) {
case LSM_ID_SELINUX:
cnt_current++;
cnt_exec++;
cnt_fscreate++;
cnt_keycreate++;
cnt_prev++;
cnt_sockcreate++;
break;
case LSM_ID_SMACK:
cnt_current++;
break;
case LSM_ID_APPARMOR:
cnt_current++;
cnt_exec++;
cnt_prev++;
break;
default:
break;
}
}
if (cnt_current) {
size = page_size;
count = lsm_get_self_attr(LSM_ATTR_CURRENT, ctx, &size, 0);
ASSERT_EQ(cnt_current, count);
tctx = ctx;
ASSERT_EQ(0, read_proc_attr("current", attr, page_size));
ASSERT_EQ(0, strcmp((char *)tctx->ctx, attr));
for (i = 1; i < count; i++) {
tctx = next_ctx(tctx);
ASSERT_NE(0, strcmp((char *)tctx->ctx, attr));
}
}
if (cnt_exec) {
size = page_size;
count = lsm_get_self_attr(LSM_ATTR_EXEC, ctx, &size, 0);
ASSERT_GE(cnt_exec, count);
if (count > 0) {
tctx = ctx;
if (read_proc_attr("exec", attr, page_size) == 0)
ASSERT_EQ(0, strcmp((char *)tctx->ctx, attr));
}
for (i = 1; i < count; i++) {
tctx = next_ctx(tctx);
ASSERT_NE(0, strcmp((char *)tctx->ctx, attr));
}
}
if (cnt_fscreate) {
size = page_size;
count = lsm_get_self_attr(LSM_ATTR_FSCREATE, ctx, &size, 0);
ASSERT_GE(cnt_fscreate, count);
if (count > 0) {
tctx = ctx;
if (read_proc_attr("fscreate", attr, page_size) == 0)
ASSERT_EQ(0, strcmp((char *)tctx->ctx, attr));
}
for (i = 1; i < count; i++) {
tctx = next_ctx(tctx);
ASSERT_NE(0, strcmp((char *)tctx->ctx, attr));
}
}
if (cnt_keycreate) {
size = page_size;
count = lsm_get_self_attr(LSM_ATTR_KEYCREATE, ctx, &size, 0);
ASSERT_GE(cnt_keycreate, count);
if (count > 0) {
tctx = ctx;
if (read_proc_attr("keycreate", attr, page_size) == 0)
ASSERT_EQ(0, strcmp((char *)tctx->ctx, attr));
}
for (i = 1; i < count; i++) {
tctx = next_ctx(tctx);
ASSERT_NE(0, strcmp((char *)tctx->ctx, attr));
}
}
if (cnt_prev) {
size = page_size;
count = lsm_get_self_attr(LSM_ATTR_PREV, ctx, &size, 0);
ASSERT_GE(cnt_prev, count);
if (count > 0) {
tctx = ctx;
ASSERT_EQ(0, read_proc_attr("prev", attr, page_size));
ASSERT_EQ(0, strcmp((char *)tctx->ctx, attr));
for (i = 1; i < count; i++) {
tctx = next_ctx(tctx);
ASSERT_NE(0, strcmp((char *)tctx->ctx, attr));
}
}
}
Annotation
- Immediate include surface: `linux/lsm.h`, `fcntl.h`, `string.h`, `stdio.h`, `unistd.h`, `sys/types.h`, `kselftest_harness.h`, `common.h`.
- 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.