{"id":248,"date":"2020-08-18T19:23:47","date_gmt":"2020-08-18T20:23:47","guid":{"rendered":"http:\/\/www.linux-tutorial.info\/?page_id=77"},"modified":"2020-08-22T19:26:02","modified_gmt":"2020-08-22T20:26:02","slug":"this-is-the-page-title-toplevel-83","status":"publish","type":"page","link":"http:\/\/www.linux-tutorial.info\/?page_id=248","title":{"rendered":"Linux Data Structures"},"content":{"rendered":"\n<title>Linux Data Structures<\/title>\n<p>\nThis section lists the major data structures that Linux uses and which are described in\nother sections.\n<p>\n<h3>block_dev_struct<\/h3>\n<tt>block_dev_struct<\/tt>\ndata structures are used to register block devices as available for use by\nthe buffer cache.\nThey are held together in the <tt>blk_dev<\/tt> vector.\n<p>\n<pre>\nstruct blk_dev_struct {\n    void (*request_fn)(void);\n    struct request * current_request;\n    struct request   plug;\n    struct tq_struct plug_tq;\n};\n<\/pre>\n<h3>buffer_head<\/h3>\nThe <tt>buffer_head<\/tt> data structure holds information about a block buffer in the\nbuffer cache.\n<p>\n<pre>\n\/* bh state bits *\/\n#define BH_Uptodate  0   \/* 1 if the buffer contains valid data      *\/\n#define BH_Dirty     1   \/* 1 if the buffer is dirty                 *\/\n#define BH_Lock      2   \/* 1 if the buffer is locked                *\/\n#define BH_Req       3   \/* 0 if the buffer has been invalidated     *\/\n#define BH_Touched   4   \/* 1 if the buffer has been touched (aging) *\/\n#define BH_Has_aged  5   \/* 1 if the buffer has been aged (aging)    *\/\n#define BH_Protected 6   \/* 1 if the buffer is protected             *\/\n#define BH_FreeOnIO  7   \/* 1 to discard the buffer_head after IO    *\/\nstruct buffer_head {\n  \/* First cache line: *\/\n  unsigned long      b_blocknr;    \/* block number                   *\/\n  kdev_t             b_dev;        \/* device (B_FREE = free)         *\/\n  kdev_t             b_rdev;       \/* Real device                    *\/\n  unsigned long      b_rsector;    \/* Real buffer location on disk   *\/\n  struct buffer_head *b_next;      \/* Hash queue list                *\/\n  struct buffer_head *b_this_page; \/* circular list of buffers in one\n                                      page                           *\/\n  \/* Second cache line: *\/\n  unsigned long      b_state;      \/* buffer state bitmap (above)    *\/\n  struct buffer_head *b_next_free;\n  unsigned int       b_count;      \/* users using this block         *\/\n  unsigned long      b_size;       \/* block size                     *\/\n  \/* Non-performance-critical data follows. *\/\n  char               *b_data;      \/* pointer to data block          *\/\n  unsigned int       b_list;       \/* List that this buffer appears  *\/\n  unsigned long      b_flushtime;  \/* Time when this (dirty) buffer\n                                    * should be written              *\/\n  unsigned long      b_lru_time;   \/* Time when this buffer was\n                                    * last used.                     *\/\n  struct wait_queue  *b_wait;\n  struct buffer_head *b_prev;      \/* doubly linked hash list        *\/\n  struct buffer_head *b_prev_free; \/* doubly linked list of buffers  *\/\n  struct buffer_head *b_reqnext;   \/* request queue                  *\/\n};\n<\/pre>\n<h3>device<\/h3>\nEvery network device in the system is represented by a <tt>device<\/tt> data\nstructure.\n<p>\n<pre>\nstruct device\n{\n  \/*\n   * This is the first field of the \"visible\" part of this structure\n   * (i.e. as seen by users in the \"Space.c\" file).  It is the name\n   * the interface.\n   *\/\n  char                    *name;\n  \/* I\/O specific fields                                           *\/\n  unsigned long           rmem_end;        \/* shmem \"recv\" end     *\/\n  unsigned long           rmem_start;      \/* shmem \"recv\" start   *\/\n  unsigned long           mem_end;         \/* shared mem end       *\/\n  unsigned long           mem_start;       \/* shared mem start     *\/\n  unsigned long           base_addr;       \/* device I\/O address   *\/\n  unsigned char           irq;             \/* device IRQ number    *\/\n  \/* Low-level status flags. *\/\n  volatile unsigned char  start,           \/* start an operation   *\/\n                          interrupt;       \/* interrupt arrived    *\/\n  unsigned long           tbusy;           \/* transmitter busy     *\/\n  struct device           *next;\n  \/* The device initialization function. Called only once.         *\/\n  int                     (*init)(struct device *dev);\n  \/* Some hardware also needs these fields, but they are not part of\n     the usual set specified in Space.c. *\/\n  unsigned char           if_port;         \/* Selectable AUI,TP,   *\/\n  unsigned char           dma;             \/* DMA channel          *\/\n  struct enet_statistics* (*get_stats)(struct device *dev);\n  \/*\n   * This marks the end of the \"visible\" part of the structure. All\n   * fields hereafter are internal to the system, and may change at\n   * will (read: may be cleaned up at will).\n   *\/\n  \/* These may be needed for future network-power-down code.       *\/\n  unsigned long           trans_start;     \/* Time (jiffies) of\n                                              last transmit        *\/\n  unsigned long           last_rx;         \/* Time of last Rx      *\/\n  unsigned short          flags;           \/* interface flags (BSD)*\/\n  unsigned short          family;          \/* address family ID    *\/\n  unsigned short          metric;          \/* routing metric       *\/\n  unsigned short          mtu;             \/* MTU value            *\/\n  unsigned short          type;            \/* hardware type        *\/\n  unsigned short          hard_header_len; \/* hardware hdr len     *\/\n  void                    *priv;           \/* private data         *\/\n  \/* Interface address info. *\/\n  unsigned char           broadcast[MAX_ADDR_LEN];\n  unsigned char           pad;\n  unsigned char           dev_addr[MAX_ADDR_LEN];\n  unsigned char           addr_len;        \/* hardware addr len    *\/\n  unsigned long           pa_addr;         \/* protocol address     *\/\n  unsigned long           pa_brdaddr;      \/* protocol broadcast addr*\/\n  unsigned long           pa_dstaddr;      \/* protocol P-P other addr*\/\n  unsigned long           pa_mask;         \/* protocol netmask     *\/\n  unsigned short          pa_alen;         \/* protocol address len *\/\n  struct dev_mc_list      *mc_list;        \/* M'cast mac addrs     *\/\n  int                     mc_count;        \/* No installed mcasts  *\/\n  struct ip_mc_list       *ip_mc_list;     \/* IP m'cast filter chain *\/\n  __u32                   tx_queue_len;    \/* Max frames per queue   *\/\n  \/* For load balancing driver pair support *\/\n  unsigned long           pkt_queue;       \/* Packets queued       *\/\n  struct device           *slave;          \/* Slave device         *\/\n  struct net_alias_info   *alias_info;     \/* main dev alias info  *\/\n  struct net_alias        *my_alias;       \/* alias devs           *\/\n  \/* Pointer to the interface buffers. *\/\n  struct sk_buff_head     buffs[DEV_NUMBUFFS];\n  \/* Pointers to interface service routines. *\/\n  int                     (*open)(struct device *dev);\n  int                     (*stop)(struct device *dev);\n  int                     (*hard_start_xmit) (struct sk_buff *skb,\n                                              struct device *dev);\n  int                     (*hard_header) (struct sk_buff *skb,\n                                          struct device *dev,\n                                          unsigned short type,\n                                          void *daddr,\n                                          void *saddr,\n                                          unsigned len);\n  int                     (*rebuild_header)(void *eth,\n                                          struct device *dev,\n                                          unsigned long raddr,\n                                          struct sk_buff *skb);\n  void                    (*set_multicast_list)(struct device *dev);\n  int                     (*set_mac_address)(struct device *dev,\n                                          void *addr);\n  int                     (*do_ioctl)(struct device *dev,\n                                          struct ifreq *ifr,\n                                          int cmd);\n  int                     (*set_config)(struct device *dev,\n                                          struct ifmap *map);\n  void                    (*header_cache_bind)(struct hh_cache **hhp,\n                                          struct device *dev,\n                                          unsigned short htype,\n                                          __u32 daddr);\n  void                    (*header_cache_update)(struct hh_cache *hh,\n                                          struct device *dev,\n                                          unsigned char *  haddr);\n  int                     (*change_mtu)(struct device *dev,\n                                          int new_mtu);\n  struct iw_statistics*   (*get_wireless_stats)(struct device *dev);\n};\n<\/pre>\n<h3>device_struct<\/h3>\n<tt>device_struct<\/tt>\ndata structures are used to register character and block devices.\n(They hold the name and the set of file operations that can be used for this\ndevice).\nEach valid member of the <tt>chrdevs<\/tt> and\n<tt>blkdevs<\/tt> vectors represents a character or block device\nrespectively.\n<p>\n<pre>\nstruct device_struct {\n    const char * name;\n    struct file_operations * fops;\n};\n<\/pre>\n<h3>file<\/h3>\nEach open file, socket etcetera is represented by a <tt>file<\/tt> data structure.\n<p>\n<pre>\nstruct file {\n  mode_t f_mode;\n  loff_t f_pos;\n  unsigned short f_flags;\n  unsigned short f_count;\n  unsigned long f_reada, f_ramax, f_raend, f_ralen, f_rawin;\n  struct file *f_next, *f_prev;\n  int f_owner;         \/* pid or -pgrp where SIGIO should be sent *\/\n  struct inode * f_inode;\n  struct file_operations * f_op;\n  unsigned long f_version;\n  void *private_data;  \/* needed for tty driver, and maybe others *\/\n};\n<\/pre>\n<h3>files_struct<\/h3>\nThe <tt>files_struct<\/tt> data structure describes the files that a process\nhas open.\n<p>\n<pre>\nstruct files_struct {\n  int count;\n  fd_set close_on_exec;\n  fd_set open_fds;\n  struct file * fd[NR_OPEN];\n};\n<\/pre>\n<h3>fs_struct<\/h3>\n<p>\n<pre>\nstruct fs_struct {\n  int count;\n  unsigned short umask;\n  struct inode * root, * pwd;\n};\n<\/pre>\n<h3>gendisk<\/h3>\nThe <tt>gendisk<\/tt> data structure holds information about a hard disk.\nThey are used during initialization when the disks are found and then probed for partitions.\n<p>\n<pre>\nstruct hd_struct {\n    long start_sect;\n    long nr_sects;\n};\nstruct gendisk {\n    int major;               \/* major number of driver *\/\n    const char *major_name;  \/* name of major driver *\/\n    int minor_shift;         \/* number of times minor is shifted to\n                                get real minor *\/\n    int max_p;               \/* maximum partitions per device *\/\n    int max_nr;              \/* maximum number of real devices *\/\n    void (*init)(struct gendisk *);\n                             \/* Initialization called before we\n                                do our thing *\/\n    struct hd_struct *part;  \/* partition table *\/\n    int *sizes;              \/* device size in blocks, copied to\n                                blk_size[] *\/\n    int nr_real;             \/* number of real devices *\/\n    void *real_devices;      \/* internal use *\/\n    struct gendisk *next;\n};\n<\/pre>\n<h3>inode<\/h3>\nThe VFS <tt>inode<\/tt> data structure holds information about a file or directory on disk.\n<p>\n<pre>\nstruct inode {\n    kdev_t                       i_dev;\n    unsigned long                i_ino;\n    umode_t                      i_mode;\n    nlink_t                      i_nlink;\n    uid_t                        i_uid;\n    gid_t                        i_gid;\n    kdev_t                       i_rdev;\n    off_t                        i_size;\n    time_t                       i_atime;\n    time_t                       i_mtime;\n    time_t                       i_ctime;\n    unsigned long                i_blksize;\n    unsigned long                i_blocks;\n    unsigned long                i_version;\n    unsigned long                i_nrpages;\n    struct semaphore             i_sem;\n    struct inode_operations      *i_op;\n    struct super_block           *i_sb;\n    struct wait_queue            *i_wait;\n    struct file_lock             *i_flock;\n    struct vm_area_struct        *i_mmap;\n    struct page                  *i_pages;\n    struct dquot                 *i_dquot[MAXQUOTAS];\n    struct inode                 *i_next, *i_prev;\n    struct inode                 *i_hash_next, *i_hash_prev;\n    struct inode                 *i_bound_to, *i_bound_by;\n    struct inode                 *i_mount;\n    unsigned short               i_count;\n    unsigned short               i_flags;\n    unsigned char                i_lock;\n    unsigned char                i_dirt;\n    unsigned char                i_pipe;\n    unsigned char                i_sock;\n    unsigned char                i_seek;\n    unsigned char                i_update;\n    unsigned short               i_writecount;\n    union {\n        struct pipe_inode_info   pipe_i;\n        struct minix_inode_info  minix_i;\n        struct ext_inode_info    ext_i;\n        struct ext2_inode_info   ext2_i;\n        struct hpfs_inode_info   hpfs_i;\n        struct msdos_inode_info  msdos_i;\n        struct umsdos_inode_info umsdos_i;\n        struct iso_inode_info    isofs_i;\n        struct nfs_inode_info    nfs_i;\n        struct xiafs_inode_info  xiafs_i;\n        struct sysv_inode_info   sysv_i;\n        struct affs_inode_info   affs_i;\n        struct ufs_inode_info    ufs_i;\n        struct socket            socket_i;\n        void                     *generic_ip;\n    } u;\n};\n<\/pre>\n<h3>ipc_perm<\/h3>\nThe <tt>ipc_perm<\/tt> data structure describes the access permissions\nof a System V IPC object .\n<p>\n<pre>\nstruct ipc_perm\n{\n  key_t  key;\n  ushort uid;   \/* owner euid and egid *\/\n  ushort gid;\n  ushort cuid;  \/* creator euid and egid *\/\n  ushort cgid;\n  ushort mode;  \/* access modes see mode flags below *\/\n  ushort seq;   \/* sequence number *\/\n};\n<\/pre>\n<h3>irqaction<\/h3>\nThe <tt>irqaction<\/tt> data structure is used to describe the\nsystem&#8217;s interrupt handlers.\n<p>\n<pre>\nstruct irqaction {\n  void (*handler)(int, void *, struct pt_regs *);\n  unsigned long flags;\n  unsigned long mask;\n  const char *name;\n  void *dev_id;\n  struct irqaction *next;\n};\n<\/pre>\n<h3>linux_binfmt<\/h3>\nEach binary file format that Linux understands is represented by a <tt>linux_binfmt<\/tt>\ndata structure.\n<p>\n<pre>\nstruct linux_binfmt {\n  struct linux_binfmt * next;\n  long *use_count;\n  int (*load_binary)(struct linux_binprm *, struct  pt_regs * regs);\n  int (*load_shlib)(int fd);\n  int (*core_dump)(long signr, struct pt_regs * regs);\n};\n<\/pre>\n<h3>mem_map_t<\/h3>\nThe <tt>mem_map_t<\/tt> data structure (also known as <tt>page<\/tt>) is used to hold\ninformation about each page of physical memory.\n<p>\n<pre>\ntypedef struct page {\n  \/* these must be first (free area handling) *\/\n  struct page        *next;\n  struct page        *prev;\n  struct inode       *inode;\n  unsigned long      offset;\n  struct page        *next_hash;\n  atomic_t           count;\n  unsigned           flags;     \/* atomic flags, some possibly\n                                   updated asynchronously *\/\n  unsigned           dirty:16,\n                     age:8;\n  struct wait_queue  *wait;\n  struct page        *prev_hash;\n  struct buffer_head *buffers;\n  unsigned long      swap_unlock_entry;\n  unsigned long      map_nr;    \/* page-&#62;map_nr == page - mem_map *\/\n} mem_map_t;\n<\/pre>\n<h3>mm_struct<\/h3>\nThe <tt>mm_struct<\/tt> data structure is used to describe the virtual memory of a task or\nprocess.\n<p>\n<pre>\nstruct mm_struct {\n  int count;\n  pgd_t * pgd;\n  unsigned long context;\n  unsigned long start_code, end_code, start_data, end_data;\n  unsigned long start_brk, brk, start_stack, start_mmap;\n  unsigned long arg_start, arg_end, env_start, env_end;\n  unsigned long rss, total_vm, locked_vm;\n  unsigned long def_flags;\n  struct vm_area_struct * mmap;\n  struct vm_area_struct * mmap_avl;\n  struct semaphore mmap_sem;\n};\n<\/pre>\n<h3>pci_bus<\/h3>\nEvery PCI bus in the system is represented by a <tt>pci_bus<\/tt> data structure.\n<p>\n<pre>\nstruct pci_bus {\n  struct pci_bus  *parent;     \/* parent bus this bridge is on *\/\n  struct pci_bus  *children;   \/* chain of P2P bridges on this bus *\/\n  struct pci_bus  *next;       \/* chain of all PCI buses *\/\n  struct pci_dev  *self;       \/* bridge device as seen by parent *\/\n  struct pci_dev  *devices;    \/* devices behind this bridge *\/\n  void    *sysdata;            \/* hook for sys-specific extension *\/\n  unsigned char  number;       \/* bus number *\/\n  unsigned char  primary;      \/* number of primary bridge *\/\n  unsigned char  secondary;    \/* number of secondary bridge *\/\n  unsigned char  subordinate;  \/* max number of subordinate buses *\/\n};\n<\/pre>\n<h3>pci_dev<\/h3>\nEvery PCI device in the system, including PCI-PCI and PCI-ISA bridge\ndevices is represented by a <tt>pci_dev<\/tt> data structure.\n<p>\n<pre>\n\/*\n * There is one pci_dev structure for each slot-number\/function-number\n * combination:\n *\/\nstruct pci_dev {\n  struct pci_bus  *bus;      \/* bus this device is on *\/\n  struct pci_dev  *sibling;  \/* next device on this bus *\/\n  struct pci_dev  *next;     \/* chain of all devices *\/\n  void    *sysdata;          \/* hook for sys-specific extension *\/\n  unsigned int  devfn;       \/* encoded device & function index *\/\n  unsigned short  vendor;\n  unsigned short  device;\n  unsigned int  class;       \/* 3 bytes: (base,sub,prog-if) *\/\n  unsigned int  master : 1;  \/* set if device is master capable *\/\n  \/*\n   * In theory, the irq level can be read from configuration\n   * space and all would be fine.  However, old PCI chips don't\n   * support these registers and return 0 instead.  For example,\n   * the Vision864-P rev 0 chip can uses INTA, but returns 0 in\n   * the interrupt line and pin registers.  pci_init()\n   * initializes this field with the value at PCI_INTERRUPT_LINE\n   * and it is the job of pcibios_fixup() to change it if\n   * necessary.  The field must not be 0 unless the device\n   * cannot generate interrupts at all.\n   *\/\n  unsigned char  irq;        \/* irq generated by this device *\/\n};\n<\/pre>\n<h3>request<\/h3>\n<tt>request<\/tt> data structures are used to make requests to the block devices in the\nsystem.\nThe requests are always to read or write blocks of data to or from the buffer cache.\n<p>\n<pre>\nstruct request {\n    volatile int rq_status;\n#define RQ_INACTIVE            (-1)\n#define RQ_ACTIVE              1\n#define RQ_SCSI_BUSY           0xffff\n#define RQ_SCSI_DONE           0xfffe\n#define RQ_SCSI_DISCONNECTING  0xffe0\n    kdev_t rq_dev;\n    int cmd;        \/* READ or WRITE *\/\n    int errors;\n    unsigned long sector;\n    unsigned long nr_sectors;\n    unsigned long current_nr_sectors;\n    char * buffer;\n    struct semaphore * sem;\n    struct buffer_head * bh;\n    struct buffer_head * bhtail;\n    struct request * next;\n};\n<\/pre>\n<h3>rtable<\/h3>\nEach <tt>rtable<\/tt> data structure holds information about the route to take in\norder to send packets to an IP host.\n<tt>rtable<\/tt> data structures are used within the IP route cache.\n<p>\n<pre>\nstruct rtable\n{\n    struct rtable     *rt_next;\n    __u32             rt_dst;\n    __u32             rt_src;\n    __u32             rt_gateway;\n    atomic_t          rt_refcnt;\n    atomic_t          rt_use;\n    unsigned long     rt_window;\n    atomic_t          rt_lastuse;\n    struct hh_cache   *rt_hh;\n    struct device     *rt_dev;\n    unsigned short    rt_flags;\n    unsigned short    rt_mtu;\n    unsigned short    rt_irtt;\n    unsigned char     rt_tos;\n};\n<\/pre>\n<h3>semaphore<\/h3>\nSemaphores are used to protect critical data structures and regions of code.\ny\n<p>\n<pre>\nstruct semaphore {\n    int count;\n    int waking;\n    int lock ;                \/* to make waking testing atomic *\/\n    struct wait_queue *wait;\n};\n<\/pre>\n<h3>sk_buff<\/h3>\nThe <tt>sk_buff<\/tt> data structure is used to describe network data as it moves\nbetween the layers of protocol.\n<p>\n<pre>\nstruct sk_buff\n{\n  struct sk_buff      *next;       \/* Next buffer in list                   *\/\n  struct sk_buff      *prev;       \/* Previous buffer in list               *\/\n  struct sk_buff_head *list;       \/* List we are on                        *\/\n  int                 magic_debug_cookie;\n  struct sk_buff      *link3;      \/* Link for IP protocol level buffer chains *\/\n  struct sock         *sk;         \/* Socket we are owned by                *\/\n  unsigned long       when;        \/* used to compute rtt's                 *\/\n  struct timeval      stamp;       \/* Time we arrived                       *\/\n  struct device       *dev;        \/* Device we arrived on\/are leaving by   *\/\n  union\n  {\n      struct tcphdr   *th;\n      struct ethhdr   *eth;\n      struct iphdr    *iph;\n      struct udphdr   *uh;\n      unsigned char   *raw;\n      \/* for passing file handles in a unix domain socket *\/\n      void            *filp;\n  } h;\n  union\n  {\n      \/* As yet incomplete physical layer views *\/\n      unsigned char   *raw;\n      struct ethhdr   *ethernet;\n  } mac;\n  struct iphdr        *ip_hdr;     \/* For IPPROTO_RAW                       *\/\n  unsigned long       len;         \/* Length of actual data                 *\/\n  unsigned long       csum;        \/* Checksum                              *\/\n  __u32               saddr;       \/* IP source address                     *\/\n  __u32               daddr;       \/* IP target address                     *\/\n  __u32               raddr;       \/* IP next hop address                   *\/\n  __u32               seq;         \/* TCP sequence number                   *\/\n  __u32               end_seq;     \/* seq [+ fin] [+ syn] + datalen         *\/\n  __u32               ack_seq;     \/* TCP ack sequence number               *\/\n  unsigned char       proto_priv[16];\n  volatile char       acked,       \/* Are we acked ?                        *\/\n                      used,        \/* Are we in use ?                       *\/\n                      free,        \/* How to free this buffer               *\/\n                      arp;         \/* Has IP\/ARP resolution finished        *\/\n  unsigned char       tries,       \/* Times tried                           *\/\n                      lock,        \/* Are we locked ?                       *\/\n                      localroute,  \/* Local routing asserted for this frame *\/\n                      pkt_type,    \/* Packet class                          *\/\n                      pkt_bridged, \/* Tracker for bridging                  *\/\n                      ip_summed;   \/* Driver fed us an IP checksum          *\/\n#define PACKET_HOST         0        \/* To us                                 *\/\n#define PACKET_BROADCAST    1        \/* To all                                *\/\n#define PACKET_MULTICAST    2        \/* To group                              *\/\n#define PACKET_OTHERHOST    3        \/* To someone else                       *\/\n  unsigned short      users;       \/* User count - see datagram.c,tcp.c     *\/\n  unsigned short      protocol;    \/* Packet protocol from driver.          *\/\n  unsigned int        truesize;    \/* Buffer size                           *\/\n  atomic_t            count;       \/* reference count                       *\/\n  struct sk_buff      *data_skb;   \/* Link to the actual data skb           *\/\n  unsigned char       *head;       \/* Head of buffer                        *\/\n  unsigned char       *data;       \/* Data head pointer                     *\/\n  unsigned char       *tail;       \/* Tail pointer                          *\/\n  unsigned char       *end;        \/* End pointer                           *\/\n  void                (*destructor)(struct sk_buff *); \/* Destruct function *\/\n  __u16               redirport;   \/* Redirect port                         *\/\n};\n<\/pre>\n<h3>sock<\/h3>\nEach <tt>sock<\/tt> data structure holds protocol specific information about\na BSD socket.\nFor example, for an INET (Internet Address Domain) socket this data structure would\nhold all of the TCP\/IP and UDP\/IP specific information.\n<p>\n<pre>\nstruct sock\n{\n    \/* This must be first. *\/\n    struct sock             *sklist_next;\n    struct sock             *sklist_prev;\n    struct options          *opt;\n    atomic_t                wmem_alloc;\n    atomic_t                rmem_alloc;\n    unsigned long           allocation;       \/* Allocation mode *\/\n    __u32                   write_seq;\n    __u32                   sent_seq;\n    __u32                   acked_seq;\n    __u32                   copied_seq;\n    __u32                   rcv_ack_seq;\n    unsigned short          rcv_ack_cnt;      \/* count of same ack *\/\n    __u32                   window_seq;\n    __u32                   fin_seq;\n    __u32                   urg_seq;\n    __u32                   urg_data;\n    __u32                   syn_seq;\n    int                     users;            \/* user count *\/\n  \/*\n   *    Not all are volatile, but some are, so we\n   *     might as well say they all are.\n   *\/\n    volatile char           dead,\n                            urginline,\n                            intr,\n                            blog,\n                            done,\n                            reuse,\n                            keepopen,\n                            linger,\n                            delay_acks,\n                            destroy,\n                            ack_timed,\n                            no_check,\n                            zapped,\n                            broadcast,\n                            nonagle,\n                            bsdism;\n    unsigned long           lingertime;\n    int                     proc;\n    struct sock             *next;\n    struct sock             **pprev;\n    struct sock             *bind_next;\n    struct sock             **bind_pprev;\n    struct sock             *pair;\n    int                     hashent;\n    struct sock             *prev;\n    struct sk_buff          *volatile send_head;\n    struct sk_buff          *volatile send_next;\n    struct sk_buff          *volatile send_tail;\n    struct sk_buff_head     back_log;\n    struct sk_buff          *partial;\n    struct timer_list       partial_timer;\n    long                    retransmits;\n    struct sk_buff_head     write_queue,\n                            receive_queue;\n    struct proto            *prot;\n    struct wait_queue       **sleep;\n    __u32                   daddr;\n    __u32                   saddr;            \/* Sending source *\/\n    __u32                   rcv_saddr;        \/* Bound address *\/\n    unsigned short          max_unacked;\n    unsigned short          window;\n    __u32                   lastwin_seq;      \/* sequence number when we last\n                                                 updated the window we offer *\/\n    __u32                   high_seq;         \/* sequence number when we did\n                                                 current fast retransmit *\/\n    volatile unsigned long  ato;              \/* ack timeout *\/\n    volatile unsigned long  lrcvtime;         \/* jiffies at last data rcv *\/\n    volatile unsigned long  idletime;         \/* jiffies at last rcv *\/\n    unsigned int            bytes_rcv;\n\/*\n *    mss is min(mtu, max_window)\n *\/\n    unsigned short          mtu;              \/* mss negotiated in the syn's *\/\n    volatile unsigned short mss;              \/* current eff. mss - can change *\/\n    volatile unsigned short user_mss;         \/* mss requested by user in ioctl *\/\n    volatile unsigned short max_window;\n    unsigned long           window_clamp;\n    unsigned int            ssthresh;\n    unsigned short          num;\n    volatile unsigned short cong_window;\n    volatile unsigned short cong_count;\n    volatile unsigned short packets_out;\n    volatile unsigned short shutdown;\n    volatile unsigned long  rtt;\n    volatile unsigned long  mdev;\n    volatile unsigned long  rto;\n    volatile unsigned short backoff;\n    int                     err, err_soft;    \/* Soft holds errors that don't\n                                                 cause failure but are the cause\n                                                 of a persistent failure not\n                                                 just 'timed out' *\/\n    unsigned char           protocol;\n    volatile unsigned char  state;\n    unsigned char           ack_backlog;\n    unsigned char           max_ack_backlog;\n    unsigned char           priority;\n    unsigned char           debug;\n    int                     rcvbuf;\n    int                     sndbuf;\n    unsigned short          type;\n    unsigned char           localroute;       \/* Route locally only *\/\n\/*\n *    This is where all the private (optional) areas that don't\n *    overlap will eventually live.\n *\/\n    union\n    {\n          struct unix_opt   af_unix;\n#if defined(CONFIG_ATALK) || defined(CONFIG_ATALK_MODULE)\n        struct atalk_sock   af_at;\n#endif\n#if defined(CONFIG_IPX) || defined(CONFIG_IPX_MODULE)\n        struct ipx_opt      af_ipx;\n#endif\n#ifdef CONFIG_INET\n        struct inet_packet_opt  af_packet;\n#ifdef CONFIG_NUTCP\n        struct tcp_opt      af_tcp;\n#endif\n#endif\n    } protinfo;\n\/*\n *    IP 'private area'\n *\/\n    int                     ip_ttl;           \/* TTL setting *\/\n    int                     ip_tos;           \/* TOS *\/\n    struct tcphdr           dummy_th;\n    struct timer_list       keepalive_timer;  \/* TCP keepalive hack *\/\n    struct timer_list       retransmit_timer; \/* TCP retransmit timer *\/\n    struct timer_list       delack_timer;     \/* TCP delayed ack timer *\/\n    int                     ip_xmit_timeout;  \/* Why the timeout is running *\/\n    struct rtable           *ip_route_cache;  \/* Cached output route *\/\n    unsigned char           ip_hdrincl;       \/* Include headers ? *\/\n#ifdef CONFIG_IP_MULTICAST\n    int                     ip_mc_ttl;        \/* Multicasting TTL *\/\n    int                     ip_mc_loop;       \/* Loopback *\/\n    char                    ip_mc_name[MAX_ADDR_LEN]; \/* Multicast device name *\/\n    struct ip_mc_socklist   *ip_mc_list;      \/* Group array *\/\n#endif\n\/*\n *    This part is used for the timeout functions (timer.c).\n *\/\n    int                      timeout;         \/* What are we waiting for? *\/\n    struct timer_list        timer;           \/* This is the TIME_WAIT\/receive\n                                               * timer when we are doing IP\n                                               *\/\n    struct timeval           stamp;\n \/*\n  *    Identd\n  *\/\n    struct socket            *socket;\n  \/*\n   *    Callbacks\n   *\/\n    void                     (*state_change)(struct sock *sk);\n    void                     (*data_ready)(struct sock *sk,int bytes);\n    void                     (*write_space)(struct sock *sk);\n    void                     (*error_report)(struct sock *sk);\n};\n<\/pre>\n<h3>socket<\/h3>\nEach <tt>socket<\/tt> data structure holds information about a BSD socket.\nIt does not exist independently; it is, instead, part of the VFS <tt>inode<\/tt>\ndata structure.\n<p>\n<pre>\nstruct socket {\n  short                type;         \/* SOCK_STREAM, ...             *\/\n  socket_state         state;\n  long                 flags;\n  struct proto_ops     *ops;         \/* protocols do most everything *\/\n  void                 *data;        \/* protocol data                *\/\n  struct socket        *conn;        \/* server socket connected to   *\/\n  struct socket        *iconn;       \/* incomplete client conn.s     *\/\n  struct socket        *next;\n  struct wait_queue    **wait;       \/* ptr to place to wait on      *\/\n  struct inode         *inode;\n  struct fasync_struct *fasync_list; \/* Asynchronous wake up list    *\/\n  struct file          *file;        \/* File back pointer for gc     *\/\n};\n<\/pre>\n<h3>task_struct<\/h3>\nEach <tt>task_struct<\/tt> data structure describes a process or task in the\nsystem.\n<p>\n<pre>\nstruct task_struct {\n\/* these are hardcoded - don't touch *\/\n  volatile long        state;          \/* -1 unrunnable, 0 runnable, &#62;0 stopped *\/\n  long                 counter;\n  long                 priority;\n  unsigned             long signal;\n  unsigned             long blocked;   \/* bitmap of masked signals *\/\n  unsigned             long flags;     \/* per process flags, defined below *\/\n  int errno;\n  long                 debugreg[8];    \/* Hardware debugging registers *\/\n  struct exec_domain   *exec_domain;\n\/* various fields *\/\n  struct linux_binfmt  *binfmt;\n  struct task_struct   *next_task, *prev_task;\n  struct task_struct   *next_run,  *prev_run;\n  unsigned long        saved_kernel_stack;\n  unsigned long        kernel_stack_page;\n  int                  exit_code, exit_signal;\n  \/* ??? *\/\n  unsigned long        personality;\n  int                  dumpable:1;\n  int                  did_exec:1;\n  int                  pid;\n  int                  pgrp;\n  int                  tty_old_pgrp;\n  int                  session;\n  \/* boolean value for session group leader *\/\n  int                  leader;\n  int                  groups[NGROUPS];\n  \/*\n   * pointers to (original) parent process, youngest child, younger sibling,\n   * older sibling, respectively.  (p-&#62;father can be replaced with\n   * p-&#62;p_pptr-&#62;pid)\n   *\/\n  struct task_struct   *p_opptr, *p_pptr, *p_cptr,\n                       *p_ysptr, *p_osptr;\n  struct wait_queue    *wait_chldexit;\n  unsigned short       uid,euid,suid,fsuid;\n  unsigned short       gid,egid,sgid,fsgid;\n  unsigned long        timeout, policy, rt_priority;\n  unsigned long        it_real_value, it_prof_value, it_virt_value;\n  unsigned long        it_real_incr, it_prof_incr, it_virt_incr;\n  struct timer_list    real_timer;\n  long                 utime, stime, cutime, cstime, start_time;\n\/* mm fault and swap info: this can arguably be seen as either\n   mm-specific or thread-specific *\/\n  unsigned long        min_flt, maj_flt, nswap, cmin_flt, cmaj_flt, cnswap;\n  int swappable:1;\n  unsigned long        swap_address;\n  unsigned long        old_maj_flt;    \/* old value of maj_flt *\/\n  unsigned long        dec_flt;        \/* page fault count of the last time *\/\n  unsigned long        swap_cnt;       \/* number of pages to swap on next pass *\/\n\/* limits *\/\n  struct rlimit        rlim[RLIM_NLIMITS];\n  unsigned short       used_math;\n  char                 comm[16];\n\/* file system info *\/\n  int                  link_count;\n  struct tty_struct    *tty;           \/* NULL if no tty *\/\n\/* ipc stuff *\/\n  struct sem_undo      *semundo;\n  struct sem_queue     *semsleeping;\n\/* ldt for this task - used by Wine.  If NULL, default_ldt is used *\/\n  struct desc_struct *ldt;\n\/* tss for this task *\/\n  struct thread_struct tss;\n\/* filesystem information *\/\n  struct fs_struct     *fs;\n\/* open file information *\/\n  struct files_struct  *files;\n\/* memory management info *\/\n  struct mm_struct     *mm;\n\/* signal handlers *\/\n  struct signal_struct *sig;\n#ifdef __SMP__\n  int                  processor;\n  int                  last_processor;\n  int                  lock_depth;     \/* Lock depth.\n                                          We can context switch in and out\n                                          of holding a syscall kernel lock... *\/\n#endif\n};\n<\/pre>\n<h3>timer_list<\/h3>\n<tt>timer_list<\/tt> data structure&#8217;s are used to implement real time timers\nfor processes.\n<p>\n<pre>\nstruct timer_list {\n  struct timer_list *next;\n  struct timer_list *prev;\n  unsigned long expires;\n  unsigned long data;\n  void (*function)(unsigned long);\n};\n<\/pre>\n<h3>tq_struct<\/h3>\nEach task queue (<tt>tq_struct<\/tt>) data structure holds information about work\nthat has been queued.\nThis is usually a task needed by a device driver but which does not have to be\ndone immediately.\n<p>\n<pre>\nstruct tq_struct {\n    struct tq_struct *next;   \/* linked list of active bh's *\/\n    int sync;                 \/* must be initialized to zero *\/\n    void (*routine)(void *);  \/* function to call *\/\n    void *data;               \/* argument to function *\/\n};\n<\/pre>\n<h3>vm_area_struct<\/h3>\nEach <tt>vm_area_struct<\/tt> data structure describes an area of virtual memory for\na process.\n<p>\n<pre>\nstruct vm_area_struct {\n  struct mm_struct * vm_mm;  \/* VM area parameters *\/\n  unsigned long vm_start;\n  unsigned long vm_end;\n  pgprot_t vm_page_prot;\n  unsigned short vm_flags;\n\/* AVL tree of VM areas per task, sorted by address *\/\n  short vm_avl_height;\n  struct vm_area_struct * vm_avl_left;\n  struct vm_area_struct * vm_avl_right;\n\/* linked list of VM areas per task, sorted by address *\/\n  struct vm_area_struct * vm_next;\n\/* for areas with inode, the circular list inode-&#62;i_mmap *\/\n\/* for shm areas, the circular list of attaches *\/\n\/* otherwise unused *\/\n  struct vm_area_struct * vm_next_share;\n  struct vm_area_struct * vm_prev_share;\n\/* more *\/\n  struct vm_operations_struct * vm_ops;\n  unsigned long vm_offset;\n  struct inode * vm_inode;\n  unsigned long vm_pte;      \/* shared mem *\/\n};\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Linux Data Structures This section lists the major data structures that Linux uses and which are described in other sections. block_dev_struct block_dev_struct data structures are used to register block devices as available for use by the buffer cache. They are &hellip; <a href=\"http:\/\/www.linux-tutorial.info\/?page_id=248\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-248","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/248","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=248"}],"version-history":[{"count":1,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/248\/revisions"}],"predecessor-version":[{"id":604,"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=\/wp\/v2\/pages\/248\/revisions\/604"}],"wp:attachment":[{"href":"http:\/\/www.linux-tutorial.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}