Chinaunix首页 | 论坛 | 博客
  • 博客访问: 473019
  • 博文数量: 58
  • 博客积分: 6047
  • 博客等级: 准将
  • 技术积分: 838
  • 用 户 组: 普通用户
  • 注册时间: 2008-01-06 21:05
文章分类

全部博文(58)

文章存档

2009年(24)

2008年(34)

我的朋友

分类: LINUX

2009-01-03 00:48:43


inode是实现文件系统的关键,每个文件和目录包含一个inode,包括了文件的访问权限,访问时间,等等。
实现一个文件系统最关键的也是实现“inode operations”和“file operations”

inode opertaions主要实现Create links, rename files, generate new file entries in a directory, and
delete files.
File Operations主要实现Act on the data contents of a file. They include obvious operations such
as read and write, but also operations such as setting file pointers and creating memory mappings.
inode的结构体如下
struct inode {
    struct hlist_node i_hash;
    struct list_head i_list;
    struct list_head i_sb_list;
    struct list_head i_dentry;
    unsigned long i_ino;
    atomic_t i_count;
    unsigned int i_nlink;
    uid_t i_uid;
    gid_t i_gid;
    dev_t i_rdev;
    unsigned long i_version;
    loff_t i_size;
    struct timespec i_atime;
    struct timespec i_mtime;
    struct timespec i_ctime;
    unsigned int i_blkbits;
    blkcnt_t i_blocks;
    umode_t i_mode;
    struct inode_operations *i_op;
    const struct file_operations *i_fop; /* former ->i_op->default_file_ops */
    struct super_block *i_sb;
    struct address_space *i_mapping;
    struct address_space i_data;
    struct dquot *i_dquot[MAXQUOTAS];
    struct list_head i_devices;
    union {
    struct pipe_inode_info *i_pipe;
    struct block_device *i_bdev;
    struct cdev *i_cdev;
    };
    int i_cindex;
    __u32 i_generation;
    unsigned long i_state;
    unsigned long dirtied_when; /* jiffies of first dirtying */
    unsigned int i_flags;
    atomic_t i_writecount;
    void *i_security;
};

另外一个比较重要的域是super_block,也叫超级块,包含了文件系统的块大小(block size),maximum file size,
阅读(1676) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~