2006-07-02 19:47:05 +00:00
|
|
|
/* vi: set sw=4 ts=4: */
|
2005-04-23 06:26:38 +00:00
|
|
|
/*
|
|
|
|
* stat -- display file or file system status
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation.
|
|
|
|
* Copyright (C) 2005 by Erik Andersen <andersen@codepoet.org>
|
|
|
|
* Copyright (C) 2005 by Mike Frysinger <vapier@gentoo.org>
|
2007-03-10 16:58:49 +00:00
|
|
|
* Copyright (C) 2006 by Yoshinori Sato <ysato@users.sourceforge.jp>
|
2005-04-23 06:26:38 +00:00
|
|
|
*
|
|
|
|
* Written by Michael Meskes
|
|
|
|
* Taken from coreutils and turned into a busybox applet by Mike Frysinger
|
|
|
|
*
|
2006-04-05 17:19:37 +00:00
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
2005-04-23 06:26:38 +00:00
|
|
|
*/
|
|
|
|
|
2007-05-26 19:00:18 +00:00
|
|
|
#include "libbb.h"
|
2005-04-23 06:26:38 +00:00
|
|
|
|
|
|
|
/* vars to control behavior */
|
2007-10-05 20:31:23 +00:00
|
|
|
#define OPT_FILESYS (1 << 0)
|
|
|
|
#define OPT_TERSE (1 << 1)
|
|
|
|
#define OPT_DEREFERENCE (1 << 2)
|
|
|
|
#define OPT_SELINUX (1 << 3)
|
2005-04-23 06:26:38 +00:00
|
|
|
|
2007-10-05 20:31:23 +00:00
|
|
|
static const char *file_type(const struct stat *st)
|
2005-04-23 06:26:38 +00:00
|
|
|
{
|
2006-01-25 00:08:53 +00:00
|
|
|
/* See POSIX 1003.1-2001 XCU Table 4-8 lines 17093-17107
|
2005-04-23 06:26:38 +00:00
|
|
|
* for some of these formats.
|
2006-01-25 00:08:53 +00:00
|
|
|
* To keep diagnostics grammatical in English, the
|
2005-04-23 06:26:38 +00:00
|
|
|
* returned string must start with a consonant.
|
|
|
|
*/
|
|
|
|
if (S_ISREG(st->st_mode)) return st->st_size == 0 ? "regular empty file" : "regular file";
|
|
|
|
if (S_ISDIR(st->st_mode)) return "directory";
|
|
|
|
if (S_ISBLK(st->st_mode)) return "block special file";
|
|
|
|
if (S_ISCHR(st->st_mode)) return "character special file";
|
|
|
|
if (S_ISFIFO(st->st_mode)) return "fifo";
|
|
|
|
if (S_ISLNK(st->st_mode)) return "symbolic link";
|
|
|
|
if (S_ISSOCK(st->st_mode)) return "socket";
|
|
|
|
if (S_TYPEISMQ(st)) return "message queue";
|
|
|
|
if (S_TYPEISSEM(st)) return "semaphore";
|
|
|
|
if (S_TYPEISSHM(st)) return "shared memory object";
|
|
|
|
#ifdef S_TYPEISTMO
|
|
|
|
if (S_TYPEISTMO(st)) return "typed memory object";
|
|
|
|
#endif
|
|
|
|
return "weird file";
|
|
|
|
}
|
|
|
|
|
2007-10-05 20:31:23 +00:00
|
|
|
static const char *human_time(time_t t)
|
2005-04-23 06:26:38 +00:00
|
|
|
{
|
2006-11-21 00:12:09 +00:00
|
|
|
/* Old
|
2005-04-23 06:26:38 +00:00
|
|
|
static char *str;
|
|
|
|
str = ctime(&t);
|
|
|
|
str[strlen(str)-1] = '\0';
|
|
|
|
return str;
|
2006-11-21 00:12:09 +00:00
|
|
|
*/
|
|
|
|
/* coreutils 6.3 compat: */
|
2007-04-04 13:58:33 +00:00
|
|
|
|
2007-10-05 20:31:23 +00:00
|
|
|
/*static char buf[sizeof("YYYY-MM-DD HH:MM:SS.000000000")] ALIGN1;*/
|
|
|
|
#define buf bb_common_bufsiz1
|
|
|
|
|
2006-11-21 00:12:09 +00:00
|
|
|
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S.000000000", localtime(&t));
|
|
|
|
return buf;
|
2007-10-05 20:31:23 +00:00
|
|
|
#undef buf
|
2005-04-23 06:26:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the type of the specified file system.
|
|
|
|
* Some systems have statfvs.f_basetype[FSTYPSZ]. (AIX, HP-UX, and Solaris)
|
|
|
|
* Others have statfs.f_fstypename[MFSNAMELEN]. (NetBSD 1.5.2)
|
|
|
|
* Still others have neither and have to get by with f_type (Linux).
|
|
|
|
*/
|
2007-10-05 20:31:23 +00:00
|
|
|
static const char *human_fstype(uint32_t f_type)
|
2005-04-23 06:26:38 +00:00
|
|
|
{
|
2007-04-08 16:07:02 +00:00
|
|
|
static const struct types {
|
2007-10-05 20:31:23 +00:00
|
|
|
uint32_t type;
|
2007-08-12 20:58:27 +00:00
|
|
|
const char *const fs;
|
2005-04-24 04:11:44 +00:00
|
|
|
} humantypes[] = {
|
|
|
|
{ 0xADFF, "affs" },
|
|
|
|
{ 0x1Cd1, "devpts" },
|
|
|
|
{ 0x137D, "ext" },
|
|
|
|
{ 0xEF51, "ext2" },
|
|
|
|
{ 0xEF53, "ext2/ext3" },
|
|
|
|
{ 0x3153464a, "jfs" },
|
|
|
|
{ 0x58465342, "xfs" },
|
|
|
|
{ 0xF995E849, "hpfs" },
|
|
|
|
{ 0x9660, "isofs" },
|
|
|
|
{ 0x4000, "isofs" },
|
|
|
|
{ 0x4004, "isofs" },
|
|
|
|
{ 0x137F, "minix" },
|
|
|
|
{ 0x138F, "minix (30 char.)" },
|
|
|
|
{ 0x2468, "minix v2" },
|
|
|
|
{ 0x2478, "minix v2 (30 char.)" },
|
|
|
|
{ 0x4d44, "msdos" },
|
|
|
|
{ 0x4006, "fat" },
|
|
|
|
{ 0x564c, "novell" },
|
|
|
|
{ 0x6969, "nfs" },
|
|
|
|
{ 0x9fa0, "proc" },
|
|
|
|
{ 0x517B, "smb" },
|
|
|
|
{ 0x012FF7B4, "xenix" },
|
|
|
|
{ 0x012FF7B5, "sysv4" },
|
|
|
|
{ 0x012FF7B6, "sysv2" },
|
|
|
|
{ 0x012FF7B7, "coh" },
|
|
|
|
{ 0x00011954, "ufs" },
|
|
|
|
{ 0x012FD16D, "xia" },
|
|
|
|
{ 0x5346544e, "ntfs" },
|
|
|
|
{ 0x1021994, "tmpfs" },
|
|
|
|
{ 0x52654973, "reiserfs" },
|
|
|
|
{ 0x28cd3d45, "cramfs" },
|
|
|
|
{ 0x7275, "romfs" },
|
|
|
|
{ 0x858458f6, "romfs" },
|
|
|
|
{ 0x73717368, "squashfs" },
|
|
|
|
{ 0x62656572, "sysfs" },
|
2006-02-22 17:01:00 +00:00
|
|
|
{ 0, "UNKNOWN" }
|
2005-04-24 04:11:44 +00:00
|
|
|
};
|
2007-10-05 20:31:23 +00:00
|
|
|
|
|
|
|
int i;
|
|
|
|
|
2007-04-08 16:07:02 +00:00
|
|
|
for (i = 0; humantypes[i].type; ++i)
|
2005-04-24 04:11:44 +00:00
|
|
|
if (humantypes[i].type == f_type)
|
2006-02-22 17:01:00 +00:00
|
|
|
break;
|
2005-04-24 04:11:44 +00:00
|
|
|
return humantypes[i].fs;
|
2005-04-23 06:26:38 +00:00
|
|
|
}
|
|
|
|
|
2007-10-05 20:31:23 +00:00
|
|
|
static void strcatc(char *str, char c)
|
|
|
|
{
|
|
|
|
int len = strlen(str);
|
|
|
|
str[len++] = c;
|
|
|
|
str[len] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
static void printfs(char *pformat, const char *msg)
|
|
|
|
{
|
|
|
|
strcatc(pformat, 's');
|
|
|
|
printf(pformat, msg);
|
|
|
|
}
|
|
|
|
|
2007-04-08 16:07:02 +00:00
|
|
|
#if ENABLE_FEATURE_STAT_FORMAT
|
2005-04-23 06:26:38 +00:00
|
|
|
/* print statfs info */
|
2007-10-05 20:31:23 +00:00
|
|
|
static void print_statfs(char *pformat, const char m,
|
|
|
|
const char *const filename, const void *data
|
|
|
|
USE_SELINUX(, security_context_t scontext))
|
2005-04-23 06:26:38 +00:00
|
|
|
{
|
2007-10-05 20:31:23 +00:00
|
|
|
const struct statfs *statfsbuf = data;
|
2007-04-04 13:58:33 +00:00
|
|
|
if (m == 'n') {
|
2007-10-05 20:31:23 +00:00
|
|
|
printfs(pformat, filename);
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'i') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "Lx");
|
2005-04-23 06:26:38 +00:00
|
|
|
printf(pformat, statfsbuf->f_fsid);
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'l') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "lu");
|
2005-04-23 06:26:38 +00:00
|
|
|
printf(pformat, statfsbuf->f_namelen);
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 't') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "lx");
|
2007-04-13 23:22:00 +00:00
|
|
|
printf(pformat, (unsigned long) (statfsbuf->f_type)); /* no equiv */
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'T') {
|
2007-10-05 20:31:23 +00:00
|
|
|
printfs(pformat, human_fstype(statfsbuf->f_type));
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'b') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "jd");
|
2005-04-23 06:26:38 +00:00
|
|
|
printf(pformat, (intmax_t) (statfsbuf->f_blocks));
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'f') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "jd");
|
2005-04-23 06:26:38 +00:00
|
|
|
printf(pformat, (intmax_t) (statfsbuf->f_bfree));
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'a') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "jd");
|
2005-04-23 06:26:38 +00:00
|
|
|
printf(pformat, (intmax_t) (statfsbuf->f_bavail));
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 's' || m == 'S') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "lu");
|
2007-04-13 23:22:00 +00:00
|
|
|
printf(pformat, (unsigned long) (statfsbuf->f_bsize));
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'c') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "jd");
|
2005-04-23 06:26:38 +00:00
|
|
|
printf(pformat, (intmax_t) (statfsbuf->f_files));
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'd') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "jd");
|
2005-04-23 06:26:38 +00:00
|
|
|
printf(pformat, (intmax_t) (statfsbuf->f_ffree));
|
2007-03-10 16:58:49 +00:00
|
|
|
#if ENABLE_SELINUX
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'C' && (option_mask32 & OPT_SELINUX)) {
|
2007-10-05 20:31:23 +00:00
|
|
|
printfs(pformat, scontext);
|
2007-03-10 16:58:49 +00:00
|
|
|
#endif
|
2007-04-04 13:58:33 +00:00
|
|
|
} else {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcatc(pformat, 'c');
|
2005-04-23 06:26:38 +00:00
|
|
|
printf(pformat, m);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* print stat info */
|
2007-10-05 20:31:23 +00:00
|
|
|
static void print_stat(char *pformat, const char m,
|
|
|
|
const char *const filename, const void *data
|
|
|
|
USE_SELINUX(, security_context_t scontext))
|
2005-04-23 06:26:38 +00:00
|
|
|
{
|
|
|
|
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
|
|
|
struct stat *statbuf = (struct stat *) data;
|
|
|
|
struct passwd *pw_ent;
|
|
|
|
struct group *gw_ent;
|
|
|
|
|
2007-04-04 13:58:33 +00:00
|
|
|
if (m == 'n') {
|
2007-10-05 20:31:23 +00:00
|
|
|
printfs(pformat, filename);
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'N') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcatc(pformat, 's');
|
2005-04-23 06:26:38 +00:00
|
|
|
if (S_ISLNK(statbuf->st_mode)) {
|
2007-02-11 16:19:28 +00:00
|
|
|
char *linkname = xmalloc_readlink_or_warn(filename);
|
2007-10-05 20:31:23 +00:00
|
|
|
if (linkname == NULL)
|
2005-04-23 06:26:38 +00:00
|
|
|
return;
|
|
|
|
/*printf("\"%s\" -> \"%s\"", filename, linkname); */
|
|
|
|
printf(pformat, filename);
|
|
|
|
printf(" -> ");
|
|
|
|
printf(pformat, linkname);
|
2007-10-05 20:31:23 +00:00
|
|
|
free(linkname);
|
2005-04-23 06:26:38 +00:00
|
|
|
} else {
|
|
|
|
printf(pformat, filename);
|
|
|
|
}
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'd') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "ju");
|
2005-04-23 06:26:38 +00:00
|
|
|
printf(pformat, (uintmax_t) statbuf->st_dev);
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'D') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "jx");
|
2005-04-23 06:26:38 +00:00
|
|
|
printf(pformat, (uintmax_t) statbuf->st_dev);
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'i') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "ju");
|
2005-04-23 06:26:38 +00:00
|
|
|
printf(pformat, (uintmax_t) statbuf->st_ino);
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'a') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "lo");
|
2007-04-13 23:22:00 +00:00
|
|
|
printf(pformat, (unsigned long) (statbuf->st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)));
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'A') {
|
2007-10-05 20:31:23 +00:00
|
|
|
printfs(pformat, bb_mode_string(statbuf->st_mode));
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'f') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "lx");
|
2007-04-13 23:22:00 +00:00
|
|
|
printf(pformat, (unsigned long) statbuf->st_mode);
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'F') {
|
2007-10-05 20:31:23 +00:00
|
|
|
printfs(pformat, file_type(statbuf));
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'h') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "lu");
|
2007-04-13 23:22:00 +00:00
|
|
|
printf(pformat, (unsigned long) statbuf->st_nlink);
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'u') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "lu");
|
2007-04-13 23:22:00 +00:00
|
|
|
printf(pformat, (unsigned long) statbuf->st_uid);
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'U') {
|
2005-04-23 06:26:38 +00:00
|
|
|
setpwent();
|
|
|
|
pw_ent = getpwuid(statbuf->st_uid);
|
2007-10-05 20:31:23 +00:00
|
|
|
printfs(pformat, (pw_ent != 0L) ? pw_ent->pw_name : "UNKNOWN");
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'g') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "lu");
|
2007-04-13 23:22:00 +00:00
|
|
|
printf(pformat, (unsigned long) statbuf->st_gid);
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'G') {
|
2005-04-23 06:26:38 +00:00
|
|
|
setgrent();
|
|
|
|
gw_ent = getgrgid(statbuf->st_gid);
|
2007-10-05 20:31:23 +00:00
|
|
|
printfs(pformat, (gw_ent != 0L) ? gw_ent->gr_name : "UNKNOWN");
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 't') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "lx");
|
2007-04-13 23:22:00 +00:00
|
|
|
printf(pformat, (unsigned long) major(statbuf->st_rdev));
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'T') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "lx");
|
2007-04-13 23:22:00 +00:00
|
|
|
printf(pformat, (unsigned long) minor(statbuf->st_rdev));
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 's') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "ju");
|
2005-04-23 06:26:38 +00:00
|
|
|
printf(pformat, (uintmax_t) (statbuf->st_size));
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'B') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "lu");
|
2007-04-13 23:22:00 +00:00
|
|
|
printf(pformat, (unsigned long) 512); //ST_NBLOCKSIZE
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'b') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "ju");
|
2005-04-23 06:26:38 +00:00
|
|
|
printf(pformat, (uintmax_t) statbuf->st_blocks);
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'o') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, "lu");
|
2007-04-13 23:22:00 +00:00
|
|
|
printf(pformat, (unsigned long) statbuf->st_blksize);
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'x') {
|
2007-10-05 20:31:23 +00:00
|
|
|
printfs(pformat, human_time(statbuf->st_atime));
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'X') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, TYPE_SIGNED(time_t) ? "ld" : "lu");
|
2007-04-13 23:22:00 +00:00
|
|
|
printf(pformat, (unsigned long) statbuf->st_atime);
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'y') {
|
2007-10-05 20:31:23 +00:00
|
|
|
printfs(pformat, human_time(statbuf->st_mtime));
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'Y') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, TYPE_SIGNED(time_t) ? "ld" : "lu");
|
2007-04-13 23:22:00 +00:00
|
|
|
printf(pformat, (unsigned long) statbuf->st_mtime);
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'z') {
|
2007-10-05 20:31:23 +00:00
|
|
|
printfs(pformat, human_time(statbuf->st_ctime));
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'Z') {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcat(pformat, TYPE_SIGNED(time_t) ? "ld" : "lu");
|
2007-04-13 23:22:00 +00:00
|
|
|
printf(pformat, (unsigned long) statbuf->st_ctime);
|
2007-03-10 16:58:49 +00:00
|
|
|
#if ENABLE_SELINUX
|
2007-04-04 13:58:33 +00:00
|
|
|
} else if (m == 'C' && (option_mask32 & OPT_SELINUX)) {
|
2007-10-05 20:31:23 +00:00
|
|
|
printfs(pformat, scontext);
|
2007-03-10 16:58:49 +00:00
|
|
|
#endif
|
2007-04-04 13:58:33 +00:00
|
|
|
} else {
|
2007-10-05 20:31:23 +00:00
|
|
|
strcatc(pformat, 'c');
|
2005-04-23 06:26:38 +00:00
|
|
|
printf(pformat, m);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-05 20:31:23 +00:00
|
|
|
static void print_it(const char *masterformat, const char *filename,
|
|
|
|
void (*print_func) (char*, char, const char*, const void* USE_SELINUX(, security_context_t scontext)),
|
|
|
|
const void *data
|
|
|
|
USE_SELINUX(, security_context_t scontext) )
|
2005-04-23 06:26:38 +00:00
|
|
|
{
|
2007-10-05 20:31:23 +00:00
|
|
|
/* Create a working copy of the format string */
|
2006-08-03 15:41:12 +00:00
|
|
|
char *format = xstrdup(masterformat);
|
2006-11-21 00:12:09 +00:00
|
|
|
/* Add 2 to accomodate our conversion of the stat '%s' format string
|
|
|
|
* to the printf '%llu' one. */
|
2007-10-05 20:31:23 +00:00
|
|
|
char *dest = xmalloc(strlen(format) + 2 + 1);
|
|
|
|
char *b;
|
2005-04-23 06:26:38 +00:00
|
|
|
|
|
|
|
b = format;
|
|
|
|
while (b) {
|
2006-11-21 00:12:09 +00:00
|
|
|
size_t len;
|
2005-04-23 06:26:38 +00:00
|
|
|
char *p = strchr(b, '%');
|
2006-11-21 00:12:09 +00:00
|
|
|
if (!p) {
|
2007-10-05 20:31:23 +00:00
|
|
|
/* coreutils 6.3 always prints <cr> at the end */
|
2006-11-21 00:12:09 +00:00
|
|
|
/*fputs(b, stdout);*/
|
|
|
|
puts(b);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
*p++ = '\0';
|
|
|
|
fputs(b, stdout);
|
|
|
|
|
2007-10-05 20:31:23 +00:00
|
|
|
/* dest = "%<modifiers>" */
|
2006-11-21 00:12:09 +00:00
|
|
|
len = strspn(p, "#-+.I 0123456789");
|
|
|
|
dest[0] = '%';
|
|
|
|
memcpy(dest + 1, p, len);
|
2007-10-05 20:31:23 +00:00
|
|
|
dest[1 + len] = '\0';
|
2006-11-21 00:12:09 +00:00
|
|
|
p += len;
|
|
|
|
|
|
|
|
b = p + 1;
|
|
|
|
switch (*p) {
|
|
|
|
case '\0':
|
2005-04-23 06:26:38 +00:00
|
|
|
b = NULL;
|
2006-11-21 00:12:09 +00:00
|
|
|
/* fall through */
|
|
|
|
case '%':
|
2007-09-27 10:20:47 +00:00
|
|
|
bb_putchar('%');
|
2006-11-21 00:12:09 +00:00
|
|
|
break;
|
|
|
|
default:
|
2007-10-05 20:31:23 +00:00
|
|
|
/* Completes "%<modifiers>" with specifier and printfs */
|
|
|
|
print_func(dest, *p, filename, data USE_SELINUX(,scontext));
|
2006-11-21 00:12:09 +00:00
|
|
|
break;
|
2005-04-23 06:26:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free(format);
|
|
|
|
free(dest);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Stat the file system and print what we find. */
|
2007-10-05 20:31:23 +00:00
|
|
|
static bool do_statfs(const char *filename, const char *format)
|
2005-04-23 06:26:38 +00:00
|
|
|
{
|
|
|
|
struct statfs statfsbuf;
|
2007-03-10 16:58:49 +00:00
|
|
|
#if ENABLE_SELINUX
|
|
|
|
security_context_t scontext = NULL;
|
2007-04-04 13:58:33 +00:00
|
|
|
|
|
|
|
if (option_mask32 & OPT_SELINUX) {
|
2007-08-09 08:10:13 +00:00
|
|
|
if ((option_mask32 & OPT_DEREFERENCE
|
|
|
|
? lgetfilecon(filename, &scontext)
|
|
|
|
: getfilecon(filename, &scontext)
|
|
|
|
) < 0
|
|
|
|
) {
|
2007-03-10 16:58:49 +00:00
|
|
|
bb_perror_msg(filename);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2005-04-23 06:26:38 +00:00
|
|
|
if (statfs(filename, &statfsbuf) != 0) {
|
|
|
|
bb_perror_msg("cannot read file system information for '%s'", filename);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-04-08 16:07:02 +00:00
|
|
|
#if ENABLE_FEATURE_STAT_FORMAT
|
2007-10-05 20:31:23 +00:00
|
|
|
if (format == NULL) {
|
2007-04-08 16:07:02 +00:00
|
|
|
#if !ENABLE_SELINUX
|
2007-04-04 13:58:33 +00:00
|
|
|
format = (option_mask32 & OPT_TERSE
|
2005-07-26 22:39:56 +00:00
|
|
|
? "%n %i %l %t %s %b %f %a %c %d\n"
|
2005-04-23 06:26:38 +00:00
|
|
|
: " File: \"%n\"\n"
|
|
|
|
" ID: %-8i Namelen: %-7l Type: %T\n"
|
2005-07-26 22:39:56 +00:00
|
|
|
"Block size: %-10s\n"
|
2005-04-23 06:26:38 +00:00
|
|
|
"Blocks: Total: %-10b Free: %-10f Available: %a\n"
|
2006-11-21 00:12:09 +00:00
|
|
|
"Inodes: Total: %-10c Free: %d");
|
2005-04-23 06:26:38 +00:00
|
|
|
#else
|
2007-10-05 20:31:23 +00:00
|
|
|
format = (option_mask32 & OPT_TERSE
|
2007-04-04 13:58:33 +00:00
|
|
|
? (option_mask32 & OPT_SELINUX ? "%n %i %l %t %s %b %f %a %c %d %C\n":
|
2007-03-10 16:58:49 +00:00
|
|
|
"%n %i %l %t %s %b %f %a %c %d\n")
|
2007-04-04 13:58:33 +00:00
|
|
|
: (option_mask32 & OPT_SELINUX ?
|
2007-03-10 16:58:49 +00:00
|
|
|
" File: \"%n\"\n"
|
|
|
|
" ID: %-8i Namelen: %-7l Type: %T\n"
|
|
|
|
"Block size: %-10s\n"
|
|
|
|
"Blocks: Total: %-10b Free: %-10f Available: %a\n"
|
|
|
|
"Inodes: Total: %-10c Free: %d"
|
|
|
|
" S_context: %C\n":
|
|
|
|
" File: \"%n\"\n"
|
|
|
|
" ID: %-8i Namelen: %-7l Type: %T\n"
|
|
|
|
"Block size: %-10s\n"
|
|
|
|
"Blocks: Total: %-10b Free: %-10f Available: %a\n"
|
|
|
|
"Inodes: Total: %-10c Free: %d\n")
|
|
|
|
);
|
|
|
|
#endif /* SELINUX */
|
2007-10-05 20:31:23 +00:00
|
|
|
}
|
|
|
|
print_it(format, filename, print_statfs, &statfsbuf USE_SELINUX(, scontext));
|
2007-03-10 16:58:49 +00:00
|
|
|
#else /* FEATURE_STAT_FORMAT */
|
2007-04-04 13:58:33 +00:00
|
|
|
format = (option_mask32 & OPT_TERSE
|
2006-03-29 22:34:47 +00:00
|
|
|
? "%s %llx %lu "
|
2005-04-23 06:26:38 +00:00
|
|
|
: " File: \"%s\"\n"
|
|
|
|
" ID: %-8Lx Namelen: %-7lu ");
|
|
|
|
printf(format,
|
|
|
|
filename,
|
|
|
|
statfsbuf.f_fsid,
|
|
|
|
statfsbuf.f_namelen);
|
|
|
|
|
2007-04-04 13:58:33 +00:00
|
|
|
if (option_mask32 & OPT_TERSE)
|
2007-04-13 23:22:00 +00:00
|
|
|
printf("%lx ", (unsigned long) (statfsbuf.f_type));
|
2005-04-23 06:26:38 +00:00
|
|
|
else
|
|
|
|
printf("Type: %s\n", human_fstype(statfsbuf.f_type));
|
|
|
|
|
2007-03-10 16:58:49 +00:00
|
|
|
#if !ENABLE_SELINUX
|
2007-04-04 13:58:33 +00:00
|
|
|
format = (option_mask32 & OPT_TERSE
|
2005-07-26 22:39:56 +00:00
|
|
|
? "%lu %ld %ld %ld %ld %ld\n"
|
|
|
|
: "Block size: %-10lu\n"
|
2006-04-12 08:03:11 +00:00
|
|
|
"Blocks: Total: %-10jd Free: %-10jd Available: %jd\n"
|
|
|
|
"Inodes: Total: %-10jd Free: %jd\n");
|
2005-04-23 06:26:38 +00:00
|
|
|
printf(format,
|
2007-04-13 23:22:00 +00:00
|
|
|
(unsigned long) (statfsbuf.f_bsize),
|
2005-04-23 06:26:38 +00:00
|
|
|
(intmax_t) (statfsbuf.f_blocks),
|
|
|
|
(intmax_t) (statfsbuf.f_bfree),
|
|
|
|
(intmax_t) (statfsbuf.f_bavail),
|
|
|
|
(intmax_t) (statfsbuf.f_files),
|
|
|
|
(intmax_t) (statfsbuf.f_ffree));
|
2007-03-10 16:58:49 +00:00
|
|
|
#else
|
2007-04-04 13:58:33 +00:00
|
|
|
format = (option_mask32 & OPT_TERSE
|
|
|
|
? (option_mask32 & OPT_SELINUX ? "%lu %ld %ld %ld %ld %ld %C\n":
|
2007-03-10 16:58:49 +00:00
|
|
|
"%lu %ld %ld %ld %ld %ld\n")
|
2007-04-04 13:58:33 +00:00
|
|
|
: (option_mask32 & OPT_SELINUX ?
|
2007-03-10 16:58:49 +00:00
|
|
|
"Block size: %-10lu\n"
|
|
|
|
"Blocks: Total: %-10jd Free: %-10jd Available: %jd\n"
|
|
|
|
"Inodes: Total: %-10jd Free: %jd"
|
|
|
|
"S_context: %C\n":
|
|
|
|
"Block size: %-10lu\n"
|
|
|
|
"Blocks: Total: %-10jd Free: %-10jd Available: %jd\n"
|
|
|
|
"Inodes: Total: %-10jd Free: %jd\n"));
|
|
|
|
printf(format,
|
2007-04-13 23:22:00 +00:00
|
|
|
(unsigned long) (statfsbuf.f_bsize),
|
2007-03-10 16:58:49 +00:00
|
|
|
(intmax_t) (statfsbuf.f_blocks),
|
|
|
|
(intmax_t) (statfsbuf.f_bfree),
|
|
|
|
(intmax_t) (statfsbuf.f_bavail),
|
|
|
|
(intmax_t) (statfsbuf.f_files),
|
|
|
|
(intmax_t) (statfsbuf.f_ffree),
|
|
|
|
scontext);
|
2005-04-23 06:26:38 +00:00
|
|
|
|
2007-03-10 16:58:49 +00:00
|
|
|
if (scontext)
|
|
|
|
freecon(scontext);
|
|
|
|
#endif
|
|
|
|
#endif /* FEATURE_STAT_FORMAT */
|
2005-04-23 06:26:38 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* stat the file and print what we find */
|
2007-10-05 20:31:23 +00:00
|
|
|
static bool do_stat(const char *filename, const char *format)
|
2005-04-23 06:26:38 +00:00
|
|
|
{
|
|
|
|
struct stat statbuf;
|
2007-03-10 16:58:49 +00:00
|
|
|
#if ENABLE_SELINUX
|
|
|
|
security_context_t scontext = NULL;
|
2007-04-04 13:58:33 +00:00
|
|
|
|
|
|
|
if (option_mask32 & OPT_SELINUX) {
|
2007-08-09 08:10:13 +00:00
|
|
|
if ((option_mask32 & OPT_DEREFERENCE
|
|
|
|
? lgetfilecon(filename, &scontext)
|
|
|
|
: getfilecon(filename, &scontext)
|
|
|
|
) < 0
|
|
|
|
) {
|
|
|
|
bb_perror_msg(filename);
|
2007-03-10 16:58:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2007-04-04 13:58:33 +00:00
|
|
|
if ((option_mask32 & OPT_DEREFERENCE ? stat : lstat) (filename, &statbuf) != 0) {
|
2005-04-23 06:26:38 +00:00
|
|
|
bb_perror_msg("cannot stat '%s'", filename);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-04-08 16:07:02 +00:00
|
|
|
#if ENABLE_FEATURE_STAT_FORMAT
|
2005-04-23 06:26:38 +00:00
|
|
|
if (format == NULL) {
|
2007-04-08 16:07:02 +00:00
|
|
|
#if !ENABLE_SELINUX
|
2007-04-04 13:58:33 +00:00
|
|
|
if (option_mask32 & OPT_TERSE) {
|
2006-11-21 00:12:09 +00:00
|
|
|
format = "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o";
|
2005-04-23 06:26:38 +00:00
|
|
|
} else {
|
|
|
|
if (S_ISBLK(statbuf.st_mode) || S_ISCHR(statbuf.st_mode)) {
|
|
|
|
format =
|
|
|
|
" File: \"%N\"\n"
|
|
|
|
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
|
|
|
|
"Device: %Dh/%dd\tInode: %-10i Links: %-5h"
|
|
|
|
" Device type: %t,%T\n"
|
|
|
|
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
|
|
|
|
"Access: %x\n" "Modify: %y\n" "Change: %z\n";
|
|
|
|
} else {
|
|
|
|
format =
|
|
|
|
" File: \"%N\"\n"
|
|
|
|
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
|
|
|
|
"Device: %Dh/%dd\tInode: %-10i Links: %h\n"
|
|
|
|
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
|
|
|
|
"Access: %x\n" "Modify: %y\n" "Change: %z\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2007-04-04 13:58:33 +00:00
|
|
|
if (option_mask32 & OPT_TERSE) {
|
|
|
|
format = (option_mask32 & OPT_SELINUX ?
|
2007-03-10 16:58:49 +00:00
|
|
|
"%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\n");
|
|
|
|
} else {
|
|
|
|
if (S_ISBLK(statbuf.st_mode) || S_ISCHR(statbuf.st_mode)) {
|
2007-04-04 13:58:33 +00:00
|
|
|
format = (option_mask32 & OPT_SELINUX ?
|
2007-03-10 16:58:49 +00:00
|
|
|
" File: \"%N\"\n"
|
|
|
|
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
|
|
|
|
"Device: %Dh/%dd\tInode: %-10i Links: %-5h"
|
|
|
|
" Device type: %t,%T\n"
|
|
|
|
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
|
|
|
|
" S_Context: %C\n"
|
|
|
|
"Access: %x\n" "Modify: %y\n" "Change: %z\n":
|
|
|
|
" File: \"%N\"\n"
|
|
|
|
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
|
|
|
|
"Device: %Dh/%dd\tInode: %-10i Links: %-5h"
|
|
|
|
" Device type: %t,%T\n"
|
|
|
|
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
|
|
|
|
"Access: %x\n" "Modify: %y\n" "Change: %z\n");
|
|
|
|
} else {
|
2007-04-04 13:58:33 +00:00
|
|
|
format = (option_mask32 & OPT_SELINUX ?
|
2007-03-10 16:58:49 +00:00
|
|
|
" File: \"%N\"\n"
|
|
|
|
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
|
|
|
|
"Device: %Dh/%dd\tInode: %-10i Links: %h\n"
|
|
|
|
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
|
|
|
|
"S_Context: %C\n"
|
|
|
|
"Access: %x\n" "Modify: %y\n" "Change: %z\n":
|
|
|
|
" File: \"%N\"\n"
|
|
|
|
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
|
|
|
|
"Device: %Dh/%dd\tInode: %-10i Links: %h\n"
|
|
|
|
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
|
|
|
|
"Access: %x\n" "Modify: %y\n" "Change: %z\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
print_it(format, filename, print_stat, &statbuf USE_SELINUX(, scontext));
|
|
|
|
#else /* FEATURE_STAT_FORMAT */
|
2007-04-04 13:58:33 +00:00
|
|
|
if (option_mask32 & OPT_TERSE) {
|
2007-03-10 16:58:49 +00:00
|
|
|
printf("%s %ju %ju %lx %lu %lu %jx %ju %lu %lx %lx %lu %lu %lu %lu"
|
|
|
|
SKIP_SELINUX("\n"),
|
2005-04-23 06:26:38 +00:00
|
|
|
filename,
|
|
|
|
(uintmax_t) (statbuf.st_size),
|
|
|
|
(uintmax_t) statbuf.st_blocks,
|
2007-04-13 23:22:00 +00:00
|
|
|
(unsigned long) statbuf.st_mode,
|
|
|
|
(unsigned long) statbuf.st_uid,
|
|
|
|
(unsigned long) statbuf.st_gid,
|
2005-04-23 06:26:38 +00:00
|
|
|
(uintmax_t) statbuf.st_dev,
|
|
|
|
(uintmax_t) statbuf.st_ino,
|
2007-04-13 23:22:00 +00:00
|
|
|
(unsigned long) statbuf.st_nlink,
|
|
|
|
(unsigned long) major(statbuf.st_rdev),
|
|
|
|
(unsigned long) minor(statbuf.st_rdev),
|
|
|
|
(unsigned long) statbuf.st_atime,
|
|
|
|
(unsigned long) statbuf.st_mtime,
|
|
|
|
(unsigned long) statbuf.st_ctime,
|
|
|
|
(unsigned long) statbuf.st_blksize
|
2005-04-23 06:26:38 +00:00
|
|
|
);
|
2007-03-10 16:58:49 +00:00
|
|
|
#if ENABLE_SELINUX
|
2007-04-04 13:58:33 +00:00
|
|
|
if (option_mask32 & OPT_SELINUX)
|
2007-03-10 16:58:49 +00:00
|
|
|
printf(" %lc\n", *scontext);
|
|
|
|
else
|
2007-09-27 10:20:47 +00:00
|
|
|
bb_putchar('\n');
|
2007-03-10 16:58:49 +00:00
|
|
|
#endif
|
2005-04-23 06:26:38 +00:00
|
|
|
} else {
|
|
|
|
char *linkname = NULL;
|
|
|
|
|
|
|
|
struct passwd *pw_ent;
|
|
|
|
struct group *gw_ent;
|
|
|
|
setgrent();
|
|
|
|
gw_ent = getgrgid(statbuf.st_gid);
|
|
|
|
setpwent();
|
|
|
|
pw_ent = getpwuid(statbuf.st_uid);
|
|
|
|
|
|
|
|
if (S_ISLNK(statbuf.st_mode))
|
2007-02-11 16:19:28 +00:00
|
|
|
linkname = xmalloc_readlink_or_warn(filename);
|
2005-04-23 06:26:38 +00:00
|
|
|
if (linkname)
|
|
|
|
printf(" File: \"%s\" -> \"%s\"\n", filename, linkname);
|
|
|
|
else
|
|
|
|
printf(" File: \"%s\"\n", filename);
|
|
|
|
|
2006-04-12 08:03:11 +00:00
|
|
|
printf(" Size: %-10ju\tBlocks: %-10ju IO Block: %-6lu %s\n"
|
|
|
|
"Device: %jxh/%jud\tInode: %-10ju Links: %-5lu",
|
2005-04-23 06:26:38 +00:00
|
|
|
(uintmax_t) (statbuf.st_size),
|
|
|
|
(uintmax_t) statbuf.st_blocks,
|
2007-04-13 23:22:00 +00:00
|
|
|
(unsigned long) statbuf.st_blksize,
|
2005-04-23 06:26:38 +00:00
|
|
|
file_type(&statbuf),
|
|
|
|
(uintmax_t) statbuf.st_dev,
|
|
|
|
(uintmax_t) statbuf.st_dev,
|
|
|
|
(uintmax_t) statbuf.st_ino,
|
2007-04-13 23:22:00 +00:00
|
|
|
(unsigned long) statbuf.st_nlink);
|
2005-04-23 06:26:38 +00:00
|
|
|
if (S_ISBLK(statbuf.st_mode) || S_ISCHR(statbuf.st_mode))
|
|
|
|
printf(" Device type: %lx,%lx\n",
|
2007-04-13 23:22:00 +00:00
|
|
|
(unsigned long) major(statbuf.st_rdev),
|
|
|
|
(unsigned long) minor(statbuf.st_rdev));
|
2005-04-23 06:26:38 +00:00
|
|
|
else
|
2007-09-27 10:20:47 +00:00
|
|
|
bb_putchar('\n');
|
2007-03-10 16:58:49 +00:00
|
|
|
printf("Access: (%04lo/%10.10s) Uid: (%5lu/%8s) Gid: (%5lu/%8s)\n",
|
2007-04-13 23:22:00 +00:00
|
|
|
(unsigned long) (statbuf.st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)),
|
2005-04-23 06:26:38 +00:00
|
|
|
bb_mode_string(statbuf.st_mode),
|
2007-04-13 23:22:00 +00:00
|
|
|
(unsigned long) statbuf.st_uid,
|
2005-04-23 06:26:38 +00:00
|
|
|
(pw_ent != 0L) ? pw_ent->pw_name : "UNKNOWN",
|
2007-04-13 23:22:00 +00:00
|
|
|
(unsigned long) statbuf.st_gid,
|
2007-03-10 16:58:49 +00:00
|
|
|
(gw_ent != 0L) ? gw_ent->gr_name : "UNKNOWN");
|
|
|
|
#if ENABLE_SELINUX
|
|
|
|
printf(" S_Context: %lc\n", *scontext);
|
|
|
|
#endif
|
|
|
|
printf("Access: %s\n" "Modify: %s\n" "Change: %s\n",
|
2005-04-23 06:26:38 +00:00
|
|
|
human_time(statbuf.st_atime),
|
|
|
|
human_time(statbuf.st_mtime),
|
|
|
|
human_time(statbuf.st_ctime));
|
|
|
|
}
|
2007-03-10 16:58:49 +00:00
|
|
|
#endif /* FEATURE_STAT_FORMAT */
|
2005-04-23 06:26:38 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-10-11 10:05:36 +00:00
|
|
|
int stat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
2005-04-23 06:26:38 +00:00
|
|
|
int stat_main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
char *format = NULL;
|
2007-04-04 13:58:33 +00:00
|
|
|
int i;
|
2005-04-23 06:26:38 +00:00
|
|
|
int ok = 1;
|
2007-10-05 20:31:23 +00:00
|
|
|
bool (*statfunc)(const char *, const char *) = do_stat;
|
2005-04-23 06:26:38 +00:00
|
|
|
|
2007-08-18 15:32:12 +00:00
|
|
|
getopt32(argv, "ftL"
|
2007-03-10 16:58:49 +00:00
|
|
|
USE_SELINUX("Z")
|
2006-11-21 00:12:09 +00:00
|
|
|
USE_FEATURE_STAT_FORMAT("c:", &format)
|
2005-04-23 06:26:38 +00:00
|
|
|
);
|
|
|
|
|
2007-04-04 13:58:33 +00:00
|
|
|
if (option_mask32 & OPT_FILESYS) /* -f */
|
2005-04-23 06:26:38 +00:00
|
|
|
statfunc = do_statfs;
|
|
|
|
if (argc == optind) /* files */
|
|
|
|
bb_show_usage();
|
|
|
|
|
2007-03-10 16:58:49 +00:00
|
|
|
#if ENABLE_SELINUX
|
2007-04-04 13:58:33 +00:00
|
|
|
if (option_mask32 & OPT_SELINUX) {
|
2007-03-10 16:58:49 +00:00
|
|
|
selinux_or_die();
|
|
|
|
}
|
|
|
|
#endif /* ENABLE_SELINUX */
|
2005-04-23 06:26:38 +00:00
|
|
|
for (i = optind; i < argc; ++i)
|
|
|
|
ok &= statfunc(argv[i], format);
|
|
|
|
|
|
|
|
return (ok ? EXIT_SUCCESS : EXIT_FAILURE);
|
|
|
|
}
|