Repository navigation
testing/fs/inotest: Add a test of the file serial numbers - #4023
Merged
Merged
Conversation
No test in testing/fs checks st_ino, d_ino and st_dev. Programs that walk a tree (find, tar, cp -r, ftw()) compare st_dev and st_ino of a directory with those of its parents, and glob() skips an entry with d_ino 0. The test checks the entries of /, /dev and /proc, and of a new tmpfs with two files and a directory: st_ino is not 0 and does not change, readdir() gives the st_ino of lstat() (except for a mount point), fstat() gives the st_dev and st_ino of lstat(), two entries are two files (except for hard links), a subdirectory does not have the numbers of its directory or of a parent directory, and a file keeps its number when it is renamed. It goes one level into the subdirectories on the same device. "inotest dir ..." checks other directories and "inotest -w dir" makes the files in dir. The option is off by default, like the other tests in testing/fs. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]>
xiaoxiang781216
approved these changes
Nov 12, 2026
casaroli
marked this pull request as ready for review
November 12, 2026 11:41
casaroli
marked this pull request as draft
November 12, 2026 14:09
casaroli
marked this pull request as ready for review
November 12, 2026 14:09
🔗 Cross-repo PR dependenciesThe read-only Build run reported the following dependent PR(s) and fetched head SHA(s):
|
🔗 Cross-repo PR dependenciesThe read-only Build run reported the following dependent PR(s) and fetched head SHA(s): |
GUIDINGLI
approved these changes
Nov 13, 2026
casaroli
marked this pull request as draft
November 13, 2026 09:31
casaroli
marked this pull request as ready for review
November 13, 2026 09:31
🔗 Cross-repo PR dependenciesThe read-only Build run reported the following dependent PR(s) and fetched head SHA(s):
|
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.
depends-on: /pull/4033
Summary
This PR adds
testing/fs/inotest(inotest), a test of the file serial numbers (st_ino,d_ino) and the device numbers (st_dev). Programs that walk a tree (find,tar,cp -r,ftw()) comparest_devandst_inoof a directory with those of its parent directories, andglob()skips an entry withd_ino0. No test intesting/fschecks these numbers.For each directory, and one level into its subdirectories on the same device, the test checks:
st_inoof the directory and of each entry is not 0, and a secondlstat()gives the samest_devandst_ino;d_inois not 0, andreaddir()gives ind_inothest_inooflstat()(not for a mount point: therereaddir()gives the number of the directory below it, as on Linux);open()andfstat()of a file or a directory give thest_devandst_inooflstat();st_devandst_ino, except hard links;st_devandst_inoof its directory or of a parent directory.It also makes two files and a directory in a new tmpfs (with
CONFIG_FS_TMPFS), checks them in the same way, and checks that a file keeps itsst_inowhen it is renamed.With no arguments the test checks
/,/devand/proc(skipped if absent) and the tmpfs.inotest dir ...checks other directories, andinotest -w dirmakes the files indir. The program prints each error andinotest: DONE pass <n> fail <n> skip <n>, and returnsEXIT_FAILUREif a check fails.Impact
Test only. New option
CONFIG_TESTING_INOTEST, default n like the other tests intesting/fs.Testing
QEMU, 1 CPU, with
CONFIG_FS_TMPFSandCONFIG_TESTING_INOTEST. knsh: kernel build, the program from/system/bin. nsh: flat build, the program as a builtin. mps2-an500:knsh: protected build, QEMU TCG, procfs mounted by hand.qemu-armv8a:knsh(HVF)qemu-armv8a:nsh(HVF)mps2-an500:knsh(TCG)On master the failures are:
/and every path of/prochavest_ino0; the subdirectories of/prochave the numbers of/proc(findsees a loop);d_inoof the procfs entries is 0; the tmpfs root hasst_dev0 andst_ino1, the same as a node of the pseudo file system; the mounted volumes look like directories of/(st_dev0), so their roots are compared with the pseudo file system. The tmpfs files pass on master.On Linux (Fedora, glibc 2.43, gcc 16, the same source with an empty
nuttx/config.handFARdefined):inotest -w /dev/shm / /dev /proc: pass 4456, fail 0;inotest -w /tmp /tmp /sys /usr: pass 6235, fail 0.rv-virt:nsh(rv32) with the test andEXTRAFLAGS=-Werror: OK. CMake (Ninja) build ofqemu-armv8a:nshwith the test: OK, no warning.tools/checkpatch.sh -c -u -m -g origin/master..HEADpasses.