summaryrefslogtreecommitdiff
path: root/e2fsprogs/lsattr.c
diff options
context:
space:
mode:
authorDenys Vlasenko2021-06-23 12:45:51 +0200
committerDenys Vlasenko2021-06-23 12:56:40 +0200
commit96436fb36a5fa0ac8e993fb093b4788fb5448afe (patch)
tree6804eb71f9dd765b193be9875ad4974d702f3d59 /e2fsprogs/lsattr.c
parente7ff017a1a8a429aabb02e80fbede1ce1126d8ea (diff)
downloadbusybox-96436fb36a5fa0ac8e993fb093b4788fb5448afe.zip
busybox-96436fb36a5fa0ac8e993fb093b4788fb5448afe.tar.gz
e2fsprogs/*: remove ioctl calling obfuscation
function old new delta change_attributes 326 416 +90 list_attributes 222 248 +26 close_silently 22 - -22 .rodata 103722 103692 -30 fgetsetversion 74 - -74 fgetsetprojid 107 - -107 fgetsetflags 148 - -148 ------------------------------------------------------------------------------ (add/remove: 0/4 grow/shrink: 2/1 up/down: 116/-381) Total: -265 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'e2fsprogs/lsattr.c')
-rw-r--r--e2fsprogs/lsattr.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/e2fsprogs/lsattr.c b/e2fsprogs/lsattr.c
index 9b035f5..3972ce8 100644
--- a/e2fsprogs/lsattr.c
+++ b/e2fsprogs/lsattr.c
@@ -46,25 +46,35 @@ enum {
static void list_attributes(const char *name)
{
- unsigned long fsflags;
+ unsigned fsflags;
+ int fd, r;
- if (fgetflags(name, &fsflags) != 0)
- goto read_err;
+ fd = open_or_warn(name, O_RDONLY | O_NONBLOCK); /* neither read nor write asked for */
+ if (fd < 0) /* for example, dangling links */
+ return;
if (option_mask32 & OPT_PROJID) {
- uint32_t p;
- if (fgetprojid(name, &p) != 0)
+ struct ext2_fsxattr fsxattr;
+ r = ioctl(fd, EXT2_IOC_FSGETXATTR, &fsxattr);
+ if (r != 0)
goto read_err;
- printf("%5lu ", (unsigned long)p);
+ printf("%5u ", (unsigned)fsxattr.fsx_projid);
}
if (option_mask32 & OPT_GENERATION) {
- unsigned long generation;
- if (fgetversion(name, &generation) != 0)
+ unsigned generation;
+ r = ioctl(fd, EXT2_IOC_GETVERSION, &generation);
+ if (r != 0)
goto read_err;
- printf("%-10lu ", generation);
+ printf("%-10u ", generation);
}
+ r = ioctl(fd, EXT2_IOC_GETFLAGS, &fsflags);
+ if (r != 0)
+ goto read_err;
+
+ close(fd);
+
if (option_mask32 & OPT_PF_LONG) {
printf("%-28s ", name);
print_e2flags(stdout, fsflags, PFOPT_LONG);
@@ -77,6 +87,7 @@ static void list_attributes(const char *name)
return;
read_err:
bb_perror_msg("reading %s", name);
+ close(fd);
}
static int FAST_FUNC lsattr_dir_proc(const char *dir_name,