Print this page
    
Add VZONEROOT flag because not all zone roots have VROOT set.
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/uts/common/sys/vnode.h
          +++ new/usr/src/uts/common/sys/vnode.h
   1    1  /*
   2    2   * CDDL HEADER START
   3    3   *
   4    4   * The contents of this file are subject to the terms of the
   5    5   * Common Development and Distribution License (the "License").
   6    6   * You may not use this file except in compliance with the License.
   7    7   *
   8    8   * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9    9   * or http://www.opensolaris.org/os/licensing.
  10   10   * See the License for the specific language governing permissions
  11   11   * and limitations under the License.
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Copyright (c) 2017, Joyent, Inc.
  25   25   * Copyright (c) 2011, 2017 by Delphix. All rights reserved.
  26   26   * Copyright 2017 RackTop Systems.
  27   27   */
  28   28  
  29   29  /*      Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T     */
  30   30  /*        All Rights Reserved   */
  31   31  
  32   32  /*
  33   33   * University Copyright- Copyright (c) 1982, 1986, 1988
  34   34   * The Regents of the University of California
  35   35   * All Rights Reserved
  36   36   *
  37   37   * University Acknowledgment- Portions of this document are derived from
  38   38   * software developed by the University of California, Berkeley, and its
  39   39   * contributors.
  40   40   */
  41   41  
  42   42  #ifndef _SYS_VNODE_H
  43   43  #define _SYS_VNODE_H
  44   44  
  45   45  #include <sys/types.h>
  46   46  #include <sys/t_lock.h>
  47   47  #include <sys/rwstlock.h>
  48   48  #include <sys/time_impl.h>
  49   49  #include <sys/cred.h>
  50   50  #include <sys/uio.h>
  51   51  #include <sys/resource.h>
  52   52  #include <vm/seg_enum.h>
  53   53  #include <sys/kstat.h>
  54   54  #include <sys/kmem.h>
  55   55  #include <sys/list.h>
  56   56  #ifdef  _KERNEL
  57   57  #include <sys/buf.h>
  58   58  #include <sys/sdt.h>
  59   59  #endif  /* _KERNEL */
  60   60  
  61   61  #ifdef  __cplusplus
  62   62  extern "C" {
  63   63  #endif
  64   64  
  65   65  /*
  66   66   * Statistics for all vnode operations.
  67   67   * All operations record number of ops (since boot/mount/zero'ed).
  68   68   * Certain I/O operations (read, write, readdir) also record number
  69   69   * of bytes transferred.
  70   70   * This appears in two places in the system: one is embedded in each
  71   71   * vfs_t.  There is also an array of vopstats_t structures allocated
  72   72   * on a per-fstype basis.
  73   73   */
  74   74  
  75   75  #define VOPSTATS_STR    "vopstats_"     /* Initial string for vopstat kstats */
  76   76  
  77   77  typedef struct vopstats {
  78   78          kstat_named_t   nopen;          /* VOP_OPEN */
  79   79          kstat_named_t   nclose;         /* VOP_CLOSE */
  80   80          kstat_named_t   nread;          /* VOP_READ */
  81   81          kstat_named_t   read_bytes;
  82   82          kstat_named_t   nwrite;         /* VOP_WRITE */
  83   83          kstat_named_t   write_bytes;
  84   84          kstat_named_t   nioctl;         /* VOP_IOCTL */
  85   85          kstat_named_t   nsetfl;         /* VOP_SETFL */
  86   86          kstat_named_t   ngetattr;       /* VOP_GETATTR */
  87   87          kstat_named_t   nsetattr;       /* VOP_SETATTR */
  88   88          kstat_named_t   naccess;        /* VOP_ACCESS */
  89   89          kstat_named_t   nlookup;        /* VOP_LOOKUP */
  90   90          kstat_named_t   ncreate;        /* VOP_CREATE */
  91   91          kstat_named_t   nremove;        /* VOP_REMOVE */
  92   92          kstat_named_t   nlink;          /* VOP_LINK */
  93   93          kstat_named_t   nrename;        /* VOP_RENAME */
  94   94          kstat_named_t   nmkdir;         /* VOP_MKDIR */
  95   95          kstat_named_t   nrmdir;         /* VOP_RMDIR */
  96   96          kstat_named_t   nreaddir;       /* VOP_READDIR */
  97   97          kstat_named_t   readdir_bytes;
  98   98          kstat_named_t   nsymlink;       /* VOP_SYMLINK */
  99   99          kstat_named_t   nreadlink;      /* VOP_READLINK */
 100  100          kstat_named_t   nfsync;         /* VOP_FSYNC */
 101  101          kstat_named_t   ninactive;      /* VOP_INACTIVE */
 102  102          kstat_named_t   nfid;           /* VOP_FID */
 103  103          kstat_named_t   nrwlock;        /* VOP_RWLOCK */
 104  104          kstat_named_t   nrwunlock;      /* VOP_RWUNLOCK */
 105  105          kstat_named_t   nseek;          /* VOP_SEEK */
 106  106          kstat_named_t   ncmp;           /* VOP_CMP */
 107  107          kstat_named_t   nfrlock;        /* VOP_FRLOCK */
 108  108          kstat_named_t   nspace;         /* VOP_SPACE */
 109  109          kstat_named_t   nrealvp;        /* VOP_REALVP */
 110  110          kstat_named_t   ngetpage;       /* VOP_GETPAGE */
 111  111          kstat_named_t   nputpage;       /* VOP_PUTPAGE */
 112  112          kstat_named_t   nmap;           /* VOP_MAP */
 113  113          kstat_named_t   naddmap;        /* VOP_ADDMAP */
 114  114          kstat_named_t   ndelmap;        /* VOP_DELMAP */
 115  115          kstat_named_t   npoll;          /* VOP_POLL */
 116  116          kstat_named_t   ndump;          /* VOP_DUMP */
 117  117          kstat_named_t   npathconf;      /* VOP_PATHCONF */
 118  118          kstat_named_t   npageio;        /* VOP_PAGEIO */
 119  119          kstat_named_t   ndumpctl;       /* VOP_DUMPCTL */
 120  120          kstat_named_t   ndispose;       /* VOP_DISPOSE */
 121  121          kstat_named_t   nsetsecattr;    /* VOP_SETSECATTR */
 122  122          kstat_named_t   ngetsecattr;    /* VOP_GETSECATTR */
 123  123          kstat_named_t   nshrlock;       /* VOP_SHRLOCK */
 124  124          kstat_named_t   nvnevent;       /* VOP_VNEVENT */
 125  125          kstat_named_t   nreqzcbuf;      /* VOP_REQZCBUF */
 126  126          kstat_named_t   nretzcbuf;      /* VOP_RETZCBUF */
 127  127  } vopstats_t;
 128  128  
 129  129  /*
 130  130   * The vnode is the focus of all file activity in UNIX.
 131  131   * A vnode is allocated for each active file, each current
 132  132   * directory, each mounted-on file, and the root.
 133  133   *
 134  134   * Each vnode is usually associated with a file-system-specific node (for
 135  135   * UFS, this is the in-memory inode).  Generally, a vnode and an fs-node
 136  136   * should be created and destroyed together as a pair.
 137  137   *
 138  138   * If a vnode is reused for a new file, it should be reinitialized by calling
 139  139   * either vn_reinit() or vn_recycle().
 140  140   *
 141  141   * vn_reinit() resets the entire vnode as if it was returned by vn_alloc().
 142  142   * The caller is responsible for setting up the entire vnode after calling
 143  143   * vn_reinit().  This is important when using kmem caching where the vnode is
 144  144   * allocated by a constructor, for instance.
 145  145   *
 146  146   * vn_recycle() is used when the file system keeps some state around in both
 147  147   * the vnode and the associated FS-node.  In UFS, for example, the inode of
 148  148   * a deleted file can be reused immediately.  The v_data, v_vfsp, v_op, etc.
 149  149   * remains the same but certain fields related to the previous instance need
 150  150   * to be reset.  In particular:
 151  151   *      v_femhead
 152  152   *      v_path
 153  153   *      v_rdcnt, v_wrcnt
 154  154   *      v_mmap_read, v_mmap_write
 155  155   */
 156  156  
 157  157  /*
 158  158   * vnode types.  VNON means no type.  These values are unrelated to
 159  159   * values in on-disk inodes.
 160  160   */
 161  161  typedef enum vtype {
 162  162          VNON    = 0,
 163  163          VREG    = 1,
 164  164          VDIR    = 2,
 165  165          VBLK    = 3,
 166  166          VCHR    = 4,
 167  167          VLNK    = 5,
 168  168          VFIFO   = 6,
 169  169          VDOOR   = 7,
 170  170          VPROC   = 8,
 171  171          VSOCK   = 9,
 172  172          VPORT   = 10,
 173  173          VBAD    = 11
 174  174  } vtype_t;
 175  175  
 176  176  /*
 177  177   * VSD - Vnode Specific Data
 178  178   * Used to associate additional private data with a vnode.
 179  179   */
 180  180  struct vsd_node {
 181  181          list_node_t vs_nodes;           /* list of all VSD nodes */
 182  182          uint_t vs_nkeys;                /* entries in value array */
 183  183          void **vs_value;                /* array of value/key */
 184  184  };
 185  185  
 186  186  /*
 187  187   * Many of the fields in the vnode are read-only once they are initialized
 188  188   * at vnode creation time.  Other fields are protected by locks.
 189  189   *
 190  190   * IMPORTANT: vnodes should be created ONLY by calls to vn_alloc().  They
 191  191   * may not be embedded into the file-system specific node (inode).  The
 192  192   * size of vnodes may change.
 193  193   *
 194  194   * The v_lock protects:
 195  195   *   v_flag
 196  196   *   v_stream
 197  197   *   v_count
 198  198   *   v_shrlocks
 199  199   *   v_path
 200  200   *   v_vsd
 201  201   *   v_xattrdir
 202  202   *
 203  203   * A special lock (implemented by vn_vfswlock in vnode.c) protects:
 204  204   *   v_vfsmountedhere
 205  205   *
 206  206   * The global flock_lock mutex (in flock.c) protects:
 207  207   *   v_filocks
 208  208   *
 209  209   * IMPORTANT NOTE:
 210  210   *
 211  211   *   The following vnode fields are considered public and may safely be
 212  212   *   accessed by file systems or other consumers:
 213  213   *
 214  214   *     v_lock
 215  215   *     v_flag
 216  216   *     v_count
 217  217   *     v_data
 218  218   *     v_vfsp
 219  219   *     v_stream
 220  220   *     v_type
 221  221   *     v_rdev
 222  222   *
 223  223   * ALL OTHER FIELDS SHOULD BE ACCESSED ONLY BY THE OWNER OF THAT FIELD.
 224  224   * In particular, file systems should not access other fields; they may
 225  225   * change or even be removed.  The functionality which was once provided
 226  226   * by these fields is available through vn_* functions.
 227  227   *
 228  228   * VNODE PATH THEORY:
 229  229   * In each vnode, the v_path field holds a cached version of the canonical
 230  230   * filesystem path which that node represents.  Because vnodes lack contextual
 231  231   * information about their own name or position in the VFS hierarchy, this path
 232  232   * must be calculated when the vnode is instantiated by operations such as
 233  233   * fop_create, fop_lookup, or fop_mkdir.  During said operations, both the
 234  234   * parent vnode (and its cached v_path) and future name are known, so the
 235  235   * v_path of the resulting object can easily be set.
 236  236   *
 237  237   * The caching nature of v_path is complicated in the face of directory
 238  238   * renames.  Filesystem drivers are responsible for calling vn_renamepath when
 239  239   * a fop_rename operation succeeds.  While the v_path on the renamed vnode will
 240  240   * be updated, existing children of the directory (direct, or at deeper levels)
 241  241   * will now possess v_path caches which are stale.
 242  242   *
 243  243   * It is expensive (and for non-directories, impossible) to recalculate stale
 244  244   * v_path entries during operations such as vnodetopath.  The best time during
 245  245   * which to correct such wrongs is the same as when v_path is first
 246  246   * initialized: during fop_create/fop_lookup/fop_mkdir/etc, where adequate
 247  247   * context is available to generate the current path.
 248  248   *
 249  249   * In order to quickly detect stale v_path entries (without full lookup
 250  250   * verification) to trigger a v_path update, the v_path_stamp field has been
 251  251   * added to vnode_t.  As part of successful fop_create/fop_lookup/fop_mkdir
 252  252   * operations, where the name and parent vnode are available, the following
 253  253   * rules are used to determine updates to the child:
 254  254   *
 255  255   * 1. If the parent lacks a v_path, clear any existing v_path and v_path_stamp
 256  256   *    on the child.  Until the parent v_path is refreshed to a valid state, the
 257  257   *    child v_path must be considered invalid too.
 258  258   *
 259  259   * 2. If the child lacks a v_path (implying v_path_stamp == 0), it inherits the
 260  260   *    v_path_stamp value from its parent and its v_path is updated.
 261  261   *
 262  262   * 3. If the child v_path_stamp is less than v_path_stamp in the parent, it is
 263  263   *    an indication that the child v_path is stale.  The v_path is updated and
 264  264   *    v_path_stamp in the child is set to the current hrtime().
 265  265   *
 266  266   *    It does _not_ inherit the parent v_path_stamp in order to propagate the
 267  267   *    the time of v_path invalidation through the directory structure.  This
 268  268   *    prevents concurrent invalidations (operating with a now-incorrect v_path)
 269  269   *    at deeper levels in the tree from persisting.
 270  270   *
 271  271   * 4. If the child v_path_stamp is greater or equal to the parent, no action
 272  272   *    needs to be taken.
 273  273   *
 274  274   * Note that fop_rename operations do not follow this ruleset.  They perform an
 275  275   * explicit update of v_path and v_path_stamp (setting it to the current time)
 276  276   *
 277  277   * With these constraints in place, v_path invalidations and updates should
 278  278   * proceed in a timely manner as vnodes are accessed.  While there still are
 279  279   * limited cases where vnodetopath operations will fail, the risk is minimized.
 280  280   */
 281  281  
 282  282  struct fem_head;        /* from fem.h */
 283  283  
 284  284  typedef struct vnode {
 285  285          kmutex_t        v_lock;         /* protects vnode fields */
 286  286          uint_t          v_flag;         /* vnode flags (see below) */
 287  287          uint_t          v_count;        /* reference count */
 288  288          void            *v_data;        /* private data for fs */
 289  289          struct vfs      *v_vfsp;        /* ptr to containing VFS */
 290  290          struct stdata   *v_stream;      /* associated stream */
 291  291          enum vtype      v_type;         /* vnode type */
 292  292          dev_t           v_rdev;         /* device (VCHR, VBLK) */
 293  293  
 294  294          /* PRIVATE FIELDS BELOW - DO NOT USE */
 295  295  
 296  296          struct vfs      *v_vfsmountedhere; /* ptr to vfs mounted here */
 297  297          struct vnodeops *v_op;          /* vnode operations */
 298  298          struct page     *v_pages;       /* vnode pages list */
 299  299          struct filock   *v_filocks;     /* ptr to filock list */
 300  300          struct shrlocklist *v_shrlocks; /* ptr to shrlock list */
 301  301          krwlock_t       v_nbllock;      /* sync for NBMAND locks */
 302  302          kcondvar_t      v_cv;           /* synchronize locking */
 303  303          void            *v_locality;    /* hook for locality info */
 304  304          struct fem_head *v_femhead;     /* fs monitoring */
 305  305          char            *v_path;        /* cached path */
 306  306          hrtime_t        v_path_stamp;   /* timestamp for cached path */
 307  307          uint_t          v_rdcnt;        /* open for read count  (VREG only) */
 308  308          uint_t          v_wrcnt;        /* open for write count (VREG only) */
 309  309          u_longlong_t    v_mmap_read;    /* mmap read count */
 310  310          u_longlong_t    v_mmap_write;   /* mmap write count */
 311  311          void            *v_mpssdata;    /* info for large page mappings */
 312  312          void            *v_fopdata;     /* list of file ops event watches */
 313  313          kmutex_t        v_vsd_lock;     /* protects v_vsd field */
 314  314          struct vsd_node *v_vsd;         /* vnode specific data */
 315  315          struct vnode    *v_xattrdir;    /* unnamed extended attr dir (GFS) */
 316  316          uint_t          v_count_dnlc;   /* dnlc reference count */
 317  317  } vnode_t;
 318  318  
 319  319  #define IS_DEVVP(vp)    \
 320  320          ((vp)->v_type == VCHR || (vp)->v_type == VBLK || (vp)->v_type == VFIFO)
 321  321  
 322  322  #define VNODE_ALIGN     64
 323  323  /* Count of low-order 0 bits in a vnode *, based on size and alignment. */
 324  324  #if defined(_LP64)
 325  325  #define VNODE_ALIGN_LOG2        8
 326  326  #else
 327  327  #define VNODE_ALIGN_LOG2        7
 328  328  #endif
 329  329  
 330  330  /*
 331  331   * vnode flags.
 332  332   */
 333  333  #define VROOT           0x01    /* root of its file system */
 334  334  #define VNOCACHE        0x02    /* don't keep cache pages on vnode */
 335  335  #define VNOMAP          0x04    /* file cannot be mapped/faulted */
 336  336  #define VDUP            0x08    /* file should be dup'ed rather then opened */
 337  337  #define VNOSWAP         0x10    /* file cannot be used as virtual swap device */
 338  338  #define VNOMOUNT        0x20    /* file cannot be covered by mount */
 339  339  #define VISSWAP         0x40    /* vnode is being used for swap */
 340  340  #define VSWAPLIKE       0x80    /* vnode acts like swap (but may not be) */
 341  341  
 342  342  #define IS_SWAPVP(vp)   (((vp)->v_flag & (VISSWAP | VSWAPLIKE)) != 0)
 343  343  
 344  344  #ifdef _KERNEL
 345  345  typedef struct vn_vfslocks_entry {
 346  346          rwstlock_t ve_lock;
 347  347          void *ve_vpvfs;
 348  348          struct vn_vfslocks_entry *ve_next;
 349  349          uint32_t ve_refcnt;
 350  350          char pad[64 - sizeof (rwstlock_t) - 2 * sizeof (void *) - \
 351  351              sizeof (uint32_t)];
 352  352  } vn_vfslocks_entry_t;
 353  353  #endif
 354  354  
 355  355  /*
 356  356   * The following two flags are used to lock the v_vfsmountedhere field
 357  357   */
 358  358  #define VVFSLOCK        0x100
 359  359  #define VVFSWAIT        0x200
 360  360  
 361  361  /*
 362  362   * Used to serialize VM operations on a vnode
 363  363   */
 364  364  #define VVMLOCK         0x400
 365  365  
 366  366  /*
 367  367   * Tell vn_open() not to fail a directory open for writing but
 368  368   * to go ahead and call VOP_OPEN() to let the filesystem check.
 369  369   */
 370  370  #define VDIROPEN        0x800
 371  371  
 372  372  /*
 373  373   * Flag to let the VM system know that this file is most likely a binary
 374  374   * or shared library since it has been mmap()ed EXEC at some time.
 375  375   */
 376  376  #define VVMEXEC         0x1000
 377  377  
 378  378  #define VPXFS           0x2000  /* clustering: global fs proxy vnode */
 379  379  
 380  380  #define IS_PXFSVP(vp)   ((vp)->v_flag & VPXFS)
 381  381  
 382  382  #define V_XATTRDIR      0x4000  /* attribute unnamed directory */
 383  383  
 384  384  #define IS_XATTRDIR(vp) ((vp)->v_flag & V_XATTRDIR)
 385  385  
 386  386  #define V_LOCALITY      0x8000  /* whether locality aware */
 387  387  
 388  388  /*
 389  389   * Flag that indicates the VM should maintain the v_pages list with all modified
 390  390   * pages on one end and unmodified pages at the other. This makes finding dirty
 391  391   * pages to write back to disk much faster at the expense of taking a minor
 392  392   * fault on the first store instruction which touches a writable page.
 393  393   */
 394  394  #define VMODSORT        (0x10000)
 395  395  #define IS_VMODSORT(vp) \
 396  396          (pvn_vmodsort_supported != 0 && ((vp)->v_flag  & VMODSORT) != 0)
 397  397  
 398  398  #define VISSWAPFS       0x20000 /* vnode is being used for swapfs */
 399  399  
 400  400  /*
 401  401   * The mdb memstat command assumes that IS_SWAPFSVP only uses the
 402  402   * vnode's v_flag field.  If this changes, cache the additional
 403  403   * fields in mdb; see vn_get in mdb/common/modules/genunix/memory.c
 404  404   */
 405  405  #define IS_SWAPFSVP(vp) (((vp)->v_flag & VISSWAPFS) != 0)
 406  406  
 407  407  #define V_SYSATTR       0x40000 /* vnode is a GFS system attribute */
  
    | 
      ↓ open down ↓ | 
    407 lines elided | 
    
      ↑ open up ↑ | 
  
 408  408  
 409  409  /*
 410  410   * Indication that VOP_LOOKUP operations on this vnode may yield results from a
 411  411   * different VFS instance.  The main use of this is to suppress v_path
 412  412   * calculation logic when filesystems such as procfs emit results which defy
 413  413   * expectations about normal VFS behavior.
 414  414   */
 415  415  #define VTRAVERSE       0x80000
 416  416  
 417  417  /*
      418 + * Indicates the vnode is a zone's root ("/" in-zone). A zone's root does NOT
      419 + * have to be a filesystem root, even if many zone brands guaranteed that.
      420 + */
      421 +#define VZONEROOT       0x100000
      422 +
      423 +
      424 +/*
 418  425   * Vnode attributes.  A bit-mask is supplied as part of the
 419  426   * structure to indicate the attributes the caller wants to
 420  427   * set (setattr) or extract (getattr).
 421  428   */
 422  429  
 423  430  /*
 424  431   * Note that va_nodeid and va_nblocks are 64bit data type.
 425  432   * We support large files over NFSV3. With Solaris client and
 426  433   * Server that generates 64bit ino's and sizes these fields
 427  434   * will overflow if they are 32 bit sizes.
 428  435   */
 429  436  
 430  437  typedef struct vattr {
 431  438          uint_t          va_mask;        /* bit-mask of attributes */
 432  439          vtype_t         va_type;        /* vnode type (for create) */
 433  440          mode_t          va_mode;        /* file access mode */
 434  441          uid_t           va_uid;         /* owner user id */
 435  442          gid_t           va_gid;         /* owner group id */
 436  443          dev_t           va_fsid;        /* file system id (dev for now) */
 437  444          u_longlong_t    va_nodeid;      /* node id */
 438  445          nlink_t         va_nlink;       /* number of references to file */
 439  446          u_offset_t      va_size;        /* file size in bytes */
 440  447          timestruc_t     va_atime;       /* time of last access */
 441  448          timestruc_t     va_mtime;       /* time of last modification */
 442  449          timestruc_t     va_ctime;       /* time of last status change */
 443  450          dev_t           va_rdev;        /* device the file represents */
 444  451          uint_t          va_blksize;     /* fundamental block size */
 445  452          u_longlong_t    va_nblocks;     /* # of blocks allocated */
 446  453          uint_t          va_seq;         /* sequence number */
 447  454  } vattr_t;
 448  455  
 449  456  #define AV_SCANSTAMP_SZ 32              /* length of anti-virus scanstamp */
 450  457  
 451  458  /*
 452  459   * Structure of all optional attributes.
 453  460   */
 454  461  typedef struct xoptattr {
 455  462          timestruc_t     xoa_createtime; /* Create time of file */
 456  463          uint8_t         xoa_archive;
 457  464          uint8_t         xoa_system;
 458  465          uint8_t         xoa_readonly;
 459  466          uint8_t         xoa_hidden;
 460  467          uint8_t         xoa_nounlink;
 461  468          uint8_t         xoa_immutable;
 462  469          uint8_t         xoa_appendonly;
 463  470          uint8_t         xoa_nodump;
 464  471          uint8_t         xoa_opaque;
 465  472          uint8_t         xoa_av_quarantined;
 466  473          uint8_t         xoa_av_modified;
 467  474          uint8_t         xoa_av_scanstamp[AV_SCANSTAMP_SZ];
 468  475          uint8_t         xoa_reparse;
 469  476          uint64_t        xoa_generation;
 470  477          uint8_t         xoa_offline;
 471  478          uint8_t         xoa_sparse;
 472  479          uint8_t         xoa_projinherit;
 473  480          uint64_t        xoa_projid;
 474  481  } xoptattr_t;
 475  482  
 476  483  /*
 477  484   * The xvattr structure is really a variable length structure that
 478  485   * is made up of:
 479  486   * - The classic vattr_t (xva_vattr)
 480  487   * - a 32 bit quantity (xva_mapsize) that specifies the size of the
 481  488   *   attribute bitmaps in 32 bit words.
 482  489   * - A pointer to the returned attribute bitmap (needed because the
 483  490   *   previous element, the requested attribute bitmap) is variable lenth.
 484  491   * - The requested attribute bitmap, which is an array of 32 bit words.
 485  492   *   Callers use the XVA_SET_REQ() macro to set the bits corresponding to
 486  493   *   the attributes that are being requested.
 487  494   * - The returned attribute bitmap, which is an array of 32 bit words.
 488  495   *   File systems that support optional attributes use the XVA_SET_RTN()
 489  496   *   macro to set the bits corresponding to the attributes that are being
 490  497   *   returned.
 491  498   * - The xoptattr_t structure which contains the attribute values
 492  499   *
 493  500   * xva_mapsize determines how many words in the attribute bitmaps.
 494  501   * Immediately following the attribute bitmaps is the xoptattr_t.
 495  502   * xva_getxoptattr() is used to get the pointer to the xoptattr_t
 496  503   * section.
 497  504   */
 498  505  
 499  506  #define XVA_MAPSIZE     3               /* Size of attr bitmaps */
 500  507  #define XVA_MAGIC       0x78766174      /* Magic # for verification */
 501  508  
 502  509  /*
 503  510   * The xvattr structure is an extensible structure which permits optional
 504  511   * attributes to be requested/returned.  File systems may or may not support
 505  512   * optional attributes.  They do so at their own discretion but if they do
 506  513   * support optional attributes, they must register the VFSFT_XVATTR feature
 507  514   * so that the optional attributes can be set/retrived.
 508  515   *
 509  516   * The fields of the xvattr structure are:
 510  517   *
 511  518   * xva_vattr - The first element of an xvattr is a legacy vattr structure
 512  519   * which includes the common attributes.  If AT_XVATTR is set in the va_mask
 513  520   * then the entire structure is treated as an xvattr.  If AT_XVATTR is not
 514  521   * set, then only the xva_vattr structure can be used.
 515  522   *
 516  523   * xva_magic - 0x78766174 (hex for "xvat"). Magic number for verification.
 517  524   *
 518  525   * xva_mapsize - Size of requested and returned attribute bitmaps.
 519  526   *
 520  527   * xva_rtnattrmapp - Pointer to xva_rtnattrmap[].  We need this since the
 521  528   * size of the array before it, xva_reqattrmap[], could change which means
 522  529   * the location of xva_rtnattrmap[] could change.  This will allow unbundled
 523  530   * file systems to find the location of xva_rtnattrmap[] when the sizes change.
 524  531   *
 525  532   * xva_reqattrmap[] - Array of requested attributes.  Attributes are
 526  533   * represented by a specific bit in a specific element of the attribute
 527  534   * map array.  Callers set the bits corresponding to the attributes
 528  535   * that the caller wants to get/set.
 529  536   *
 530  537   * xva_rtnattrmap[] - Array of attributes that the file system was able to
 531  538   * process.  Not all file systems support all optional attributes.  This map
 532  539   * informs the caller which attributes the underlying file system was able
 533  540   * to set/get.  (Same structure as the requested attributes array in terms
 534  541   * of each attribute  corresponding to specific bits and array elements.)
 535  542   *
 536  543   * xva_xoptattrs - Structure containing values of optional attributes.
 537  544   * These values are only valid if the corresponding bits in xva_reqattrmap
 538  545   * are set and the underlying file system supports those attributes.
 539  546   */
 540  547  typedef struct xvattr {
 541  548          vattr_t         xva_vattr;      /* Embedded vattr structure */
 542  549          uint32_t        xva_magic;      /* Magic Number */
 543  550          uint32_t        xva_mapsize;    /* Size of attr bitmap (32-bit words) */
 544  551          uint32_t        *xva_rtnattrmapp;       /* Ptr to xva_rtnattrmap[] */
 545  552          uint32_t        xva_reqattrmap[XVA_MAPSIZE];    /* Requested attrs */
 546  553          uint32_t        xva_rtnattrmap[XVA_MAPSIZE];    /* Returned attrs */
 547  554          xoptattr_t      xva_xoptattrs;  /* Optional attributes */
 548  555  } xvattr_t;
 549  556  
 550  557  #ifdef _SYSCALL32
 551  558  /*
 552  559   * For bigtypes time_t changed to 64 bit on the 64-bit kernel.
 553  560   * Define an old version for user/kernel interface
 554  561   */
 555  562  
 556  563  #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
 557  564  #pragma pack(4)
 558  565  #endif
 559  566  
 560  567  typedef struct vattr32 {
 561  568          uint32_t        va_mask;        /* bit-mask of attributes */
 562  569          vtype_t         va_type;        /* vnode type (for create) */
 563  570          mode32_t        va_mode;        /* file access mode */
 564  571          uid32_t         va_uid;         /* owner user id */
 565  572          gid32_t         va_gid;         /* owner group id */
 566  573          dev32_t         va_fsid;        /* file system id (dev for now) */
 567  574          u_longlong_t    va_nodeid;      /* node id */
 568  575          nlink_t         va_nlink;       /* number of references to file */
 569  576          u_offset_t      va_size;        /* file size in bytes */
 570  577          timestruc32_t   va_atime;       /* time of last access */
 571  578          timestruc32_t   va_mtime;       /* time of last modification */
 572  579          timestruc32_t   va_ctime;       /* time of last status change */
 573  580          dev32_t         va_rdev;        /* device the file represents */
 574  581          uint32_t        va_blksize;     /* fundamental block size */
 575  582          u_longlong_t    va_nblocks;     /* # of blocks allocated */
 576  583          uint32_t        va_seq;         /* sequence number */
 577  584  } vattr32_t;
 578  585  
 579  586  #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
 580  587  #pragma pack()
 581  588  #endif
 582  589  
 583  590  #else  /* not _SYSCALL32 */
 584  591  #define vattr32         vattr
 585  592  typedef vattr_t         vattr32_t;
 586  593  #endif /* _SYSCALL32 */
 587  594  
 588  595  /*
 589  596   * Attributes of interest to the caller of setattr or getattr.
 590  597   */
 591  598  #define AT_TYPE         0x00001
 592  599  #define AT_MODE         0x00002
 593  600  #define AT_UID          0x00004
 594  601  #define AT_GID          0x00008
 595  602  #define AT_FSID         0x00010
 596  603  #define AT_NODEID       0x00020
 597  604  #define AT_NLINK        0x00040
 598  605  #define AT_SIZE         0x00080
 599  606  #define AT_ATIME        0x00100
 600  607  #define AT_MTIME        0x00200
 601  608  #define AT_CTIME        0x00400
 602  609  #define AT_RDEV         0x00800
 603  610  #define AT_BLKSIZE      0x01000
 604  611  #define AT_NBLOCKS      0x02000
 605  612  /*                      0x04000 */      /* unused */
 606  613  #define AT_SEQ          0x08000
 607  614  /*
 608  615   * If AT_XVATTR is set then there are additional bits to process in
 609  616   * the xvattr_t's attribute bitmap.  If this is not set then the bitmap
 610  617   * MUST be ignored.  Note that this bit must be set/cleared explicitly.
 611  618   * That is, setting AT_ALL will NOT set AT_XVATTR.
 612  619   */
 613  620  #define AT_XVATTR       0x10000
 614  621  
 615  622  #define AT_ALL          (AT_TYPE|AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|\
 616  623                          AT_NLINK|AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|\
 617  624                          AT_RDEV|AT_BLKSIZE|AT_NBLOCKS|AT_SEQ)
 618  625  
 619  626  #define AT_STAT         (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\
 620  627                          AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|AT_RDEV|AT_TYPE)
 621  628  
 622  629  #define AT_TIMES        (AT_ATIME|AT_MTIME|AT_CTIME)
 623  630  
 624  631  #define AT_NOSET        (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\
 625  632                          AT_BLKSIZE|AT_NBLOCKS|AT_SEQ)
 626  633  
 627  634  /*
 628  635   * Attribute bits used in the extensible attribute's (xva's) attribute
 629  636   * bitmaps.  Note that the bitmaps are made up of a variable length number
 630  637   * of 32-bit words.  The convention is to use XAT{n}_{attrname} where "n"
 631  638   * is the element in the bitmap (starting at 1).  This convention is for
 632  639   * the convenience of the maintainer to keep track of which element each
 633  640   * attribute belongs to.
 634  641   *
 635  642   * NOTE THAT CONSUMERS MUST *NOT* USE THE XATn_* DEFINES DIRECTLY.  CONSUMERS
 636  643   * MUST USE THE XAT_* DEFINES.
 637  644   */
 638  645  #define XAT0_INDEX      0LL             /* Index into bitmap for XAT0 attrs */
 639  646  #define XAT0_CREATETIME 0x00000001      /* Create time of file */
 640  647  #define XAT0_ARCHIVE    0x00000002      /* Archive */
 641  648  #define XAT0_SYSTEM     0x00000004      /* System */
 642  649  #define XAT0_READONLY   0x00000008      /* Readonly */
 643  650  #define XAT0_HIDDEN     0x00000010      /* Hidden */
 644  651  #define XAT0_NOUNLINK   0x00000020      /* Nounlink */
 645  652  #define XAT0_IMMUTABLE  0x00000040      /* immutable */
 646  653  #define XAT0_APPENDONLY 0x00000080      /* appendonly */
 647  654  #define XAT0_NODUMP     0x00000100      /* nodump */
 648  655  #define XAT0_OPAQUE     0x00000200      /* opaque */
 649  656  #define XAT0_AV_QUARANTINED     0x00000400      /* anti-virus quarantine */
 650  657  #define XAT0_AV_MODIFIED        0x00000800      /* anti-virus modified */
 651  658  #define XAT0_AV_SCANSTAMP       0x00001000      /* anti-virus scanstamp */
 652  659  #define XAT0_REPARSE    0x00002000      /* FS reparse point */
 653  660  #define XAT0_GEN        0x00004000      /* object generation number */
 654  661  #define XAT0_OFFLINE    0x00008000      /* offline */
 655  662  #define XAT0_SPARSE     0x00010000      /* sparse */
 656  663  #define XAT0_PROJINHERIT        0x00020000      /* Create with parent projid */
 657  664  #define XAT0_PROJID     0x00040000      /* Project ID */
 658  665  
 659  666  #define XAT0_ALL_ATTRS  (XAT0_CREATETIME|XAT0_ARCHIVE|XAT0_SYSTEM| \
 660  667      XAT0_READONLY|XAT0_HIDDEN|XAT0_NOUNLINK|XAT0_IMMUTABLE|XAT0_APPENDONLY| \
 661  668      XAT0_NODUMP|XAT0_OPAQUE|XAT0_AV_QUARANTINED|  XAT0_AV_MODIFIED| \
 662  669      XAT0_AV_SCANSTAMP|XAT0_REPARSE|XATO_GEN|XAT0_OFFLINE|XAT0_SPARSE| \
 663  670      XAT0_PROJINHERIT | XAT0_PROJID)
 664  671  
 665  672  /* Support for XAT_* optional attributes */
 666  673  #define XVA_MASK                0xffffffff      /* Used to mask off 32 bits */
 667  674  #define XVA_SHFT                32              /* Used to shift index */
 668  675  
 669  676  /*
 670  677   * Used to pry out the index and attribute bits from the XAT_* attributes
 671  678   * defined below.  Note that we're masking things down to 32 bits then
 672  679   * casting to uint32_t.
 673  680   */
 674  681  #define XVA_INDEX(attr)         ((uint32_t)(((attr) >> XVA_SHFT) & XVA_MASK))
 675  682  #define XVA_ATTRBIT(attr)       ((uint32_t)((attr) & XVA_MASK))
 676  683  
 677  684  /*
 678  685   * The following defines present a "flat namespace" so that consumers don't
 679  686   * need to keep track of which element belongs to which bitmap entry.
 680  687   *
 681  688   * NOTE THAT THESE MUST NEVER BE OR-ed TOGETHER
 682  689   */
 683  690  #define XAT_CREATETIME          ((XAT0_INDEX << XVA_SHFT) | XAT0_CREATETIME)
 684  691  #define XAT_ARCHIVE             ((XAT0_INDEX << XVA_SHFT) | XAT0_ARCHIVE)
 685  692  #define XAT_SYSTEM              ((XAT0_INDEX << XVA_SHFT) | XAT0_SYSTEM)
 686  693  #define XAT_READONLY            ((XAT0_INDEX << XVA_SHFT) | XAT0_READONLY)
 687  694  #define XAT_HIDDEN              ((XAT0_INDEX << XVA_SHFT) | XAT0_HIDDEN)
 688  695  #define XAT_NOUNLINK            ((XAT0_INDEX << XVA_SHFT) | XAT0_NOUNLINK)
 689  696  #define XAT_IMMUTABLE           ((XAT0_INDEX << XVA_SHFT) | XAT0_IMMUTABLE)
 690  697  #define XAT_APPENDONLY          ((XAT0_INDEX << XVA_SHFT) | XAT0_APPENDONLY)
 691  698  #define XAT_NODUMP              ((XAT0_INDEX << XVA_SHFT) | XAT0_NODUMP)
 692  699  #define XAT_OPAQUE              ((XAT0_INDEX << XVA_SHFT) | XAT0_OPAQUE)
 693  700  #define XAT_AV_QUARANTINED      ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_QUARANTINED)
 694  701  #define XAT_AV_MODIFIED         ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_MODIFIED)
 695  702  #define XAT_AV_SCANSTAMP        ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_SCANSTAMP)
 696  703  #define XAT_REPARSE             ((XAT0_INDEX << XVA_SHFT) | XAT0_REPARSE)
 697  704  #define XAT_GEN                 ((XAT0_INDEX << XVA_SHFT) | XAT0_GEN)
 698  705  #define XAT_OFFLINE             ((XAT0_INDEX << XVA_SHFT) | XAT0_OFFLINE)
 699  706  #define XAT_SPARSE              ((XAT0_INDEX << XVA_SHFT) | XAT0_SPARSE)
 700  707  #define XAT_PROJINHERIT         ((XAT0_INDEX << XVA_SHFT) | XAT0_PROJINHERIT)
 701  708  #define XAT_PROJID              ((XAT0_INDEX << XVA_SHFT) | XAT0_PROJID)
 702  709  
 703  710  /*
 704  711   * The returned attribute map array (xva_rtnattrmap[]) is located past the
 705  712   * requested attribute map array (xva_reqattrmap[]).  Its location changes
 706  713   * when the array sizes change.  We use a separate pointer in a known location
 707  714   * (xva_rtnattrmapp) to hold the location of xva_rtnattrmap[].  This is
 708  715   * set in xva_init()
 709  716   */
 710  717  #define XVA_RTNATTRMAP(xvap)    ((xvap)->xva_rtnattrmapp)
 711  718  
 712  719  /*
 713  720   * XVA_SET_REQ() sets an attribute bit in the proper element in the bitmap
 714  721   * of requested attributes (xva_reqattrmap[]).
 715  722   */
 716  723  #define XVA_SET_REQ(xvap, attr)                                 \
 717  724          ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR);          \
 718  725          ASSERT((xvap)->xva_magic == XVA_MAGIC);                 \
 719  726          (xvap)->xva_reqattrmap[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr)
 720  727  /*
 721  728   * XVA_CLR_REQ() clears an attribute bit in the proper element in the bitmap
 722  729   * of requested attributes (xva_reqattrmap[]).
 723  730   */
 724  731  #define XVA_CLR_REQ(xvap, attr)                                 \
 725  732          ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR);          \
 726  733          ASSERT((xvap)->xva_magic == XVA_MAGIC);                 \
 727  734          (xvap)->xva_reqattrmap[XVA_INDEX(attr)] &= ~XVA_ATTRBIT(attr)
 728  735  
 729  736  /*
 730  737   * XVA_SET_RTN() sets an attribute bit in the proper element in the bitmap
 731  738   * of returned attributes (xva_rtnattrmap[]).
 732  739   */
 733  740  #define XVA_SET_RTN(xvap, attr)                                 \
 734  741          ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR);          \
 735  742          ASSERT((xvap)->xva_magic == XVA_MAGIC);                 \
 736  743          (XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr)
 737  744  
 738  745  /*
 739  746   * XVA_ISSET_REQ() checks the requested attribute bitmap (xva_reqattrmap[])
 740  747   * to see of the corresponding attribute bit is set.  If so, returns non-zero.
 741  748   */
 742  749  #define XVA_ISSET_REQ(xvap, attr)                                       \
 743  750          ((((xvap)->xva_vattr.va_mask | AT_XVATTR) &&                    \
 744  751                  ((xvap)->xva_magic == XVA_MAGIC) &&                     \
 745  752                  ((xvap)->xva_mapsize > XVA_INDEX(attr))) ?              \
 746  753          ((xvap)->xva_reqattrmap[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) : 0)
 747  754  
 748  755  /*
 749  756   * XVA_ISSET_RTN() checks the returned attribute bitmap (xva_rtnattrmap[])
 750  757   * to see of the corresponding attribute bit is set.  If so, returns non-zero.
 751  758   */
 752  759  #define XVA_ISSET_RTN(xvap, attr)                                       \
 753  760          ((((xvap)->xva_vattr.va_mask | AT_XVATTR) &&                    \
 754  761                  ((xvap)->xva_magic == XVA_MAGIC) &&                     \
 755  762                  ((xvap)->xva_mapsize > XVA_INDEX(attr))) ?              \
 756  763          ((XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) : 0)
 757  764  
 758  765  /*
 759  766   *  Modes.  Some values same as S_xxx entries from stat.h for convenience.
 760  767   */
 761  768  #define VSUID           04000           /* set user id on execution */
 762  769  #define VSGID           02000           /* set group id on execution */
 763  770  #define VSVTX           01000           /* save swapped text even after use */
 764  771  
 765  772  /*
 766  773   * Permissions.
 767  774   */
 768  775  #define VREAD           00400
 769  776  #define VWRITE          00200
 770  777  #define VEXEC           00100
 771  778  
 772  779  #define MODEMASK        07777           /* mode bits plus permission bits */
 773  780  #define PERMMASK        00777           /* permission bits */
 774  781  
 775  782  /*
 776  783   * VOP_ACCESS flags
 777  784   */
 778  785  #define V_ACE_MASK      0x1     /* mask represents  NFSv4 ACE permissions */
 779  786  #define V_APPEND        0x2     /* want to do append only check */
 780  787  
 781  788  /*
 782  789   * Check whether mandatory file locking is enabled.
 783  790   */
 784  791  
 785  792  #define MANDMODE(mode)          (((mode) & (VSGID|(VEXEC>>3))) == VSGID)
 786  793  #define MANDLOCK(vp, mode)      ((vp)->v_type == VREG && MANDMODE(mode))
 787  794  
 788  795  /*
 789  796   * Flags for vnode operations.
 790  797   */
 791  798  enum rm         { RMFILE, RMDIRECTORY };        /* rm or rmdir (remove) */
 792  799  enum symfollow  { NO_FOLLOW, FOLLOW };          /* follow symlinks (or not) */
 793  800  enum vcexcl     { NONEXCL, EXCL };              /* (non)excl create */
 794  801  enum create     { CRCREAT, CRMKNOD, CRMKDIR };  /* reason for create */
 795  802  
 796  803  typedef enum rm         rm_t;
 797  804  typedef enum symfollow  symfollow_t;
 798  805  typedef enum vcexcl     vcexcl_t;
 799  806  typedef enum create     create_t;
 800  807  
 801  808  /*
 802  809   * Vnode Events - Used by VOP_VNEVENT
 803  810   * The VE_PRE_RENAME_* events fire before the rename operation and are
 804  811   * primarily used for specialized applications, such as NFSv4 delegation, which
 805  812   * need to know about rename before it occurs.
 806  813   */
 807  814  typedef enum vnevent    {
 808  815          VE_SUPPORT      = 0,    /* Query */
 809  816          VE_RENAME_SRC   = 1,    /* Rename, with vnode as source */
 810  817          VE_RENAME_DEST  = 2,    /* Rename, with vnode as target/destination */
 811  818          VE_REMOVE       = 3,    /* Remove of vnode's name */
 812  819          VE_RMDIR        = 4,    /* Remove of directory vnode's name */
 813  820          VE_CREATE       = 5,    /* Create with vnode's name which exists */
 814  821          VE_LINK         = 6,    /* Link with vnode's name as source */
 815  822          VE_RENAME_DEST_DIR      = 7,    /* Rename with vnode as target dir */
 816  823          VE_MOUNTEDOVER  = 8,    /* File or Filesystem got mounted over vnode */
 817  824          VE_TRUNCATE = 9,        /* Truncate */
 818  825          VE_PRE_RENAME_SRC = 10, /* Pre-rename, with vnode as source */
 819  826          VE_PRE_RENAME_DEST = 11, /* Pre-rename, with vnode as target/dest. */
 820  827          VE_PRE_RENAME_DEST_DIR = 12 /* Pre-rename with vnode as target dir */
 821  828  } vnevent_t;
 822  829  
 823  830  /*
 824  831   * Values for checking vnode open and map counts
 825  832   */
 826  833  enum v_mode { V_READ, V_WRITE, V_RDORWR, V_RDANDWR };
 827  834  
 828  835  typedef enum v_mode v_mode_t;
 829  836  
 830  837  #define V_TRUE  1
 831  838  #define V_FALSE 0
 832  839  
 833  840  /*
 834  841   * Structure used on VOP_GETSECATTR and VOP_SETSECATTR operations
 835  842   */
 836  843  
 837  844  typedef struct vsecattr {
 838  845          uint_t          vsa_mask;       /* See below */
 839  846          int             vsa_aclcnt;     /* ACL entry count */
 840  847          void            *vsa_aclentp;   /* pointer to ACL entries */
 841  848          int             vsa_dfaclcnt;   /* default ACL entry count */
 842  849          void            *vsa_dfaclentp; /* pointer to default ACL entries */
 843  850          size_t          vsa_aclentsz;   /* ACE size in bytes of vsa_aclentp */
 844  851          uint_t          vsa_aclflags;   /* ACE ACL flags */
 845  852  } vsecattr_t;
 846  853  
 847  854  /* vsa_mask values */
 848  855  #define VSA_ACL                 0x0001
 849  856  #define VSA_ACLCNT              0x0002
 850  857  #define VSA_DFACL               0x0004
 851  858  #define VSA_DFACLCNT            0x0008
 852  859  #define VSA_ACE                 0x0010
 853  860  #define VSA_ACECNT              0x0020
 854  861  #define VSA_ACE_ALLTYPES        0x0040
 855  862  #define VSA_ACE_ACLFLAGS        0x0080  /* get/set ACE ACL flags */
 856  863  
 857  864  /*
 858  865   * Structure used by various vnode operations to determine
 859  866   * the context (pid, host, identity) of a caller.
 860  867   *
 861  868   * The cc_caller_id is used to identify one or more callers who invoke
 862  869   * operations, possibly on behalf of others.  For example, the NFS
 863  870   * server could have it's own cc_caller_id which can be detected by
 864  871   * vnode/vfs operations or (FEM) monitors on those operations.  New
 865  872   * caller IDs are generated by fs_new_caller_id().
 866  873   */
 867  874  typedef struct caller_context {
 868  875          pid_t           cc_pid;         /* Process ID of the caller */
 869  876          int             cc_sysid;       /* System ID, used for remote calls */
 870  877          u_longlong_t    cc_caller_id;   /* Identifier for (set of) caller(s) */
 871  878          ulong_t         cc_flags;
 872  879  } caller_context_t;
 873  880  
 874  881  /*
 875  882   * Flags for caller context.  The caller sets CC_DONTBLOCK if it does not
 876  883   * want to block inside of a FEM monitor.  The monitor will set CC_WOULDBLOCK
 877  884   * and return EAGAIN if the operation would have blocked.
 878  885   */
 879  886  #define CC_WOULDBLOCK   0x01
 880  887  #define CC_DONTBLOCK    0x02
 881  888  
 882  889  /*
 883  890   * Structure tags for function prototypes, defined elsewhere.
 884  891   */
 885  892  struct pathname;
 886  893  struct fid;
 887  894  struct flock64;
 888  895  struct flk_callback;
 889  896  struct shrlock;
 890  897  struct page;
 891  898  struct seg;
 892  899  struct as;
 893  900  struct pollhead;
 894  901  struct taskq;
 895  902  
 896  903  #ifdef  _KERNEL
 897  904  
 898  905  /*
 899  906   * VNODE_OPS defines all the vnode operations.  It is used to define
 900  907   * the vnodeops structure (below) and the fs_func_p union (vfs_opreg.h).
 901  908   */
 902  909  #define VNODE_OPS                                                       \
 903  910          int     (*vop_open)(vnode_t **, int, cred_t *,                  \
 904  911                                  caller_context_t *);                    \
 905  912          int     (*vop_close)(vnode_t *, int, int, offset_t, cred_t *,   \
 906  913                                  caller_context_t *);                    \
 907  914          int     (*vop_read)(vnode_t *, uio_t *, int, cred_t *,          \
 908  915                                  caller_context_t *);                    \
 909  916          int     (*vop_write)(vnode_t *, uio_t *, int, cred_t *,         \
 910  917                                  caller_context_t *);                    \
 911  918          int     (*vop_ioctl)(vnode_t *, int, intptr_t, int, cred_t *,   \
 912  919                                  int *, caller_context_t *);             \
 913  920          int     (*vop_setfl)(vnode_t *, int, int, cred_t *,             \
 914  921                                  caller_context_t *);                    \
 915  922          int     (*vop_getattr)(vnode_t *, vattr_t *, int, cred_t *,     \
 916  923                                  caller_context_t *);                    \
 917  924          int     (*vop_setattr)(vnode_t *, vattr_t *, int, cred_t *,     \
 918  925                                  caller_context_t *);                    \
 919  926          int     (*vop_access)(vnode_t *, int, int, cred_t *,            \
 920  927                                  caller_context_t *);                    \
 921  928          int     (*vop_lookup)(vnode_t *, char *, vnode_t **,            \
 922  929                                  struct pathname *,                      \
 923  930                                  int, vnode_t *, cred_t *,               \
 924  931                                  caller_context_t *, int *,              \
 925  932                                  struct pathname *);                     \
 926  933          int     (*vop_create)(vnode_t *, char *, vattr_t *, vcexcl_t,   \
 927  934                                  int, vnode_t **, cred_t *, int,         \
 928  935                                  caller_context_t *, vsecattr_t *);      \
 929  936          int     (*vop_remove)(vnode_t *, char *, cred_t *,              \
 930  937                                  caller_context_t *, int);               \
 931  938          int     (*vop_link)(vnode_t *, vnode_t *, char *, cred_t *,     \
 932  939                                  caller_context_t *, int);               \
 933  940          int     (*vop_rename)(vnode_t *, char *, vnode_t *, char *,     \
 934  941                                  cred_t *, caller_context_t *, int);     \
 935  942          int     (*vop_mkdir)(vnode_t *, char *, vattr_t *, vnode_t **,  \
 936  943                                  cred_t *, caller_context_t *, int,      \
 937  944                                  vsecattr_t *);                          \
 938  945          int     (*vop_rmdir)(vnode_t *, char *, vnode_t *, cred_t *,    \
 939  946                                  caller_context_t *, int);               \
 940  947          int     (*vop_readdir)(vnode_t *, uio_t *, cred_t *, int *,     \
 941  948                                  caller_context_t *, int);               \
 942  949          int     (*vop_symlink)(vnode_t *, char *, vattr_t *, char *,    \
 943  950                                  cred_t *, caller_context_t *, int);     \
 944  951          int     (*vop_readlink)(vnode_t *, uio_t *, cred_t *,           \
 945  952                                  caller_context_t *);                    \
 946  953          int     (*vop_fsync)(vnode_t *, int, cred_t *,                  \
 947  954                                  caller_context_t *);                    \
 948  955          void    (*vop_inactive)(vnode_t *, cred_t *,                    \
 949  956                                  caller_context_t *);                    \
 950  957          int     (*vop_fid)(vnode_t *, struct fid *,                     \
 951  958                                  caller_context_t *);                    \
 952  959          int     (*vop_rwlock)(vnode_t *, int, caller_context_t *);      \
 953  960          void    (*vop_rwunlock)(vnode_t *, int, caller_context_t *);    \
 954  961          int     (*vop_seek)(vnode_t *, offset_t, offset_t *,            \
 955  962                                  caller_context_t *);                    \
 956  963          int     (*vop_cmp)(vnode_t *, vnode_t *, caller_context_t *);   \
 957  964          int     (*vop_frlock)(vnode_t *, int, struct flock64 *,         \
 958  965                                  int, offset_t,                          \
 959  966                                  struct flk_callback *, cred_t *,        \
 960  967                                  caller_context_t *);                    \
 961  968          int     (*vop_space)(vnode_t *, int, struct flock64 *,          \
 962  969                                  int, offset_t,                          \
 963  970                                  cred_t *, caller_context_t *);          \
 964  971          int     (*vop_realvp)(vnode_t *, vnode_t **,                    \
 965  972                                  caller_context_t *);                    \
 966  973          int     (*vop_getpage)(vnode_t *, offset_t, size_t, uint_t *,   \
 967  974                                  struct page **, size_t, struct seg *,   \
 968  975                                  caddr_t, enum seg_rw, cred_t *,         \
 969  976                                  caller_context_t *);                    \
 970  977          int     (*vop_putpage)(vnode_t *, offset_t, size_t,             \
 971  978                                  int, cred_t *, caller_context_t *);     \
 972  979          int     (*vop_map)(vnode_t *, offset_t, struct as *,            \
 973  980                                  caddr_t *, size_t,                      \
 974  981                                  uchar_t, uchar_t, uint_t, cred_t *,     \
 975  982                                  caller_context_t *);                    \
 976  983          int     (*vop_addmap)(vnode_t *, offset_t, struct as *,         \
 977  984                                  caddr_t, size_t,                        \
 978  985                                  uchar_t, uchar_t, uint_t, cred_t *,     \
 979  986                                  caller_context_t *);                    \
 980  987          int     (*vop_delmap)(vnode_t *, offset_t, struct as *,         \
 981  988                                  caddr_t, size_t,                        \
 982  989                                  uint_t, uint_t, uint_t, cred_t *,       \
 983  990                                  caller_context_t *);                    \
 984  991          int     (*vop_poll)(vnode_t *, short, int, short *,             \
 985  992                                  struct pollhead **,                     \
 986  993                                  caller_context_t *);                    \
 987  994          int     (*vop_dump)(vnode_t *, caddr_t, offset_t, offset_t,     \
 988  995                                  caller_context_t *);                    \
 989  996          int     (*vop_pathconf)(vnode_t *, int, ulong_t *, cred_t *,    \
 990  997                                  caller_context_t *);                    \
 991  998          int     (*vop_pageio)(vnode_t *, struct page *,                 \
 992  999                                  u_offset_t, size_t, int, cred_t *,      \
 993 1000                                  caller_context_t *);                    \
 994 1001          int     (*vop_dumpctl)(vnode_t *, int, offset_t *,              \
 995 1002                                  caller_context_t *);                    \
 996 1003          void    (*vop_dispose)(vnode_t *, struct page *,                \
 997 1004                                  int, int, cred_t *,                     \
 998 1005                                  caller_context_t *);                    \
 999 1006          int     (*vop_setsecattr)(vnode_t *, vsecattr_t *,              \
1000 1007                                  int, cred_t *, caller_context_t *);     \
1001 1008          int     (*vop_getsecattr)(vnode_t *, vsecattr_t *,              \
1002 1009                                  int, cred_t *, caller_context_t *);     \
1003 1010          int     (*vop_shrlock)(vnode_t *, int, struct shrlock *,        \
1004 1011                                  int, cred_t *, caller_context_t *);     \
1005 1012          int     (*vop_vnevent)(vnode_t *, vnevent_t, vnode_t *,         \
1006 1013                                  char *, caller_context_t *);            \
1007 1014          int     (*vop_reqzcbuf)(vnode_t *, enum uio_rw, xuio_t *,       \
1008 1015                                  cred_t *, caller_context_t *);          \
1009 1016          int     (*vop_retzcbuf)(vnode_t *, xuio_t *, cred_t *,          \
1010 1017                                  caller_context_t *)
1011 1018          /* NB: No ";" */
1012 1019  
1013 1020  /*
1014 1021   * Operations on vnodes.  Note: File systems must never operate directly
1015 1022   * on a 'vnodeops' structure -- it WILL change in future releases!  They
1016 1023   * must use vn_make_ops() to create the structure.
1017 1024   */
1018 1025  typedef struct vnodeops {
1019 1026          const char *vnop_name;
1020 1027          VNODE_OPS;      /* Signatures of all vnode operations (vops) */
1021 1028  } vnodeops_t;
1022 1029  
1023 1030  typedef int (*fs_generic_func_p) ();    /* Generic vop/vfsop/femop/fsemop ptr */
1024 1031  
1025 1032  extern int      fop_open(vnode_t **, int, cred_t *, caller_context_t *);
1026 1033  extern int      fop_close(vnode_t *, int, int, offset_t, cred_t *,
1027 1034                                  caller_context_t *);
1028 1035  extern int      fop_read(vnode_t *, uio_t *, int, cred_t *, caller_context_t *);
1029 1036  extern int      fop_write(vnode_t *, uio_t *, int, cred_t *,
1030 1037                                  caller_context_t *);
1031 1038  extern int      fop_ioctl(vnode_t *, int, intptr_t, int, cred_t *, int *,
1032 1039                                  caller_context_t *);
1033 1040  extern int      fop_setfl(vnode_t *, int, int, cred_t *, caller_context_t *);
1034 1041  extern int      fop_getattr(vnode_t *, vattr_t *, int, cred_t *,
1035 1042                                  caller_context_t *);
1036 1043  extern int      fop_setattr(vnode_t *, vattr_t *, int, cred_t *,
1037 1044                                  caller_context_t *);
1038 1045  extern int      fop_access(vnode_t *, int, int, cred_t *, caller_context_t *);
1039 1046  extern int      fop_lookup(vnode_t *, char *, vnode_t **, struct pathname *,
1040 1047                                  int, vnode_t *, cred_t *, caller_context_t *,
1041 1048                                  int *, struct pathname *);
1042 1049  extern int      fop_create(vnode_t *, char *, vattr_t *, vcexcl_t, int,
1043 1050                                  vnode_t **, cred_t *, int, caller_context_t *,
1044 1051                                  vsecattr_t *);
1045 1052  extern int      fop_remove(vnode_t *vp, char *, cred_t *, caller_context_t *,
1046 1053                                  int);
1047 1054  extern int      fop_link(vnode_t *, vnode_t *, char *, cred_t *,
1048 1055                                  caller_context_t *, int);
1049 1056  extern int      fop_rename(vnode_t *, char *, vnode_t *, char *, cred_t *,
1050 1057                                  caller_context_t *, int);
1051 1058  extern int      fop_mkdir(vnode_t *, char *, vattr_t *, vnode_t **, cred_t *,
1052 1059                                  caller_context_t *, int, vsecattr_t *);
1053 1060  extern int      fop_rmdir(vnode_t *, char *, vnode_t *, cred_t *,
1054 1061                                  caller_context_t *, int);
1055 1062  extern int      fop_readdir(vnode_t *, uio_t *, cred_t *, int *,
1056 1063                                  caller_context_t *, int);
1057 1064  extern int      fop_symlink(vnode_t *, char *, vattr_t *, char *, cred_t *,
1058 1065                                  caller_context_t *, int);
1059 1066  extern int      fop_readlink(vnode_t *, uio_t *, cred_t *, caller_context_t *);
1060 1067  extern int      fop_fsync(vnode_t *, int, cred_t *, caller_context_t *);
1061 1068  extern void     fop_inactive(vnode_t *, cred_t *, caller_context_t *);
1062 1069  extern int      fop_fid(vnode_t *, struct fid *, caller_context_t *);
1063 1070  extern int      fop_rwlock(vnode_t *, int, caller_context_t *);
1064 1071  extern void     fop_rwunlock(vnode_t *, int, caller_context_t *);
1065 1072  extern int      fop_seek(vnode_t *, offset_t, offset_t *, caller_context_t *);
1066 1073  extern int      fop_cmp(vnode_t *, vnode_t *, caller_context_t *);
1067 1074  extern int      fop_frlock(vnode_t *, int, struct flock64 *, int, offset_t,
1068 1075                                  struct flk_callback *, cred_t *,
1069 1076                                  caller_context_t *);
1070 1077  extern int      fop_space(vnode_t *, int, struct flock64 *, int, offset_t,
1071 1078                                  cred_t *, caller_context_t *);
1072 1079  extern int      fop_realvp(vnode_t *, vnode_t **, caller_context_t *);
1073 1080  extern int      fop_getpage(vnode_t *, offset_t, size_t, uint_t *,
1074 1081                                  struct page **, size_t, struct seg *,
1075 1082                                  caddr_t, enum seg_rw, cred_t *,
1076 1083                                  caller_context_t *);
1077 1084  extern int      fop_putpage(vnode_t *, offset_t, size_t, int, cred_t *,
1078 1085                                  caller_context_t *);
1079 1086  extern int      fop_map(vnode_t *, offset_t, struct as *, caddr_t *, size_t,
1080 1087                                  uchar_t, uchar_t, uint_t, cred_t *cr,
1081 1088                                  caller_context_t *);
1082 1089  extern int      fop_addmap(vnode_t *, offset_t, struct as *, caddr_t, size_t,
1083 1090                                  uchar_t, uchar_t, uint_t, cred_t *,
1084 1091                                  caller_context_t *);
1085 1092  extern int      fop_delmap(vnode_t *, offset_t, struct as *, caddr_t, size_t,
1086 1093                                  uint_t, uint_t, uint_t, cred_t *,
1087 1094                                  caller_context_t *);
1088 1095  extern int      fop_poll(vnode_t *, short, int, short *, struct pollhead **,
1089 1096                                  caller_context_t *);
1090 1097  extern int      fop_dump(vnode_t *, caddr_t, offset_t, offset_t,
1091 1098      caller_context_t *);
1092 1099  extern int      fop_pathconf(vnode_t *, int, ulong_t *, cred_t *,
1093 1100                                  caller_context_t *);
1094 1101  extern int      fop_pageio(vnode_t *, struct page *, u_offset_t, size_t, int,
1095 1102                                  cred_t *, caller_context_t *);
1096 1103  extern int      fop_dumpctl(vnode_t *, int, offset_t *, caller_context_t *);
1097 1104  extern void     fop_dispose(vnode_t *, struct page *, int, int, cred_t *,
1098 1105                                  caller_context_t *);
1099 1106  extern int      fop_setsecattr(vnode_t *, vsecattr_t *, int, cred_t *,
1100 1107                                  caller_context_t *);
1101 1108  extern int      fop_getsecattr(vnode_t *, vsecattr_t *, int, cred_t *,
1102 1109                                  caller_context_t *);
1103 1110  extern int      fop_shrlock(vnode_t *, int, struct shrlock *, int, cred_t *,
1104 1111                                  caller_context_t *);
1105 1112  extern int      fop_vnevent(vnode_t *, vnevent_t, vnode_t *, char *,
1106 1113                                  caller_context_t *);
1107 1114  extern int      fop_reqzcbuf(vnode_t *, enum uio_rw, xuio_t *, cred_t *,
1108 1115                                  caller_context_t *);
1109 1116  extern int      fop_retzcbuf(vnode_t *, xuio_t *, cred_t *, caller_context_t *);
1110 1117  
1111 1118  #endif  /* _KERNEL */
1112 1119  
1113 1120  #define VOP_OPEN(vpp, mode, cr, ct) \
1114 1121          fop_open(vpp, mode, cr, ct)
1115 1122  #define VOP_CLOSE(vp, f, c, o, cr, ct) \
1116 1123          fop_close(vp, f, c, o, cr, ct)
1117 1124  #define VOP_READ(vp, uiop, iof, cr, ct) \
1118 1125          fop_read(vp, uiop, iof, cr, ct)
1119 1126  #define VOP_WRITE(vp, uiop, iof, cr, ct) \
1120 1127          fop_write(vp, uiop, iof, cr, ct)
1121 1128  #define VOP_IOCTL(vp, cmd, a, f, cr, rvp, ct) \
1122 1129          fop_ioctl(vp, cmd, a, f, cr, rvp, ct)
1123 1130  #define VOP_SETFL(vp, f, a, cr, ct) \
1124 1131          fop_setfl(vp, f, a, cr, ct)
1125 1132  #define VOP_GETATTR(vp, vap, f, cr, ct) \
1126 1133          fop_getattr(vp, vap, f, cr, ct)
1127 1134  #define VOP_SETATTR(vp, vap, f, cr, ct) \
1128 1135          fop_setattr(vp, vap, f, cr, ct)
1129 1136  #define VOP_ACCESS(vp, mode, f, cr, ct) \
1130 1137          fop_access(vp, mode, f, cr, ct)
1131 1138  #define VOP_LOOKUP(vp, cp, vpp, pnp, f, rdir, cr, ct, defp, rpnp) \
1132 1139          fop_lookup(vp, cp, vpp, pnp, f, rdir, cr, ct, defp, rpnp)
1133 1140  #define VOP_CREATE(dvp, p, vap, ex, mode, vpp, cr, flag, ct, vsap) \
1134 1141          fop_create(dvp, p, vap, ex, mode, vpp, cr, flag, ct, vsap)
1135 1142  #define VOP_REMOVE(dvp, p, cr, ct, f) \
1136 1143          fop_remove(dvp, p, cr, ct, f)
1137 1144  #define VOP_LINK(tdvp, fvp, p, cr, ct, f) \
1138 1145          fop_link(tdvp, fvp, p, cr, ct, f)
1139 1146  #define VOP_RENAME(fvp, fnm, tdvp, tnm, cr, ct, f) \
1140 1147          fop_rename(fvp, fnm, tdvp, tnm, cr, ct, f)
1141 1148  #define VOP_MKDIR(dp, p, vap, vpp, cr, ct, f, vsap) \
1142 1149          fop_mkdir(dp, p, vap, vpp, cr, ct, f, vsap)
1143 1150  #define VOP_RMDIR(dp, p, cdir, cr, ct, f) \
1144 1151          fop_rmdir(dp, p, cdir, cr, ct, f)
1145 1152  #define VOP_READDIR(vp, uiop, cr, eofp, ct, f) \
1146 1153          fop_readdir(vp, uiop, cr, eofp, ct, f)
1147 1154  #define VOP_SYMLINK(dvp, lnm, vap, tnm, cr, ct, f) \
1148 1155          fop_symlink(dvp, lnm, vap, tnm, cr, ct, f)
1149 1156  #define VOP_READLINK(vp, uiop, cr, ct) \
1150 1157          fop_readlink(vp, uiop, cr, ct)
1151 1158  #define VOP_FSYNC(vp, syncflag, cr, ct) \
1152 1159          fop_fsync(vp, syncflag, cr, ct)
1153 1160  #define VOP_INACTIVE(vp, cr, ct) \
1154 1161          fop_inactive(vp, cr, ct)
1155 1162  #define VOP_FID(vp, fidp, ct) \
1156 1163          fop_fid(vp, fidp, ct)
1157 1164  #define VOP_RWLOCK(vp, w, ct) \
1158 1165          fop_rwlock(vp, w, ct)
1159 1166  #define VOP_RWUNLOCK(vp, w, ct) \
1160 1167          fop_rwunlock(vp, w, ct)
1161 1168  #define VOP_SEEK(vp, ooff, noffp, ct) \
1162 1169          fop_seek(vp, ooff, noffp, ct)
1163 1170  #define VOP_CMP(vp1, vp2, ct) \
1164 1171          fop_cmp(vp1, vp2, ct)
1165 1172  #define VOP_FRLOCK(vp, cmd, a, f, o, cb, cr, ct) \
1166 1173          fop_frlock(vp, cmd, a, f, o, cb, cr, ct)
1167 1174  #define VOP_SPACE(vp, cmd, a, f, o, cr, ct) \
1168 1175          fop_space(vp, cmd, a, f, o, cr, ct)
1169 1176  #define VOP_REALVP(vp1, vp2, ct) \
1170 1177          fop_realvp(vp1, vp2, ct)
1171 1178  #define VOP_GETPAGE(vp, of, sz, pr, pl, ps, sg, a, rw, cr, ct) \
1172 1179          fop_getpage(vp, of, sz, pr, pl, ps, sg, a, rw, cr, ct)
1173 1180  #define VOP_PUTPAGE(vp, of, sz, fl, cr, ct) \
1174 1181          fop_putpage(vp, of, sz, fl, cr, ct)
1175 1182  #define VOP_MAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \
1176 1183          fop_map(vp, of, as, a, sz, p, mp, fl, cr, ct)
1177 1184  #define VOP_ADDMAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \
1178 1185          fop_addmap(vp, of, as, a, sz, p, mp, fl, cr, ct)
1179 1186  #define VOP_DELMAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \
1180 1187          fop_delmap(vp, of, as, a, sz, p, mp, fl, cr, ct)
1181 1188  #define VOP_POLL(vp, events, anyyet, reventsp, phpp, ct) \
1182 1189          fop_poll(vp, events, anyyet, reventsp, phpp, ct)
1183 1190  #define VOP_DUMP(vp, addr, bn, count, ct) \
1184 1191          fop_dump(vp, addr, bn, count, ct)
1185 1192  #define VOP_PATHCONF(vp, cmd, valp, cr, ct) \
1186 1193          fop_pathconf(vp, cmd, valp, cr, ct)
1187 1194  #define VOP_PAGEIO(vp, pp, io_off, io_len, flags, cr, ct) \
1188 1195          fop_pageio(vp, pp, io_off, io_len, flags, cr, ct)
1189 1196  #define VOP_DUMPCTL(vp, action, blkp, ct) \
1190 1197          fop_dumpctl(vp, action, blkp, ct)
1191 1198  #define VOP_DISPOSE(vp, pp, flag, dn, cr, ct) \
1192 1199          fop_dispose(vp, pp, flag, dn, cr, ct)
1193 1200  #define VOP_GETSECATTR(vp, vsap, f, cr, ct) \
1194 1201          fop_getsecattr(vp, vsap, f, cr, ct)
1195 1202  #define VOP_SETSECATTR(vp, vsap, f, cr, ct) \
1196 1203          fop_setsecattr(vp, vsap, f, cr, ct)
1197 1204  #define VOP_SHRLOCK(vp, cmd, shr, f, cr, ct) \
1198 1205          fop_shrlock(vp, cmd, shr, f, cr, ct)
1199 1206  #define VOP_VNEVENT(vp, vnevent, dvp, fnm, ct) \
1200 1207          fop_vnevent(vp, vnevent, dvp, fnm, ct)
1201 1208  #define VOP_REQZCBUF(vp, rwflag, xuiop, cr, ct) \
1202 1209          fop_reqzcbuf(vp, rwflag, xuiop, cr, ct)
1203 1210  #define VOP_RETZCBUF(vp, xuiop, cr, ct) \
1204 1211          fop_retzcbuf(vp, xuiop, cr, ct)
1205 1212  
1206 1213  #define VOPNAME_OPEN            "open"
1207 1214  #define VOPNAME_CLOSE           "close"
1208 1215  #define VOPNAME_READ            "read"
1209 1216  #define VOPNAME_WRITE           "write"
1210 1217  #define VOPNAME_IOCTL           "ioctl"
1211 1218  #define VOPNAME_SETFL           "setfl"
1212 1219  #define VOPNAME_GETATTR         "getattr"
1213 1220  #define VOPNAME_SETATTR         "setattr"
1214 1221  #define VOPNAME_ACCESS          "access"
1215 1222  #define VOPNAME_LOOKUP          "lookup"
1216 1223  #define VOPNAME_CREATE          "create"
1217 1224  #define VOPNAME_REMOVE          "remove"
1218 1225  #define VOPNAME_LINK            "link"
1219 1226  #define VOPNAME_RENAME          "rename"
1220 1227  #define VOPNAME_MKDIR           "mkdir"
1221 1228  #define VOPNAME_RMDIR           "rmdir"
1222 1229  #define VOPNAME_READDIR         "readdir"
1223 1230  #define VOPNAME_SYMLINK         "symlink"
1224 1231  #define VOPNAME_READLINK        "readlink"
1225 1232  #define VOPNAME_FSYNC           "fsync"
1226 1233  #define VOPNAME_INACTIVE        "inactive"
1227 1234  #define VOPNAME_FID             "fid"
1228 1235  #define VOPNAME_RWLOCK          "rwlock"
1229 1236  #define VOPNAME_RWUNLOCK        "rwunlock"
1230 1237  #define VOPNAME_SEEK            "seek"
1231 1238  #define VOPNAME_CMP             "cmp"
1232 1239  #define VOPNAME_FRLOCK          "frlock"
1233 1240  #define VOPNAME_SPACE           "space"
1234 1241  #define VOPNAME_REALVP          "realvp"
1235 1242  #define VOPNAME_GETPAGE         "getpage"
1236 1243  #define VOPNAME_PUTPAGE         "putpage"
1237 1244  #define VOPNAME_MAP             "map"
1238 1245  #define VOPNAME_ADDMAP          "addmap"
1239 1246  #define VOPNAME_DELMAP          "delmap"
1240 1247  #define VOPNAME_POLL            "poll"
1241 1248  #define VOPNAME_DUMP            "dump"
1242 1249  #define VOPNAME_PATHCONF        "pathconf"
1243 1250  #define VOPNAME_PAGEIO          "pageio"
1244 1251  #define VOPNAME_DUMPCTL         "dumpctl"
1245 1252  #define VOPNAME_DISPOSE         "dispose"
1246 1253  #define VOPNAME_GETSECATTR      "getsecattr"
1247 1254  #define VOPNAME_SETSECATTR      "setsecattr"
1248 1255  #define VOPNAME_SHRLOCK         "shrlock"
1249 1256  #define VOPNAME_VNEVENT         "vnevent"
1250 1257  #define VOPNAME_REQZCBUF        "reqzcbuf"
1251 1258  #define VOPNAME_RETZCBUF        "retzcbuf"
1252 1259  
1253 1260  /*
1254 1261   * Flags for VOP_LOOKUP
1255 1262   *
1256 1263   * Defined in file.h, but also possible, FIGNORECASE and FSEARCH
1257 1264   *
1258 1265   */
1259 1266  #define LOOKUP_DIR              0x01    /* want parent dir vp */
1260 1267  #define LOOKUP_XATTR            0x02    /* lookup up extended attr dir */
1261 1268  #define CREATE_XATTR_DIR        0x04    /* Create extended attr dir */
1262 1269  #define LOOKUP_HAVE_SYSATTR_DIR 0x08    /* Already created virtual GFS dir */
1263 1270  
1264 1271  /*
1265 1272   * Flags for VOP_READDIR
1266 1273   */
1267 1274  #define V_RDDIR_ENTFLAGS        0x01    /* request dirent flags */
1268 1275  #define V_RDDIR_ACCFILTER       0x02    /* filter out inaccessible dirents */
1269 1276  
1270 1277  /*
1271 1278   * Flags for VOP_RWLOCK/VOP_RWUNLOCK
1272 1279   * VOP_RWLOCK will return the flag that was actually set, or -1 if none.
1273 1280   */
1274 1281  #define V_WRITELOCK_TRUE        (1)     /* Request write-lock on the vnode */
1275 1282  #define V_WRITELOCK_FALSE       (0)     /* Request read-lock on the vnode */
1276 1283  
1277 1284  /*
1278 1285   * Flags for VOP_DUMPCTL
1279 1286   */
1280 1287  #define DUMP_ALLOC      0
1281 1288  #define DUMP_FREE       1
1282 1289  #define DUMP_SCAN       2
1283 1290  
1284 1291  /*
1285 1292   * Public vnode manipulation functions.
1286 1293   */
1287 1294  #ifdef  _KERNEL
1288 1295  
1289 1296  vnode_t *vn_alloc(int);
1290 1297  void    vn_reinit(vnode_t *);
1291 1298  void    vn_recycle(vnode_t *);
1292 1299  void    vn_free(vnode_t *);
1293 1300  
1294 1301  int     vn_is_readonly(vnode_t *);
1295 1302  int     vn_is_opened(vnode_t *, v_mode_t);
1296 1303  int     vn_is_mapped(vnode_t *, v_mode_t);
1297 1304  int     vn_has_other_opens(vnode_t *, v_mode_t);
1298 1305  void    vn_open_upgrade(vnode_t *, int);
1299 1306  void    vn_open_downgrade(vnode_t *, int);
1300 1307  
1301 1308  int     vn_can_change_zones(vnode_t *vp);
1302 1309  
1303 1310  int     vn_has_flocks(vnode_t *);
1304 1311  int     vn_has_mandatory_locks(vnode_t *, int);
1305 1312  int     vn_has_cached_data(vnode_t *);
1306 1313  
1307 1314  void    vn_setops(vnode_t *, vnodeops_t *);
1308 1315  vnodeops_t *vn_getops(vnode_t *);
1309 1316  int     vn_matchops(vnode_t *, vnodeops_t *);
1310 1317  int     vn_matchopval(vnode_t *, char *, fs_generic_func_p);
1311 1318  int     vn_ismntpt(vnode_t *);
1312 1319  
1313 1320  struct vfs *vn_mountedvfs(vnode_t *);
1314 1321  
1315 1322  int     vn_in_dnlc(vnode_t *);
1316 1323  
1317 1324  void    vn_create_cache(void);
1318 1325  void    vn_destroy_cache(void);
1319 1326  
1320 1327  void    vn_freevnodeops(vnodeops_t *);
1321 1328  
1322 1329  int     vn_open(char *pnamep, enum uio_seg seg, int filemode, int createmode,
1323 1330                  struct vnode **vpp, enum create crwhy, mode_t umask);
1324 1331  int     vn_openat(char *pnamep, enum uio_seg seg, int filemode, int createmode,
1325 1332                  struct vnode **vpp, enum create crwhy,
1326 1333                  mode_t umask, struct vnode *startvp, int fd);
1327 1334  int     vn_create(char *pnamep, enum uio_seg seg, struct vattr *vap,
1328 1335                  enum vcexcl excl, int mode, struct vnode **vpp,
1329 1336                  enum create why, int flag, mode_t umask);
1330 1337  int     vn_createat(char *pnamep, enum uio_seg seg, struct vattr *vap,
1331 1338                  enum vcexcl excl, int mode, struct vnode **vpp,
1332 1339                  enum create why, int flag, mode_t umask, struct vnode *startvp);
1333 1340  int     vn_rdwr(enum uio_rw rw, struct vnode *vp, caddr_t base, ssize_t len,
1334 1341                  offset_t offset, enum uio_seg seg, int ioflag, rlim64_t ulimit,
1335 1342                  cred_t *cr, ssize_t *residp);
1336 1343  void    vn_rele(struct vnode *vp);
1337 1344  void    vn_rele_async(struct vnode *vp, struct taskq *taskq);
1338 1345  void    vn_rele_dnlc(struct vnode *vp);
1339 1346  void    vn_rele_stream(struct vnode *vp);
1340 1347  int     vn_link(char *from, char *to, enum uio_seg seg);
1341 1348  int     vn_linkat(vnode_t *fstartvp, char *from, enum symfollow follow,
1342 1349                  vnode_t *tstartvp, char *to, enum uio_seg seg);
1343 1350  int     vn_rename(char *from, char *to, enum uio_seg seg);
1344 1351  int     vn_renameat(vnode_t *fdvp, char *fname, vnode_t *tdvp, char *tname,
1345 1352                  enum uio_seg seg);
1346 1353  int     vn_remove(char *fnamep, enum uio_seg seg, enum rm dirflag);
1347 1354  int     vn_removeat(vnode_t *startvp, char *fnamep, enum uio_seg seg,
1348 1355                  enum rm dirflag);
1349 1356  int     vn_compare(vnode_t *vp1, vnode_t *vp2);
1350 1357  int     vn_vfswlock(struct vnode *vp);
1351 1358  int     vn_vfswlock_wait(struct vnode *vp);
1352 1359  int     vn_vfsrlock(struct vnode *vp);
1353 1360  int     vn_vfsrlock_wait(struct vnode *vp);
1354 1361  void    vn_vfsunlock(struct vnode *vp);
1355 1362  int     vn_vfswlock_held(struct vnode *vp);
1356 1363  vnode_t *specvp(struct vnode *vp, dev_t dev, vtype_t type, struct cred *cr);
1357 1364  vnode_t *makespecvp(dev_t dev, vtype_t type);
1358 1365  vn_vfslocks_entry_t *vn_vfslocks_getlock(void *);
1359 1366  void    vn_vfslocks_rele(vn_vfslocks_entry_t *);
1360 1367  boolean_t vn_is_reparse(vnode_t *, cred_t *, caller_context_t *);
1361 1368  
1362 1369  void vn_copypath(struct vnode *src, struct vnode *dst);
1363 1370  void vn_setpath_str(struct vnode *vp, const char *str, size_t len);
1364 1371  void vn_setpath(vnode_t *rootvp, struct vnode *startvp, struct vnode *vp,
1365 1372      const char *path, size_t plen);
1366 1373  void vn_renamepath(vnode_t *dvp, vnode_t *vp, const char *nm, size_t len);
1367 1374  
1368 1375  /* Private vnode manipulation functions */
1369 1376  void vn_clearpath(vnode_t *, hrtime_t);
1370 1377  void vn_updatepath(vnode_t *, vnode_t *, const char *);
1371 1378  
1372 1379  
1373 1380  /* Vnode event notification */
1374 1381  void    vnevent_rename_src(vnode_t *, vnode_t *, char *, caller_context_t *);
1375 1382  void    vnevent_rename_dest(vnode_t *, vnode_t *, char *, caller_context_t *);
1376 1383  void    vnevent_remove(vnode_t *, vnode_t *, char *, caller_context_t *);
1377 1384  void    vnevent_rmdir(vnode_t *, vnode_t *, char *, caller_context_t *);
1378 1385  void    vnevent_create(vnode_t *, caller_context_t *);
1379 1386  void    vnevent_link(vnode_t *, caller_context_t *);
1380 1387  void    vnevent_rename_dest_dir(vnode_t *, caller_context_t *ct);
1381 1388  void    vnevent_mountedover(vnode_t *, caller_context_t *);
1382 1389  void    vnevent_truncate(vnode_t *, caller_context_t *);
1383 1390  int     vnevent_support(vnode_t *, caller_context_t *);
1384 1391  void    vnevent_pre_rename_src(vnode_t *, vnode_t *, char *,
1385 1392              caller_context_t *);
1386 1393  void    vnevent_pre_rename_dest(vnode_t *, vnode_t *, char *,
1387 1394              caller_context_t *);
1388 1395  void    vnevent_pre_rename_dest_dir(vnode_t *, vnode_t *, char *,
1389 1396              caller_context_t *);
1390 1397  
1391 1398  /* Vnode specific data */
1392 1399  void vsd_create(uint_t *, void (*)(void *));
1393 1400  void vsd_destroy(uint_t *);
1394 1401  void *vsd_get(vnode_t *, uint_t);
1395 1402  int vsd_set(vnode_t *, uint_t, void *);
1396 1403  void vsd_free(vnode_t *);
1397 1404  
1398 1405  /*
1399 1406   * Extensible vnode attribute (xva) routines:
1400 1407   * xva_init() initializes an xvattr_t (zero struct, init mapsize, set AT_XATTR)
1401 1408   * xva_getxoptattr() returns a ponter to the xoptattr_t section of xvattr_t
1402 1409   */
1403 1410  void            xva_init(xvattr_t *);
1404 1411  xoptattr_t      *xva_getxoptattr(xvattr_t *);   /* Get ptr to xoptattr_t */
1405 1412  
1406 1413  void xattr_init(void);          /* Initialize vnodeops for xattrs */
1407 1414  
1408 1415  /* GFS tunnel for xattrs */
1409 1416  int xattr_dir_lookup(vnode_t *, vnode_t **, int, cred_t *);
1410 1417  
1411 1418  /* Reparse Point */
1412 1419  void reparse_point_init(void);
1413 1420  
1414 1421  /* Context identification */
1415 1422  u_longlong_t    fs_new_caller_id();
1416 1423  
1417 1424  int     vn_vmpss_usepageio(vnode_t *);
1418 1425  
1419 1426  /* Empty v_path placeholder */
1420 1427  extern char *vn_vpath_empty;
1421 1428  
1422 1429  /*
1423 1430   * Needed for use of IS_VMODSORT() in kernel.
1424 1431   */
1425 1432  extern uint_t pvn_vmodsort_supported;
1426 1433  
1427 1434  /*
1428 1435   * All changes to v_count should be done through VN_HOLD() or VN_RELE(), or
1429 1436   * one of their variants. This makes it possible to ensure proper locking,
1430 1437   * and to guarantee that all modifications are accompanied by a firing of
1431 1438   * the vn-hold or vn-rele SDT DTrace probe.
1432 1439   *
1433 1440   * Example DTrace command for tracing vnode references using these probes:
1434 1441   *
1435 1442   * dtrace -q -n 'sdt:::vn-hold,sdt:::vn-rele
1436 1443   * {
1437 1444   *      this->vp = (vnode_t *)arg0;
1438 1445   *      printf("%s %s(%p[%s]) %d\n", execname, probename, this->vp,
1439 1446   *          this->vp->v_path == NULL ? "NULL" : stringof(this->vp->v_path),
1440 1447   *          this->vp->v_count)
1441 1448   * }'
1442 1449   */
1443 1450  #define VN_HOLD_LOCKED(vp) {                    \
1444 1451          ASSERT(mutex_owned(&(vp)->v_lock));     \
1445 1452          (vp)->v_count++;                        \
1446 1453          DTRACE_PROBE1(vn__hold, vnode_t *, vp); \
1447 1454  }
1448 1455  
1449 1456  #define VN_HOLD(vp)     {               \
1450 1457          mutex_enter(&(vp)->v_lock);     \
1451 1458          VN_HOLD_LOCKED(vp);             \
1452 1459          mutex_exit(&(vp)->v_lock);      \
1453 1460  }
1454 1461  
1455 1462  #define VN_RELE(vp)     { \
1456 1463          vn_rele(vp); \
1457 1464  }
1458 1465  
1459 1466  #define VN_RELE_ASYNC(vp, taskq)        { \
1460 1467          vn_rele_async(vp, taskq); \
1461 1468  }
1462 1469  
1463 1470  #define VN_RELE_LOCKED(vp) {                    \
1464 1471          ASSERT(mutex_owned(&(vp)->v_lock));     \
1465 1472          ASSERT((vp)->v_count >= 1);             \
1466 1473          (vp)->v_count--;                        \
1467 1474          DTRACE_PROBE1(vn__rele, vnode_t *, vp); \
1468 1475  }
1469 1476  
1470 1477  #define VN_SET_VFS_TYPE_DEV(vp, vfsp, type, dev)        { \
1471 1478          (vp)->v_vfsp = (vfsp); \
1472 1479          (vp)->v_type = (type); \
1473 1480          (vp)->v_rdev = (dev); \
1474 1481  }
1475 1482  
1476 1483  /*
1477 1484   * Compare two vnodes for equality.  In general this macro should be used
1478 1485   * in preference to calling VOP_CMP directly.
1479 1486   */
1480 1487  #define VN_CMP(VP1, VP2)        ((VP1) == (VP2) ? 1 :   \
1481 1488          ((VP1) && (VP2) && (vn_getops(VP1) == vn_getops(VP2)) ? \
1482 1489          VOP_CMP(VP1, VP2, NULL) : 0))
1483 1490  
1484 1491  /*
1485 1492   * Some well-known global vnodes used by the VM system to name pages.
1486 1493   */
1487 1494  extern struct vnode kvps[];
1488 1495  
1489 1496  typedef enum {
1490 1497          KV_KVP,         /* vnode for all segkmem pages */
1491 1498          KV_ZVP,         /* vnode for all ZFS pages */
1492 1499  #if defined(__sparc)
1493 1500          KV_MPVP,        /* vnode for all page_t meta-pages */
1494 1501          KV_PROMVP,      /* vnode for all PROM pages */
1495 1502  #endif  /* __sparc */
1496 1503          KV_MAX          /* total number of vnodes in kvps[] */
1497 1504  } kvps_index_t;
1498 1505  
1499 1506  #define VN_ISKAS(vp)    ((vp) >= &kvps[0] && (vp) < &kvps[KV_MAX])
1500 1507  
1501 1508  #endif  /* _KERNEL */
1502 1509  
1503 1510  /*
1504 1511   * Flags to VOP_SETATTR/VOP_GETATTR.
1505 1512   */
1506 1513  #define ATTR_UTIME      0x01    /* non-default utime(2) request */
1507 1514  #define ATTR_EXEC       0x02    /* invocation from exec(2) */
1508 1515  #define ATTR_COMM       0x04    /* yield common vp attributes */
1509 1516  #define ATTR_HINT       0x08    /* information returned will be `hint' */
1510 1517  #define ATTR_REAL       0x10    /* yield attributes of the real vp */
1511 1518  #define ATTR_NOACLCHECK 0x20    /* Don't check ACL when checking permissions */
1512 1519  #define ATTR_TRIGGER    0x40    /* Mount first if vnode is a trigger mount */
1513 1520  /*
1514 1521   * Generally useful macros.
1515 1522   */
1516 1523  #define VBSIZE(vp)      ((vp)->v_vfsp->vfs_bsize)
1517 1524  
1518 1525  #define VTOZONE(vp)     ((vp)->v_vfsp->vfs_zone)
1519 1526  
1520 1527  #define NULLVP          ((struct vnode *)0)
1521 1528  #define NULLVPP         ((struct vnode **)0)
1522 1529  
1523 1530  #ifdef  _KERNEL
1524 1531  
1525 1532  /*
1526 1533   * Structure used while handling asynchronous VOP_PUTPAGE operations.
1527 1534   */
1528 1535  struct async_reqs {
1529 1536          struct async_reqs *a_next;      /* pointer to next arg struct */
1530 1537          struct vnode *a_vp;             /* vnode pointer */
1531 1538          u_offset_t a_off;                       /* offset in file */
1532 1539          uint_t a_len;                   /* size of i/o request */
1533 1540          int a_flags;                    /* flags to indicate operation type */
1534 1541          struct cred *a_cred;            /* cred pointer */
1535 1542          ushort_t a_prealloced;          /* set if struct is pre-allocated */
1536 1543  };
1537 1544  
1538 1545  /*
1539 1546   * VN_DISPOSE() -- given a page pointer, safely invoke VOP_DISPOSE().
1540 1547   * Note that there is no guarantee that the page passed in will be
1541 1548   * freed.  If that is required, then a check after calling VN_DISPOSE would
1542 1549   * be necessary to ensure the page was freed.
1543 1550   */
1544 1551  #define VN_DISPOSE(pp, flag, dn, cr)    { \
1545 1552          if ((pp)->p_vnode != NULL && !VN_ISKAS((pp)->p_vnode)) \
1546 1553                  VOP_DISPOSE((pp)->p_vnode, (pp), (flag), (dn), (cr), NULL); \
1547 1554          else if ((flag) == B_FREE) \
1548 1555                  page_free((pp), (dn)); \
1549 1556          else \
1550 1557                  page_destroy((pp), (dn)); \
1551 1558          }
1552 1559  
1553 1560  #endif  /* _KERNEL */
1554 1561  
1555 1562  #ifdef  __cplusplus
1556 1563  }
1557 1564  #endif
1558 1565  
1559 1566  #endif  /* _SYS_VNODE_H */
  
    | 
      ↓ open down ↓ | 
    1132 lines elided | 
    
      ↑ open up ↑ | 
  
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX