1、Linux驱动重要的数据结构
2016-04-08 15:36
645 查看
1、struct file
这个结构体定义在 linuxsource/include/linux/fs.h 中第960行左右
具体成员如下:
从内核来看,每一个打开的文件都需要有一个file结构体来描述它
具体查看
http://blog.csdn.net/wangchaoxjtuse/article/details/6036684
2、struct inode
索引节点对象由inode结构体表示,定义文件在linux/fs.h中。
linux 中每一个文件都需要有一个inode节点来描述
View Code
这个结构体定义在 linuxsource/include/linux/fs.h 中第960行左右
具体成员如下:
struct file { /* * fu_list becomes invalid after file_free is called and queued via * fu_rcuhead for RCU freeing */ union { struct list_head fu_list; struct rcu_head fu_rcuhead; } f_u; struct path f_path; #define f_dentry f_path.dentry #define f_vfsmnt f_path.mnt const struct file_operations *f_op; spinlock_t f_lock; /* f_ep_links, f_flags, no IRQ */ #ifdef CONFIG_SMP int f_sb_list_cpu; #endif atomic_long_t f_count; unsigned int f_flags; fmode_t f_mode; loff_t f_pos; struct fown_struct f_owner; const struct cred *f_cred; struct file_ra_state f_ra; u64 f_version; #ifdef CONFIG_SECURITY void *f_security; #endif /* needed for tty driver, and maybe others */ void *private_data; #ifdef CONFIG_EPOLL /* Used by fs/eventpoll.c to link all the hooks to this file */ struct list_head f_ep_links; #endif /* #ifdef CONFIG_EPOLL */ struct address_space *f_mapping; #ifdef CONFIG_DEBUG_WRITECOUNT unsigned long f_mnt_write_state; #endif };
从内核来看,每一个打开的文件都需要有一个file结构体来描述它
具体查看
http://blog.csdn.net/wangchaoxjtuse/article/details/6036684
2、struct inode
索引节点对象由inode结构体表示,定义文件在linux/fs.h中。
linux 中每一个文件都需要有一个inode节点来描述
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; };
View Code
相关文章推荐
- 数据结构学习(1)
- 【学习笔记----数据结构02--线性表】
- SDUT 2116----数据结构实验之链表一:顺序建立链表
- 数据结构与算法——AVL树类的C++实现
- mysql 中decimal数据结构
- 二叉树遍历总结
- 算法与数据结构 - 二叉树
- 【AC自动机】【数据结构】【树】【Aho-Corasick automation】AC自动机理解(入门)
- Java模拟单链表和双端链表数据结构的实例讲解
- 【后缀自动机】【SAM】【自动机】【数据结构】后缀自动机理解(入门)
- 数据结构学习笔记(五)
- MD5加密算法
- 数据结构(C语言)---单链表的简单应用
- 字符串转成整数大数乘法
- 有序表的最小和
- 二叉树的非递归遍历方法(前序,中序,后序)
- 数据结构学习笔记(四)
- 数据结构(9):二叉树的遍历、构建以及显示(凹入法)
- 数据结构(8):二叉树的存储结构
- 第17章 二叉树,堆和优先队列(2/3)