您的位置:首页 > 其它

LDD和scull相关各种结构体的故事(学习笔记 不定期更新)

2014-07-28 17:32 507 查看

LDD和各种结构体的故事

struct scull_dev     位置:scull/scull.h

struct scull_dev {
struct scull_qset *data;  /* Pointer to first quantum set */
int quantum;              /* the current quantum size */
int qset;                 /* the current array size */
unsigned long size;       /* amount of data stored here */
unsigned int access_key;  /* used by sculluid and scullpriv */
struct mutex mutex;     /* mutual exclusion semaphore     */
struct cdev cdev;	  /* Char device structure		*/
};


struct mutex       位置:/usr/src/linux-source/include/linux/

struct mutex {
/* 1: unlocked, 0: locked, negative: locked, possible waiters */
atomic_t                count;
spinlock_t              wait_lock;
struct list_head        wait_list;
#if defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_SMP)
struct task_struct      *owner;
#endif
#ifdef CONFIG_DEBUG_MUTEXES
const char              *name;
void                    *magic;
#endif
#ifdef CONFIG_DEBUG_LOCK_ALLOC
struct lockdep_map      dep_map;
#endif
};


这个有点点长哇。。。

struct inode
   位置:/usr/src/linux-source/include/linux/fs.h

/*
* Keep mostly read-only and often accessed (especially for
* the RCU path lookup and 'stat' data) fields at the beginning
* of the 'struct inode'
*/
struct inode {
umode_t                 i_mode;
unsigned short          i_opflags;
kuid_t                  i_uid;
kgid_t                  i_gid;
unsigned int            i_flags;

#ifdef CONFIG_FS_POSIX_ACL
struct posix_acl        *i_acl;
struct posix_acl        *i_default_acl;
#endif

const struct inode_operations   *i_op;
struct super_block      *i_sb;
struct address_space    *i_mapping;

#ifdef CONFIG_SECURITY
void                    *i_security;
#endif

/* Stat data, not accessed from path walking */
unsigned long           i_ino;
/*
* Filesystems may only read i_nlink directly.  They shall use the
* following functions for modification:
*
*    (set|clear|inc|drop)_nlink
*    inode_(inc|dec)_link_count
*/
union {
const unsigned int i_nlink;
unsigned int __i_nlink;
};
dev_t                   i_rdev;
loff_t                  i_size;
struct timespec         i_atime;
struct timespec         i_mtime;
struct timespec         i_ctime;
spinlock_t              i_lock; /* i_blocks, i_bytes, maybe i_size */
unsigned short          i_bytes;
unsigned int            i_blkbits;
blkcnt_t                i_blocks;

#ifdef __NEED_I_SIZE_ORDERED
seqcount_t              i_size_seqcount;
#endif

/* Misc */

unsigned long           i_state;
struct mutex            i_mutex;

unsigned long           dirtied_when;   /* jiffies of first dirtying */

struct hlist_node       i_hash;
struct list_head        i_wb_list;      /* backing dev IO list */
struct list_head        i_lru;          /* inode LRU list */
struct list_head        i_sb_list;
union {
struct hlist_head       i_dentry;
struct rcu_head         i_rcu;
};
u64                     i_version;
atomic_t                i_count;
atomic_t                i_dio_count;
atomic_t                i_writecount;
const struct file_operations    *i_fop; /* former ->i_op->default_file_ops */
struct file_lock        *i_flock;
struct address_space    i_data;
#ifdef CONFIG_QUOTA
struct dquot            *i_dquot[MAXQUOTAS];
#endif
struct list_head        i_devices;
union {
struct pipe_inode_info  *i_pipe;
struct block_device     *i_bdev;
struct cdev             *i_cdev;
};
__u32                   i_generation;

#ifdef CONFIG_FSNOTIFY
__u32                   i_fsnotify_mask; /* all events this inode cares about */
struct hlist_head       i_fsnotify_marks;
#endif

#ifdef CONFIG_IMA
atomic_t                i_readcount; /* struct files open RO */
#endif
void                    *i_private; /* fs or device private pointer */
};


struct file     
位置:/usr/src/linux-source/include/linux/fs.h

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;

/*
* Protects f_ep_links, f_flags, f_pos vs i_size in lseek SEEK_CUR.
* Must not be taken from IRQ context.
*/
spinlock_t              f_lock;
#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;
struct list_head        f_tfile_llink;
#endif /* #ifdef CONFIG_EPOLL */
struct address_space    *f_mapping;
#ifdef CONFIG_DEBUG_WRITECOUNT
unsigned long f_mnt_write_state;
#endif
};


struct cdev      位置:/usr/src/linux-source/include/linux/cdev.h

struct cdev {
struct kobject kobj;
struct module *owner;
const struct file_operations *ops;
struct list_head list;
dev_t dev;
unsigned int count;
};


 

struct scull_qset                             位置:scull/scull.h

struct scull_qset {
void **data;
struct scull_qset *next;
};


struct seq_file       位置:/usr/src/linux-source/include/linux/sqe_file.h

struct seq_file {
char *buf;
size_t size;
size_t from;
size_t count;
loff_t index;
loff_t read_pos;
u64 version;
struct mutex lock;
const struct seq_operations *op;
int poll_event;
#ifdef CONFIG_USER_NS
struct user_namespace *user_ns;
#endif
void *private;
};


kmem_cache 


位置:/usr/src/linux-source/include/linux/slab.h

struct kmem_cache {
unsigned int object_size;/* The original size of the object */
unsigned int size;	/* The aligned/padded/added on size  */
unsigned int align;	/* Alignment as calculated */
unsigned long flags;	/* Active flags on the slab */
const char *name;	/* Slab name for sysfs */
int refcount;		/* Use counter */
void (*ctor)(void *);	/* Called on object slot creation */
struct list_head list;	/* List of all slab caches on the system */
};


poll_table


位置:/usr/src/linux-source/include/linux/poll.h

typedef struct poll_table_struct {
poll_queue_proc _qproc;
unsigned long _key;
} poll_table;


work_struct


位置:/usr/src/linux-source/include/linux/workqueue.h

struct work_struct {
atomic_long_t data;
struct list_head entry;
work_func_t func;
#ifdef CONFIG_LOCKDEP
struct lockdep_map lockdep_map;
#endif
};

"也哭也笑,平凡着"

—— 平凡之路

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: