Skip to content

testing/fs/inotest: Add a test of the file serial numbers - #4023

Merged
acassis merged 1 commit into
apache:masterfrom
casaroli:apps-fs-inode-test-up
Nov 13, 2026
Merged

acassis merged 1 commit into
apache:masterfrom
casaroli:apps-fs-inode-test-up

Conversation

@casaroli

@casaroli casaroli commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

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()) compare st_dev and st_ino of a directory with those of its parent directories, and glob() skips an entry with d_ino 0. No test in testing/fs checks these numbers.

For each directory, and one level into its subdirectories on the same device, the test checks:

  • st_ino of the directory and of each entry is not 0, and a second lstat() gives the same st_dev and st_ino;
  • d_ino is not 0, and readdir() gives in d_ino the st_ino of lstat() (not for a mount point: there readdir() gives the number of the directory below it, as on Linux);
  • open() and fstat() of a file or a directory give the st_dev and st_ino of lstat();
  • two entries of a directory have different st_dev and st_ino, except hard links;
  • a subdirectory does not have the st_dev and st_ino of 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 its st_ino when it is renamed.

With no arguments the test checks /, /dev and /proc (skipped if absent) and the tmpfs. inotest dir ... checks other directories, and inotest -w dir makes the files in dir. The program prints each error and inotest: DONE pass <n> fail <n> skip <n>, and returns EXIT_FAILURE if a check fails.

Impact

Test only. New option CONFIG_TESTING_INOTEST, default n like the other tests in testing/fs.

Testing

QEMU, 1 CPU, with CONFIG_FS_TMPFS and CONFIG_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.

Configuration nuttx master 03aea786390 nuttx with apache/nuttx#21682
qemu-armv8a:knsh (HVF) pass 901, fail 186 pass 475, fail 0
qemu-armv8a:nsh (HVF) pass 419, fail 192 pass 473, fail 0
mps2-an500:knsh (TCG) pass 355, fail 159 pass 405, fail 0

On master the failures are: / and every path of /proc have st_ino 0; the subdirectories of /proc have the numbers of /proc (find sees a loop); d_ino of the procfs entries is 0; the tmpfs root has st_dev 0 and st_ino 1, the same as a node of the pseudo file system; the mounted volumes look like directories of / (st_dev 0), 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.h and FAR defined): 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 and EXTRAFLAGS=-Werror: OK. CMake (Ninja) build of qemu-armv8a:nsh with the test: OK, no warning.

tools/checkpatch.sh -c -u -m -g origin/master..HEAD passes.

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]>
@casaroli
casaroli marked this pull request as ready for review November 12, 2026 11:41
@casaroli
casaroli marked this pull request as draft November 12, 2026 14:09
@casaroli
casaroli marked this pull request as ready for review November 12, 2026 14:09
@github-actions

Copy link
Copy Markdown

🔗 Cross-repo PR dependencies

The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):

CI run: https://github.com/apache/nuttx-apps/actions/runs/43234303459

@github-actions

Copy link
Copy Markdown

🔗 Cross-repo PR dependencies

The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):

CI run: https://github.com/apache/nuttx-apps/actions/runs/43211380815

@casaroli
casaroli marked this pull request as draft November 13, 2026 09:31
@casaroli
casaroli marked this pull request as ready for review November 13, 2026 09:31
@github-actions

Copy link
Copy Markdown

🔗 Cross-repo PR dependencies

The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):

CI run: https://github.com/apache/nuttx-apps/actions/runs/43402009250

@acassis
acassis merged commit da90ced into apache:master Nov 13, 2026
101 of 199 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants