MFC r207153: stat: Allow -f %Sf to display the file flags symbolically.
PR: 124349
This commit is contained in:
parent
312a3c0cba
commit
5d05d542eb
@ -36,7 +36,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd April 27, 2007
|
.Dd April 24, 2010
|
||||||
.Dt STAT 1
|
.Dt STAT 1
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -239,6 +239,11 @@ Display date in
|
|||||||
format.
|
format.
|
||||||
.It Cm dr
|
.It Cm dr
|
||||||
Display actual device name.
|
Display actual device name.
|
||||||
|
.It Cm f
|
||||||
|
Display the flags of
|
||||||
|
.Ar file
|
||||||
|
as in
|
||||||
|
.Nm ls Fl lTdo .
|
||||||
.It Cm gu
|
.It Cm gu
|
||||||
Display group or user name.
|
Display group or user name.
|
||||||
.It Cm p
|
.It Cm p
|
||||||
|
@ -189,6 +189,9 @@ int format1(const struct stat *, /* stat info */
|
|||||||
char *, size_t, /* a place to put the output */
|
char *, size_t, /* a place to put the output */
|
||||||
int, int, int, int, /* the parsed format */
|
int, int, int, int, /* the parsed format */
|
||||||
int, int);
|
int, int);
|
||||||
|
#if HAVE_STRUCT_STAT_ST_FLAGS
|
||||||
|
char *xfflagstostr(unsigned long);
|
||||||
|
#endif
|
||||||
|
|
||||||
char *timefmt;
|
char *timefmt;
|
||||||
int linkfail;
|
int linkfail;
|
||||||
@ -340,6 +343,25 @@ main(int argc, char *argv[])
|
|||||||
return (am_readlink ? linkfail : errs);
|
return (am_readlink ? linkfail : errs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAVE_STRUCT_STAT_ST_FLAGS
|
||||||
|
/*
|
||||||
|
* fflagstostr() wrapper that leaks only once
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
xfflagstostr(unsigned long fflags)
|
||||||
|
{
|
||||||
|
static char *str = NULL;
|
||||||
|
|
||||||
|
if (str != NULL)
|
||||||
|
free(str);
|
||||||
|
|
||||||
|
str = fflagstostr(fflags);
|
||||||
|
if (str == NULL)
|
||||||
|
err(1, "fflagstostr");
|
||||||
|
return (str);
|
||||||
|
}
|
||||||
|
#endif /* HAVE_STRUCT_STAT_ST_FLAGS */
|
||||||
|
|
||||||
void
|
void
|
||||||
usage(const char *synopsis)
|
usage(const char *synopsis)
|
||||||
{
|
{
|
||||||
@ -732,8 +754,11 @@ format1(const struct stat *st,
|
|||||||
case SHOW_st_flags:
|
case SHOW_st_flags:
|
||||||
small = (sizeof(st->st_flags) == 4);
|
small = (sizeof(st->st_flags) == 4);
|
||||||
data = st->st_flags;
|
data = st->st_flags;
|
||||||
sdata = NULL;
|
sdata = xfflagstostr(st->st_flags);
|
||||||
formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX;
|
if (*sdata == '\0')
|
||||||
|
sdata = "-";
|
||||||
|
formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX |
|
||||||
|
FMTF_STRING;
|
||||||
if (ofmt == 0)
|
if (ofmt == 0)
|
||||||
ofmt = FMTF_UNSIGNED;
|
ofmt = FMTF_UNSIGNED;
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user