http://blog.sina.com.cn/s/blog_5219094a01009a4h.html
進程相關的信息
和進程相關的信息, 涉及到四個重要的數據結構:
file, fs_struct, files_struct 和 namespace
相關的數據結構爲:
struct file {
struct list_head f_list;
struct dentry *f_dentry;
struct vfsmount *f_vfsmnt;
struct file_operations *f_op;
atomic_t f_count;
unsigned int f_flags;
mode_t f_mode;
int f_error;
loff_t f_pos;
struct fown_struct f_owner;
unsigned int f_uid, f_gid;
struct file_ra_state f_ra;
size_t f_maxcount;
unsigned long f_version;
void *f_security;
void *private_data;
#ifdef CONFIG_EPOLL
struct list_head f_ep_links;
spinlock_t f_ep_lock;
#endif
struct address_space *f_mapping;
};
-------------------------------------------------------------------------------
struct fs_struct {
atomic_t count;
rwlock_t lock;
int umask;
struct dentry * root, * pwd, * altroot;
struct vfsmount * rootmnt, * pwdmnt, * altrootmnt;
};
-------------------------------------------------------------------------------
struct files_struct {
atomic_t count;
spinlock_t file_lock;
int max_fds;
int max_fdset;
int next_fd;
struct file ** fd;
fd_set *close_on_exec;
fd_set *open_fds;
fd_set close_on_exec_init;
fd_set open_fds_init;
struct file * fd_array[NR_OPEN_DEFAULT];
};
-------------------------------------------------------------------------------
struct namespace {
atomic_t count;
struct vfsmount * root;
struct list_head list;
struct rw_semaphore sem;
};
每個進程都有自己的namespace.
fs_struct用於表示進程與文件系統之間的結構關係,比如當前的工作目錄,進程的根目錄等等.
files_struct 用於表示當前進程打開的文件.
而對於每一個打開的文件,由file對象來表示.
task_struct
+-------------+