Chinaunix首页 | 论坛 | 博客
  • 博客访问: 378488
  • 博文数量: 73
  • 博客积分: 2620
  • 博客等级: 少校
  • 技术积分: 1212
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-09 10:47
文章分类
文章存档

2011年(18)

2010年(50)

2009年(5)

我的朋友

分类: LINUX

2010-01-12 20:04:47

struct stat{
  mode_t  st_mode;
  ino_t   st_ino;
  dev_t   st_dev;
  dev_t   st_rdev;
  nlink_t st_nlink;
  uid_t   st_uid;
  gid_t   st_gid;
  off_t   st_size;
  time_t  st_atime;
  time_t  st_mtime;
  time_t  st_ctime;
  long    st_blksize;
  long    st_blocks;
}
 
int stat(const char* pathname, struct stat* buf);
int fstat(int fieldes, struct stat* buf);
int lstat(const char* pathname, struct stat* buf); /*lstat只返回符号链接信息*/
返回:成功0,错误-1
 
文件类型宏:
S_ISREG(),S_ISDIR(),S_ISCHR(),S_ISBLK(),S_ISFIFO(),S_ISLNK(),S_ISSOCK()
文件许可权位:
S_ISUID,S_ISGID,S_ISVTX;
S_IRUSR,S_IWUSR,S_IXUSR;
S_IRGRP,S_IWGRP,S_IXGRP;
S_IROTH,S_IWOTH,S_IXOTH;
S_IRWXU,S_IRWXG,S_IRWXO;
 
int access(const char* pathname, int mode); 返回:成功0,错误-1
次函数按实际用户ID和实际组ID进行存取许可权测试。mode: R_OK,W_OK,X_OK,F_OK
 
mode_t umask(mode_t cmask); 返回:以前的文件方式创建屏蔽字
 
int chmod(const char* pathname, mode_t mode);
int fchmod(int filedes, mode_t mode);
返回:成功0,错误-1
 
int chown(const char* pathname, uid_t owner, gid_t group);
int fchown(int filedes, uid_t owner, gid_t group);
int lchown(const char* pathname, uid_t owner, gid_t group); /*只改变符号链接*/
返回:成功0,错误-1
 
int truncate(const char* pathname, off_t length);
int ftruncate(int filedes, off_t length);
返回:成功0,错误-1
 
int link(const char* existingpath, const char* newpath); 返回:成功0,错误-1
 
int unlink(const char* pathname); 返回:成功0,错误-1
 
int remove(const char* pathname); 返回:成功0,错误-1
 
int rename(const char* oldname, const char* newname); 返回:成功0,错误-1
 
int symlink(const char* actualpath, const char* sympath); 返回:成功0,错误-1
 
int readlink(const char* pathname, char* buf, size_t bufsize);
返回:成功为读的字节数,错误-1
 
struct utimbuf{
  time_t  actime;
  time_t  modtime;
}
int utime(const char* pathname, const struct utimbuf* times);返回:成功0,错误-1
 
int mkdir(const char* pathname, mode_t mode); 返回:成功0,错误-1  /*mode除了文件许可权位还要至少设置一个执行许可权位*/
 
int rmdir(const char* pathname); 返回:成功0,错误-1
 
struct dirent{
  ino_t  d_ino;
  char d_name[NAME_MAX+1];
}
DIR* opendir(const char* pathname); 返回:成功为DIR指针,错误NULL
struct dirent* readdir(DIR* dp); 返回:成功为目录项指针,错误或目录尾NULL
void rewinddir(DIR* dp);
int closedir(DIR* dp);
返回:成功0,错误-1
 
int chdir(const char* pathname); /*当前工作目录是进程属性,只影响调用chdir()的进程本身*/
int fchdir(int filedes);
返回:成功0,错误-1
 
char* getcwd(char* buf, size_t size); 返回:成功buf,错误NULL
 
void sync(void);
int fsync(int filedes);
返回:成功0,错误-1
 
 
 
阅读(872) | 评论(0) | 转发(0) |
0

上一篇:学习linux编程计划

下一篇:chapter3 文件I/O

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