version 1.7, 2014/11/20 18:44:10 |
version 1.8, 2014/12/15 01:48:54 |
|
|
} |
} |
|
|
static void |
static void |
print_time(time_t t, int relative) |
print_time(time_t t, int relative, int have_subsec) |
{ |
{ |
char timestr[PATH_MAX + 4]; |
char timestr[PATH_MAX + 4]; |
struct tm *tm; |
struct tm *tm; |
|
|
if (resolv == 0 || relative) |
if (t < 0 && have_subsec) { |
|
/* negative times with non-zero subsecs require care */ |
|
printf("-%jd", -(intmax_t)(t + 1)); |
|
} else |
printf("%jd", (intmax_t)t); |
printf("%jd", (intmax_t)t); |
else { |
|
|
if (!relative) { |
tm = localtime(&t); |
tm = localtime(&t); |
(void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm); |
(void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm); |
printf("\"%s\"", timestr); |
printf("<\"%s\">", timestr); |
} |
} |
} |
} |
|
|
|
|
printf("UTIME_NOW"); |
printf("UTIME_NOW"); |
else if (tsp->tv_nsec == UTIME_OMIT) |
else if (tsp->tv_nsec == UTIME_OMIT) |
printf("UTIME_OMIT"); |
printf("UTIME_OMIT"); |
else if ((resolv == 0 || relative) && tsp->tv_sec < 0 && |
else { |
tsp->tv_nsec > 0) { |
print_time(tsp->tv_sec, relative, tsp->tv_nsec); |
/* negative relative times with non-zero nsecs require care */ |
|
printf("-%jd.%09ld", -(intmax_t)(tsp->tv_sec+1), |
|
1000000000 - tsp->tv_nsec); |
|
} else { |
|
print_time(tsp->tv_sec, relative); |
|
if (tsp->tv_nsec != 0) |
if (tsp->tv_nsec != 0) |
printf(".%09ld", tsp->tv_nsec); |
printf(".%09ld", tsp->tv_sec >= 0 ? tsp->tv_nsec : |
|
1000000000 - tsp->tv_nsec); |
} |
} |
} |
} |
|
|
|
void |
|
uidname(int uid) |
|
{ |
|
const char *name; |
|
|
|
if (uid == -1) |
|
printf("-1"); |
|
else { |
|
printf("%u<", (unsigned)uid); |
|
if (uid > UID_MAX || (name = user_from_uid(uid, 1)) == NULL) |
|
printf("unknown>"); |
|
else |
|
printf("\"%s\">", name); |
|
} |
|
} |
|
|
|
void |
|
gidname(int gid) |
|
{ |
|
const char *name; |
|
|
|
if (gid == -1) |
|
printf("-1"); |
|
else { |
|
printf("%u<", (unsigned)gid); |
|
if (gid > GID_MAX || (name = group_from_gid(gid, 1)) == NULL) |
|
printf("unknown>"); |
|
else |
|
printf("\"%s\">", name); |
|
} |
|
} |
|
|
static void |
static void |
ktrstat(const struct stat *statp) |
ktrstat(const struct stat *statp) |
{ |
{ |
char mode[12]; |
char mode[12]; |
struct passwd *pwd; |
|
struct group *grp; |
|
|
|
/* |
/* |
* note: ktrstruct() has already verified that statp points to a |
* note: ktrstruct() has already verified that statp points to a |
|
|
*/ |
*/ |
printf("struct stat { "); |
printf("struct stat { "); |
strmode(statp->st_mode, mode); |
strmode(statp->st_mode, mode); |
printf("dev=%d, ino=%llu, mode=%s, nlink=%u, ", |
printf("dev=%d, ino=%llu, mode=%s, nlink=%u, uid=", |
statp->st_dev, (unsigned long long)statp->st_ino, |
statp->st_dev, (unsigned long long)statp->st_ino, |
mode, statp->st_nlink); |
mode, statp->st_nlink); |
if (resolv == 0 || (pwd = getpwuid(statp->st_uid)) == NULL) |
uidname(statp->st_uid); |
printf("uid=%u, ", statp->st_uid); |
printf(", gid="); |
else |
gidname(statp->st_gid); |
printf("uid=\"%s\", ", pwd->pw_name); |
printf(", rdev=%d, ", statp->st_rdev); |
if (resolv == 0 || (grp = getgrgid(statp->st_gid)) == NULL) |
|
printf("gid=%u, ", statp->st_gid); |
|
else |
|
printf("gid=\"%s\", ", grp->gr_name); |
|
printf("rdev=%d, ", statp->st_rdev); |
|
printf("atime="); |
printf("atime="); |
print_timespec(&statp->st_atim, 0); |
print_timespec(&statp->st_atim, 0); |
printf(", mtime="); |
printf(", mtime="); |
|
|
static void |
static void |
print_timeval(const struct timeval *tvp, int relative) |
print_timeval(const struct timeval *tvp, int relative) |
{ |
{ |
if ((resolv == 0 || relative) && tvp->tv_sec < 0 && |
print_time(tvp->tv_sec, relative, tvp->tv_usec); |
tvp->tv_usec > 0) { |
if (tvp->tv_usec != 0) |
/* negative relative times with non-zero usecs require care */ |
printf(".%06ld", tvp->tv_sec >= 0 ? tvp->tv_usec : |
printf("-%jd.%06ld", -(intmax_t)(tvp->tv_sec+1), |
|
1000000 - tvp->tv_usec); |
1000000 - tvp->tv_usec); |
} else { |
|
print_time(tvp->tv_sec, relative); |
|
if (tvp->tv_usec != 0) |
|
printf(".%06ld", tvp->tv_usec); |
|
} |
|
} |
} |
|
|
static void |
static void |
|
|
quota->dqb_bhardlimit, quota->dqb_bsoftlimit, |
quota->dqb_bhardlimit, quota->dqb_bsoftlimit, |
quota->dqb_curblocks, quota->dqb_ihardlimit, |
quota->dqb_curblocks, quota->dqb_ihardlimit, |
quota->dqb_isoftlimit, quota->dqb_curinodes); |
quota->dqb_isoftlimit, quota->dqb_curinodes); |
print_time(quota->dqb_btime, 0); |
print_time(quota->dqb_btime, 0, 0); |
printf(", itime="); |
printf(", itime="); |
print_time(quota->dqb_itime, 0); |
print_time(quota->dqb_itime, 0, 0); |
printf(" }\n"); |
printf(" }\n"); |
} |
} |
|
|