tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc
Source file repositories/reference/linux-study-clean/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc- Extension
.tc- Size
- 2991 bytes
- Lines
- 123
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
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.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: Test file and directory ownership changes for eventfs
# requires: "[gid=<gid>]":README
original_group=`stat -c "%g" .`
original_owner=`stat -c "%u" .`
local mount_point=$(get_mount_point)
mount_options=$(get_mnt_options "$mount_point")
# find another owner and group that is not the original
other_group=`tac /etc/group | grep -v ":$original_group:" | head -1 | cut -d: -f3`
other_owner=`tac /etc/passwd | grep -v ":$original_owner:" | head -1 | cut -d: -f3`
# Remove any group ownership already
new_options=`echo "$mount_options" | sed -e "s/gid=[0-9]*/gid=$other_group/"`
if [ "$new_options" = "$mount_options" ]; then
new_options="$mount_options,gid=$other_group"
mount_options="$mount_options,gid=$original_group"
fi
canary="events/timer events/timer/timer_cancel events/timer/timer_cancel/format"
test() {
file=$1
test_group=$2
owner=`stat -c "%u" $file`
group=`stat -c "%g" $file`
echo "testing $file $owner=$original_owner and $group=$test_group"
if [ $owner -ne $original_owner ]; then
exit_fail
fi
if [ $group -ne $test_group ]; then
exit_fail
fi
# Note, the remount does not update ownership so test going to and from owner
echo "test owner $file to $other_owner"
chown $other_owner $file
owner=`stat -c "%u" $file`
if [ $owner -ne $other_owner ]; then
exit_fail
fi
chown $original_owner $file
owner=`stat -c "%u" $file`
if [ $owner -ne $original_owner ]; then
exit_fail
fi
}
run_tests() {
for d in "." "events" "events/sched" "events/sched/sched_switch" "events/sched/sched_switch/enable" $canary; do
test "$d" $other_group
done
chgrp $original_group events
test "events" $original_group
for d in "." "events/sched" "events/sched/sched_switch" "events/sched/sched_switch/enable" $canary; do
test "$d" $other_group
done
chgrp $original_group events/sched
test "events/sched" $original_group
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
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.