diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-23 12:45:51 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-06-23 12:56:40 +0200 |
commit | 96436fb36a5fa0ac8e993fb093b4788fb5448afe (patch) | |
tree | 6804eb71f9dd765b193be9875ad4974d702f3d59 /e2fsprogs/lsattr.c | |
parent | e7ff017a1a8a429aabb02e80fbede1ce1126d8ea (diff) | |
download | busybox-w32-96436fb36a5fa0ac8e993fb093b4788fb5448afe.tar.gz busybox-w32-96436fb36a5fa0ac8e993fb093b4788fb5448afe.tar.bz2 busybox-w32-96436fb36a5fa0ac8e993fb093b4788fb5448afe.zip |
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.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/e2fsprogs/lsattr.c b/e2fsprogs/lsattr.c index 9b035f584..3972ce8a7 100644 --- a/e2fsprogs/lsattr.c +++ b/e2fsprogs/lsattr.c | |||
@@ -46,25 +46,35 @@ enum { | |||
46 | 46 | ||
47 | static void list_attributes(const char *name) | 47 | static void list_attributes(const char *name) |
48 | { | 48 | { |
49 | unsigned long fsflags; | 49 | unsigned fsflags; |
50 | int fd, r; | ||
50 | 51 | ||
51 | if (fgetflags(name, &fsflags) != 0) | 52 | fd = open_or_warn(name, O_RDONLY | O_NONBLOCK); /* neither read nor write asked for */ |
52 | goto read_err; | 53 | if (fd < 0) /* for example, dangling links */ |
54 | return; | ||
53 | 55 | ||
54 | if (option_mask32 & OPT_PROJID) { | 56 | if (option_mask32 & OPT_PROJID) { |
55 | uint32_t p; | 57 | struct ext2_fsxattr fsxattr; |
56 | if (fgetprojid(name, &p) != 0) | 58 | r = ioctl(fd, EXT2_IOC_FSGETXATTR, &fsxattr); |
59 | if (r != 0) | ||
57 | goto read_err; | 60 | goto read_err; |
58 | printf("%5lu ", (unsigned long)p); | 61 | printf("%5u ", (unsigned)fsxattr.fsx_projid); |
59 | } | 62 | } |
60 | 63 | ||
61 | if (option_mask32 & OPT_GENERATION) { | 64 | if (option_mask32 & OPT_GENERATION) { |
62 | unsigned long generation; | 65 | unsigned generation; |
63 | if (fgetversion(name, &generation) != 0) | 66 | r = ioctl(fd, EXT2_IOC_GETVERSION, &generation); |
67 | if (r != 0) | ||
64 | goto read_err; | 68 | goto read_err; |
65 | printf("%-10lu ", generation); | 69 | printf("%-10u ", generation); |
66 | } | 70 | } |
67 | 71 | ||
72 | r = ioctl(fd, EXT2_IOC_GETFLAGS, &fsflags); | ||
73 | if (r != 0) | ||
74 | goto read_err; | ||
75 | |||
76 | close(fd); | ||
77 | |||
68 | if (option_mask32 & OPT_PF_LONG) { | 78 | if (option_mask32 & OPT_PF_LONG) { |
69 | printf("%-28s ", name); | 79 | printf("%-28s ", name); |
70 | print_e2flags(stdout, fsflags, PFOPT_LONG); | 80 | print_e2flags(stdout, fsflags, PFOPT_LONG); |
@@ -77,6 +87,7 @@ static void list_attributes(const char *name) | |||
77 | return; | 87 | return; |
78 | read_err: | 88 | read_err: |
79 | bb_perror_msg("reading %s", name); | 89 | bb_perror_msg("reading %s", name); |
90 | close(fd); | ||
80 | } | 91 | } |
81 | 92 | ||
82 | static int FAST_FUNC lsattr_dir_proc(const char *dir_name, | 93 | static int FAST_FUNC lsattr_dir_proc(const char *dir_name, |