[git commit] chattr,lsattr: share stat error message

Denys Vlasenko vda.linux at googlemail.com
Wed Jun 23 13:33:22 UTC 2021


commit: https://git.busybox.net/busybox/commit/?id=85a5bc91487ae1b4014f2ee6595873c8330fa7a7
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
.rodata                                           103692  103684      -8

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 e2fsprogs/chattr.c | 3 ++-
 e2fsprogs/lsattr.c | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/e2fsprogs/chattr.c b/e2fsprogs/chattr.c
index f6a9fcf30..b424e797b 100644
--- a/e2fsprogs/chattr.c
+++ b/e2fsprogs/chattr.c
@@ -154,7 +154,7 @@ static void change_attributes(const char *name, struct globals *gp)
 	struct stat st;
 
 	if (lstat(name, &st) != 0) {
-		bb_perror_msg("stat %s", name);
+		bb_perror_msg("can't stat '%s'", name);
 		return;
 	}
 	if (S_ISLNK(st.st_mode) && gp->recursive)
@@ -180,6 +180,7 @@ static void change_attributes(const char *name, struct globals *gp)
 		if (gp->flags & OPT_SET_PROJ) {
 			struct ext2_fsxattr fsxattr;
 			r = ioctl(fd, EXT2_IOC_FSGETXATTR, &fsxattr);
+			/* note: ^^^ may fail in 32-bit userspace on 64-bit kernel (seen on 4.12.0) */
 			if (r != 0)
 				bb_perror_msg("getting %s on %s", "project ID", name);
 			fsxattr.fsx_projid = gp->projid;
diff --git a/e2fsprogs/lsattr.c b/e2fsprogs/lsattr.c
index 3972ce8a7..b4ed12d50 100644
--- a/e2fsprogs/lsattr.c
+++ b/e2fsprogs/lsattr.c
@@ -56,6 +56,7 @@ static void list_attributes(const char *name)
 	if (option_mask32 & OPT_PROJID) {
 		struct ext2_fsxattr fsxattr;
 		r = ioctl(fd, EXT2_IOC_FSGETXATTR, &fsxattr);
+		/* note: ^^^ may fail in 32-bit userspace on 64-bit kernel (seen on 4.12.0) */
 		if (r != 0)
 			goto read_err;
 		printf("%5u ", (unsigned)fsxattr.fsx_projid);
@@ -100,7 +101,7 @@ static int FAST_FUNC lsattr_dir_proc(const char *dir_name,
 	path = concat_path_file(dir_name, de->d_name);
 
 	if (lstat(path, &st) != 0)
-		bb_perror_msg("stat %s", path);
+		bb_perror_msg("can't stat '%s'", path);
 	else if (de->d_name[0] != '.' || (option_mask32 & OPT_ALL)) {
 		list_attributes(path);
 		if (S_ISDIR(st.st_mode) && (option_mask32 & OPT_RECUR)
@@ -121,7 +122,7 @@ static void lsattr_args(const char *name)
 	struct stat st;
 
 	if (lstat(name, &st) == -1) {
-		bb_perror_msg("stat %s", name);
+		bb_perror_msg("can't stat '%s'", name);
 	} else if (S_ISDIR(st.st_mode) && !(option_mask32 & OPT_DIRS_OPT)) {
 		iterate_on_dir(name, lsattr_dir_proc, NULL);
 	} else {


More information about the busybox-cvs mailing list