Linux struct inode Structure

Source: Internet
Author: User

* The index Node object is represented by an inode struct. The definition file is in Linux/fs. h.
*/
Struct inode {
Struct hlist_node I _hash;/* hash table */
Struct list_head I _list;/* index node linked list */
Struct list_head I _dentry;/* directory linked list */
Unsigned long I _ino;/* node number */
Atomic_t I _count;/* Reference count */
Umode_t I _mode;/* Access Control */
Unsigned int I _nlink;/* Number of hard links */
Uid_t I _uid;/* User ID */
Gid_t I _gid;/* User ID Group */
Kdev_t I _rdev;/* real device identifier */
Loff_t I _size;/* file size in bytes */
Struct timespec I _atime;/* last access time */
Struct timespec I _mtime;/* Last modify time */
Struct timespec I _ctime;/* the last change time */
Unsigned int I _blkbits;/* block size in bit */
Unsigned long I _blksize;/* block size in bytes */
Unsigned long I _version;/* version */
Unsigned long I _blocks;/* Number of file blocks */
Unsigned short I _bytes;/* number of bytes used */
Spinlock_t I _lock;/* spin lock */
Struct rw_semaphore I _alloc_sem;/* index node semaphore */
Struct inode_operations * I _op;/* index node operation table */
Struct file_operations * I _fop;/* default index node operation */
Struct super_block * I _sb;/* related Super blocks */
Struct file_lock * I _flock;/* file lock linked list */
Struct address_space * I _mapping;/* address ing */
Struct address_space I _data;/* Device address ing */
Struct dquot * I _dquot [maxquotas];/* Disk Quota of nodes */
Struct list_head I _devices;/* block device linked list */
Struct pipe_inode_info * I _pipe;/* pipeline information */
Struct block_device * I _bdev;/* block device driver */
Unsigned long I _dpolicy_mask;/* Directory Notification mask */
Struct dnotify_struct * I _dnotify;/* Directory Notification */
Unsigned long I _state;/* Status flag */
Unsigned long dirtied_when;/* first modification time */
Unsigned int I _flags;/* File System flag */
Unsigned char I _sock;/* it may be a socket */
Atomic_t I _writecount;/* Writer count */
Void * I _security;/* security module */
_ U32 I _generation;/* index node version number */
Union {
Void * generic_ip;/* Special file information */
} U;
};
/*
* Inode_operations of index nodes are defined in Linux/fs. h.
*/
Struct inode_operations {
INT (* Create) (struct inode *, struct dentry *, INT );
/* VFS calls this function by calling CREATE () and open () to create a new index node for the dentry object. Use mode to set the initial mode during creation */
Struct dentry * (* lookup) (struct inode *, struct dentry *);
/* This Korean style searches for index nodes in a specific directory. The index node corresponds to the file name given in dentry */
INT (* link) (struct dentry *, struct inode *, struct dentry *);
/* The system calls Link () electrophoresis to create a hard connection. The hard link name is specified by the dentry parameter. The connection object is the file to be represented by the ld_dentry directory in the Dir directory */
INT (* unlink) (struct inode *, struct dentry *);
/* This function is called by the system to call unlink () and delete the index Node object that is braved by the Directory item dentry from the directory dir */
INT (* symlink) (struct inode *, struct dentry *, const char *);
/* This function is called by system electrophoresis symlik () to create a symbolic connection. The symbolic connection name is specified by symname, and the connection object is the dentry directory item in the Dir directory */
INT (* mkdir) (struct inode *, struct dentry *, INT );
/* This function is called by mkdir () to create a new lumm. Use the initial mode specified by mode during creation */
INT (* rmdir) (struct inode *, struct dentry *);
/* This function is called by the system to call rmdir (). delete the files represented by the dentry directory in the Dir directory */
INT (* mknod) (struct inode *, struct dentry *, Int, dev_t );
/* This function is called by the system to create a special file (device file, named pipe, or socket ). The file to be created is placed in the Dir directory, and the Directory item asks dentry. The associated device is rdev, and the initial permission is specified by mode */
INT (* rename) (struct inode *, struct dentry *,
Struct inode *, struct dentry *);
/* VFS calls this function to move files. The file source path is in the old_dir directory. The source file is specified by the old_dentry directory, the target path is in the new_dir directory, and the target file is specified by new_dentry */
INT (* readlink) (struct dentry *, char *, INT );
/* This function is called by the system to call readlink () and copy data to a specific buffer. The copied data comes from the symbolic link specified by dentry. The maximum copy size can reach buflen bytes */
INT (* follow_link) (struct dentry *, struct nameidata *);
/* This function is called by VFS. it searches for the index node to which it points from a symbolic connection, and the connection to which dentry points is parsed */
INT (* put_link) (struct dentry *, struct nameidata *);
/* After follow_link () is called, this function is called by VFS for clarity */
Void (* truncate) (struct inode *);
/* This function is called by VFS to modify the file size. Before calling this function, the I _size of the index node must be set to the expected size */
INT (* permission) (struct inode *, INT );
 

/* This function is used to check whether the file represented by the low-level inode allows a specific access mode. If a specific access mode is allowed, 0 is returned; otherwise, negative error codes are returned. Most file systems
Set this region to null, and use the common method provided by VFS to perform the check. This check operation only compares the index and the access mode bit in the object with that in the mask, complex Systems,
For example, a file system that supports access control chain (ACL) requires a special permission () method */
INT (* setattr) (struct dentry *, struct iattr *);
/* This function is called by yy_change. After the index node is modified, a change event is notified */
INT (* getattr) (struct vfsmount *, struct dentry *, struct kstat *);
/* When the index node needs to be updated from the disk, VFS will call this function */
INT (* setxattr) (struct dentry *, const char *,
Const void *, size_t, INT );
/* This function is called by VFS and sets the extension attribute to the file specified by dentry. The attribute name and value are value */
Ssize_t (* getxattr) (struct dentry *, const char *, void *, size_t );
/* This function is called by VFS to copy the value corresponding to the extension attribute name of the given file to the value */
Ssize_t (* listxattr) (struct dentry *, char *, size_t );
/* This function copies all gender tables of a specific file to a buffer list */
INT (* removexattr) (struct dentry *, const char *);
/* This function deletes the specified attribute from the specified file */
};

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.