mbox series

[pseudo,0/1] pseudo: add nftw wrapper

Message ID 20250317113445.3855518-1-skandigraun@gmail.com
Headers show
Series pseudo: add nftw wrapper | expand

Message

Gyorgy Sarvari March 17, 2025, 11:34 a.m. UTC
This is an (attempt at the) implementation of the nftw[1] call in pseudo.

The main motivation is a change in btrfs-tools[2], in which
they have changed from walking the filetree and calling stat
on each entries separately to using the nftw call. As a result,
btrfs filesystem generation currently happens with incorrect
ownership details, as the nftw calls go around pseudo.

See also the relevant report[3] on the Yocto mailing list.

The idea is also described in the commit message, though the actual,
non-generated code is also only just a few lines, under 20 I think:
with a custom wrapper capture the nftw call, and switch the callback
to our own callback. When our own callback is called, fix the received
stat struct, and call the original callback, this time with the correct
stat struct.

Big thanks to Lander Van Loock, who not only reported the
original issue, but also helped testing and reviewing the change beside
fixing some issues in prior iterations of the code.

Please let me know what you think.

[1]: https://linux.die.net/man/3/nftw
[2]: https://github.com/kdave/btrfs-progs/commit/c6464d3f99ed1dabceff1168eabb207492c37624
[3]: https://lists.yoctoproject.org/g/yocto/message/64889


Gyorgy Sarvari (1):
  nftw: add wrapper

 ports/unix/guts/nftw.c            |  16 ----
 ports/unix/nftw/guts/nftw.c       |  22 +++++
 ports/unix/nftw/pseudo_wrappers.c | 122 +++++++++++++++++++++++++
 ports/unix/nftw/wrapfuncs.in      |   1 +
 ports/unix/subports               |   2 +
 ports/unix/wrapfuncs.in           |   1 -
 test/test-nftw.c                  | 144 ++++++++++++++++++++++++++++++
 test/test-nftw.sh                 |  42 +++++++++
 8 files changed, 333 insertions(+), 17 deletions(-)
 delete mode 100644 ports/unix/guts/nftw.c
 create mode 100644 ports/unix/nftw/guts/nftw.c
 create mode 100644 ports/unix/nftw/pseudo_wrappers.c
 create mode 100644 ports/unix/nftw/wrapfuncs.in
 create mode 100644 test/test-nftw.c
 create mode 100755 test/test-nftw.sh


Cc: Lander Van Loock <landervanloock@gmail.com>