stat/fstat/lstat functions.


All three functions return information about a file. Please note that devices are seen as files to Unix, so you could 'stat' things like /dev/mouse to see when the mouse was last moved.

stat return the status of a file.

fstat stats an open file.

lstat reports on a link, not the file it points too.

Libraries: sys/stat.h
	   unistd.h

Syntax:    struct stat stat_p;
           stat ("martin", &stat_p);

Stat Structure:

           struct stat
           {
             dev_t         st_dev;      /* device */
             ino_t         st_ino;      /* inode */
             umode_t       st_mode;     /* protection */
             nlink_t       st_nlink;    /* number of hard links */
             uid_t         st_uid;      /* user ID of owner */
             gid_t         st_gid;      /* group ID of owner */
             dev_t         st_rdev;     /* device type (if inode device) */
             off_t         st_size;     /* total size, in bytes */
             unsigned long st_blksize;  /* blocksize for filesystem I/O */
             unsigned long st_blocks;   /* number of blocks allocated */
             time_t        st_atime;    /* time of last access */
             time_t        st_mtime;    /* time of last modification */
             time_t        st_ctime;    /* time of last change */
           };

st_mode can be used with the following macros to discover the type of file being statted.
	S_ISLNK(st_mode)  is it a symbolic link

        S_ISREG(st_mode)  regular file

        S_ISDIR(st_mode)  directory

        S_ISCHR(st_mode)  character device

        S_ISBLK(st_mode)  block device

        S_ISFIFO(st_mode) fifo

        S_ISSOCK(st_mode) socket	
These functions return a large amount of information. See the man page (below) for details. You will need to understand
structures to work with stat.

man page to provide all the details.


Examples

example program.


See also:

POSIX functions to read directory information.


Note

I have seen a problem with the 'access time', it only seems to get updated if the file system is local. If the filesystem is NFS mounted and accessed via 'cat' or 'head' the access date is not updated.


Top Master Index Keywords Functions


Martin Leslie

emove&id=5db4992d8f040b8d8db0b86d42806e0c417f7ccf'>arch/arm/boot/dts/imx6ul-pico-hobbit.dts

diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2016-10-20 15:44:19 +0200
committerTobias Klauser <tklauser@distanz.ch>2017-02-15 10:34:18 +0100
commit5db4992d8f040b8d8db0b86d42806e0c417f7ccf (patch)
tree5b06e952af482d45f3ade64e77824662e34b7fa2 /arch/arm/boot/dts/imx6ul-pico-hobbit.dts
parent370ebb0ef6255132373ed35d13e7b1d8d2eb7003 (diff)
usbnet: pegasus: Use net_device_stats from struct net_devicends-private-remove
Instead of using a private copy of struct net_device_stats in struct pegasus, use stats from struct net_device. Also remove the now unnecessary .ndo_get_stats function. Cc: Petko Manolov <petkan@nucleusys.com> Cc: linux-usb@vger.kernel.org Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'arch/arm/boot/dts/imx6ul-pico-hobbit.dts')