下面看一下上层应用open() 调用系统调用函数的过程 对于一个字符设备文件, 其inode->i_cdev 指向字符驱动对象cdev, 如果i_cdev为 NULL ,则说明该设备文件没有被打开. 由于多个设备可以共用同一个驱动程序.所以,通过字符设备的inode 中的i_devices 和 cdev中的list组成一个链表 首先,系统调用open打开一个字符设备...
union {conststructfile_operations *i_fop;/*former ->i_op->default_file_ops*/void(*free_inode)(structinode *); };structfile_lock_context *i_flctx;structaddress_space i_data;structlist_head i_devices; union {structpipe_inode_info *i_pipe;structcdev *i_cdev;char*i_link; unsigned i_d...
struct file_lock_context *i_flctx; struct address_space i_data; struct list_head i_devices; union { struct pipe_inode_info *i_pipe; struct cdev *i_cdev; char *i_link; unsigned i_dir_seq; }; __u32 i_generation; #ifdef CONFIG_FSNOTIFY __u32 i_fsnotify_mask; struct fsnotify_mark...
(struct inode *); }; struct file_lock_context *i_flctx; struct address_space i_data; struct list_head i_devices; union { struct pipe_inode_info *i_pipe; struct cdev *i_cdev; char *i_link; unsigned i_dir_seq; }; __u32 i_generation; void *i_private; /* fs or device ...
i_devices:设备链表。共用同一个驱动程序的设备形成的链表。 i_pipe:指向管道文件(如果文件是管道文件时使用) i_bdev:指向块设备文件指针(如果文件是块设备文件时使用) i_cdev:指向字符设备文件指针(如果文件是字符设备时使用) i_dnotify_mask:目录通知事件掩码 ...
conststructfile_operations*i_fop;/* former ->i_op->default_file_ops */structaddress_spacei_data;structlist_headi_devices;union{structpipe_inode_info*i_pipe;structblock_device*i_bdev;structcdev*i_cdev;char*i_link;unsignedi_dir_seq;};void*i_private;/* fs or device private pointer */}...
在文件系统中,有三大缓冲为了提升效率:inode缓冲区、dentry缓冲区、块缓冲。 (内核:2.4.37) 一、inode缓冲区 为了加快对索引节点的索引,引入inode缓冲区,下面我们看Linux/fs/inode.c代码。inod
atomic_t i_readcount;/* struct files open RO */ #endif conststruct file_operations *i_fop;/* former ->i_op->default_file_ops */ struct file_lock_context *i_flctx; struct address_space i_data; struct list_head i_devices;
Linux 中一切都可以看作文件,包括普通文件、链接文件、Socket 以及设备驱动等,对其进行相关操作时,都可能会创建对应的文件描述符。文件描述符(file descriptor)是内核为了高效管理已被打开的文件所创建的索引,用于指代被打开的文件,对文件所有 I/O 操作相关的系统调用都需要通过文件描述符。
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; /* 块设备驱动 */ ...