4.25 小结

本章内容一直围绕stat结构,分析了stat各个成员在表示文件相关属性中的意义以及相对应的操作函数:

1、文件的stat结构反应了文件在文件系统中的管理信息。

2、GNU C 对stat结构的定义如下,熟悉这个定义很重要。

struct stat
  {
    __dev_t st_dev;			/* Device.  */
    unsigned short int __pad1;
    __ino_t __st_ino;			/* 32bit file serial number.	*/
    __mode_t st_mode;			/* File mode.  */
    __nlink_t st_nlink;			/* Link count.  */
    __uid_t st_uid;			/* User ID of the file's owner.	*/
    __gid_t st_gid;			/* Group ID of the file's group.*/
    __dev_t st_rdev;			/* Device number, if device.  */
    unsigned short int __pad2;
    __off_t st_size;			/* Size of file, in bytes.  */
    __blksize_t st_blksize;		/* Optimal block size for I/O.  */
    __blkcnt_t st_blocks;		/* Number 512-byte blocks allocated. */
    __time_t st_atime;			/* Time of last access.  */
    unsigned long int st_atimensec;	/* Nscecs of last access.  */
    __time_t st_mtime;			/* Time of last modification.  */
    unsigned long int st_mtimensec;	/* Nsecs of last modification.  */
    __time_t st_ctime;			/* Time of last status change.  */
    unsigned long int st_ctimensec;	/* Nsecs of last status change.  */
  };

3、成员及其相关操作函数列表
成员操作函数或宏
st_modeS_ISXXX系列宏
S_ISUID宏
S_ISGID宏
S_IXXXX系列常量及位运算
umask函数
chomd和fchmod函数
st_uid
st_gid
chown、fchown和lchown函数
st_atime
st_mtime
st_ctime
utime
  
  
  
  
  
  

4、stat结构反映的文件信息实质是与目录项和i节点相关的信息。理解下图对理解文件系统和文件目录项相关的操作函数是有帮助的。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值