📄 inode.h
字号:
/* * This Cplant(TM) source code is the property of Sandia National * Laboratories. * * This Cplant(TM) source code is copyrighted by Sandia National * Laboratories. * * The redistribution of this Cplant(TM) source code is subject to the * terms of the GNU Lesser General Public License * (see cit/LGPL or http://www.gnu.org/licenses/lgpl.html) * * Cplant(TM) Copyright 1998-2006 Sandia Corporation. * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive * license for use of this work by or on behalf of the US Government. * Export of this program may require a license from the United States * Government. *//* * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Questions or comments about this library should be sent to: * * Lee Ward * Sandia National Laboratories, New Mexico * P.O. Box 5800 * Albuquerque, NM 87185-1110 * * lee@sandia.gov */#if defined(AUTOMOUNT_FILE_NAME) && !defined(MAX_MOUNT_DEPTH)/* * Maximum number of automounts to attempt in path traversal. */#define MAX_MOUNT_DEPTH 64#endif/* * Each i-node is uniquely identified by a file identifier, supplied by * the relevant file system driver. The i-node number returned in the getattrs * call is not always enough. */struct file_identifier { void *fid_data; size_t fid_len;};struct pnode;struct inode;struct intent;struct intnl_dirent;struct intnl_stat;#ifdef _HAVE_STATVFSstruct intnl_statvfs;#endifstruct io_arguments;struct ioctx;/* * Operations on i-nodes. * * Should this be split up into file and name space operations? */struct inode_ops { int (*inop_lookup)(struct pnode *pno, struct inode **inop, struct intent *intnt, const char *path); int (*inop_getattr)(struct pnode *pno, struct inode *ino, struct intnl_stat *stbuf); int (*inop_setattr)(struct pnode *pno, struct inode *ino, unsigned mask, struct intnl_stat *stbuf); ssize_t (*inop_filldirentries)(struct inode *ino, _SYSIO_OFF_T *posp, char *buf, size_t nbytes); int (*inop_mkdir)(struct pnode *pno, mode_t mode); int (*inop_rmdir)(struct pnode *pno); int (*inop_symlink)(struct pnode *pno, const char *data); int (*inop_readlink)(struct pnode *pno, char *buf, size_t bufsiz); int (*inop_open)(struct pnode *pno, int flags, mode_t mode); int (*inop_close)(struct inode *ino); int (*inop_link)(struct pnode *old, struct pnode *new); int (*inop_unlink)(struct pnode *pno); int (*inop_rename)(struct pnode *old, struct pnode *new); int (*inop_read)(struct inode *ino, struct ioctx *ioctx); int (*inop_write)(struct inode *ino, struct ioctx *ioctx); _SYSIO_OFF_T (*inop_pos)(struct inode *ino, _SYSIO_OFF_T off); int (*inop_iodone)(struct ioctx *iocp); int (*inop_fcntl)(struct inode *ino, int cmd, va_list ap, int *rtn); int (*inop_sync)(struct inode *ino); int (*inop_datasync)(struct inode *ino); int (*inop_ioctl)(struct inode *ino, unsigned long int request, va_list ap); int (*inop_mknod)(struct pnode *pno, mode_t mode, dev_t dev);#ifdef _HAVE_STATVFS int (*inop_statvfs)(struct pnode *pno, struct inode *ino, struct intnl_statvfs *buf);#endif void (*inop_gone)(struct inode *ino);};/* * Values for the mask to inop_setattr. */#define SETATTR_MODE 0x01#define SETATTR_MTIME 0x02#define SETATTR_ATIME 0x04#define SETATTR_UID 0x08#define SETATTR_GID 0x10#define SETATTR_LEN 0x20/* * An i-node record is maintained for each file object in the system. */struct inode { LIST_ENTRY(inode) i_link; /* FS i-nodes link */ unsigned i_immune : 1, /* immune from GC */ i_zombie : 1; /* stale inode */ unsigned i_ref; /* soft ref counter */ struct inode_ops i_ops; /* operations */ struct intnl_stat i_stbuf; /* attrs */ struct filesys *i_fs; /* file system ptr */ struct file_identifier *i_fid; /* file ident */ void *i_private; /* driver data */ TAILQ_ENTRY(inode) i_nodes; /* all i-nodes link */};/* * Init an i-node record. */#define I_INIT(ino, fs, stat, ops, fid, immunity, private) \ do { \ (ino)->i_immune = (immunity) ? 1 : 0; \ (ino)->i_zombie = 0; \ (ino)->i_ref = 0; \ (ino)->i_ops = *(ops); \ (ino)->i_stbuf = *(stat); \ (ino)->i_fs = (fs); \ (ino)->i_fid = (fid); \ (ino)->i_private = (private); \ } while (0)/* * Take soft reference to i-node. */#define I_REF(ino) \ do { \ TAILQ_REMOVE(&_sysio_inodes, (ino), i_nodes); \ TAILQ_INSERT_TAIL(&_sysio_inodes, (ino), i_nodes); \ (ino)->i_ref++; \ assert((ino)->i_ref); \ } while (0)/* * Release soft reference to i-node. */#define I_RELE(ino) \ do { \ assert((ino)->i_ref); \ if (!--(ino)->i_ref && (ino)->i_zombie) \ _sysio_i_gone(ino); \ } while (0)/* * Attempt to kill an inode. */#define I_GONE(ino) \ do { \ _sysio_i_undead(ino); \ I_RELE(ino); \ } while (0)/* * The "quick string" record (inspired by the structure of the same name * from Linux) is used to pass a string without delimiters as well as useful * information about the string. */struct qstr { const char *name; size_t len; unsigned hashval;};/* * A path node is an entry in a directory. It may have many aliases, one * for each name space in which it occurs. This record holds the * common information. */struct pnode_base { struct qstr pb_name; /* entry name */ struct inode *pb_ino; /* inode */ LIST_HEAD(, pnode_base) pb_children; /* children if a dir */ LIST_ENTRY(pnode_base) pb_sibs; /* links to siblings */ LIST_ENTRY(pnode_base) pb_names; /* near names links */ LIST_HEAD(, pnode) pb_aliases; /* aliases */ struct pnode_base *pb_parent; /* parent */};/* * Since a file system may be multiply mounted, in different parts of the local * tree, a file system object may appear in different places. We handle that * with aliases. There is one pnode for every alias the system is tracking. * * Name space traversal depends heavily on the interpretation of many * of the fields in this structure. For that reason a detailed discussion * of the various fields is given. * * The reference field records soft references to the record. For instance, * it tracks file and directory opens. It does not track sibling references, * though, as those are hard references and can be found by examining the * aliases list in the base part of the node. * * The parent value points to the parent directory for this entry, in the * *system* name space -- Not the mounted volumes. If you want to examine * the moutned volume name space, use the base record. * * The base value points to the base path node information. It is info common * to all of the aliases. * * The mount value points to the mount record for the rooted name space in * which the alias is found. Notably, if a node is the root of a sub-tree then * the mount record, among other things, indicates another node * (in another sub-tree) that is covered by this one. * * Another sub-tree, mounted on this node, is indicated by a non-null cover. * The pnode pointed to, then, is the root of the mounted sub-tree.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -