fs: widen ino_t to uint32_t and add d_ino to struct dirent#19179
Open
xiaoxiang781216 wants to merge 3 commits into
Open
fs: widen ino_t to uint32_t and add d_ino to struct dirent#19179xiaoxiang781216 wants to merge 3 commits into
xiaoxiang781216 wants to merge 3 commits into
Conversation
Move uid_t/gid_t out of the CONFIG_SMALL_MEMORY #ifdef so they are always defined as unsigned int regardless of SMALL_MEMORY. Update include/nuttx/fs/hostfs.h to match: drop the int16_t variants of nuttx_gid_t/nuttx_uid_t and keep a single unsigned int definition so the hostfs RPC ABI stays in sync with sys/types.h. Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
A 16-bit ino_t can only address 65536 distinct file serial numbers, which is not enough for filesystems with large directory trees and breaks portable software (e.g. dropbear's scp) that expects a wider inode number space. Widen ino_t (and nuttx_ino_t in the hostfs ABI) to uint32_t to match common POSIX practice. Update fs/rpmsgfs/rpmsgfs.h accordingly: promote the 'ino' field in struct rpmsgfs_stat_priv_s from uint16_t to uint32_t and move 'nlink' into the trailing 16-bit slot previously occupied by the reserved field, keeping the overall packed-struct layout/size unchanged. Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
There was a problem hiding this comment.
Pull request overview
This PR widens core filesystem identity types (notably ino_t) and adds the POSIX-required d_ino field to struct dirent, then threads inode numbers through multiple readdir() implementations (pseudofs, sim hostfs, rpmsgfs) to support portable software that expects stable/non-zero inode serial numbers.
Changes:
- Make
uid_t/gid_tconsistentlyunsigned intand widenino_ttouint32_t. - Add
d_inotostruct direntand hostfs’nuttx_dirent_s, and propagate inode numbers through rpmsgfs + sim hostfsreaddir. - Refactor
dir_close()cleanup logic (currently introduces build issues).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| include/sys/types.h | Makes uid_t/gid_t unconditional and widens ino_t to 32-bit. |
| include/nuttx/fs/hostfs.h | Keeps hostfs ABI types in sync; adds d_ino to nuttx_dirent_s. |
| include/dirent.h | Adds POSIX d_ino to struct dirent. |
| fs/vfs/fs_dir.c | Populates d_ino for pseudodir entries; modifies dir_close() cleanup path. |
| fs/rpmsgfs/rpmsgfs.h | Updates rpmsgfs stat/readdir wire structs to carry 32-bit inode. |
| fs/rpmsgfs/rpmsgfs_server.c | Sends inode number back in rpmsgfs readdir response. |
| fs/rpmsgfs/rpmsgfs_client.c | Receives inode number and populates entry->d_ino. |
| arch/sim/src/sim/posix/sim_hostfs.c | Propagates host dirent.d_ino into NuttX hostfs dirent ABI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add the POSIX d_ino (file serial number) member to struct dirent and
populate it on every readdir() path, so portable callers (e.g. scp in
dropbear) that read dp->d_ino observe a meaningful, non-zero inode
number:
- include/dirent.h: declare d_ino in struct dirent and drop the
outdated comment claiming the field is unimplemented.
- include/nuttx/fs/hostfs.h: add d_ino to struct nuttx_dirent_s so
the hostfs ABI can carry the inode number across the VFS boundary.
- arch/sim/src/sim/posix/sim_hostfs.c: forward the host's
ent->d_ino into entry->d_ino.
- fs/vfs/fs_dir.c (read_pseudodir): copy the in-memory inode's
i_ino into entry->d_ino for the pseudo filesystem.
- fs/yaffs/yaffs_vfs.c: forward yaffs's dirent->d_ino into
entry->d_ino.
- fs/rpmsgfs: extend struct rpmsgfs_readdir_s with an 'ino' field
and propagate it across the RPC in both rpmsgfs_server (fills it
from the underlying entry) and rpmsgfs_client (writes it back to
the caller's nuttx_dirent_s).
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
331f152 to
5d32630
Compare
|
Contributor
Author
|
need merge apache/nuttx-apps#3554 first |
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
This series widens NuttX's inode/uid integer types and adds the POSIX
d_inomember tostruct dirent, so portable software (e.g. dropbear'sscp) that relies on a meaningful, wide file serial number works correctly.uid_t/gid_tout of theCONFIG_SMALL_MEMORY#ifdefso they arealways
unsigned int; keepinclude/nuttx/fs/hostfs.hin sync (drop theint16_tvariants ofnuttx_gid_t/nuttx_uid_t).ino_tonlyaddresses 65536 file serial numbers, which breaks large directory trees
and portable callers. Widen
ino_t(andnuttx_ino_tin the hostfs ABI)to
uint32_t. Adjustfs/rpmsgfs/rpmsgfs.hso the packedrpmsgfs_stat_priv_slayout/size stays unchanged.d_inoandpopulate it on every
readdir()path (pseudofs, hostfs/sim, yaffs,rpmsgfs), so callers observe a non-zero inode number.
Impact
d_inofield tostruct dirent(was previously absent).ino_twidened from 16-bit to 32-bit;uid_t/gid_tare now alwaysunsigned intregardless ofCONFIG_SMALL_MEMORY.struct nuttx_dirent_s,nuttx_ino_t,nuttx_uid_t/nuttx_gid_t) updated to match; rpmsgfs packed struct sizepreserved (verified 112 bytes before and after).
Testing
Style:
tools/checkpatch.sh -g apache/master..HEAD→ all checks pass.Build:
sim:nshbuilds cleanly (all changed files —fs/vfs/fs_dir.c,fs/rpmsgfs/*,arch/sim/src/sim/posix/sim_hostfs.c, and the headers —compile and link without errors/warnings).
Runtime (sim:nsh): A small
readdir()test confirmssizeof(d_ino) == 4(ino_t is now 32-bit) and every entry reports a non-zero
d_ino:ABI size check: A standalone host program reproducing the
rpmsgfs_stat_priv_spacked layout confirms the struct size is unchanged(
old=112 new=112) after movingnlinkinto the former reserved slot andwidening
inoto 32-bit.Changelog
commit (those helpers do not exist upstream, which broke the CI build),
and correct
read_pseudodir()to assignentry->d_ino = pdir->next->i_ino(the prior
next->i_inoreferenced an undeclared variable). The netchange to
fs/vfs/fs_dir.cis now a single added line.Related
examples/userfsstruct direntinitializer that the newd_inofield broke. The two PRs must be merged together.