fix(starry): provide /sys/fs/cgroup mount point in sysfs#1243
Merged
ZR233 merged 1 commit intoJun 15, 2026
Merged
Conversation
The hand-built sysfs root only exposed class/bus/devices/dev/kernel and
had no `fs/` directory. Once sysfs is mounted over /sys it shadows the
rootfs's own /sys/fs/cgroup, so systemd's `mount("/sys/fs/cgroup")`
failed with ENOENT and it could not set up the cgroup hierarchy.
在 sysfs 中补 `fs/cgroup` 空目录作为挂载点,对齐 Linux 由内核在 sysfs 中
提供该目录的行为。systemd 据此成功在其上挂载 tmpfs + cgroup2。
This was referenced Jun 12, 2026
Merged
feat(ax-net): add multi-interface support with per-interface routing, DNS, and SO_BINDTODEVICE
#1244
Merged
Contributor
There was a problem hiding this comment.
PR 变更概述
本 PR 修复 sysfs 缺少 /sys/fs/cgroup 挂载点导致 systemd 无法建立 cgroup 层级的问题。改动仅 2 个文件,+26 行:
os/StarryOS/kernel/src/pseudofs/sysfs.rs:在 sysfs 根目录下新增fs/cgroup空目录节点,完全仿照已有的kernel/debug模式(DirMapping::new())。注释清晰说明了 Linux 内核在 sysfs 中提供此空目录的原因,以及 sysfs 挂载后会遮蔽 rootfs 同名路径的机制。test-suit/starryos/qemu-smp1/system/c-regression-test-sysfs-class/src/main.c:扩展现有 sysfs-class 测试用例,新增/sys/fs和/sys/fs/cgroup的stat目录验证,以及 tmpfs 挂载/卸载验证。测试覆盖了修复前不存在路径时的 FAIL 行为。
实现逻辑
修复对齐 Linux 内核行为:真实 Linux 在 sysfs 内提供 /sys/fs/cgroup 空目录作为 cgroup v2 的挂载点。systemd 启动时先将 sysfs 挂载到 /sys,遮蔽了 rootfs 中预先 mkdir 的路径,因此挂载点必须在 sysfs 自身的目录树中存在。PR 使用与 kernel/debug 完全相同的 DirMapping::new() 模式创建空目录,无额外依赖,不影响现有 class/bus/devices/dev/kernel 结构。
验证结果
cargo fmt --check:✅ 通过cargo clippy --all-features -D warnings(starry-kernel):✅ 通过,无警告- 测试用例结构合理:
CHECK_RET/CHECK宏覆盖 stat 和 mount/umount,能可靠检测修复前的 ENOENT
CI 状态
所有 GitHub Actions check runs 状态为 skipped(共 14 个 jobs),属于 fork PR 未触发 CI 的预期行为(run_host / run_container 互斥作业均被跳过)。CI 失败不是 PR 引起的。合并后 CI 将正常运行。
重复/重叠分析
- base 分支(dev)不包含任何
cgroup相关的 sysfs 代码,本 PR 为新增内容。 - PR #1234(
feat(ax-cgroup): extract cgroup v2 subsystem into standalone crate)将 cgroup 核心逻辑抽取为独立 crate,与本 PR 互补而非冲突:#1234 解决 cgroup 实现的模块化,本 PR 提供 sysfs 中的挂载点。两者可独立合并。 - 未发现其他重复或冲突的 open PR。
结论
代码简洁、遵循既有模式、注释充分、测试覆盖合理,无阻塞问题。APPROVE。
Powered by mimo-v2.5-pro
Merged
fzg-23
pushed a commit
to fzg-23/tgoskits
that referenced
this pull request
Jun 16, 2026
The hand-built sysfs root only exposed class/bus/devices/dev/kernel and
had no `fs/` directory. Once sysfs is mounted over /sys it shadows the
rootfs's own /sys/fs/cgroup, so systemd's `mount("/sys/fs/cgroup")`
failed with ENOENT and it could not set up the cgroup hierarchy.
在 sysfs 中补 `fs/cgroup` 空目录作为挂载点,对齐 Linux 由内核在 sysfs 中
提供该目录的行为。systemd 据此成功在其上挂载 tmpfs + cgroup2。
luodeb
pushed a commit
that referenced
this pull request
Jun 30, 2026
The hand-built sysfs root only exposed class/bus/devices/dev/kernel and
had no `fs/` directory. Once sysfs is mounted over /sys it shadows the
rootfs's own /sys/fs/cgroup, so systemd's `mount("/sys/fs/cgroup")`
failed with ENOENT and it could not set up the cgroup hierarchy.
在 sysfs 中补 `fs/cgroup` 空目录作为挂载点,对齐 Linux 由内核在 sysfs 中
提供该目录的行为。systemd 据此成功在其上挂载 tmpfs + cgroup2。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
在 StarryOS 上以 Debian trixie 的 systemd 作为 PID 1 启动时,首次 boot 暴露了若干内核问题。本 PR 修复其中之一:sysfs 缺少
/sys/fs/cgroup挂载点,导致 systemd 无法建立 cgroup 层级。现象
systemd 在
/sys/fs/cgroup上挂载 tmpfs 时失败,mount(2)返回ENOENT(挂载点路径不存在):根因
手搓的 sysfs 根目录只暴露
class/bus/devices/dev/kernel,没有fs/目录。systemd 早期把 sysfs 挂到
/sys,盖住了 rootfs 里mkdir出来的/sys/fs/cgroup;而 sysfs 自身没有这个目录,挂载时路径解析即ENOENT。真实 Linux 中/sys/fs/cgroup是内核在 sysfs 内提供的空目录。修复
在 sysfs 中补
fs/cgroup空目录作为挂载点(仿照已有的kernel/debug),对齐 Linux 行为。影响范围
仅向 sysfs 树新增一个空目录节点,不影响现有
class/bus/devices等 libudev 相关结构。测试
扩展现有用例
qemu-smp1/system/c-regression-test-sysfs-class,新增对挂载点的检查:/sys/fs与/sys/fs/cgroup均存在且为目录,并验证可在/sys/fs/cgroup上挂载 / 卸载 tmpfs。修复前/sys/fs/cgroup不存在,相关检查会 FAIL。cargo xtask starry test qemu --arch aarch64 -c qemu-smp1/system/c-regression-test-sysfs-class验证
修复后 systemd 成功建立 cgroup 层级并打出欢迎语: