码迷,mamicode.com
首页 > 系统相关 > 详细

linux驱动开发记录

时间:2017-07-15 22:45:11      阅读:298      评论:0      收藏:0      [点我收藏+]

标签:eve   mic   pipe   from   ping   spec   ons   mutex   color   

inode:

include/linux/fs.h

 1 /*
 2  * Keep mostly read-only and often accessed (especially for
 3  * the RCU path lookup and ‘stat‘ data) fields at the beginning
 4  * of the ‘struct inode‘
 5  */
 6 struct inode {
 7     umode_t            i_mode;
 8     unsigned short        i_opflags;
 9     kuid_t            i_uid;
10     kgid_t            i_gid;
11     unsigned int        i_flags;
12 
13 #ifdef CONFIG_FS_POSIX_ACL
14     struct posix_acl    *i_acl;
15     struct posix_acl    *i_default_acl;
16 #endif
17 
18     const struct inode_operations    *i_op;
19     struct super_block    *i_sb;
20     struct address_space    *i_mapping;
21 
22 #ifdef CONFIG_SECURITY
23     void            *i_security;
24 #endif
25 
26     /* Stat data, not accessed from path walking */
27     unsigned long        i_ino;
28     /*
29      * Filesystems may only read i_nlink directly.  They shall use the
30      * following functions for modification:
31      *
32      *    (set|clear|inc|drop)_nlink
33      *    inode_(inc|dec)_link_count
34      */
35     union {
36         const unsigned int i_nlink;
37         unsigned int __i_nlink;
38     };
39     dev_t            i_rdev;
40     loff_t            i_size;
41     struct timespec        i_atime;
42     struct timespec        i_mtime;
43     struct timespec        i_ctime;
44     spinlock_t        i_lock;    /* i_blocks, i_bytes, maybe i_size */
45     unsigned short          i_bytes;
46     unsigned int        i_blkbits;
47     blkcnt_t        i_blocks;
48 
49 #ifdef __NEED_I_SIZE_ORDERED
50     seqcount_t        i_size_seqcount;
51 #endif
52 
53     /* Misc */
54     unsigned long        i_state;
55     struct mutex        i_mutex;
56 
57     unsigned long        dirtied_when;    /* jiffies of first dirtying */
58 
59     struct hlist_node    i_hash;
60     struct list_head    i_wb_list;    /* backing dev IO list */
61     struct list_head    i_lru;        /* inode LRU list */
62     struct list_head    i_sb_list;
63     union {
64         struct hlist_head    i_dentry;
65         struct rcu_head        i_rcu;
66     };
67     u64            i_version;
68     atomic_t        i_count;
69     atomic_t        i_dio_count;
70     atomic_t        i_writecount;
71 #ifdef CONFIG_IMA
72     atomic_t        i_readcount; /* struct files open RO */
73 #endif
74     const struct file_operations    *i_fop;    /* former ->i_op->default_file_ops */
75     struct file_lock_context    *i_flctx;
76     struct address_space    i_data;
77     struct list_head    i_devices;
78     union {
79         struct pipe_inode_info    *i_pipe;
80         struct block_device    *i_bdev;
81         struct cdev        *i_cdev;
82     };
83 
84     __u32            i_generation;
85 
86 #ifdef CONFIG_FSNOTIFY
87     __u32            i_fsnotify_mask; /* all events this inode cares about */
88     struct hlist_head    i_fsnotify_marks;
89 #endif
90 
91     void            *i_private; /* fs or device private pointer */
92 };

 

file:

include/linux/fs.h

 1 struct file {
 2     union {
 3         struct llist_node    fu_llist;
 4         struct rcu_head     fu_rcuhead;
 5     } f_u;
 6     struct path        f_path;
 7     struct inode        *f_inode;    /* cached value */
 8     const struct file_operations    *f_op;
 9 
10     /*
11      * Protects f_ep_links, f_flags.
12      * Must not be taken from IRQ context.
13      */
14     spinlock_t        f_lock;
15     atomic_long_t        f_count;
16     unsigned int         f_flags;
17     fmode_t            f_mode;
18     struct mutex        f_pos_lock;
19     loff_t            f_pos;
20     struct fown_struct    f_owner;
21     const struct cred    *f_cred;
22     struct file_ra_state    f_ra;
23 
24     u64            f_version;
25 #ifdef CONFIG_SECURITY
26     void            *f_security;
27 #endif
28     /* needed for tty driver, and maybe others */
29     void            *private_data;
30 
31 #ifdef CONFIG_EPOLL
32     /* Used by fs/eventpoll.c to link all the hooks to this file */
33     struct list_head    f_ep_links;
34     struct list_head    f_tfile_llink;
35 #endif /* #ifdef CONFIG_EPOLL */
36     struct address_space    *f_mapping;
37 } __attribute__((aligned(4)));    /* lest something weird decides that 2 is OK */

 

 

cdev

include/linux/cdev.h

1  struct cdev {
2  13         struct kobject kobj;
3  14         struct module *owner;
4  15         const struct file_operations *ops;
5  16         struct list_head list;
6  17         dev_t dev;
7  18         unsigned int count;
8  19 };

 

linux驱动开发记录

标签:eve   mic   pipe   from   ping   spec   ons   mutex   color   

原文地址:http://www.cnblogs.com/wjx321/p/7186621.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!