mirror of
https://github.com/sheumann/hush.git
synced 2024-08-20 19:29:02 +00:00
stat: get rid on intmax_t
function old new delta print_it 225 218 -7 print_stat 919 889 -30 print_statfs 370 339 -31 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-68) Total: -68 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
4b061461d3
commit
5b9b1365a0
181
coreutils/stat.c
181
coreutils/stat.c
@ -12,10 +12,8 @@
|
|||||||
*
|
*
|
||||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
|
|
||||||
/* vars to control behavior */
|
|
||||||
#define OPT_FILESYS (1 << 0)
|
#define OPT_FILESYS (1 << 0)
|
||||||
#define OPT_TERSE (1 << 1)
|
#define OPT_TERSE (1 << 1)
|
||||||
#define OPT_DEREFERENCE (1 << 2)
|
#define OPT_DEREFERENCE (1 << 2)
|
||||||
@ -154,7 +152,7 @@ static void printfs(char *pformat, const char *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* print statfs info */
|
/* print statfs info */
|
||||||
static void print_statfs(char *pformat, const char m,
|
static void FAST_FUNC print_statfs(char *pformat, const char m,
|
||||||
const char *const filename, const void *data
|
const char *const filename, const void *data
|
||||||
IF_SELINUX(, security_context_t scontext))
|
IF_SELINUX(, security_context_t scontext))
|
||||||
{
|
{
|
||||||
@ -166,34 +164,34 @@ static void print_statfs(char *pformat, const char m,
|
|||||||
printf(pformat, get_f_fsid(statfsbuf));
|
printf(pformat, get_f_fsid(statfsbuf));
|
||||||
} else if (m == 'l') {
|
} else if (m == 'l') {
|
||||||
strcat(pformat, "lu");
|
strcat(pformat, "lu");
|
||||||
printf(pformat, (unsigned long) (statfsbuf->f_namelen));
|
printf(pformat, (unsigned long) statfsbuf->f_namelen);
|
||||||
} else if (m == 't') {
|
} else if (m == 't') {
|
||||||
strcat(pformat, "lx");
|
strcat(pformat, "lx");
|
||||||
printf(pformat, (unsigned long) (statfsbuf->f_type)); /* no equiv */
|
printf(pformat, (unsigned long) statfsbuf->f_type); /* no equiv */
|
||||||
} else if (m == 'T') {
|
} else if (m == 'T') {
|
||||||
printfs(pformat, human_fstype(statfsbuf->f_type));
|
printfs(pformat, human_fstype(statfsbuf->f_type));
|
||||||
} else if (m == 'b') {
|
} else if (m == 'b') {
|
||||||
strcat(pformat, "jd");
|
strcat(pformat, "llu");
|
||||||
printf(pformat, (intmax_t) (statfsbuf->f_blocks));
|
printf(pformat, (unsigned long long) statfsbuf->f_blocks);
|
||||||
} else if (m == 'f') {
|
} else if (m == 'f') {
|
||||||
strcat(pformat, "jd");
|
strcat(pformat, "llu");
|
||||||
printf(pformat, (intmax_t) (statfsbuf->f_bfree));
|
printf(pformat, (unsigned long long) statfsbuf->f_bfree);
|
||||||
} else if (m == 'a') {
|
} else if (m == 'a') {
|
||||||
strcat(pformat, "jd");
|
strcat(pformat, "llu");
|
||||||
printf(pformat, (intmax_t) (statfsbuf->f_bavail));
|
printf(pformat, (unsigned long long) statfsbuf->f_bavail);
|
||||||
} else if (m == 's' || m == 'S') {
|
} else if (m == 's' || m == 'S') {
|
||||||
strcat(pformat, "lu");
|
strcat(pformat, "lu");
|
||||||
printf(pformat, (unsigned long) (statfsbuf->f_bsize));
|
printf(pformat, (unsigned long) statfsbuf->f_bsize);
|
||||||
} else if (m == 'c') {
|
} else if (m == 'c') {
|
||||||
strcat(pformat, "jd");
|
strcat(pformat, "llu");
|
||||||
printf(pformat, (intmax_t) (statfsbuf->f_files));
|
printf(pformat, (unsigned long long) statfsbuf->f_files);
|
||||||
} else if (m == 'd') {
|
} else if (m == 'd') {
|
||||||
strcat(pformat, "jd");
|
strcat(pformat, "llu");
|
||||||
printf(pformat, (intmax_t) (statfsbuf->f_ffree));
|
printf(pformat, (unsigned long long) statfsbuf->f_ffree);
|
||||||
#if ENABLE_SELINUX
|
# if ENABLE_SELINUX
|
||||||
} else if (m == 'C' && (option_mask32 & OPT_SELINUX)) {
|
} else if (m == 'C' && (option_mask32 & OPT_SELINUX)) {
|
||||||
printfs(pformat, scontext);
|
printfs(pformat, scontext);
|
||||||
#endif
|
# endif
|
||||||
} else {
|
} else {
|
||||||
strcatc(pformat, 'c');
|
strcatc(pformat, 'c');
|
||||||
printf(pformat, m);
|
printf(pformat, m);
|
||||||
@ -201,7 +199,7 @@ static void print_statfs(char *pformat, const char m,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* print stat info */
|
/* print stat info */
|
||||||
static void print_stat(char *pformat, const char m,
|
static void FAST_FUNC print_stat(char *pformat, const char m,
|
||||||
const char *const filename, const void *data
|
const char *const filename, const void *data
|
||||||
IF_SELINUX(, security_context_t scontext))
|
IF_SELINUX(, security_context_t scontext))
|
||||||
{
|
{
|
||||||
@ -227,14 +225,14 @@ static void print_stat(char *pformat, const char m,
|
|||||||
printf(pformat, filename);
|
printf(pformat, filename);
|
||||||
}
|
}
|
||||||
} else if (m == 'd') {
|
} else if (m == 'd') {
|
||||||
strcat(pformat, "ju");
|
strcat(pformat, "llu");
|
||||||
printf(pformat, (uintmax_t) statbuf->st_dev);
|
printf(pformat, (unsigned long long) statbuf->st_dev);
|
||||||
} else if (m == 'D') {
|
} else if (m == 'D') {
|
||||||
strcat(pformat, "jx");
|
strcat(pformat, "llx");
|
||||||
printf(pformat, (uintmax_t) statbuf->st_dev);
|
printf(pformat, (unsigned long long) statbuf->st_dev);
|
||||||
} else if (m == 'i') {
|
} else if (m == 'i') {
|
||||||
strcat(pformat, "ju");
|
strcat(pformat, "llu");
|
||||||
printf(pformat, (uintmax_t) statbuf->st_ino);
|
printf(pformat, (unsigned long long) statbuf->st_ino);
|
||||||
} else if (m == 'a') {
|
} else if (m == 'a') {
|
||||||
strcat(pformat, "lo");
|
strcat(pformat, "lo");
|
||||||
printf(pformat, (unsigned long) (statbuf->st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)));
|
printf(pformat, (unsigned long) (statbuf->st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)));
|
||||||
@ -269,14 +267,14 @@ static void print_stat(char *pformat, const char m,
|
|||||||
strcat(pformat, "lx");
|
strcat(pformat, "lx");
|
||||||
printf(pformat, (unsigned long) minor(statbuf->st_rdev));
|
printf(pformat, (unsigned long) minor(statbuf->st_rdev));
|
||||||
} else if (m == 's') {
|
} else if (m == 's') {
|
||||||
strcat(pformat, "ju");
|
strcat(pformat, "llu");
|
||||||
printf(pformat, (uintmax_t) (statbuf->st_size));
|
printf(pformat, (unsigned long long) statbuf->st_size);
|
||||||
} else if (m == 'B') {
|
} else if (m == 'B') {
|
||||||
strcat(pformat, "lu");
|
strcat(pformat, "lu");
|
||||||
printf(pformat, (unsigned long) 512); //ST_NBLOCKSIZE
|
printf(pformat, (unsigned long) 512); //ST_NBLOCKSIZE
|
||||||
} else if (m == 'b') {
|
} else if (m == 'b') {
|
||||||
strcat(pformat, "ju");
|
strcat(pformat, "llu");
|
||||||
printf(pformat, (uintmax_t) statbuf->st_blocks);
|
printf(pformat, (unsigned long long) statbuf->st_blocks);
|
||||||
} else if (m == 'o') {
|
} else if (m == 'o') {
|
||||||
strcat(pformat, "lu");
|
strcat(pformat, "lu");
|
||||||
printf(pformat, (unsigned long) statbuf->st_blksize);
|
printf(pformat, (unsigned long) statbuf->st_blksize);
|
||||||
@ -284,31 +282,34 @@ static void print_stat(char *pformat, const char m,
|
|||||||
printfs(pformat, human_time(statbuf->st_atime));
|
printfs(pformat, human_time(statbuf->st_atime));
|
||||||
} else if (m == 'X') {
|
} else if (m == 'X') {
|
||||||
strcat(pformat, TYPE_SIGNED(time_t) ? "ld" : "lu");
|
strcat(pformat, TYPE_SIGNED(time_t) ? "ld" : "lu");
|
||||||
printf(pformat, (unsigned long) statbuf->st_atime);
|
/* note: (unsigned long) would be wrong:
|
||||||
|
* imagine (unsigned long64)int32 */
|
||||||
|
printf(pformat, (long) statbuf->st_atime);
|
||||||
} else if (m == 'y') {
|
} else if (m == 'y') {
|
||||||
printfs(pformat, human_time(statbuf->st_mtime));
|
printfs(pformat, human_time(statbuf->st_mtime));
|
||||||
} else if (m == 'Y') {
|
} else if (m == 'Y') {
|
||||||
strcat(pformat, TYPE_SIGNED(time_t) ? "ld" : "lu");
|
strcat(pformat, TYPE_SIGNED(time_t) ? "ld" : "lu");
|
||||||
printf(pformat, (unsigned long) statbuf->st_mtime);
|
printf(pformat, (long) statbuf->st_mtime);
|
||||||
} else if (m == 'z') {
|
} else if (m == 'z') {
|
||||||
printfs(pformat, human_time(statbuf->st_ctime));
|
printfs(pformat, human_time(statbuf->st_ctime));
|
||||||
} else if (m == 'Z') {
|
} else if (m == 'Z') {
|
||||||
strcat(pformat, TYPE_SIGNED(time_t) ? "ld" : "lu");
|
strcat(pformat, TYPE_SIGNED(time_t) ? "ld" : "lu");
|
||||||
printf(pformat, (unsigned long) statbuf->st_ctime);
|
printf(pformat, (long) statbuf->st_ctime);
|
||||||
#if ENABLE_SELINUX
|
# if ENABLE_SELINUX
|
||||||
} else if (m == 'C' && (option_mask32 & OPT_SELINUX)) {
|
} else if (m == 'C' && (option_mask32 & OPT_SELINUX)) {
|
||||||
printfs(pformat, scontext);
|
printfs(pformat, scontext);
|
||||||
#endif
|
# endif
|
||||||
} else {
|
} else {
|
||||||
strcatc(pformat, 'c');
|
strcatc(pformat, 'c');
|
||||||
printf(pformat, m);
|
printf(pformat, m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_it(const char *masterformat, const char *filename,
|
static void print_it(const char *masterformat,
|
||||||
void (*print_func) (char*, char, const char*, const void* IF_SELINUX(, security_context_t scontext)),
|
const char *filename,
|
||||||
|
void FAST_FUNC (*print_func)(char*, char, const char*, const void* IF_SELINUX(, security_context_t scontext)),
|
||||||
const void *data
|
const void *data
|
||||||
IF_SELINUX(, security_context_t scontext) )
|
IF_SELINUX(, security_context_t scontext))
|
||||||
{
|
{
|
||||||
/* Create a working copy of the format string */
|
/* Create a working copy of the format string */
|
||||||
char *format = xstrdup(masterformat);
|
char *format = xstrdup(masterformat);
|
||||||
@ -355,7 +356,7 @@ static void print_it(const char *masterformat, const char *filename,
|
|||||||
free(format);
|
free(format);
|
||||||
free(dest);
|
free(dest);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* FEATURE_STAT_FORMAT */
|
||||||
|
|
||||||
/* Stat the file system and print what we find. */
|
/* Stat the file system and print what we find. */
|
||||||
#if !ENABLE_FEATURE_STAT_FORMAT
|
#if !ENABLE_FEATURE_STAT_FORMAT
|
||||||
@ -364,7 +365,6 @@ static void print_it(const char *masterformat, const char *filename,
|
|||||||
static bool do_statfs(const char *filename, const char *format)
|
static bool do_statfs(const char *filename, const char *format)
|
||||||
{
|
{
|
||||||
struct statfs statfsbuf;
|
struct statfs statfsbuf;
|
||||||
|
|
||||||
#if !ENABLE_FEATURE_STAT_FORMAT
|
#if !ENABLE_FEATURE_STAT_FORMAT
|
||||||
const char *format;
|
const char *format;
|
||||||
#endif
|
#endif
|
||||||
@ -389,7 +389,7 @@ static bool do_statfs(const char *filename, const char *format)
|
|||||||
|
|
||||||
#if ENABLE_FEATURE_STAT_FORMAT
|
#if ENABLE_FEATURE_STAT_FORMAT
|
||||||
if (format == NULL) {
|
if (format == NULL) {
|
||||||
#if !ENABLE_SELINUX
|
# if !ENABLE_SELINUX
|
||||||
format = (option_mask32 & OPT_TERSE
|
format = (option_mask32 & OPT_TERSE
|
||||||
? "%n %i %l %t %s %b %f %a %c %d\n"
|
? "%n %i %l %t %s %b %f %a %c %d\n"
|
||||||
: " File: \"%n\"\n"
|
: " File: \"%n\"\n"
|
||||||
@ -397,7 +397,7 @@ static bool do_statfs(const char *filename, const char *format)
|
|||||||
"Block size: %-10s\n"
|
"Block size: %-10s\n"
|
||||||
"Blocks: Total: %-10b Free: %-10f Available: %a\n"
|
"Blocks: Total: %-10b Free: %-10f Available: %a\n"
|
||||||
"Inodes: Total: %-10c Free: %d");
|
"Inodes: Total: %-10c Free: %d");
|
||||||
#else
|
# else
|
||||||
format = (option_mask32 & OPT_TERSE
|
format = (option_mask32 & OPT_TERSE
|
||||||
? (option_mask32 & OPT_SELINUX ? "%n %i %l %t %s %b %f %a %c %d %C\n":
|
? (option_mask32 & OPT_SELINUX ? "%n %i %l %t %s %b %f %a %c %d %C\n":
|
||||||
"%n %i %l %t %s %b %f %a %c %d\n")
|
"%n %i %l %t %s %b %f %a %c %d\n")
|
||||||
@ -414,7 +414,7 @@ static bool do_statfs(const char *filename, const char *format)
|
|||||||
"Blocks: Total: %-10b Free: %-10f Available: %a\n"
|
"Blocks: Total: %-10b Free: %-10f Available: %a\n"
|
||||||
"Inodes: Total: %-10c Free: %d\n")
|
"Inodes: Total: %-10c Free: %d\n")
|
||||||
);
|
);
|
||||||
#endif /* SELINUX */
|
# endif /* SELINUX */
|
||||||
}
|
}
|
||||||
print_it(format, filename, print_statfs, &statfsbuf IF_SELINUX(, scontext));
|
print_it(format, filename, print_statfs, &statfsbuf IF_SELINUX(, scontext));
|
||||||
#else /* FEATURE_STAT_FORMAT */
|
#else /* FEATURE_STAT_FORMAT */
|
||||||
@ -428,47 +428,48 @@ static bool do_statfs(const char *filename, const char *format)
|
|||||||
statfsbuf.f_namelen);
|
statfsbuf.f_namelen);
|
||||||
|
|
||||||
if (option_mask32 & OPT_TERSE)
|
if (option_mask32 & OPT_TERSE)
|
||||||
printf("%lx ", (unsigned long) (statfsbuf.f_type));
|
printf("%lx ", (unsigned long) statfsbuf.f_type);
|
||||||
else
|
else
|
||||||
printf("Type: %s\n", human_fstype(statfsbuf.f_type));
|
printf("Type: %s\n", human_fstype(statfsbuf.f_type));
|
||||||
|
|
||||||
#if !ENABLE_SELINUX
|
# if !ENABLE_SELINUX
|
||||||
format = (option_mask32 & OPT_TERSE
|
format = (option_mask32 & OPT_TERSE
|
||||||
? "%lu %ld %ld %ld %ld %ld\n"
|
? "%lu %llu %llu %llu %llu %llu\n"
|
||||||
: "Block size: %-10lu\n"
|
: "Block size: %-10lu\n"
|
||||||
"Blocks: Total: %-10jd Free: %-10jd Available: %jd\n"
|
"Blocks: Total: %-10llu Free: %-10llu Available: %llu\n"
|
||||||
"Inodes: Total: %-10jd Free: %jd\n");
|
"Inodes: Total: %-10llu Free: %llu\n");
|
||||||
printf(format,
|
printf(format,
|
||||||
(unsigned long) (statfsbuf.f_bsize),
|
(unsigned long) statfsbuf.f_bsize,
|
||||||
(intmax_t) (statfsbuf.f_blocks),
|
(unsigned long long) statfsbuf.f_blocks,
|
||||||
(intmax_t) (statfsbuf.f_bfree),
|
(unsigned long long) statfsbuf.f_bfree,
|
||||||
(intmax_t) (statfsbuf.f_bavail),
|
(unsigned long long) statfsbuf.f_bavail,
|
||||||
(intmax_t) (statfsbuf.f_files),
|
(unsigned long long) statfsbuf.f_files,
|
||||||
(intmax_t) (statfsbuf.f_ffree));
|
(unsigned long long) statfsbuf.f_ffree);
|
||||||
#else
|
# else
|
||||||
format = (option_mask32 & OPT_TERSE
|
format = (option_mask32 & OPT_TERSE
|
||||||
? (option_mask32 & OPT_SELINUX ? "%lu %ld %ld %ld %ld %ld %C\n":
|
? (option_mask32 & OPT_SELINUX ? "%lu %llu %llu %llu %llu %llu %C\n" : "%lu %llu %llu %llu %llu %llu\n")
|
||||||
"%lu %ld %ld %ld %ld %ld\n")
|
: (option_mask32 & OPT_SELINUX
|
||||||
: (option_mask32 & OPT_SELINUX ?
|
? "Block size: %-10lu\n"
|
||||||
"Block size: %-10lu\n"
|
"Blocks: Total: %-10llu Free: %-10llu Available: %llu\n"
|
||||||
"Blocks: Total: %-10jd Free: %-10jd Available: %jd\n"
|
"Inodes: Total: %-10llu Free: %llu"
|
||||||
"Inodes: Total: %-10jd Free: %jd"
|
"S_context: %C\n"
|
||||||
"S_context: %C\n":
|
: "Block size: %-10lu\n"
|
||||||
"Block size: %-10lu\n"
|
"Blocks: Total: %-10llu Free: %-10llu Available: %llu\n"
|
||||||
"Blocks: Total: %-10jd Free: %-10jd Available: %jd\n"
|
"Inodes: Total: %-10llu Free: %llu\n"
|
||||||
"Inodes: Total: %-10jd Free: %jd\n"));
|
)
|
||||||
|
);
|
||||||
printf(format,
|
printf(format,
|
||||||
(unsigned long) (statfsbuf.f_bsize),
|
(unsigned long) statfsbuf.f_bsize,
|
||||||
(intmax_t) (statfsbuf.f_blocks),
|
(unsigned long long) statfsbuf.f_blocks,
|
||||||
(intmax_t) (statfsbuf.f_bfree),
|
(unsigned long long) statfsbuf.f_bfree,
|
||||||
(intmax_t) (statfsbuf.f_bavail),
|
(unsigned long long) statfsbuf.f_bavail,
|
||||||
(intmax_t) (statfsbuf.f_files),
|
(unsigned long long) statfsbuf.f_files,
|
||||||
(intmax_t) (statfsbuf.f_ffree),
|
(unsigned long long) statfsbuf.f_ffree,
|
||||||
scontext);
|
scontext);
|
||||||
|
|
||||||
if (scontext)
|
if (scontext)
|
||||||
freecon(scontext);
|
freecon(scontext);
|
||||||
#endif
|
# endif
|
||||||
#endif /* FEATURE_STAT_FORMAT */
|
#endif /* FEATURE_STAT_FORMAT */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -501,7 +502,7 @@ static bool do_stat(const char *filename, const char *format)
|
|||||||
|
|
||||||
#if ENABLE_FEATURE_STAT_FORMAT
|
#if ENABLE_FEATURE_STAT_FORMAT
|
||||||
if (format == NULL) {
|
if (format == NULL) {
|
||||||
#if !ENABLE_SELINUX
|
# if !ENABLE_SELINUX
|
||||||
if (option_mask32 & OPT_TERSE) {
|
if (option_mask32 & OPT_TERSE) {
|
||||||
format = "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o";
|
format = "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o";
|
||||||
} else {
|
} else {
|
||||||
@ -522,7 +523,7 @@ static bool do_stat(const char *filename, const char *format)
|
|||||||
"Access: %x\n" "Modify: %y\n" "Change: %z\n";
|
"Access: %x\n" "Modify: %y\n" "Change: %z\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
# else
|
||||||
if (option_mask32 & OPT_TERSE) {
|
if (option_mask32 & OPT_TERSE) {
|
||||||
format = (option_mask32 & OPT_SELINUX ?
|
format = (option_mask32 & OPT_SELINUX ?
|
||||||
"%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o %C\n":
|
"%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o %C\n":
|
||||||
@ -558,21 +559,21 @@ static bool do_stat(const char *filename, const char *format)
|
|||||||
"Access: %x\n" "Modify: %y\n" "Change: %z\n");
|
"Access: %x\n" "Modify: %y\n" "Change: %z\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
print_it(format, filename, print_stat, &statbuf IF_SELINUX(, scontext));
|
print_it(format, filename, print_stat, &statbuf IF_SELINUX(, scontext));
|
||||||
#else /* FEATURE_STAT_FORMAT */
|
#else /* FEATURE_STAT_FORMAT */
|
||||||
if (option_mask32 & OPT_TERSE) {
|
if (option_mask32 & OPT_TERSE) {
|
||||||
printf("%s %ju %ju %lx %lu %lu %jx %ju %lu %lx %lx %lu %lu %lu %lu"
|
printf("%s %llu %llu %lx %lu %lu %llx %llu %lu %lx %lx %lu %lu %lu %lu"
|
||||||
IF_NOT_SELINUX("\n"),
|
IF_NOT_SELINUX("\n"),
|
||||||
filename,
|
filename,
|
||||||
(uintmax_t) (statbuf.st_size),
|
(unsigned long long) statbuf.st_size,
|
||||||
(uintmax_t) statbuf.st_blocks,
|
(unsigned long long) statbuf.st_blocks,
|
||||||
(unsigned long) statbuf.st_mode,
|
(unsigned long) statbuf.st_mode,
|
||||||
(unsigned long) statbuf.st_uid,
|
(unsigned long) statbuf.st_uid,
|
||||||
(unsigned long) statbuf.st_gid,
|
(unsigned long) statbuf.st_gid,
|
||||||
(uintmax_t) statbuf.st_dev,
|
(unsigned long long) statbuf.st_dev,
|
||||||
(uintmax_t) statbuf.st_ino,
|
(unsigned long long) statbuf.st_ino,
|
||||||
(unsigned long) statbuf.st_nlink,
|
(unsigned long) statbuf.st_nlink,
|
||||||
(unsigned long) major(statbuf.st_rdev),
|
(unsigned long) major(statbuf.st_rdev),
|
||||||
(unsigned long) minor(statbuf.st_rdev),
|
(unsigned long) minor(statbuf.st_rdev),
|
||||||
@ -581,12 +582,12 @@ static bool do_stat(const char *filename, const char *format)
|
|||||||
(unsigned long) statbuf.st_ctime,
|
(unsigned long) statbuf.st_ctime,
|
||||||
(unsigned long) statbuf.st_blksize
|
(unsigned long) statbuf.st_blksize
|
||||||
);
|
);
|
||||||
#if ENABLE_SELINUX
|
# if ENABLE_SELINUX
|
||||||
if (option_mask32 & OPT_SELINUX)
|
if (option_mask32 & OPT_SELINUX)
|
||||||
printf(" %lc\n", *scontext);
|
printf(" %lc\n", *scontext);
|
||||||
else
|
else
|
||||||
bb_putchar('\n');
|
bb_putchar('\n');
|
||||||
#endif
|
# endif
|
||||||
} else {
|
} else {
|
||||||
char *linkname = NULL;
|
char *linkname = NULL;
|
||||||
|
|
||||||
@ -604,15 +605,15 @@ static bool do_stat(const char *filename, const char *format)
|
|||||||
else
|
else
|
||||||
printf(" File: \"%s\"\n", filename);
|
printf(" File: \"%s\"\n", filename);
|
||||||
|
|
||||||
printf(" Size: %-10ju\tBlocks: %-10ju IO Block: %-6lu %s\n"
|
printf(" Size: %-10llu\tBlocks: %-10llu IO Block: %-6lu %s\n"
|
||||||
"Device: %jxh/%jud\tInode: %-10ju Links: %-5lu",
|
"Device: %llxh/%llud\tInode: %-10llu Links: %-5lu",
|
||||||
(uintmax_t) (statbuf.st_size),
|
(unsigned long long) statbuf.st_size,
|
||||||
(uintmax_t) statbuf.st_blocks,
|
(unsigned long long) statbuf.st_blocks,
|
||||||
(unsigned long) statbuf.st_blksize,
|
(unsigned long) statbuf.st_blksize,
|
||||||
file_type(&statbuf),
|
file_type(&statbuf),
|
||||||
(uintmax_t) statbuf.st_dev,
|
(unsigned long long) statbuf.st_dev,
|
||||||
(uintmax_t) statbuf.st_dev,
|
(unsigned long long) statbuf.st_dev,
|
||||||
(uintmax_t) statbuf.st_ino,
|
(unsigned long long) statbuf.st_ino,
|
||||||
(unsigned long) statbuf.st_nlink);
|
(unsigned long) statbuf.st_nlink);
|
||||||
if (S_ISBLK(statbuf.st_mode) || S_ISCHR(statbuf.st_mode))
|
if (S_ISBLK(statbuf.st_mode) || S_ISCHR(statbuf.st_mode))
|
||||||
printf(" Device type: %lx,%lx\n",
|
printf(" Device type: %lx,%lx\n",
|
||||||
@ -627,9 +628,9 @@ static bool do_stat(const char *filename, const char *format)
|
|||||||
(pw_ent != NULL) ? pw_ent->pw_name : "UNKNOWN",
|
(pw_ent != NULL) ? pw_ent->pw_name : "UNKNOWN",
|
||||||
(unsigned long) statbuf.st_gid,
|
(unsigned long) statbuf.st_gid,
|
||||||
(gw_ent != NULL) ? gw_ent->gr_name : "UNKNOWN");
|
(gw_ent != NULL) ? gw_ent->gr_name : "UNKNOWN");
|
||||||
#if ENABLE_SELINUX
|
# if ENABLE_SELINUX
|
||||||
printf(" S_Context: %lc\n", *scontext);
|
printf(" S_Context: %lc\n", *scontext);
|
||||||
#endif
|
# endif
|
||||||
printf("Access: %s\n" "Modify: %s\n" "Change: %s\n",
|
printf("Access: %s\n" "Modify: %s\n" "Change: %s\n",
|
||||||
human_time(statbuf.st_atime),
|
human_time(statbuf.st_atime),
|
||||||
human_time(statbuf.st_mtime),
|
human_time(statbuf.st_mtime),
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
@ -215,6 +215,7 @@
|
|||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
# include <arpa/inet.h>
|
# include <arpa/inet.h>
|
||||||
# if !defined(__socklen_t_defined) && !defined(_SOCKLEN_T_DECLARED)
|
# if !defined(__socklen_t_defined) && !defined(_SOCKLEN_T_DECLARED)
|
||||||
|
# define socklen_t bb_socklen_t
|
||||||
typedef int socklen_t;
|
typedef int socklen_t;
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
@ -250,21 +251,6 @@ typedef int socklen_t;
|
|||||||
#if defined __GLIBC__ || defined __UCLIBC__ \
|
#if defined __GLIBC__ || defined __UCLIBC__ \
|
||||||
|| defined __dietlibc__ || defined _NEWLIB_VERSION
|
|| defined __dietlibc__ || defined _NEWLIB_VERSION
|
||||||
# include <features.h>
|
# include <features.h>
|
||||||
# define HAVE_FEATURES_H
|
|
||||||
# include <stdint.h>
|
|
||||||
# define HAVE_STDINT_H
|
|
||||||
#elif !defined __APPLE__
|
|
||||||
/* Largest integral types. */
|
|
||||||
# if BB_BIG_ENDIAN
|
|
||||||
/* Looks BROKEN! */
|
|
||||||
typedef long intmax_t;
|
|
||||||
typedef unsigned long uintmax_t;
|
|
||||||
# else
|
|
||||||
__extension__
|
|
||||||
typedef long long intmax_t;
|
|
||||||
__extension__
|
|
||||||
typedef unsigned long long uintmax_t;
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Size-saving "small" ints (arch-dependent) */
|
/* Size-saving "small" ints (arch-dependent) */
|
||||||
|
Loading…
Reference in New Issue
Block a user