Message ID | 20211222062538.1073176-1-troglobit@gmail.com |
---|---|
State | Superseded |
Headers | show |
Series | [1/1] package/makedevs: allow recursive on directory with symlinks | expand |
diff --git a/package/makedevs/makedevs.c b/package/makedevs/makedevs.c index c57b964f5c..7927b4122a 100644 --- a/package/makedevs/makedevs.c +++ b/package/makedevs/makedevs.c @@ -437,8 +437,10 @@ void bb_show_usage(void) exit(1); } -int bb_recursive(const char *fpath, const struct stat *sb, - int tflag, struct FTW *ftwbuf){ +int bb_recursive(const char *fpath, const struct stat *_, int type, struct FTW *__) +{ + if (type == FTW_SL) + return 0; /* Skip symlinks, cannot chown/chmod them */ if (chown(fpath, recursive_uid, recursive_gid) == -1) { bb_perror_msg("chown failed for %s", fpath);
When using BR2_ROOTFS_DEVICE_TABLE to change ownership of /etc, like so: /etc r -1 root wheel - - - - - makdevs fails due to it trying to chown() a symlink: makedevs: chown failed for /src/myLinux/output/build/buildroot-fs/ext2/target/etc/mtab: No such file or directory makedevs: line 25: recursive failed for /src/myLinux/output/build/buildroot-fs/ext2/target/etc: No such file or directory make[2]: *** [fs/ext2/ext2.mk:63: /src/myLinux/output/images/rootfs.ext2] Error 1 make[1]: *** [Makefile:84: _all] Error 2 make[1]: Leaving directory '/src/myLinux/buildroot' This patch checks the type of fpath before continuing, since we call nftw() with FTW_PHYS we can rely on FTW_SL to check and skip. Also included, some minor coding style cleanup and marking of unused callback arguments. Signed-off-by: Joachim Wiberg <troglobit@gmail.com> --- package/makedevs/makedevs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)