Repository navigation
fs/procfs: list registered entries once and in their directory - #21724
Merged
xiaoxiang781216 merged 3 commits intoNov 12, 2026
Merged
Conversation
procfs_readdir() assumes that the entries of one directory are adjacent in g_procfs_entries, and drops a first-level name only when it repeats the name reported just before it. procfs_register() appends to the end of the table, so after registering "fs/foo" and "foo_bar": - "ls /proc" reports "fs" a second time, and hides "foo_bar" because its first two characters match the "fs" reported before it. - "ls /proc/fs" stops at the first entry outside fs/ and never reaches "foo". Scan the rest of the table for each directory instead, and skip a name when an earlier entry already yields it. Since the scan now covers the whole table, a member of a subdirectory must also have '/' right after the directory name, so "foo_bar" is not taken as part of "fs". Signed-off-by: yezhonghui <[email protected]> Signed-off-by: jingfei <[email protected]>
The node field of struct proc_node_s is already uint8_t, so the explicit casts on the initializers do nothing. Signed-off-by: Xiang Xiao <[email protected]> Signed-off-by: jingfei <[email protected]>
tcbinfo_running_regs() is a non-optimized wrapper around running_regs(). It was added to keep g_running_tasks from being optimized out, but g_running_tasks is now used by the scheduler on every configuration, so the wrapper is no longer needed. Signed-off-by: xuxingliang <[email protected]> Signed-off-by: jingfei <[email protected]>
xiaoxiang781216
approved these changes
Nov 11, 2026
xiaoxiang781216
marked this pull request as ready for review
November 11, 2026 16:53
GUIDINGLI
approved these changes
Nov 12, 2026
xiaoxiang781216
pushed a commit
that referenced
this pull request
Nov 12, 2026
ab32vg1-generic:ostest runs from the 114 KB SRAM. After #21724 the image does not fit: riscv-none-elf-ld: region `sram' overflowed by 54 bytes This configuration starts ostest_main and has no shell, and ostest does not read /proc, so nothing in it uses procfs. Disable it: this frees about 12 KB. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]>
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.
Summary
procfs_readdir()assumes that the entries of one directory are adjacentin
g_procfs_entries, and drops a first-level name only when it repeatsthe name reported just before it.
procfs_register()appends to the endof the table, so after registering
fs/fooandfoo_bar,ls /procshows
fstwice and hidesfoo_bar, andls /proc/fsnever reachesfoo. Each directory now scans the rest of the table and skips a namean earlier entry already yields.
field is already
uint8_t.tcbinfo_running_regs()is a non-optimized wrapper that keptg_running_tasksfrom being optimized out; the scheduler now usesg_running_taskson every configuration.Impact
Only directory listings of procfs change, and only when entries were added
with
procfs_register(). The built-in table lists as before.Testing
Host: Ubuntu x86_64, gcc (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0, master 5fbae0c (rebased onto 5fbae0c; no new
commit touches fs/procfs),
sim:nshwithCONFIG_FS_PROCFS_REGISTER,CONFIG_NET_LOOPBACKandCONFIG_NET_ROUTE. A small test program callsprocfs_register()forfs/fsup_aandfsup_nodup, then lists thedirectories with
opendir()/readdir():/proc... uptime version fs(fstwice, nofsup_nodup)... uptime version fsup_nodup/proc/fsblocks mount usageblocks mount usage fsup_a/proc/netroute loroute lo/proc/net/routeipv4ipv4cat /proc/tcbinfostill prints the current regs pointer../tools/checkpatch.sh -g master..HEAD: all checks pass.ostestexits with status 0.