Skip to content

Latest commit

 

History

History
37 lines (36 loc) · 1.34 KB

文件操作.md

File metadata and controls

37 lines (36 loc) · 1.34 KB

Linux和各种Unix-like系统中有一重要概念————万物皆文件

分类

  • 根据处理方法的不同,分为:
  • 缓冲区文件
  • 非缓冲区文件
  • 根据其数据组织形式的不同,分为:
  • 文本文件
  • 二进制文件
  • 根据其存放数据的作用的不同,分为:
  • - 普通文件(regular)
  • d 目录文件
  • l 符号链接文件
  • 设备文件
    • b 块设备文件
    • c 字符设备文件
  • p 知名管道文件(FIFO)
  • s 套接字文件(socket)

索引节点

索引节点(inode)所包含的信息都封装在结构体stat中:

struct stat {
    dev_t     st_dev;     /* ID of device containing file */
    ino_t     st_ino;     /* inode number */
    mode_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 ID (if special file) */
    off_t     st_size;    /* total size, in bytes */
    blksize_t st_blksize; /* blocksize for filesystem I/O */
    blkcnt_t  st_blocks;  /* number of 512B 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 status change */
};