#endif
#endif
-/* Commenting FBSDID, as it is not needed in OSX.
__FBSDID("$FreeBSD: src/usr.bin/stat/stat.c,v 1.6 2003/10/06 01:55:17 dougb Exp $");
-*/
#if HAVE_CONFIG_H
#include "config.h"
#else /* HAVE_CONFIG_H */
#define HAVE_STRUCT_STAT_ST_FLAGS 1
#define HAVE_STRUCT_STAT_ST_GEN 1
-#define HAVE_STRUCT_STAT_ST_BIRTHTIME 0 /* was 1; not needed if ! __BSD_VISIBLE ? */
+#define HAVE_STRUCT_STAT_ST_BIRTHTIME 1
#define HAVE_STRUCT_STAT_ST_MTIMENSEC 1
+#define HAVE_STRUCT_STAT_ST_ATIM 0
#define HAVE_DEVNAME 1
#endif /* HAVE_CONFIG_H */
#define LINUX_FORMAT \
" File: \"%N\"%n" \
" Size: %-11z FileType: %HT%n" \
- " Mode: (%04OLp/%.10Sp) Uid: (%5u/%8Su) Gid: (%5g/%8Sg)%n" \
+ " Mode: (%04OA/%.10Sp) Uid: (%5u/%8Su) Gid: (%5g/%8Sg)%n" \
"Device: %Hd,%Ld Inode: %i Links: %l%n" \
"Access: %Sa%n" \
"Modify: %Sm%n" \
#define SHOW_st_dev 'd'
#define SHOW_st_ino 'i'
#define SHOW_st_mode 'p'
+#define SHOW_st_mode2 'A'
#define SHOW_st_nlink 'l'
#define SHOW_st_uid 'u'
#define SHOW_st_gid 'g'
fmtcase(what, SHOW_st_dev);
fmtcase(what, SHOW_st_ino);
fmtcase(what, SHOW_st_mode);
+ fmtcase(what, SHOW_st_mode2);
fmtcase(what, SHOW_st_nlink);
fmtcase(what, SHOW_st_uid);
fmtcase(what, SHOW_st_gid);
struct passwd *pw;
struct group *gr;
const struct timespec *tsp;
- struct timespec ts;
+ struct timespec ts = {0,0};
struct tm *tm;
int l, small, formats;
tsp = NULL;
- formats = 0;
- small = 0;
+// formats = 0;
+// small = 0;
/*
* First, pick out the data and tweak it based on hilo or
ofmt = FMTF_UNSIGNED;
break;
case SHOW_st_mode:
+ case SHOW_st_mode2:
small = (sizeof(st->st_mode) == 4);
data = st->st_mode;
strmode(st->st_mode, smode);
l = strlen(sdata);
if (sdata[l - 1] == ' ')
sdata[--l] = '\0';
+ if (what == SHOW_st_mode2)
+ data &= 07777;
if (hilo == HIGH_PIECE) {
data >>= 12;
sdata += 1;
ts = *tsp; /* copy so we can muck with it */
small = (sizeof(ts.tv_sec) == 4);
data = ts.tv_sec;
- small = 1;
tm = localtime(&ts.tv_sec);
+ if (tm == NULL) {
+ ts.tv_sec = 0;
+ tm = localtime(&ts.tv_sec);
+ }
(void)strftime(path, sizeof(path), timefmt, tm);
sdata = path;
formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX |
small = (sizeof(st->st_flags) == 4);
data = st->st_flags;
sdata = NULL;
- formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX;
+ formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX |
+ FMTF_STRING;
+ if (ofmt == FMTF_STRING) {
+ small = 0;
+ data = 0;
+ snprintf(path, sizeof(path), "%s", fflagstostr(st->st_flags));
+ sdata = path;
+ }
if (ofmt == 0)
ofmt = FMTF_UNSIGNED;
break;