Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9728
  • 博文数量: 4
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 40
  • 用 户 组: 普通用户
  • 注册时间: 2014-09-03 21:26
文章分类
文章存档

2015年(4)

我的朋友

分类: LINUX

2015-07-01 22:23:48

1. struct inode

点击(此处)折叠或打开

  1. struct inode {
  2.     umode_t            i_mode;/* 保存了文件访问权限和所有权 */
  3.     unsigned short        i_opflags;
  4.     kuid_t            i_uid;/* 与文件相关的uid */
  5.     kgid_t            i_gid;/* 与文件相关的gid */
  6.     unsigned int        i_flags;

  7. #ifdef CONFIG_FS_POSIX_ACL
  8.     struct posix_acl    *i_acl;
  9.     struct posix_acl    *i_default_acl;
  10. #endif

  11.     const struct inode_operations    *i_op;/* 指向一个特定于inode操作的函数接口 */
  12.     struct super_block    *i_sb;
  13.     struct address_space    *i_mapping;

  14. #ifdef CONFIG_SECURITY
  15.     void            *i_security;
  16. #endif

  17.     /* Stat data, not accessed from path walking */
  18.     unsigned long        i_ino;/* 每个VFS inode(对给定的文件系统)都由一个唯一的编号标识,保存在i_ino中 */
  19.     /*
  20.      * Filesystems may only read i_nlink directly. They shall use the
  21.      * following functions for modification:
  22.      *
  23.      * (set|clear|inc|drop)_nlink
  24.      * inode_(inc|dec)_link_count
  25.      */
  26.     union {
  27.         const unsigned int i_nlink;/* 记录了使用该inode的硬链接总数 */
  28.         unsigned int __i_nlink;
  29.     };
  30.     dev_t            i_rdev;/* 在inode表示设备文件时,则需要i_rdev.它表示与那个设备进行通信.要注意,i_rdev只是一个数字,不是数据结构!但这个数据包含的信息,即足以找到有关目标设备、我们感兴趣的所有信息。对块设备,最终会找到struct block_device的一个实例 */
  31.     loff_t            i_size;/* 存储了文件长度(单位为字节) */
  32.     struct timespec        i_atime;/* 存储了最后访问的时间 */
  33.     struct timespec        i_mtime;/* 存储了最后修改的时间 */
  34.     struct timespec        i_ctime;/* 存储了最后修改inode的时间 */
  35.     spinlock_t        i_lock;    /* i_blocks, i_bytes, maybe i_size */
  36.     unsigned short i_bytes;
  37.     unsigned int        i_blkbits;
  38.     blkcnt_t        i_blocks;/* 按照块计算的长度 */

  39. #ifdef __NEED_I_SIZE_ORDERED
  40.     seqcount_t        i_size_seqcount;
  41. #endif

  42.     /* Misc */
  43.     unsigned long        i_state;
  44.     struct mutex        i_mutex;

  45.     unsigned long        dirtied_when;    /* jiffies of first dirtying */

  46.     struct hlist_node    i_hash; /* 作为存放在inode_hashtable链表中的元素,该链表是以inode编号和超级块对象的地址合并为关键点 */
  47.     /* i_wb_list将inode存储在一个链表中。根据inode的状态,它可能有3种主要的情况。 */
  48.     /* a、inode存在于内存中,未关联到任何文件,也不处于活动使用状态. */
  49.     /* b、inode结构在内存中,正在由一个或多个进程使用,通常表示一个文件 */
  50.     /* c、inode处于活动使用状态。其数据内容已经改变,与存储介质上的内容不同。这种状态的inode被称作脏的 */
  51.     struct list_head    i_wb_list;    /* backing dev IO list */
  52.     struct list_head    i_lru;        /* inode LRU list */
  53.     struct list_head    i_sb_list;/* 作为super_block->s_inodes链表的元素 */
  54.     union {
  55.         struct hlist_head    i_dentry;
  56.         struct rcu_head        i_rcu;
  57.     };
  58.     u64            i_version;
  59.     atomic_t        i_count;/* 使用计数器,指定访问该inode结构的进程数目 */
  60.     atomic_t        i_dio_count;
  61.     atomic_t        i_writecount;
  62.     const struct file_operations    *i_fop;    /* former ->i_op->default_file_ops */
  63.     struct file_lock    *i_flock;
  64.     struct address_space    i_data;
  65. #ifdef CONFIG_QUOTA
  66.     struct dquot        *i_dquot[MAXQUOTAS];
  67. #endif
  68.     struct list_head    i_devices;/* 该元素与设备文件的处理有关联:利用该成员作为链表元素,使得块设备或字符设备可以维护一个inode的链表,每个inode表示一个设备文件,通过设备文件可以访问对应的设备。尽管在很多情况下每个设备一个设备文件就足够了,但还有很多种可能性。例如chroot造成的环境,其中一个给定的块设备或字符设备可以通过多个设备文件,因而需要多个inode */
  69.     union {
  70.         struct pipe_inode_info    *i_pipe;/* 用于管道 */
  71.         struct block_device    *i_bdev;/* 用于块设备 */
  72.         struct cdev        *i_cdev;/* 用于字符设备 */
  73.     };

  74.     __u32            i_generation;

  75. #ifdef CONFIG_FSNOTIFY
  76.     __u32            i_fsnotify_mask; /* all events this inode cares about */
  77.     struct hlist_head    i_fsnotify_marks;
  78. #endif

  79. #ifdef CONFIG_IMA
  80.     atomic_t        i_readcount; /* struct files open RO */
  81. #endif
  82.     void            *i_private; /* fs or device private pointer */
  83. };

阅读(230) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~