首页 > 系统相关 >Linux struct inode结构【转】

Linux struct inode结构【转】

时间:2023-07-03 15:44:08浏览次数:50  
标签:调用 struct dentry int Linux inode 节点

转自:https://www.cnblogs.com/wanghetao/archive/2012/05/28/2521675.html

*索引节点对象由inode结构体表示,定义文件在linux/fs.h中
*/
struct inode {
        struct hlist_node       i_hash;              /* 哈希表 */
        struct list_head        i_list;              /* 索引节点链表 */
        struct list_head        i_dentry;            /* 目录项链表 */
        unsigned long           i_ino;               /* 节点号 */
        atomic_t                i_count;             /* 引用记数 */
        umode_t                 i_mode;              /* 访问权限控制 */
        unsigned int            i_nlink;             /* 硬链接数 */
        uid_t                   i_uid;               /* 使用者id */
        gid_t                   i_gid;               /* 使用者id组 */
        kdev_t                  i_rdev;              /* 实设备标识符 */
        loff_t                  i_size;              /* 以字节为单位的文件大小 */
        struct timespec         i_atime;             /* 最后访问时间 */
        struct timespec         i_mtime;             /* 最后修改(modify)时间 */
        struct timespec         i_ctime;             /* 最后改变(change)时间 */
        unsigned int            i_blkbits;           /* 以位为单位的块大小 */
        unsigned long           i_blksize;           /* 以字节为单位的块大小 */
        unsigned long           i_version;           /* 版本号 */
        unsigned long           i_blocks;            /* 文件的块数 */
        unsigned short          i_bytes;             /* 使用的字节数 */
        spinlock_t              i_lock;              /* 自旋锁 */
        struct rw_semaphore     i_alloc_sem;         /* 索引节点信号量 */
        struct inode_operations *i_op;               /* 索引节点操作表 */
        struct file_operations  *i_fop;              /* 默认的索引节点操作 */
        struct super_block      *i_sb;               /* 相关的超级块 */
        struct file_lock        *i_flock;            /* 文件锁链表 */
        struct address_space    *i_mapping;          /* 相关的地址映射 */
        struct address_space    i_data;              /* 设备地址映射 */
        struct dquot            *i_dquot[MAXQUOTAS]; /* 节点的磁盘限额 */
        struct list_head        i_devices;           /* 块设备链表 */
        struct pipe_inode_info  *i_pipe;             /* 管道信息 */
        struct block_device     *i_bdev;             /* 块设备驱动 */
        unsigned long           i_dnotify_mask;      /* 目录通知掩码 */
        struct dnotify_struct   *i_dnotify;          /* 目录通知 */
        unsigned long           i_state;             /* 状态标志 */
        unsigned long           dirtied_when;        /* 首次修改时间 */
        unsigned int            i_flags;             /* 文件系统标志 */
        unsigned char           i_sock;              /* 可能是个套接字吧 */
        atomic_t                i_writecount;        /* 写者记数 */
        void                    *i_security;         /* 安全模块 */
        __u32                   i_generation;        /* 索引节点版本号 */
        union {
                void            *generic_ip;         /* 文件特殊信息 */
        } u;
};
/*
*索引节点的操作inode_operations定义在linux/fs.h中
*/
struct inode_operations {
        int (*create) (struct inode *, struct dentry *,int);
        /*VFS通过系统调用create()和open()来调用该函数,从而为dentry对象创建一个新的索引节点。在创建时使用mode制定初始模式*/
        struct dentry * (*lookup) (struct inode *, struct dentry *);
        /*该韩式在特定目录中寻找索引节点,该索引节点要对应于dentry中给出的文件名*/
        int (*link) (struct dentry *, struct inode *, struct dentry *);
        /*该函数被系统调用link()电泳,用来创建硬连接。硬链接名称由dentry参数指定,连接对象是dir目录中ld_dentry目录想所代表的文件*/
        int (*unlink) (struct inode *, struct dentry *);
        /*该函数被系统调用unlink()调用,从目录dir中删除由目录项dentry制动的索引节点对象*/
        int (*symlink) (struct inode *, struct dentry *, const char *);
        /*该函数被系统电泳symlik()调用,创建符号连接,该符号连接名称由symname指定,连接对象是dir目录中的dentry目录项*/
        int (*mkdir) (struct inode *, struct dentry *, int);
        /*该函数被mkdir()调用,创建一个新鲁姆。创建时使用mode制定的初始模式*/
        int (*rmdir) (struct inode *, struct dentry *);
        /*该函数被系统调用rmdir()调用,删除dir目录中的dentry目录项代表的文件*/
        int (*mknod) (struct inode *, struct dentry *, int, dev_t);
        /*该函数被系统调用mknod()调用,创建特殊文件(设备文件、命名管道或套接字)。要创建的文件放在dir目录中,其目录项问dentry,关联的设备为rdev,初始权限由mode指定*/
        int (*rename) (struct inode *, struct dentry *,
                       struct inode *, struct dentry *);
        /*VFS调用该函数来移动文件。文件源路径在old_dir目录中,源文件由old_dentry目录项所指定,目标路径在new_dir目录中,目标文件由new_dentry指定*/
        int (*readlink) (struct dentry *, char *, int);
        /*该函数被系统调用readlink()调用,拷贝数据到特定的缓冲buffer中。拷贝的数据来自dentry指定的符号链接,最大拷贝大小可达到buflen字节*/
        int (*follow_link) (struct dentry *, struct nameidata *);
        /*该函数由VFS调用,从一个符号连接查找他指向的索引节点,由dentry指向的连接被解析*/
        int (*put_link) (struct dentry *, struct nameidata *);
        /*在follow_link()调用之后,该函数由vfs调用进行清楚工作*/
        void (*truncate) (struct inode *);
        /*该函数由VFS调用,修改文件的大小,在调用之前,索引节点的i_size项必须被设置成预期的大小*/
        int (*permission) (struct inode *, int);
        /*该函数用来检查给低昂的inode所代表的文件是否允许特定的访问模式,如果允许特定的访问模式,返回0,否则返回负值的错误码。多数文件系统 都将此区域设置为null,使用VFS提供的通用方法进行检查,这种检查操作仅仅比较索引及诶但对象中的访问模式位是否和mask一致,比较复杂的系统, 比如支持访问控制链(ACL)的文件系统,需要使用特殊的permission()方法*/
        int (*setattr) (struct dentry *, struct iattr *);
        /*该函数被notify_change调用,在修改索引节点之后,通知发生了改变事件*/
        int (*getattr) (struct vfsmount *, struct dentry *, struct kstat *);
        /*在通知索引节点需要从磁盘中更新时,VFS会调用该函数*/
        int (*setxattr) (struct dentry *, const char *,
                         const void *, size_t, int);
        /*该函数由VFS调用,向dentry指定的文件设置扩展属性,属性名为name,值为value*/
        ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
        /*该函数被VFS调用,向value中拷贝给定文件的扩展属性name对应的数值*/
        ssize_t (*listxattr) (struct dentry *, char *, size_t);
        /*该函数将特定文件所有属性别表拷贝到一个缓冲列表中*/
        int (*removexattr) (struct dentry *, const char *);
        /*该函数从给定文件中删除指定的属性*/
};

标签:调用,struct,dentry,int,Linux,inode,节点
From: https://www.cnblogs.com/sky-heaven/p/17523053.html

相关文章

  • linux基础2
    ##用户和权限的基本概念用户管理包含用户和组的管理linux系统必须有一个用户,而且对于不同的用户有不同的系统资源权限对文件、目录的权限:在实际工作中,是通过对用户进行分组,对组赋予对应的权限,来管理用户的权限什么类型的文件文件的拥有者权限拥有者所在组的权限组......
  • linux搭建LAMP环境
    LAMP环境指在linux系统下搭建Apache服务器+mysql+php(1)安装Apache服务及其扩展包yum-yinstallhttpdhttpd-manualmod_sslmod_perlmod_auth_mysql(2)启动Apache服务systemctlstarthttpd.service(3)安装mysql  wgethttp://dev.mysql.com/get/mysql57-community-release......
  • linux 常用脚本
    启动python脚本并输出日志到文件nohuppython3-udoReport.py--env=prod>doReport.out2>&1&pip使用清华源pip3installscikit-learn-ihttps://pypi.tuna.tsinghua.edu.cn/simple......
  • linux | 时间同步 | 时钟同步 | ntp同步系统时间
    一、说明        1、linux系统        2、centos        3、系统时间快了2分钟,需要搞成同步二、具体实现1)安装ntpyum-yinstallntp2)启动systemctlstartntpd3)设置开机自启systemctlenablentpd4)查看状态systemctlstatusntpd5)修改配置文......
  • nodejs——linux安装环境
    yum安装nodejsv18.16.1model:unknown,wordcount:7,tokenestimate:14   在yum仓库中,可能没有提供Node.js18.16.1的特定版本。通常,yum仓库中提供的是最新稳定版本的软件包。如果您需要安装特定版本的Node.js,可以考虑使用Node版本管理工具(例如nvm......
  • Linux SPI-NAND 驱动开发指南
    文章目录LinuxSPI-NAND驱动开发指南1概述1.1编写目的1.2适用范围1.3相关人员3流程设计3.1体系结构3.2源码结构3.3关键数据定义3.3.1flash设备信息数据结构3.3.2flashchip数据结构3.3.3aw_spinand_chip_request3.3.4ubi_ec_hdr3.3.5ubi_vid_hdr3.4关键接口说明3......
  • Tina_Linux打包流程说明指南_new
    OpenRemoved_Tina_Linux_打包流程_说明指南_new1概述1.1编写目的介绍Allwinner平台上打包流程。1.2适用范围Allwinner软件平台Tinav3.0版本以上。1.3相关人员适用Tina平台的广大客户,想了解Tina打包流程的开发人员。2固件打包简介固件打包是指将我们编译出来的bootloader......
  • Linux USB 开发指南
    文章目录LinuxUSB开发指南1前言1.1文档简介1.2目标读者1.3适用范围2模块介绍2.1模块功能介绍2.2相关术语介绍2.3模块配置介绍2.3.1DeviceTree配置说明2.3.2board.dts配置说明2.3.3kernelmenuconfig配置说明2.4源码结构介绍2.5驱动框架介绍2.6Gadget配置2.6.......
  • Linux U-Boot 开发指南
    文章目录LinuxU-Boot开发指南1前言1.1编写目的1.2适用范围1.3相关人员2LICHEE类宏关键字解释3编译方法介绍3.1准备编译工具链3.2快速编译boot0及U-Boot3.3编译U-Boot3.4编译boot0/fes/sboot4U-Boot功能及其配置方法/文件介绍4.1U-Boot功能介绍4.2U-Boot功......
  • Linux MMC 开发指南
    文章目录LinuxMMC开发指南1前言1.1文档简介1.2目标读者1.3适用范围2模块介绍2.1模块功能介绍2.2相关术语介绍2.2.1硬件术语2.2.2软件术语2.3模块配置介绍2.3.1sys_config.fex配置说明2.3.2DeviceTree配置说明2.3.2.11.uboot阶段2.3.2.1.1(1)sdc02.3.2.1.2(2)sdc22......