]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/stat.2
prctl.2: ffix
[thirdparty/man-pages.git] / man2 / stat.2
CommitLineData
fea681da 1'\" t
fea681da
MK
2.\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
3.\" Parts Copyright (c) 1995 Nicolai Langfeldt (janl@ifi.uio.no), 1/1/95
40084043 4.\" and Copyright (c) 2006, 2007, 2014 Michael Kerrisk <mtk.manpages@gmail.com>
fea681da 5.\"
93015253 6.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
7.\" Permission is granted to make and distribute verbatim copies of this
8.\" manual provided the copyright notice and this permission notice are
9.\" preserved on all copies.
10.\"
11.\" Permission is granted to copy and distribute modified versions of this
12.\" manual under the conditions for verbatim copying, provided that the
13.\" entire resulting derived work is distributed under the terms of a
14.\" permission notice identical to this one.
c13182ef 15.\"
fea681da
MK
16.\" Since the Linux kernel and libraries are constantly changing, this
17.\" manual page may be incorrect or out-of-date. The author(s) assume no
18.\" responsibility for errors or omissions, or for damages resulting from
19.\" the use of the information contained herein. The author(s) may not
20.\" have taken the same level of care in the production of this manual,
21.\" which is licensed free of charge, as they might when working
22.\" professionally.
c13182ef 23.\"
fea681da
MK
24.\" Formatted or processed versions of this manual, if unaccompanied by
25.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 26.\" %%%LICENSE_END
fea681da
MK
27.\"
28.\" Modified by Michael Haardt <michael@moria.de>
29.\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
30.\" Modified 1995-05-18 by Todd Larason <jtl@molehill.org>
31.\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
32.\" Modified 1995-01-09 by Richard Kettlewell <richard@greenend.org.uk>
33.\" Modified 1998-05-13 by Michael Haardt <michael@cantor.informatik.rwth-aachen.de>
34.\" Modified 1999-07-06 by aeb & Albert Cahalan
35.\" Modified 2000-01-07 by aeb
c11b1abf 36.\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
bc7ff20e 37.\" 2007-06-08 mtk: Added example program
cd667553 38.\" 2007-07-05 mtk: Added details on underlying system call interfaces
c13182ef 39.\"
9ba01802 40.TH STAT 2 2019-03-06 "Linux" "Linux Programmer's Manual"
fea681da 41.SH NAME
40084043 42stat, fstat, lstat, fstatat \- get file status
fea681da 43.SH SYNOPSIS
40084043 44.nf
fea681da 45.B #include <sys/types.h>
fea681da 46.B #include <sys/stat.h>
fea681da 47.B #include <unistd.h>
68e4db0a 48.PP
9a38b2ce 49.BI "int stat(const char *" pathname ", struct stat *" statbuf );
9a38b2ce 50.BI "int fstat(int " fd ", struct stat *" statbuf );
9a38b2ce 51.BI "int lstat(const char *" pathname ", struct stat *" statbuf );
f90f031e 52
40084043
MK
53.BR "#include <fcntl.h> " "/* Definition of AT_* constants */"
54.B #include <sys/stat.h>
68e4db0a 55.PP
40084043 56.BI "int fstatat(int " dirfd ", const char *" pathname ", struct stat *" \
9a38b2ce 57statbuf ,
40084043
MK
58.BI " int " flags );
59.fi
68e4db0a 60.PP
8179def1
MK
61.in -4n
62Feature Test Macro Requirements for glibc (see
63.BR feature_test_macros (7)):
64.in
68e4db0a 65.PP
43e0fe7d 66.ad l
8179def1 67.BR lstat ():
43e0fe7d 68.RS 4
cf7fa0a1 69/* glibc 2.19 and earlier */ _BSD_SOURCE
afb9bd5d 70.br
cf7fa0a1 71 || /* Since glibc 2.20 */ _DEFAULT_SOURCE
afb9bd5d 72.br
cf7fa0a1
MK
73 || _XOPEN_SOURCE\ >=\ 500
74.\" _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
3ba63d80 75.br
cf7fa0a1 76 || /* Since glibc 2.10: */ _POSIX_C_SOURCE\ >=\ 200112L
43e0fe7d 77.RE
68e4db0a 78.PP
40084043 79.BR fstatat ():
40084043
MK
80.ad l
81.RS 4
68e4db0a 82.PD 0
40084043
MK
83.TP 4
84Since glibc 2.10:
b0da7b8b 85_POSIX_C_SOURCE\ >=\ 200809L
40084043
MK
86.TP
87Before glibc 2.10:
88_ATFILE_SOURCE
89.RE
43e0fe7d
MK
90.PD
91.ad
fea681da
MK
92.SH DESCRIPTION
93.PP
e096bd70 94These functions return information about a file, in the buffer pointed to by
9a38b2ce 95.IR statbuf .
5503c85e 96No permissions are required on the file itself, but\(emin the case of
071d1c4f
MK
97.BR stat (),
98.BR fstatat (),
c13182ef 99and
827edbd2
MK
100.BR lstat ()\(emexecute
101(search) permission is required on all of the directories in
66cbeaf4 102.I pathname
da2d9dad 103that lead to the file.
fea681da 104.PP
da2d9dad 105.BR stat ()
071d1c4f
MK
106and
107.BR fstatat ()
e096bd70
MK
108retrieve information about the file pointed to by
109.IR pathname ;
071d1c4f
MK
110the differences for
111.BR fstatat ()
112are described below.
efeece04 113.PP
da2d9dad 114.BR lstat ()
fea681da 115is identical to
da2d9dad
MK
116.BR stat (),
117except that if
66cbeaf4 118.I pathname
e096bd70 119is a symbolic link, then it returns information about the link itself,
fea681da 120not the file that it refers to.
efeece04 121.PP
da2d9dad 122.BR fstat ()
fea681da 123is identical to
da2d9dad 124.BR stat (),
5201bb40 125except that the file about which information is to be retrieved
e096bd70 126is specified by the file descriptor
d3b03141 127.IR fd .
9152b8c9
MK
128.\"
129.SS The stat structure
da2d9dad 130All of these system calls return a
fea681da
MK
131.I stat
132structure, which contains the following fields:
133.PP
bd191423 134.in +4n
b8302363 135.EX
fea681da 136struct stat {
e9e9e87e 137 dev_t st_dev; /* ID of device containing file */
96dea201
MK
138 ino_t st_ino; /* Inode number */
139 mode_t st_mode; /* File type and mode */
140 nlink_t st_nlink; /* Number of hard links */
141 uid_t st_uid; /* User ID of owner */
142 gid_t st_gid; /* Group ID of owner */
143 dev_t st_rdev; /* Device ID (if special file) */
144 off_t st_size; /* Total size, in bytes */
145 blksize_t st_blksize; /* Block size for filesystem I/O */
146 blkcnt_t st_blocks; /* Number of 512B blocks allocated */
e9e9e87e
MK
147
148 /* Since Linux 2.6, the kernel supports nanosecond
149 precision for the following timestamp fields.
150 For the details before Linux 2.6, see NOTES. */
151
96dea201
MK
152 struct timespec st_atim; /* Time of last access */
153 struct timespec st_mtim; /* Time of last modification */
154 struct timespec st_ctim; /* Time of last status change */
e9e9e87e
MK
155
156#define st_atime st_atim.tv_sec /* Backward compatibility */
157#define st_mtime st_mtim.tv_sec
158#define st_ctime st_ctim.tv_sec
fea681da 159};
b8302363 160.EE
bd191423 161.in
efeece04 162.PP
b3deaf0f 163.IR Note :
496bdb56
MK
164the order of fields in the
165.I stat
166structure varies somewhat
167across architectures.
168In addition,
169the definition above does not show the padding bytes
170that may be present between some fields on various architectures.
409b0278 171Consult the glibc and kernel source code
496bdb56 172if you need to know the details.
efeece04 173.PP
64639e9a
MK
174.\" Background: inode attributes are modified with i_mutex held, but
175.\" read by stat() without taking the mutex.
b3deaf0f 176.IR Note :
7ad5fb5d 177for performance and simplicity reasons, different fields in the
f240296d
JH
178.I stat
179structure may contain state information from different moments
64639e9a
MK
180during the execution of the system call.
181For example, if
addfd6c3
MK
182.IR st_mode
183or
f240296d 184.IR st_uid
addfd6c3
MK
185is changed by another process by calling
186.BR chmod (2)
187or
64639e9a 188.BR chown (2),
f240296d
JH
189.BR stat ()
190might return the old
191.I st_mode
192together with the new
193.IR st_uid ,
194or the old
195.I st_uid
196together with the new
197.IR st_mode .
efeece04 198.PP
53cb52e5
MK
199The fields in the
200.I stat
201structure are as follows:
202.TP
29de83af 203.I st_dev
53cb52e5 204This field describes the device on which this file resides.
e9ef777f
MK
205(The
206.BR major (3)
207and
208.BR minor (3)
209macros may be useful to decompose the device ID in this field.)
53cb52e5 210.TP
c61617be
MK
211.I st_ino
212This field contains the file's inode number.
213.TP
cafa9752 214.I st_mode
e8ff4f53
MK
215This field contains the file type and mode.
216See
217.BR inode (7)
218for further information.
cafa9752 219.TP
d41bfb20
MK
220.I st_nlink
221This field contains the number of hard links to the file.
222.TP
78909f3e
MK
223.I st_uid
224This field contains the user ID of the owner of the file.
225.TP
226.I st_gid
227This field contains the ID of the group owner of the file.
228.TP
da2d9dad 229.I st_rdev
53cb52e5
MK
230This field describes the device that this file (inode) represents.
231.TP
fea681da 232.I st_size
53cb52e5 233This field gives the size of the file (if it is a regular
c13182ef 234file or a symbolic link) in bytes.
280ff209
MK
235The size of a symbolic link is the length of the pathname
236it contains, without a terminating null byte.
53cb52e5 237.TP
28f042cc 238.I st_blksize
96dea201 239This field gives the "preferred" block size for efficient filesystem I/O.
28f042cc 240.TP
fea681da 241.I st_blocks
53cb52e5 242This field indicates the number of blocks allocated to the file,
e8ff4f53 243in 512-byte units.
fea681da 244(This may be smaller than
eee0a2ec
MK
245.IR st_size /512
246when the file has holes.)
53cb52e5 247.TP
fea681da 248.I st_atime
53cb52e5 249This is the file's last access timestamp.
53cb52e5 250.TP
fea681da 251.I st_mtime
53cb52e5 252This is the file's last modification timestamp.
53cb52e5 253.TP
fea681da 254.I st_ctime
53cb52e5 255This is the file's last status change timestamp.
fea681da 256.PP
e8ff4f53
MK
257For further information on the above fields, see
258.BR inode (7).
40084043 259.\"
1fef0fa3 260.SS fstatat()
40084043
MK
261The
262.BR fstatat ()
57bc46c2
N
263system call is a more general interface for accessing file information
264which can still provide exactly the behavior of each of
cadd38ba 265.BR stat (),
57bc46c2
N
266.BR lstat (),
267and
268.BR fstat ().
efeece04 269.PP
40084043
MK
270If the pathname given in
271.I pathname
272is relative, then it is interpreted relative to the directory
273referred to by the file descriptor
274.I dirfd
275(rather than relative to the current working directory of
276the calling process, as is done by
cadd38ba 277.BR stat ()
57bc46c2
N
278and
279.BR lstat ()
40084043 280for a relative pathname).
efeece04 281.PP
40084043
MK
282If
283.I pathname
284is relative and
285.I dirfd
286is the special value
287.BR AT_FDCWD ,
288then
289.I pathname
290is interpreted relative to the current working
291directory of the calling process (like
57bc46c2
N
292.BR stat ()
293and
294.BR lstat ()).
efeece04 295.PP
40084043
MK
296If
297.I pathname
298is absolute, then
299.I dirfd
300is ignored.
efeece04 301.PP
40084043
MK
302.I flags
303can either be 0, or include one or more of the following flags ORed:
304.TP
305.BR AT_EMPTY_PATH " (since Linux 2.6.39)"
306.\" commit 65cfc6722361570bfe255698d9cd4dccaf47570d
307If
308.I pathname
309is an empty string, operate on the file referred to by
310.IR dirfd
311(which may have been obtained using the
312.BR open (2)
313.B O_PATH
314flag).
b78969ac
MÅš
315In this case,
316.I dirfd
57bc46c2
N
317can refer to any type of file, not just a directory, and
318the behavior of
319.BR fstatat ()
320is similar to that of
321.BR fstat ().
a6fcbdf8
MK
322If
323.I dirfd
324is
325.BR AT_FDCWD ,
326the call operates on the current working directory.
40084043
MK
327This flag is Linux-specific; define
328.B _GNU_SOURCE
329.\" Before glibc 2.16, defining _ATFILE_SOURCE sufficed
330to obtain its definition.
331.TP
332.BR AT_NO_AUTOMOUNT " (since Linux 2.6.38)"
333Don't automount the terminal ("basename") component of
334.I pathname
335if it is a directory that is an automount point.
336This allows the caller to gather attributes of an automount point
337(rather than the location it would mount).
76e4954f
MK
338Since Linux 4.14,
339.\" commit 42f46148217865a545e129612075f3d828a2c4e4
3d5c9255 340also don't instantiate a nonexistent name in an
57bc46c2 341on-demand directory such as used for automounter indirect maps.
40084043
MK
342This flag can be used in tools that scan directories
343to prevent mass-automounting of a directory of automount points.
344The
345.B AT_NO_AUTOMOUNT
346flag has no effect if the mount point has already been mounted over.
347This flag is Linux-specific; define
348.B _GNU_SOURCE
349.\" Before glibc 2.16, defining _ATFILE_SOURCE sufficed
350to obtain its definition.
57bc46c2
N
351Both
352.BR stat ()
353and
354.BR lstat ()
355act as though
356.B AT_NO_AUTOMOUNT
357was set.
40084043
MK
358.TP
359.B AT_SYMLINK_NOFOLLOW
360If
361.I pathname
362is a symbolic link, do not dereference it:
363instead return information about the link itself, like
cadd38ba 364.BR lstat ().
40084043
MK
365(By default,
366.BR fstatat ()
367dereferences symbolic links, like
cadd38ba 368.BR stat ().)
40084043
MK
369.PP
370See
371.BR openat (2)
372for an explanation of the need for
373.BR fstatat ().
47297adb 374.SH RETURN VALUE
c13182ef
MK
375On success, zero is returned.
376On error, \-1 is returned, and
fea681da
MK
377.I errno
378is set appropriately.
379.SH ERRORS
380.TP
381.B EACCES
382Search permission is denied for one of the directories
383in the path prefix of
66cbeaf4 384.IR pathname .
fea681da 385(See also
ad7cc990 386.BR path_resolution (7).)
fea681da
MK
387.TP
388.B EBADF
d3b03141 389.I fd
0fa890e0 390is not a valid open file descriptor.
fea681da
MK
391.TP
392.B EFAULT
393Bad address.
394.TP
395.B ELOOP
396Too many symbolic links encountered while traversing the path.
397.TP
398.B ENAMETOOLONG
66cbeaf4 399.I pathname
c066b169 400is too long.
fea681da
MK
401.TP
402.B ENOENT
5cf0b3b4 403A component of
66cbeaf4 404.I pathname
ad9533eb 405does not exist or is a dangling symbolic link.
33909153
MK
406.TP
407.B ENOENT
66cbeaf4 408.I pathname
96dea201
MK
409is an empty string and
410.B AT_EMPTY_PATH
411was not specified in
412.IR flags .
fea681da
MK
413.TP
414.B ENOMEM
75b94dc3 415Out of memory (i.e., kernel memory).
fea681da
MK
416.TP
417.B ENOTDIR
94ea1e9d 418A component of the path prefix of
66cbeaf4 419.I pathname
5cf0b3b4 420is not a directory.
9dcc4605
MK
421.TP
422.B EOVERFLOW
66cbeaf4 423.I pathname
fec75159
SP
424or
425.I fd
426refers to a file whose size, inode number,
427or number of blocks cannot be represented in, respectively, the types
428.IR off_t ,
429.IR ino_t ,
430or
431.IR blkcnt_t .
432This error can occur when, for example,
433an application compiled on a 32-bit platform without
5e4dc269 434.I -D_FILE_OFFSET_BITS=64
9dcc4605
MK
435calls
436.BR stat ()
437on a file whose size exceeds
4d69ed2e 438.I (1<<31)-1
fec75159 439bytes.
40084043 440.PP
40084043
MK
441The following additional errors can occur for
442.BR fstatat ():
443.TP
444.B EBADF
445.I dirfd
446is not a valid file descriptor.
447.TP
448.B EINVAL
449Invalid flag specified in
450.IR flags .
451.TP
452.B ENOTDIR
453.I pathname
454is relative and
455.I dirfd
456is a file descriptor referring to a file other than a directory.
457.SH VERSIONS
458.BR fstatat ()
459was added to Linux in kernel 2.6.16;
460library support was added to glibc in version 2.4.
47297adb 461.SH CONFORMING TO
40084043
MK
462.BR stat (),
463.BR fstat (),
464.BR lstat ():
282daba9 465SVr4, 4.3BSD, POSIX.1-2001, POSIX.1.2008.
97c1eac8
MK
466.\" SVr4 documents additional
467.\" .BR fstat ()
468.\" error conditions EINTR, ENOLINK, and EOVERFLOW. SVr4
469.\" documents additional
470.\" .BR stat ()
471.\" and
472.\" .BR lstat ()
473.\" error conditions EINTR, EMULTIHOP, ENOLINK, and EOVERFLOW.
efeece04 474.PP
40084043
MK
475.BR fstatat ():
476POSIX.1-2008.
efeece04 477.PP
d3e8b141
MK
478According to POSIX.1-2001,
479.BR lstat ()
480on a symbolic link need return valid information only in the
481.I st_size
44b1f5a0 482field and the file type of the
d3e8b141
MK
483.IR st_mode
484field of the
485.IR stat
486structure.
a03c016c 487POSIX.1-2008 tightens the specification, requiring
d3e8b141 488.BR lstat ()
7901c9c3 489to return valid information in all fields except the mode bits in
d3e8b141 490.IR st_mode .
efeece04 491.PP
fea681da
MK
492Use of the
493.I st_blocks
494and
495.I st_blksize
c13182ef
MK
496fields may be less portable.
497(They were introduced in BSD.
498The interpretation differs between systems,
499and possibly on a single system when NFS mounts are involved.)
2b2581ee 500.SH NOTES
1ef5b280 501.SS Timestamp fields
e9e9e87e
MK
502Older kernels and older standards did not support nanosecond timestamp
503fields.
b8efc3ed 504Instead, there were three timestamp
e9e9e87e
MK
505.RI fields\(em st_atime ,
506.IR st_mtime ,
507and
508.IR st_ctime \(emtyped
b8efc3ed 509as
e9e9e87e
MK
510.IR time_t
511that recorded timestamps with one-second precision.
efeece04 512.PP
2b2581ee
MK
513Since kernel 2.5.48, the
514.I stat
f5935752 515structure supports nanosecond resolution for the three file timestamp fields.
e9e9e87e
MK
516The nanosecond components of each timestamp are available
517via names of the form
2a0bd971
MK
518.IR st_atim.tv_nsec ,
519if suitable feature test macros are defined.
520Nanosecond timestamps were standardized in POSIX.1-2008,
521and, starting with version 2.12,
522glibc exposes the nanosecond component names if
f5935752
MK
523.BR _POSIX_C_SOURCE
524is defined with the value 200809L or greater, or
525.BR _XOPEN_SOURCE
526is defined with the value 700 or greater.
2a0bd971
MK
527Up to and including glibc 2.19,
528the definitions of the nanoseconds components are also defined if
529.B _BSD_SOURCE
530or
531.B _SVID_SOURCE
532is defined.
f5935752
MK
533If none of the aforementioned macros are defined,
534then the nanosecond values are exposed with names of the form
535.IR st_atimensec .
e8ff4f53 536.\"
0722a578 537.SS C library/kernel differences
b8f9d9dd
MK
538Over time, increases in the size of the
539.I stat
0c8dd254 540structure have led to three successive versions of
b8f9d9dd
MK
541.BR stat ():
542.IR sys_stat ()
543(slot
544.IR __NR_oldstat ),
545.IR sys_newstat ()
546(slot
547.IR __NR_stat ),
548and
0daa9e92 549.I sys_stat64()
a39f2f4d 550(slot
94971420
MK
551.IR __NR_stat64 )
552on 32-bit platforms such as i386.
553The first two versions were already present in Linux 1.0
554(albeit with different names);
cd358be3 555.\" See include/asm-i386/stat.h in the Linux 2.4 source code for the
94971420
MK
556.\" various versions of the structure definitions
557the last was added in Linux 2.4.
558Similar remarks apply for
559.BR fstat ()
560and
561.BR lstat ().
efeece04 562.PP
94971420
MK
563The kernel-internal versions of the
564.I stat
565structure dealt with by the different versions are, respectively:
94971420
MK
566.TP
567.IR __old_kernel_stat
568The original structure, with rather narrow fields, and no padding.
569.TP
570.IR stat
571Larger
572.I st_ino
573field and padding added to various parts of the structure to
574allow for future expansion.
575.TP
576.IR stat64
577Even larger
578.I st_ino
579field,
580larger
581.I st_uid
582and
583.I st_gid
584fields to accommodate the Linux-2.4 expansion of UIDs and GIDs to 32 bits,
585and various other enlarged fields and further padding in the structure.
586(Various padding bytes were eventually consumed in Linux 2.6,
587with the advent of 32-bit device IDs and nanosecond components
588for the timestamp fields.)
94971420 589.PP
d28a0b77 590The glibc
b8f9d9dd 591.BR stat ()
d28a0b77 592wrapper function hides these details from applications,
6f1a1e61
MK
593invoking the most recent version of the system call provided by the kernel,
594and repacking the returned information if required for old binaries.
8179def1
MK
595.\"
596.\" A note from Andries Brouwer, July 2007
e0bf9127
MK
597.\"
598.\" > Is the story not rather more complicated for some calls like
8179def1 599.\" > stat(2)?
e0bf9127 600.\"
8179def1 601.\" Yes and no, mostly no. See /usr/include/sys/stat.h .
e0bf9127 602.\"
8179def1
MK
603.\" The idea is here not so much that syscalls change, but that
604.\" the definitions of struct stat and of the types dev_t and mode_t change.
605.\" This means that libc (even if it does not call the kernel
606.\" but only calls some internal function) must know what the
607.\" format of dev_t or of struct stat is.
608.\" The communication between the application and libc goes via
609.\" the include file <sys/stat.h> that defines a _STAT_VER and
610.\" _MKNOD_VER describing the layout of the data that user space
611.\" uses. Each (almost each) occurrence of stat() is replaced by
612.\" an occurrence of xstat() where the first parameter of xstat()
613.\" is this version number _STAT_VER.
e0bf9127 614.\"
8179def1
MK
615.\" Now, also the definitions used by the kernel change.
616.\" But glibc copes with this in the standard way, and the
617.\" struct stat as returned by the kernel is repacked into
618.\" the struct stat as expected by the application.
619.\" Thus, _STAT_VER and this setup cater for the application-libc
620.\" interface, rather than the libc-kernel interface.
e0bf9127 621.\"
8179def1 622.\" (Note that the details depend on gcc being used as c compiler.)
efeece04 623.PP
94971420
MK
624On modern 64-bit systems, life is simpler: there is a single
625.BR stat ()
626system call and the kernel deals with a
627.I stat
628structure that contains fields of a sufficient size.
efeece04 629.PP
40084043
MK
630The underlying system call employed by the glibc
631.BR fstatat ()
632wrapper function is actually called
cad6df32
MK
633.BR fstatat64 ()
634or, on some architectures,
635.\" strace(1) shows the name "newfstatat" on x86-64
636.BR newfstatat ().
bc7ff20e 637.SH EXAMPLE
988db661 638The following program calls
133ca6ca 639.BR lstat ()
bc7ff20e
MK
640and displays selected fields in the returned
641.I stat
642structure.
207050fa
MK
643.PP
644.EX
bc7ff20e
MK
645#include <sys/types.h>
646#include <sys/stat.h>
647#include <time.h>
648#include <stdio.h>
988db661 649#include <stdlib.h>
51dbffc5 650#include <sys/sysmacros.h>
bc7ff20e
MK
651
652int
653main(int argc, char *argv[])
654{
655 struct stat sb;
656
657 if (argc != 2) {
d1a71985 658 fprintf(stderr, "Usage: %s <pathname>\en", argv[0]);
bc7ff20e
MK
659 exit(EXIT_FAILURE);
660 }
661
133ca6ca
MK
662 if (lstat(argv[1], &sb) == \-1) {
663 perror("lstat");