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>
This commit is contained in:
@@ -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,
|
||||
|
Reference in New Issue
Block a user