Chinaunix首页 | 论坛 | 博客
  • 博客访问: 515697
  • 博文数量: 174
  • 博客积分: 8001
  • 博客等级: 中将
  • 技术积分: 1840
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-04 19:30
文章分类

全部博文(174)

文章存档

2011年(1)

2010年(24)

2009年(149)

我的朋友

分类: LINUX

2009-04-19 18:23:58

Given a pathname, the stat function returns a structure of information about the
 named file. The fstat function obtains information about the file that is already 
open on the descriptor filedes. The lstat function is similar to stat, but when 
the named file is a symbolic link, lstat returns information about the symbolic 
link, not the file referenced by the symbolic link.

#include <sys/stat.h>

int stat(const char *restrict pathname, struct
 stat *restrict buf);

int fstat(int filedes, struct stat *buf);

int lstat(const char *restrict pathname, struct
 stat *restrict buf);

All three return: 0 if OK, 1 on error


The second argument is a pointer to a structure that we must supply. The function fills in the structure pointed to by buf. The definition of the structure can differ among implementations, but it could look like

struct stat {
       mode_t st_mode; /* file type & mode (permissions) */
       ino_t st_ino; /* i-node number (serial number) */
       dev_t st_dev; /* device number (file system) */
       dev_t st_rdev; /* device number for special files */
       nlink_t st_nlink; /* number of links */
       uid_t st_uid; /* user ID of owner */
       gid_t st_gid; /* group ID of owner */
       off_t st_size; /* size in bytes, for regular files */
       time_t st_atime; /* time of last access */
       time_t st_mtime; /* time of last modification */
       time_t st_ctime; /* time of last file status change */
       blksize_t st_blksize; /* best I/O block size */
       blkcnt_t st_blocks; /* number of disk blocks allocated */
     };


阅读(470) | 评论(0) | 转发(0) |
0

上一篇:内存映射

下一篇:JM开篇

给主人留下些什么吧!~~