summaryrefslogtreecommitdiffstats
path: root/usr.bin/stat/stat.1
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/stat/stat.1')
-rw-r--r--usr.bin/stat/stat.1104
1 files changed, 81 insertions, 23 deletions
diff --git a/usr.bin/stat/stat.1 b/usr.bin/stat/stat.1
index 8bbdda4..92a8515 100644
--- a/usr.bin/stat/stat.1
+++ b/usr.bin/stat/stat.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: stat.1,v 1.11 2003/05/08 13:07:10 wiz Exp $
+.\" $NetBSD: stat.1,v 1.28 2010/04/05 21:25:01 joerg Exp $
.\"
.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 24, 2010
+.Dd December 5, 2010
.Dt STAT 1
.Os
.Sh NAME
@@ -43,15 +43,15 @@
.Op Fl t Ar timefmt
.Op Ar
.Nm readlink
-.Op Fl n
+.Op Fl fn
.Op Ar
.Sh DESCRIPTION
The
.Nm
utility displays information about the file pointed to by
.Ar file .
-Read, write or execute permissions of the named file are not required, but
-all directories listed in the path name leading to the file must be
+Read, write, or execute permissions of the named file are not required, but
+all directories listed in the pathname leading to the file must be
searchable.
If no argument is given,
.Nm
@@ -60,13 +60,42 @@ displays information about the file descriptor for standard input.
When invoked as
.Nm readlink ,
only the target of the symbolic link is printed.
-If the given argument is not a symbolic link,
+If the given argument is not a symbolic link and the
+.Fl f
+option is not specified,
.Nm readlink
will print nothing and exit with an error.
+If the
+.Fl f
+option is specified, the output is canonicalized by following every symlink
+in every component of the given path recursively.
+.Nm readlink
+will resolve both absolute and relative paths, and return the absolute pathname
+corresponding to
+.Ar file .
+In this case, the argument does not need to be a symbolic link.
.Pp
The information displayed is obtained by calling
.Xr lstat 2
with the given argument and evaluating the returned structure.
+The default format displays the
+.Fa st_dev ,
+.Fa st_ino ,
+.Fa st_mode ,
+.Fa st_nlink ,
+.Fa st_uid ,
+.Fa st_gid ,
+.Fa st_rdev ,
+.Fa st_size ,
+.Fa st_atime ,
+.Fa st_mtime ,
+.Fa st_ctime ,
+.Fa st_birthtime ,
+.Fa st_blksize ,
+.Fa st_blocks ,
+and
+.Fa st_flags
+fields, in that order.
.Pp
The options are as follows:
.Bl -tag -width indent
@@ -107,6 +136,14 @@ will refer to the target of
if file is a symbolic link, and not to
.Ar file
itself.
+If the link is broken or the target does not exist,
+fall back on
+.Xr lstat 2
+and report information about the link.
+.It Fl l
+Display output in
+.Ic ls Fl lT
+format.
.It Fl n
Do not force a newline to appear at the end of each piece of output.
.It Fl q
@@ -136,7 +173,8 @@ display the raw, numerical value (for example, times in seconds since the
epoch, etc.).
.It Fl s
Display information in
-.Dq "shell output" ,
+.Dq shell output
+format,
suitable for initializing variables.
.It Fl x
Display information in a more verbose way as known from some
@@ -334,49 +372,62 @@ A required field specifier, being one of the following:
.It Cm d
Device upon which
.Ar file
-resides.
+resides
+.Pq Fa st_dev .
.It Cm i
.Ar file Ns 's
-inode number.
+inode number
+.Pq Fa st_ino .
.It Cm p
-File type and permissions.
+File type and permissions
+.Pq Fa st_mode .
.It Cm l
Number of hard links to
-.Ar file .
+.Ar file
+.Pq Fa st_nlink .
.It Cm u , g
User ID and group ID of
.Ar file Ns 's
-owner.
+owner
+.Pq Fa st_uid , st_gid .
.It Cm r
-Device number for character and block device special files.
+Device number for character and block device special files
+.Pq Fa st_rdev .
.It Cm a , m , c , B
The time
.Ar file
-was last accessed or modified, of when the inode was last changed, or
-the birth time of the inode.
+was last accessed or modified, or when the inode was last changed, or
+the birth time of the inode
+.Pq Fa st_atime , st_mtime , st_ctime , st_birthtime .
.It Cm z
The size of
.Ar file
-in bytes.
+in bytes
+.Pq Fa st_size .
.It Cm b
Number of blocks allocated for
-.Ar file .
+.Ar file
+.Pq Fa st_blocks .
.It Cm k
-Optimal file system I/O operation block size.
+Optimal file system I/O operation block size
+.Pq Fa st_blksize .
.It Cm f
User defined flags for
.Ar file .
.It Cm v
-Inode generation number.
+Inode generation number
+.Pq Fa st_gen .
.El
.Pp
-The following four field specifiers are not drawn directly from the
+The following five field specifiers are not drawn directly from the
data in
.Vt "struct stat" ,
but are:
.Bl -tag -width indent
.It Cm N
The name of the file.
+.It Cm R
+The absolute pathname corresponding to the file.
.It Cm T
The file type, either as in
.Nm ls Fl F
@@ -406,12 +457,12 @@ as an output form, with the
exception of
.Cm p
which defaults to
-.Cm O ,
+.Cm O ;
.Cm a , m ,
and
.Cm c
which default to
-.Cm D ,
+.Cm D ;
and
.Cm Y , T ,
and
@@ -421,8 +472,15 @@ which default to
.Sh EXIT STATUS
.Ex -std stat readlink
.Sh EXAMPLES
+If no options are specified, the default format is
+"%d %i %Sp %l %Su %Sg %r %z \e"%Sa\e" \e"%Sm\e" \e"%Sc\e" \e"%SB\e" %k %b %#Xf %N".
+.Bd -literal -offset indent
+\*[Gt] stat /tmp/bar
+0 78852 -rw-r--r-- 1 root wheel 0 0 "Jul 8 10:26:03 2004" "Jul 8 10:26:03 2004" "Jul 8 10:28:13 2004" "Jan 1 09:00:00 1970" 16384 0 0 /tmp/bar
+.Ed
+.Pp
Given a symbolic link
-.Pa foo
+.Dq foo
that points from
.Pa /tmp/foo
to
OpenPOWER on IntegriCloud