AutoCAD 3DMAX C语言 Pro/E UG JAVA编程 PHP编程 Maya动画 Matlab应用 Android
Photoshop Word Excel flash VB编程 VC编程 Coreldraw SolidWorks A Designer Unity3D
 首页 > Linux

Linux Data Structures(Linux数据结构)

51自学网 http://www.wanshiok.com


device_struct

 

device_struct数据结构用于登记字符和块设备(存放这个设备的名称和可能进行的文件操作)。Chrdevs和blkdevs向量表中的每一个有效的成员都分别代表一个字符或块设备。

参见fs/devices.c

 

struct device_struct {

const char * name;

struct file_operations * fops;

};

 

file

每一个打开的文件、socket等等都用一个file数据结构代表

参见include/linux/fs.h

 

struct file {

mode_t f_mode;

loff_t f_pos;

unsigned short f_flags;

unsigned short f_count;

unsigned long f_reada, f_ramax, f_raend, f_ralen, f_rawin;

struct file *f_next, *f_prev;

int f_owner; /* pid or -pgrp where SIGIO should be sent */

struct inode * f_inode;

struct file_operations * f_op;

unsigned long f_version;

void *private_data; /* needed for tty driver, and maybe others */

};

 

file_struct

file_struct数据结构描述了一个进程打开的文件

参见include/linux/sched.h

struct files_struct {

int count;

fd_set close_on_exec;

fd_set open_fds;

struct file * fd[NR_OPEN];

};

 

fs_struct

参见include/linux/sched.h

struct fs_struct {

int count;

unsigned short umask;

struct inode * root, * pwd;

};

 

gendisk

 

gendisk数据结构存放硬盘的信息。用在初始化过程中找到磁盘,探测分区的时候

参见include/linux/genhd.h

 

struct hd_struct {

long start_sect;

long nr_sects;

};

struct gendisk {

int major; /* major number of driver */

const char *major_name; /* name of major driver */

int minor_shift; /* number of times minor is shifted to

get real minor */

int max_p; /* maximum partitions per device */

int max_nr; /* maximum number of real devices */

void (*init)(struct gendisk *);

/* Initialization called before we

do our thing */

struct hd_struct *part; /* partition table */

int *sizes; /* device size in blocks, copied to

blk_size[] */

int nr_real; /* number of real devices */

void *real_devices; /* internal use */

struct gendisk *next;

};

 

inode

VFS inode数据结构存放磁盘上的一个文件或目录的信息

参见include/linux/fs.h

 

struct inode {

kdev_t i_dev;

unsigned long i_ino;

umode_t i_mode;

nlink_t i_nlink;

uid_t i_uid;

gid_t i_gid;

kdev_t i_rdev;

off_t i_size;

time_t i_atime;

time_t i_mtime;

time_t i_ctime;

unsigned long i_blksize;

unsigned long i_blocks;

unsigned long i_version;

unsigned long i_nrpages;

struct semaphore i_sem;

struct inode_operations *i_op;

struct super_block *i_sb;

struct wait_queue *i_wait;

struct file_lock *i_flock;

struct vm_area_struct *i_mmap;

struct page *i_pages;

struct dquot *i_dquot[MAXQUOTAS];

struct inode *i_next, *i_prev;

struct inode *i_hash_next, *i_hash_prev;

struct inode *i_bound_to, *i_bound_by;

struct inode *i_mount;

unsigned short i_count;

unsigned short i_flags;

unsigned char i_lock;

unsigned char i_dirt;

unsigned char i_pipe;

unsigned char i_sock;

unsigned char i_seek;

unsigned char i_update;

unsigned short i_writecount;

union {

struct pipe_inode_info pipe_i;

struct minix_inode_info minix_i;

struct ext_inode_info ext_i;

struct ext2_inode_info ext2_i;

struct hpfs_inode_info hpfs_i;

struct msdos_inode_info msdos_i;

struct umsdos_inode_info umsdos_i;

struct iso_inode_info isofs_i;

struct nfs_inode_info nfs_i;

struct xiafs_inode_info xiafs_i;

struct sysv_inode_info sysv_i;

struct affs_inode_info affs_i;

struct ufs_inode_info ufs_i;

struct socket socket_i;

void *generic_ip;

} u;

};

 

 
 

上一篇:Linux下C语言编程--信号处理函数  下一篇:Sed编辑器