The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/fs/nfs/nfsproto.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1989, 1993
    3  *      The Regents of the University of California.  All rights reserved.
    4  *
    5  * This code is derived from software contributed to Berkeley by
    6  * Rick Macklem at The University of Guelph.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  * 4. Neither the name of the University nor the names of its contributors
   17  *    may be used to endorse or promote products derived from this software
   18  *    without specific prior written permission.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   30  * SUCH DAMAGE.
   31  *
   32  * $FreeBSD$
   33  */
   34 
   35 #ifndef _NFS_NFSPROTO_H_
   36 #define _NFS_NFSPROTO_H_
   37 
   38 /*
   39  * nfs definitions as per the Version 2, 3 and 4 specs
   40  */
   41 
   42 /*
   43  * Constants as defined in the NFS Version 2, 3 and 4 specs.
   44  * "NFS: Network File System Protocol Specification" RFC1094
   45  * and in the "NFS: Network File System Version 3 Protocol
   46  * Specification"
   47  */
   48 
   49 #define NFS_PORT        2049
   50 #define NFS_PROG        100003
   51 #define NFS_CALLBCKPROG 0x40000000      /* V4 only */
   52 #define NFS_VER2        2
   53 #define NFS_VER3        3
   54 #define NFS_VER4        4
   55 #define NFS_V2MAXDATA   8192
   56 #define NFS_MAXDGRAMDATA 16384
   57 #define NFS_MAXPATHLEN  1024
   58 #define NFS_MAXNAMLEN   255
   59 #define NFS_MAXPKTHDR   404
   60 #define NFS_MAXPACKET   (NFS_SRVMAXIO + 2048)
   61 #define NFS_MINPACKET   20
   62 #define NFS_FABLKSIZE   512     /* Size in bytes of a block wrt fa_blocks */
   63 #define NFSV4_MINORVERSION      0       /* V4 Minor version */
   64 #define NFSV4_CBVERS            1       /* V4 CB Version */
   65 #define NFSV4_SMALLSTR  50              /* Strings small enough for stack */
   66 
   67 /*
   68  * This value isn't a fixed value in the RFCs.
   69  * It is the maximum data size supported by NFSv3 or NFSv4 over TCP for
   70  * the server.  It should be set to the I/O size preferred by ZFS or
   71  * MAXBSIZE, whichever is greater.
   72  * ZFS currently prefers 128K.
   73  * It used to be called NFS_MAXDATA, but has been renamed to clarify that
   74  * it refers to server side only and doesn't conflict with the NFS_MAXDATA
   75  * defined in rpcsvc/nfs_prot.h for userland.
   76  */
   77 #define NFS_SRVMAXIO    (128 * 1024)
   78 
   79 /* Stat numbers for rpc returns (version 2, 3 and 4) */
   80 /*
   81  * These numbers are hard-wired in the RFCs, so they can't be changed.
   82  * The code currently assumes that the ones < 10000 are the same as
   83  * sys/errno.h and that sys/errno.h will never go as high as 10000.
   84  * If the value in sys/errno.h of any entry listed below is changed,
   85  * the NFS code must be modified to do the mapping between them.
   86  * (You can ignore NFSERR_WFLUSH, since it is never actually used.)
   87  */
   88 #define NFSERR_OK               0
   89 #define NFSERR_PERM             1
   90 #define NFSERR_NOENT            2
   91 #define NFSERR_IO               5
   92 #define NFSERR_NXIO             6
   93 #define NFSERR_ACCES            13
   94 #define NFSERR_EXIST            17
   95 #define NFSERR_XDEV             18      /* Version 3, 4 only */
   96 #define NFSERR_NODEV            19
   97 #define NFSERR_NOTDIR           20
   98 #define NFSERR_ISDIR            21
   99 #define NFSERR_INVAL            22      /* Version 3, 4 only */
  100 #define NFSERR_FBIG             27
  101 #define NFSERR_NOSPC            28
  102 #define NFSERR_ROFS             30
  103 #define NFSERR_MLINK            31      /* Version 3, 4 only */
  104 #define NFSERR_NAMETOL          63
  105 #define NFSERR_NOTEMPTY         66
  106 #define NFSERR_DQUOT            69
  107 #define NFSERR_STALE            70
  108 #define NFSERR_REMOTE           71      /* Version 3 only */
  109 #define NFSERR_WFLUSH           99      /* Version 2 only */
  110 #define NFSERR_BADHANDLE        10001   /* These are Version 3, 4 only */
  111 #define NFSERR_NOT_SYNC         10002   /* Version 3 Only */
  112 #define NFSERR_BAD_COOKIE       10003
  113 #define NFSERR_NOTSUPP          10004
  114 #define NFSERR_TOOSMALL         10005
  115 #define NFSERR_SERVERFAULT      10006
  116 #define NFSERR_BADTYPE          10007
  117 #define NFSERR_DELAY            10008   /* Called NFSERR_JUKEBOX for V3 */
  118 #define NFSERR_SAME             10009   /* These are Version 4 only */
  119 #define NFSERR_DENIED           10010
  120 #define NFSERR_EXPIRED          10011
  121 #define NFSERR_LOCKED           10012
  122 #define NFSERR_GRACE            10013
  123 #define NFSERR_FHEXPIRED        10014
  124 #define NFSERR_SHAREDENIED      10015
  125 #define NFSERR_WRONGSEC         10016
  126 #define NFSERR_CLIDINUSE        10017
  127 #define NFSERR_RESOURCE         10018
  128 #define NFSERR_MOVED            10019
  129 #define NFSERR_NOFILEHANDLE     10020
  130 #define NFSERR_MINORVERMISMATCH 10021
  131 #define NFSERR_STALECLIENTID    10022
  132 #define NFSERR_STALESTATEID     10023
  133 #define NFSERR_OLDSTATEID       10024
  134 #define NFSERR_BADSTATEID       10025
  135 #define NFSERR_BADSEQID         10026
  136 #define NFSERR_NOTSAME          10027
  137 #define NFSERR_LOCKRANGE        10028
  138 #define NFSERR_SYMLINK          10029
  139 #define NFSERR_RESTOREFH        10030
  140 #define NFSERR_LEASEMOVED       10031
  141 #define NFSERR_ATTRNOTSUPP      10032
  142 #define NFSERR_NOGRACE          10033
  143 #define NFSERR_RECLAIMBAD       10034
  144 #define NFSERR_RECLAIMCONFLICT  10035
  145 #define NFSERR_BADXDR           10036
  146 #define NFSERR_LOCKSHELD        10037
  147 #define NFSERR_OPENMODE         10038
  148 #define NFSERR_BADOWNER         10039
  149 #define NFSERR_BADCHAR          10040
  150 #define NFSERR_BADNAME          10041
  151 #define NFSERR_BADRANGE         10042
  152 #define NFSERR_LOCKNOTSUPP      10043
  153 #define NFSERR_OPILLEGAL        10044
  154 #define NFSERR_DEADLOCK         10045
  155 #define NFSERR_FILEOPEN         10046
  156 #define NFSERR_ADMINREVOKED     10047
  157 #define NFSERR_CBPATHDOWN       10048
  158 
  159 #define NFSERR_STALEWRITEVERF   30001   /* Fake return for nfs_commit() */
  160 #define NFSERR_DONTREPLY        30003   /* Don't process request */
  161 #define NFSERR_RETVOID          30004   /* Return void, not error */
  162 #define NFSERR_REPLYFROMCACHE   30005   /* Reply from recent request cache */
  163 #define NFSERR_STALEDONTRECOVER 30006   /* Don't initiate recovery */
  164 
  165 #define NFSERR_RPCERR           0x40000000 /* Mark an RPC layer error */
  166 #define NFSERR_AUTHERR          0x80000000 /* Mark an authentication error */
  167 
  168 #define NFSERR_RPCMISMATCH      (NFSERR_RPCERR | RPC_MISMATCH)
  169 #define NFSERR_PROGUNAVAIL      (NFSERR_RPCERR | RPC_PROGUNAVAIL)
  170 #define NFSERR_PROGMISMATCH     (NFSERR_RPCERR | RPC_PROGMISMATCH)
  171 #define NFSERR_PROGNOTV4        (NFSERR_RPCERR | 0xffff)
  172 #define NFSERR_PROCUNAVAIL      (NFSERR_RPCERR | RPC_PROCUNAVAIL)
  173 #define NFSERR_GARBAGE          (NFSERR_RPCERR | RPC_GARBAGE)
  174 
  175 /* Sizes in bytes of various nfs rpc components */
  176 #define NFSX_UNSIGNED   4
  177 #define NFSX_HYPER      (2 * NFSX_UNSIGNED)
  178 
  179 /* specific to NFS Version 2 */
  180 #define NFSX_V2FH       32
  181 #define NFSX_V2FATTR    68
  182 #define NFSX_V2SATTR    32
  183 #define NFSX_V2COOKIE   4
  184 #define NFSX_V2STATFS   20
  185 
  186 /* specific to NFS Version 3 */
  187 #define NFSX_V3FHMAX            64      /* max. allowed by protocol */
  188 #define NFSX_V3FATTR            84
  189 #define NFSX_V3SATTR            60      /* max. all fields filled in */
  190 #define NFSX_V3SRVSATTR         (sizeof (struct nfsv3_sattr))
  191 #define NFSX_V3POSTOPATTR       (NFSX_V3FATTR + NFSX_UNSIGNED)
  192 #define NFSX_V3WCCDATA          (NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED)
  193 #define NFSX_V3STATFS           52
  194 #define NFSX_V3FSINFO           48
  195 #define NFSX_V3PATHCONF         24
  196 
  197 /* specific to NFS Version 4 */
  198 #define NFSX_V4FHMAX            128
  199 #define NFSX_V4FSID             (2 * NFSX_HYPER)
  200 #define NFSX_V4SPECDATA         (2 * NFSX_UNSIGNED)
  201 #define NFSX_V4TIME             (NFSX_HYPER + NFSX_UNSIGNED)
  202 #define NFSX_V4SETTIME          (NFSX_UNSIGNED + NFSX_V4TIME)
  203 
  204 /* sizes common to multiple NFS versions */
  205 #define NFSX_FHMAX              (NFSX_V4FHMAX)
  206 #define NFSX_MYFH               (sizeof (fhandle_t)) /* size this server uses */
  207 #define NFSX_VERF               8
  208 #define NFSX_STATEIDOTHER       12
  209 #define NFSX_STATEID            (NFSX_UNSIGNED + NFSX_STATEIDOTHER)
  210 #define NFSX_GSSH               12
  211 
  212 /* variants for multiple versions */
  213 #define NFSX_STATFS(v3)         ((v3) ? NFSX_V3STATFS : NFSX_V2STATFS)
  214 
  215 /* nfs rpc procedure numbers (before version mapping) */
  216 #define NFSPROC_NULL            0
  217 #define NFSPROC_GETATTR         1
  218 #define NFSPROC_SETATTR         2
  219 #define NFSPROC_LOOKUP          3
  220 #define NFSPROC_ACCESS          4
  221 #define NFSPROC_READLINK        5
  222 #define NFSPROC_READ            6
  223 #define NFSPROC_WRITE           7
  224 #define NFSPROC_CREATE          8
  225 #define NFSPROC_MKDIR           9
  226 #define NFSPROC_SYMLINK         10
  227 #define NFSPROC_MKNOD           11
  228 #define NFSPROC_REMOVE          12
  229 #define NFSPROC_RMDIR           13
  230 #define NFSPROC_RENAME          14
  231 #define NFSPROC_LINK            15
  232 #define NFSPROC_READDIR         16
  233 #define NFSPROC_READDIRPLUS     17
  234 #define NFSPROC_FSSTAT          18
  235 #define NFSPROC_FSINFO          19
  236 #define NFSPROC_PATHCONF        20
  237 #define NFSPROC_COMMIT          21
  238 
  239 /*
  240  * The lower numbers -> 21 are used by NFSv2 and v3. These define higher
  241  * numbers used by NFSv4.
  242  * NFS_V3NPROCS is one greater than the last V3 op and NFS_NPROCS is
  243  * one greater than the last number.
  244  */
  245 #ifndef NFS_V3NPROCS
  246 #define NFS_V3NPROCS            22
  247 
  248 #define NFSPROC_LOOKUPP         22
  249 #define NFSPROC_SETCLIENTID     23
  250 #define NFSPROC_SETCLIENTIDCFRM 24
  251 #define NFSPROC_LOCK            25
  252 #define NFSPROC_LOCKU           26
  253 #define NFSPROC_OPEN            27
  254 #define NFSPROC_CLOSE           28
  255 #define NFSPROC_OPENCONFIRM     29
  256 #define NFSPROC_LOCKT           30
  257 #define NFSPROC_OPENDOWNGRADE   31
  258 #define NFSPROC_RENEW           32
  259 #define NFSPROC_PUTROOTFH       33
  260 #define NFSPROC_RELEASELCKOWN   34
  261 #define NFSPROC_DELEGRETURN     35
  262 #define NFSPROC_RETDELEGREMOVE  36
  263 #define NFSPROC_RETDELEGRENAME1 37
  264 #define NFSPROC_RETDELEGRENAME2 38
  265 #define NFSPROC_GETACL          39
  266 #define NFSPROC_SETACL          40
  267 
  268 /*
  269  * Must be defined as one higher than the last Proc# above.
  270  */
  271 #define NFSV4_NPROCS            41
  272 #endif  /* NFS_V3NPROCS */
  273 
  274 /*
  275  * Define NFS_NPROCS as NFSV4_NPROCS for the experimental kernel code.
  276  */
  277 #ifndef NFS_NPROCS
  278 #define NFS_NPROCS              NFSV4_NPROCS
  279 #endif
  280 
  281 /*
  282  * NFSPROC_NOOP is a fake op# that can't be the same as any V2/3/4 Procedure
  283  * or Operation#. Since the NFS V4 Op #s go higher, use NFSV4OP_NOPS, which
  284  * is one greater than the highest Op#.
  285  */
  286 #define NFSPROC_NOOP            NFSV4OP_NOPS
  287 
  288 /* Actual Version 2 procedure numbers */
  289 #define NFSV2PROC_NULL          0
  290 #define NFSV2PROC_GETATTR       1
  291 #define NFSV2PROC_SETATTR       2
  292 #define NFSV2PROC_NOOP          3
  293 #define NFSV2PROC_ROOT          NFSV2PROC_NOOP  /* Obsolete */
  294 #define NFSV2PROC_LOOKUP        4
  295 #define NFSV2PROC_READLINK      5
  296 #define NFSV2PROC_READ          6
  297 #define NFSV2PROC_WRITECACHE    NFSV2PROC_NOOP  /* Obsolete */
  298 #define NFSV2PROC_WRITE         8
  299 #define NFSV2PROC_CREATE        9
  300 #define NFSV2PROC_REMOVE        10
  301 #define NFSV2PROC_RENAME        11
  302 #define NFSV2PROC_LINK          12
  303 #define NFSV2PROC_SYMLINK       13
  304 #define NFSV2PROC_MKDIR         14
  305 #define NFSV2PROC_RMDIR         15
  306 #define NFSV2PROC_READDIR       16
  307 #define NFSV2PROC_STATFS        17
  308 
  309 /*
  310  * V4 Procedure numbers
  311  */
  312 #define NFSV4PROC_COMPOUND      1
  313 #define NFSV4PROC_CBNULL        0
  314 #define NFSV4PROC_CBCOMPOUND    1
  315 
  316 /*
  317  * Constants used by the Version 3 and 4 protocols for various RPCs
  318  */
  319 #define NFSV3SATTRTIME_DONTCHANGE       0
  320 #define NFSV3SATTRTIME_TOSERVER         1
  321 #define NFSV3SATTRTIME_TOCLIENT         2
  322 
  323 #define NFSV4SATTRTIME_TOSERVER         0
  324 #define NFSV4SATTRTIME_TOCLIENT         1
  325 
  326 #define NFSV4LOCKT_READ                 1
  327 #define NFSV4LOCKT_WRITE                2
  328 #define NFSV4LOCKT_READW                3
  329 #define NFSV4LOCKT_WRITEW               4
  330 #define NFSV4LOCKT_RELEASE              5
  331 
  332 #define NFSV4OPEN_NOCREATE              0
  333 #define NFSV4OPEN_CREATE                1
  334 #define NFSV4OPEN_CLAIMNULL             0
  335 #define NFSV4OPEN_CLAIMPREVIOUS         1
  336 #define NFSV4OPEN_CLAIMDELEGATECUR      2
  337 #define NFSV4OPEN_CLAIMDELEGATEPREV     3
  338 #define NFSV4OPEN_DELEGATENONE          0
  339 #define NFSV4OPEN_DELEGATEREAD          1
  340 #define NFSV4OPEN_DELEGATEWRITE         2
  341 #define NFSV4OPEN_LIMITSIZE             1
  342 #define NFSV4OPEN_LIMITBLOCKS           2
  343 
  344 /*
  345  * Nfs V4 ACE stuff
  346  */
  347 #define NFSV4ACE_ALLOWEDTYPE            0x00000000
  348 #define NFSV4ACE_DENIEDTYPE             0x00000001
  349 #define NFSV4ACE_AUDITTYPE              0x00000002
  350 #define NFSV4ACE_ALARMTYPE              0x00000003
  351 
  352 #define NFSV4ACE_SUPALLOWED             0x00000001
  353 #define NFSV4ACE_SUPDENIED              0x00000002
  354 #define NFSV4ACE_SUPAUDIT               0x00000004
  355 #define NFSV4ACE_SUPALARM               0x00000008
  356 
  357 #define NFSV4ACE_SUPTYPES       (NFSV4ACE_SUPALLOWED | NFSV4ACE_SUPDENIED)
  358 
  359 #define NFSV4ACE_FILEINHERIT            0x00000001
  360 #define NFSV4ACE_DIRECTORYINHERIT       0x00000002
  361 #define NFSV4ACE_NOPROPAGATEINHERIT     0x00000004
  362 #define NFSV4ACE_INHERITONLY            0x00000008
  363 #define NFSV4ACE_SUCCESSFULACCESS       0x00000010
  364 #define NFSV4ACE_FAILEDACCESS           0x00000020
  365 #define NFSV4ACE_IDENTIFIERGROUP        0x00000040
  366 
  367 #define NFSV4ACE_READDATA               0x00000001
  368 #define NFSV4ACE_LISTDIRECTORY          0x00000001
  369 #define NFSV4ACE_WRITEDATA              0x00000002
  370 #define NFSV4ACE_ADDFILE                0x00000002
  371 #define NFSV4ACE_APPENDDATA             0x00000004
  372 #define NFSV4ACE_ADDSUBDIRECTORY        0x00000004
  373 #define NFSV4ACE_READNAMEDATTR          0x00000008
  374 #define NFSV4ACE_WRITENAMEDATTR         0x00000010
  375 #define NFSV4ACE_EXECUTE                0x00000020
  376 #define NFSV4ACE_SEARCH                 0x00000020
  377 #define NFSV4ACE_DELETECHILD            0x00000040
  378 #define NFSV4ACE_READATTRIBUTES         0x00000080
  379 #define NFSV4ACE_WRITEATTRIBUTES        0x00000100
  380 #define NFSV4ACE_DELETE                 0x00010000
  381 #define NFSV4ACE_READACL                0x00020000
  382 #define NFSV4ACE_WRITEACL               0x00040000
  383 #define NFSV4ACE_WRITEOWNER             0x00080000
  384 #define NFSV4ACE_SYNCHRONIZE            0x00100000
  385 
  386 /*
  387  * Here are the mappings between mode bits and acl mask bits for
  388  * directories and other files.
  389  * (Named attributes have not been included, since named attributes are
  390  *  not yet supported.)
  391  * The mailing list seems to indicate that NFSV4ACE_EXECUTE refers to
  392  * searching a directory, although I can't find a statement of that in
  393  * the RFC.
  394  */
  395 #define NFSV4ACE_ALLFILESMASK   (NFSV4ACE_READATTRIBUTES | NFSV4ACE_READACL)
  396 #define NFSV4ACE_OWNERMASK      (NFSV4ACE_WRITEATTRIBUTES | NFSV4ACE_WRITEACL)
  397 #define NFSV4ACE_DIRREADMASK    NFSV4ACE_LISTDIRECTORY
  398 #define NFSV4ACE_DIREXECUTEMASK NFSV4ACE_EXECUTE
  399 #define NFSV4ACE_DIRWRITEMASK   (NFSV4ACE_ADDFILE |                     \
  400                 NFSV4ACE_ADDSUBDIRECTORY | NFSV4ACE_DELETECHILD)
  401 #define NFSV4ACE_READMASK       NFSV4ACE_READDATA
  402 #define NFSV4ACE_WRITEMASK      (NFSV4ACE_WRITEDATA | NFSV4ACE_APPENDDATA)
  403 #define NFSV4ACE_EXECUTEMASK    NFSV4ACE_EXECUTE
  404 #define NFSV4ACE_ALLFILEBITS    (NFSV4ACE_READMASK | NFSV4ACE_WRITEMASK | \
  405         NFSV4ACE_EXECUTEMASK | NFSV4ACE_SYNCHRONIZE)
  406 #define NFSV4ACE_ALLDIRBITS     (NFSV4ACE_DIRREADMASK |                 \
  407         NFSV4ACE_DIRWRITEMASK | NFSV4ACE_DIREXECUTEMASK)
  408 #define NFSV4ACE_AUDITMASK      0x0
  409 
  410 /*
  411  * These GENERIC masks are not used and are no longer believed to be useful.
  412  */
  413 #define NFSV4ACE_GENERICREAD            0x00120081
  414 #define NFSV4ACE_GENERICWRITE           0x00160106
  415 #define NFSV4ACE_GENERICEXECUTE         0x001200a0
  416 
  417 #define NFSSTATEID_PUTALLZERO           0
  418 #define NFSSTATEID_PUTALLONE            1
  419 #define NFSSTATEID_PUTSTATEID           2
  420 
  421 /*
  422  * Bits for share access and deny.
  423  */
  424 #define NFSV4OPEN_ACCESSREAD            0x00000001
  425 #define NFSV4OPEN_ACCESSWRITE           0x00000002
  426 #define NFSV4OPEN_ACCESSBOTH            0x00000003
  427 
  428 #define NFSV4OPEN_DENYNONE              0x00000000
  429 #define NFSV4OPEN_DENYREAD              0x00000001
  430 #define NFSV4OPEN_DENYWRITE             0x00000002
  431 #define NFSV4OPEN_DENYBOTH              0x00000003
  432 
  433 /*
  434  * Open result flags
  435  * (The first two are in the spec. The rest are used internally.)
  436  */
  437 #define NFSV4OPEN_RESULTCONFIRM         0x00000002
  438 #define NFSV4OPEN_LOCKTYPEPOSIX         0x00000004
  439 #define NFSV4OPEN_RFLAGS                                                \
  440                 (NFSV4OPEN_RESULTCONFIRM | NFSV4OPEN_LOCKTYPEPOSIX)
  441 #define NFSV4OPEN_RECALL                0x00010000
  442 #define NFSV4OPEN_READDELEGATE          0x00020000
  443 #define NFSV4OPEN_WRITEDELEGATE         0x00040000
  444 
  445 /*
  446  * NFS V4 File Handle types
  447  */
  448 #define NFSV4FHTYPE_PERSISTENT          0x0
  449 #define NFSV4FHTYPE_NOEXPIREWITHOPEN    0x1
  450 #define NFSV4FHTYPE_VOLATILEANY         0x2
  451 #define NFSV4FHTYPE_VOLATILEMIGRATE     0x4
  452 #define NFSV4FHTYPE_VOLATILERENAME      0x8
  453 
  454 /*
  455  * Maximum size of V4 opaque strings.
  456  */
  457 #define NFSV4_OPAQUELIMIT       1024
  458 
  459 /*
  460  * These are the same for V3 and V4.
  461  */
  462 #define NFSACCESS_READ                  0x01
  463 #define NFSACCESS_LOOKUP                0x02
  464 #define NFSACCESS_MODIFY                0x04
  465 #define NFSACCESS_EXTEND                0x08
  466 #define NFSACCESS_DELETE                0x10
  467 #define NFSACCESS_EXECUTE               0x20
  468 
  469 #define NFSWRITE_UNSTABLE               0
  470 #define NFSWRITE_DATASYNC               1
  471 #define NFSWRITE_FILESYNC               2
  472 
  473 #define NFSCREATE_UNCHECKED             0
  474 #define NFSCREATE_GUARDED               1
  475 #define NFSCREATE_EXCLUSIVE             2
  476 
  477 #define NFSV3FSINFO_LINK                0x01
  478 #define NFSV3FSINFO_SYMLINK             0x02
  479 #define NFSV3FSINFO_HOMOGENEOUS         0x08
  480 #define NFSV3FSINFO_CANSETTIME          0x10
  481 
  482 /* Conversion macros */
  483 #define vtonfsv2_mode(t,m)                                              \
  484                 txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) :   \
  485                                 MAKEIMODE((t), (m)))
  486 #define vtonfsv34_mode(m)       txdr_unsigned((m) & 07777)
  487 #define nfstov_mode(a)          (fxdr_unsigned(u_int16_t, (a))&07777)
  488 #define vtonfsv2_type(a)  (((u_int32_t)(a)) >= 9 ? txdr_unsigned(NFNON) : \
  489                 txdr_unsigned(newnfsv2_type[((u_int32_t)(a))]))
  490 #define vtonfsv34_type(a)  (((u_int32_t)(a)) >= 9 ? txdr_unsigned(NFNON) : \
  491                 txdr_unsigned(nfsv34_type[((u_int32_t)(a))]))
  492 #define nfsv2tov_type(a)        newnv2tov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
  493 #define nfsv34tov_type(a)       nv34tov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
  494 #define vtonfs_dtype(a) (((u_int32_t)(a)) >= 9 ? IFTODT(VTTOIF(VNON)) : \
  495                          IFTODT(VTTOIF(a)))
  496 
  497 /* File types */
  498 typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5,
  499         NFSOCK=6, NFFIFO=7, NFATTRDIR=8, NFNAMEDATTR=9 } nfstype;
  500 
  501 /* Structs for common parts of the rpc's */
  502 
  503 struct nfsv2_time {
  504         u_int32_t nfsv2_sec;
  505         u_int32_t nfsv2_usec;
  506 };
  507 typedef struct nfsv2_time       nfstime2;
  508 
  509 struct nfsv3_time {
  510         u_int32_t nfsv3_sec;
  511         u_int32_t nfsv3_nsec;
  512 };
  513 typedef struct nfsv3_time       nfstime3;
  514 
  515 struct nfsv4_time {
  516         u_int32_t nfsv4_highsec;
  517         u_int32_t nfsv4_sec;
  518         u_int32_t nfsv4_nsec;
  519 };
  520 typedef struct nfsv4_time       nfstime4;
  521 
  522 /*
  523  * Quads are defined as arrays of 2 longs to ensure dense packing for the
  524  * protocol and to facilitate xdr conversion.
  525  */
  526 struct nfs_uquad {
  527         u_int32_t nfsuquad[2];
  528 };
  529 typedef struct nfs_uquad        nfsuint64;
  530 
  531 /*
  532  * Used to convert between two u_longs and a u_quad_t.
  533  */
  534 union nfs_quadconvert {
  535         u_int32_t lval[2];
  536         u_quad_t  qval;
  537 };
  538 typedef union nfs_quadconvert   nfsquad_t;
  539 
  540 /*
  541  * NFS Version 3 special file number.
  542  */
  543 struct nfsv3_spec {
  544         u_int32_t specdata1;
  545         u_int32_t specdata2;
  546 };
  547 typedef struct nfsv3_spec       nfsv3spec;
  548 
  549 /*
  550  * File attributes and setable attributes. These structures cover both
  551  * NFS version 2 and the version 3 protocol. Note that the union is only
  552  * used so that one pointer can refer to both variants. These structures
  553  * go out on the wire and must be densely packed, so no quad data types
  554  * are used. (all fields are longs or u_longs or structures of same)
  555  * NB: You can't do sizeof(struct nfs_fattr), you must use the
  556  *     NFSX_FATTR(v3) macro.
  557  */
  558 struct nfs_fattr {
  559         u_int32_t fa_type;
  560         u_int32_t fa_mode;
  561         u_int32_t fa_nlink;
  562         u_int32_t fa_uid;
  563         u_int32_t fa_gid;
  564         union {
  565                 struct {
  566                         u_int32_t nfsv2fa_size;
  567                         u_int32_t nfsv2fa_blocksize;
  568                         u_int32_t nfsv2fa_rdev;
  569                         u_int32_t nfsv2fa_blocks;
  570                         u_int32_t nfsv2fa_fsid;
  571                         u_int32_t nfsv2fa_fileid;
  572                         nfstime2  nfsv2fa_atime;
  573                         nfstime2  nfsv2fa_mtime;
  574                         nfstime2  nfsv2fa_ctime;
  575                 } fa_nfsv2;
  576                 struct {
  577                         nfsuint64 nfsv3fa_size;
  578                         nfsuint64 nfsv3fa_used;
  579                         nfsv3spec nfsv3fa_rdev;
  580                         nfsuint64 nfsv3fa_fsid;
  581                         nfsuint64 nfsv3fa_fileid;
  582                         nfstime3  nfsv3fa_atime;
  583                         nfstime3  nfsv3fa_mtime;
  584                         nfstime3  nfsv3fa_ctime;
  585                 } fa_nfsv3;
  586         } fa_un;
  587 };
  588 
  589 /* and some ugly defines for accessing union components */
  590 #define fa2_size                fa_un.fa_nfsv2.nfsv2fa_size
  591 #define fa2_blocksize           fa_un.fa_nfsv2.nfsv2fa_blocksize
  592 #define fa2_rdev                fa_un.fa_nfsv2.nfsv2fa_rdev
  593 #define fa2_blocks              fa_un.fa_nfsv2.nfsv2fa_blocks
  594 #define fa2_fsid                fa_un.fa_nfsv2.nfsv2fa_fsid
  595 #define fa2_fileid              fa_un.fa_nfsv2.nfsv2fa_fileid
  596 #define fa2_atime               fa_un.fa_nfsv2.nfsv2fa_atime
  597 #define fa2_mtime               fa_un.fa_nfsv2.nfsv2fa_mtime
  598 #define fa2_ctime               fa_un.fa_nfsv2.nfsv2fa_ctime
  599 #define fa3_size                fa_un.fa_nfsv3.nfsv3fa_size
  600 #define fa3_used                fa_un.fa_nfsv3.nfsv3fa_used
  601 #define fa3_rdev                fa_un.fa_nfsv3.nfsv3fa_rdev
  602 #define fa3_fsid                fa_un.fa_nfsv3.nfsv3fa_fsid
  603 #define fa3_fileid              fa_un.fa_nfsv3.nfsv3fa_fileid
  604 #define fa3_atime               fa_un.fa_nfsv3.nfsv3fa_atime
  605 #define fa3_mtime               fa_un.fa_nfsv3.nfsv3fa_mtime
  606 #define fa3_ctime               fa_un.fa_nfsv3.nfsv3fa_ctime
  607 
  608 struct nfsv2_sattr {
  609         u_int32_t sa_mode;
  610         u_int32_t sa_uid;
  611         u_int32_t sa_gid;
  612         u_int32_t sa_size;
  613         nfstime2  sa_atime;
  614         nfstime2  sa_mtime;
  615 };
  616 
  617 /*
  618  * NFS Version 3 sattr structure for the new node creation case.
  619  */
  620 struct nfsv3_sattr {
  621         u_int32_t sa_modetrue;
  622         u_int32_t sa_mode;
  623         u_int32_t sa_uidfalse;
  624         u_int32_t sa_gidfalse;
  625         u_int32_t sa_sizefalse;
  626         u_int32_t sa_atimetype;
  627         nfstime3  sa_atime;
  628         u_int32_t sa_mtimetype;
  629         nfstime3  sa_mtime;
  630 };
  631 
  632 /*
  633  * The attribute bits used for V4.
  634  * NFSATTRBIT_xxx defines the attribute# (and its bit position)
  635  * NFSATTRBM_xxx is a 32bit mask with the correct bit set within the
  636  *      appropriate 32bit word.
  637  * NFSATTRBIT_MAX is one greater than the largest NFSATTRBIT_xxx
  638  */
  639 #define NFSATTRBIT_SUPPORTEDATTRS       0
  640 #define NFSATTRBIT_TYPE                 1
  641 #define NFSATTRBIT_FHEXPIRETYPE         2
  642 #define NFSATTRBIT_CHANGE               3
  643 #define NFSATTRBIT_SIZE                 4
  644 #define NFSATTRBIT_LINKSUPPORT          5
  645 #define NFSATTRBIT_SYMLINKSUPPORT       6
  646 #define NFSATTRBIT_NAMEDATTR            7
  647 #define NFSATTRBIT_FSID                 8
  648 #define NFSATTRBIT_UNIQUEHANDLES        9
  649 #define NFSATTRBIT_LEASETIME            10
  650 #define NFSATTRBIT_RDATTRERROR          11
  651 #define NFSATTRBIT_ACL                  12
  652 #define NFSATTRBIT_ACLSUPPORT           13
  653 #define NFSATTRBIT_ARCHIVE              14
  654 #define NFSATTRBIT_CANSETTIME           15
  655 #define NFSATTRBIT_CASEINSENSITIVE      16
  656 #define NFSATTRBIT_CASEPRESERVING       17
  657 #define NFSATTRBIT_CHOWNRESTRICTED      18
  658 #define NFSATTRBIT_FILEHANDLE           19
  659 #define NFSATTRBIT_FILEID               20
  660 #define NFSATTRBIT_FILESAVAIL           21
  661 #define NFSATTRBIT_FILESFREE            22
  662 #define NFSATTRBIT_FILESTOTAL           23
  663 #define NFSATTRBIT_FSLOCATIONS          24
  664 #define NFSATTRBIT_HIDDEN               25
  665 #define NFSATTRBIT_HOMOGENEOUS          26
  666 #define NFSATTRBIT_MAXFILESIZE          27
  667 #define NFSATTRBIT_MAXLINK              28
  668 #define NFSATTRBIT_MAXNAME              29
  669 #define NFSATTRBIT_MAXREAD              30
  670 #define NFSATTRBIT_MAXWRITE             31
  671 #define NFSATTRBIT_MIMETYPE             32
  672 #define NFSATTRBIT_MODE                 33
  673 #define NFSATTRBIT_NOTRUNC              34
  674 #define NFSATTRBIT_NUMLINKS             35
  675 #define NFSATTRBIT_OWNER                36
  676 #define NFSATTRBIT_OWNERGROUP           37
  677 #define NFSATTRBIT_QUOTAHARD            38
  678 #define NFSATTRBIT_QUOTASOFT            39
  679 #define NFSATTRBIT_QUOTAUSED            40
  680 #define NFSATTRBIT_RAWDEV               41
  681 #define NFSATTRBIT_SPACEAVAIL           42
  682 #define NFSATTRBIT_SPACEFREE            43
  683 #define NFSATTRBIT_SPACETOTAL           44
  684 #define NFSATTRBIT_SPACEUSED            45
  685 #define NFSATTRBIT_SYSTEM               46
  686 #define NFSATTRBIT_TIMEACCESS           47
  687 #define NFSATTRBIT_TIMEACCESSSET        48
  688 #define NFSATTRBIT_TIMEBACKUP           49
  689 #define NFSATTRBIT_TIMECREATE           50
  690 #define NFSATTRBIT_TIMEDELTA            51
  691 #define NFSATTRBIT_TIMEMETADATA         52
  692 #define NFSATTRBIT_TIMEMODIFY           53
  693 #define NFSATTRBIT_TIMEMODIFYSET        54
  694 #define NFSATTRBIT_MOUNTEDONFILEID      55
  695 
  696 #define NFSATTRBM_SUPPORTEDATTRS        0x00000001
  697 #define NFSATTRBM_TYPE                  0x00000002
  698 #define NFSATTRBM_FHEXPIRETYPE          0x00000004
  699 #define NFSATTRBM_CHANGE                0x00000008
  700 #define NFSATTRBM_SIZE                  0x00000010
  701 #define NFSATTRBM_LINKSUPPORT           0x00000020
  702 #define NFSATTRBM_SYMLINKSUPPORT        0x00000040
  703 #define NFSATTRBM_NAMEDATTR             0x00000080
  704 #define NFSATTRBM_FSID                  0x00000100
  705 #define NFSATTRBM_UNIQUEHANDLES         0x00000200
  706 #define NFSATTRBM_LEASETIME             0x00000400
  707 #define NFSATTRBM_RDATTRERROR           0x00000800
  708 #define NFSATTRBM_ACL                   0x00001000
  709 #define NFSATTRBM_ACLSUPPORT            0x00002000
  710 #define NFSATTRBM_ARCHIVE               0x00004000
  711 #define NFSATTRBM_CANSETTIME            0x00008000
  712 #define NFSATTRBM_CASEINSENSITIVE       0x00010000
  713 #define NFSATTRBM_CASEPRESERVING        0x00020000
  714 #define NFSATTRBM_CHOWNRESTRICTED       0x00040000
  715 #define NFSATTRBM_FILEHANDLE            0x00080000
  716 #define NFSATTRBM_FILEID                0x00100000
  717 #define NFSATTRBM_FILESAVAIL            0x00200000
  718 #define NFSATTRBM_FILESFREE             0x00400000
  719 #define NFSATTRBM_FILESTOTAL            0x00800000
  720 #define NFSATTRBM_FSLOCATIONS           0x01000000
  721 #define NFSATTRBM_HIDDEN                0x02000000
  722 #define NFSATTRBM_HOMOGENEOUS           0x04000000
  723 #define NFSATTRBM_MAXFILESIZE           0x08000000
  724 #define NFSATTRBM_MAXLINK               0x10000000
  725 #define NFSATTRBM_MAXNAME               0x20000000
  726 #define NFSATTRBM_MAXREAD               0x40000000
  727 #define NFSATTRBM_MAXWRITE              0x80000000
  728 #define NFSATTRBM_MIMETYPE              0x00000001
  729 #define NFSATTRBM_MODE                  0x00000002
  730 #define NFSATTRBM_NOTRUNC               0x00000004
  731 #define NFSATTRBM_NUMLINKS              0x00000008
  732 #define NFSATTRBM_OWNER                 0x00000010
  733 #define NFSATTRBM_OWNERGROUP            0x00000020
  734 #define NFSATTRBM_QUOTAHARD             0x00000040
  735 #define NFSATTRBM_QUOTASOFT             0x00000080
  736 #define NFSATTRBM_QUOTAUSED             0x00000100
  737 #define NFSATTRBM_RAWDEV                0x00000200
  738 #define NFSATTRBM_SPACEAVAIL            0x00000400
  739 #define NFSATTRBM_SPACEFREE             0x00000800
  740 #define NFSATTRBM_SPACETOTAL            0x00001000
  741 #define NFSATTRBM_SPACEUSED             0x00002000
  742 #define NFSATTRBM_SYSTEM                0x00004000
  743 #define NFSATTRBM_TIMEACCESS            0x00008000
  744 #define NFSATTRBM_TIMEACCESSSET         0x00010000
  745 #define NFSATTRBM_TIMEBACKUP            0x00020000
  746 #define NFSATTRBM_TIMECREATE            0x00040000
  747 #define NFSATTRBM_TIMEDELTA             0x00080000
  748 #define NFSATTRBM_TIMEMETADATA          0x00100000
  749 #define NFSATTRBM_TIMEMODIFY            0x00200000
  750 #define NFSATTRBM_TIMEMODIFYSET         0x00400000
  751 #define NFSATTRBM_MOUNTEDONFILEID       0x00800000
  752 
  753 #define NFSATTRBIT_MAX                  56
  754 
  755 /*
  756  * Sets of attributes that are supported, by words in the bitmap.
  757  */
  758 /*
  759  * NFSATTRBIT_SUPPORTED - SUPP0 - bits 0<->31
  760  *                        SUPP1 - bits 32<->63
  761  */
  762 #define NFSATTRBIT_SUPP0                                                \
  763         (NFSATTRBM_SUPPORTEDATTRS |                                     \
  764         NFSATTRBM_TYPE |                                                \
  765         NFSATTRBM_FHEXPIRETYPE |                                        \
  766         NFSATTRBM_CHANGE |                                              \
  767         NFSATTRBM_SIZE |                                                \
  768         NFSATTRBM_LINKSUPPORT |                                         \
  769         NFSATTRBM_SYMLINKSUPPORT |                                      \
  770         NFSATTRBM_NAMEDATTR |                                           \
  771         NFSATTRBM_FSID |                                                \
  772         NFSATTRBM_UNIQUEHANDLES |                                       \
  773         NFSATTRBM_LEASETIME |                                           \
  774         NFSATTRBM_RDATTRERROR |                                         \
  775         NFSATTRBM_ACL |                                                 \
  776         NFSATTRBM_ACLSUPPORT |                                          \
  777         NFSATTRBM_CANSETTIME |                                          \
  778         NFSATTRBM_CASEINSENSITIVE |                                     \
  779         NFSATTRBM_CASEPRESERVING |                                      \
  780         NFSATTRBM_CHOWNRESTRICTED |                                     \
  781         NFSATTRBM_FILEHANDLE |                                          \
  782         NFSATTRBM_FILEID |                                              \
  783         NFSATTRBM_FILESAVAIL |                                          \
  784         NFSATTRBM_FILESFREE |                                           \
  785         NFSATTRBM_FILESTOTAL |                                          \
  786         NFSATTRBM_FSLOCATIONS |                                         \
  787         NFSATTRBM_HOMOGENEOUS |                                         \
  788         NFSATTRBM_MAXFILESIZE |                                         \
  789         NFSATTRBM_MAXLINK |                                             \
  790         NFSATTRBM_MAXNAME |                                             \
  791         NFSATTRBM_MAXREAD |                                             \
  792         NFSATTRBM_MAXWRITE)
  793 
  794 /*
  795  * NFSATTRBIT_S1 - subset of SUPP1 - OR of the following bits:
  796  */
  797 #define NFSATTRBIT_S1                                                   \
  798         (NFSATTRBM_MODE |                                               \
  799         NFSATTRBM_NOTRUNC |                                             \
  800         NFSATTRBM_NUMLINKS |                                            \
  801         NFSATTRBM_OWNER |                                               \
  802         NFSATTRBM_OWNERGROUP |                                          \
  803         NFSATTRBM_RAWDEV |                                              \
  804         NFSATTRBM_SPACEAVAIL |                                          \
  805         NFSATTRBM_SPACEFREE |                                           \
  806         NFSATTRBM_SPACETOTAL |                                          \
  807         NFSATTRBM_SPACEUSED |                                           \
  808         NFSATTRBM_TIMEACCESS |                                          \
  809         NFSATTRBM_TIMEDELTA |                                           \
  810         NFSATTRBM_TIMEMETADATA |                                        \
  811         NFSATTRBM_TIMEMODIFY |                                          \
  812         NFSATTRBM_MOUNTEDONFILEID)
  813 
  814 #ifdef QUOTA
  815 /*
  816  * If QUOTA OR in NFSATTRBIT_QUOTAHARD, NFSATTRBIT_QUOTASOFT and
  817  * NFSATTRBIT_QUOTAUSED.
  818  */
  819 #define NFSATTRBIT_SUPP1        (NFSATTRBIT_S1 |                        \
  820                                 NFSATTRBM_QUOTAHARD |                   \
  821                                 NFSATTRBM_QUOTASOFT |                   \
  822                                 NFSATTRBM_QUOTAUSED)
  823 #else
  824 #define NFSATTRBIT_SUPP1        NFSATTRBIT_S1
  825 #endif
  826 
  827 /*
  828  * NFSATTRBIT_SUPPSETONLY is the OR of NFSATTRBIT_TIMEACCESSSET and
  829  * NFSATTRBIT_TIMEMODIFYSET.
  830  */
  831 #define NFSATTRBIT_SUPPSETONLY   (NFSATTRBM_TIMEACCESSSET |             \
  832                                  NFSATTRBM_TIMEMODIFYSET)
  833 
  834 /*
  835  * NFSATTRBIT_SETABLE - SETABLE0 - bits 0<->31
  836  *                      SETABLE1 - bits 32<->63
  837  */
  838 #define NFSATTRBIT_SETABLE0                                             \
  839         (NFSATTRBM_SIZE |                                               \
  840         NFSATTRBM_ACL)
  841 #define NFSATTRBIT_SETABLE1                                             \
  842         (NFSATTRBM_MODE |                                               \
  843         NFSATTRBM_OWNER |                                               \
  844         NFSATTRBM_OWNERGROUP |                                          \
  845         NFSATTRBM_TIMEACCESSSET |                                       \
  846         NFSATTRBM_TIMEMODIFYSET)
  847 
  848 /*
  849  * Set of attributes that the getattr vnode op needs.
  850  * OR of the following bits.
  851  * NFSATTRBIT_GETATTR0 - bits 0<->31
  852  */
  853 #define NFSATTRBIT_GETATTR0                                             \
  854         (NFSATTRBM_SUPPORTEDATTRS |                                     \
  855         NFSATTRBM_TYPE |                                                \
  856         NFSATTRBM_CHANGE |                                              \
  857         NFSATTRBM_SIZE |                                                \
  858         NFSATTRBM_FSID |                                                \
  859         NFSATTRBM_FILEID |                                              \
  860         NFSATTRBM_MAXREAD)
  861 
  862 /*
  863  * NFSATTRBIT_GETATTR1 - bits 32<->63
  864  */
  865 #define NFSATTRBIT_GETATTR1                                             \
  866         (NFSATTRBM_MODE |                                               \
  867         NFSATTRBM_NUMLINKS |                                            \
  868         NFSATTRBM_OWNER |                                               \
  869         NFSATTRBM_OWNERGROUP |                                          \
  870         NFSATTRBM_RAWDEV |                                              \
  871         NFSATTRBM_SPACEUSED |                                           \
  872         NFSATTRBM_TIMEACCESS |                                          \
  873         NFSATTRBM_TIMEMETADATA |                                        \
  874         NFSATTRBM_TIMEMODIFY)
  875 
  876 /*
  877  * Subset of the above that the Write RPC gets.
  878  * OR of the following bits.
  879  * NFSATTRBIT_WRITEGETATTR0 - bits 0<->31
  880  */
  881 #define NFSATTRBIT_WRITEGETATTR0                                        \
  882         (NFSATTRBM_SUPPORTEDATTRS |                                     \
  883         NFSATTRBM_TYPE |                                                \
  884         NFSATTRBM_CHANGE |                                              \
  885         NFSATTRBM_SIZE |                                                \
  886         NFSATTRBM_FSID |                                                \
  887         NFSATTRBM_FILEID |                                              \
  888         NFSATTRBM_MAXREAD)
  889 
  890 /*
  891  * NFSATTRBIT_WRITEGETATTR1 - bits 32<->63
  892  */
  893 #define NFSATTRBIT_WRITEGETATTR1                                        \
  894         (NFSATTRBM_MODE |                                               \
  895         NFSATTRBM_NUMLINKS |                                            \
  896         NFSATTRBM_RAWDEV |                                              \
  897         NFSATTRBM_SPACEUSED |                                           \
  898         NFSATTRBM_TIMEACCESS |                                          \
  899         NFSATTRBM_TIMEMETADATA |                                        \
  900         NFSATTRBM_TIMEMODIFY)
  901 
  902 /*
  903  * Set of attributes that the wccattr operation op needs.
  904  * OR of the following bits.
  905  * NFSATTRBIT_WCCATTR0 - bits 0<->31
  906  */
  907 #define NFSATTRBIT_WCCATTR0     0
  908 
  909 /*
  910  * NFSATTRBIT_WCCATTR1 - bits 32<->63
  911  */
  912 #define NFSATTRBIT_WCCATTR1                                             \
  913         (NFSATTRBM_TIMEMODIFY)
  914 
  915 /*
  916  * NFSATTRBIT_CBGETATTR0 - bits 0<->31
  917  */
  918 #define NFSATTRBIT_CBGETATTR0   (NFSATTRBM_CHANGE | NFSATTRBM_SIZE)
  919 
  920 /*
  921  * NFSATTRBIT_CBGETATTR1 - bits 32<->63
  922  */
  923 #define NFSATTRBIT_CBGETATTR1           0x0
  924 
  925 /*
  926  * Sets of attributes that require a VFS_STATFS() call to get the
  927  * values of.
  928  * NFSATTRBIT_STATFS0 - bits 0<->31
  929  */
  930 #define NFSATTRBIT_STATFS0                                              \
  931         (NFSATTRBM_LINKSUPPORT |                                        \
  932         NFSATTRBM_SYMLINKSUPPORT |                                      \
  933         NFSATTRBM_CANSETTIME |                                          \
  934         NFSATTRBM_FILESAVAIL |                                          \
  935         NFSATTRBM_FILESFREE |                                           \
  936         NFSATTRBM_FILESTOTAL |                                          \
  937         NFSATTRBM_HOMOGENEOUS |                                         \
  938         NFSATTRBM_MAXFILESIZE |                                         \
  939         NFSATTRBM_MAXNAME |                                             \
  940         NFSATTRBM_MAXREAD |                                             \
  941         NFSATTRBM_MAXWRITE)
  942 
  943 /*
  944  * NFSATTRBIT_STATFS1 - bits 32<->63
  945  */
  946 #define NFSATTRBIT_STATFS1                                              \
  947         (NFSATTRBM_QUOTAHARD |                                          \
  948         NFSATTRBM_QUOTASOFT |                                           \
  949         NFSATTRBM_QUOTAUSED |                                           \
  950         NFSATTRBM_SPACEAVAIL |                                          \
  951         NFSATTRBM_SPACEFREE |                                           \
  952         NFSATTRBM_SPACETOTAL |                                          \
  953         NFSATTRBM_SPACEUSED |                                           \
  954         NFSATTRBM_TIMEDELTA)
  955 
  956 /*
  957  * These are the bits that are needed by the nfs_statfs() call.
  958  * (The regular getattr bits are or'd in so the vnode gets the correct
  959  *  type, etc.)
  960  * NFSGETATTRBIT_STATFS0 - bits 0<->31
  961  */
  962 #define NFSGETATTRBIT_STATFS0   (NFSATTRBIT_GETATTR0 |                  \
  963                                 NFSATTRBM_LINKSUPPORT |                 \
  964                                 NFSATTRBM_SYMLINKSUPPORT |              \
  965                                 NFSATTRBM_CANSETTIME |                  \
  966                                 NFSATTRBM_FILESFREE |                   \
  967                                 NFSATTRBM_FILESTOTAL |                  \
  968                                 NFSATTRBM_HOMOGENEOUS |                 \
  969                                 NFSATTRBM_MAXFILESIZE |                 \
  970                                 NFSATTRBM_MAXNAME |                     \
  971                                 NFSATTRBM_MAXREAD |                     \
  972                                 NFSATTRBM_MAXWRITE)
  973 
  974 /*
  975  * NFSGETATTRBIT_STATFS1 - bits 32<->63
  976  */
  977 #define NFSGETATTRBIT_STATFS1   (NFSATTRBIT_GETATTR1 |                  \
  978                                 NFSATTRBM_SPACEAVAIL |                  \
  979                                 NFSATTRBM_SPACEFREE |                   \
  980                                 NFSATTRBM_SPACETOTAL |                  \
  981                                 NFSATTRBM_TIMEDELTA)
  982 
  983 /*
  984  * Set of attributes for the equivalent of an nfsv3 pathconf rpc.
  985  * NFSGETATTRBIT_PATHCONF0 - bits 0<->31
  986  */
  987 #define NFSGETATTRBIT_PATHCONF0 (NFSATTRBIT_GETATTR0 |                  \
  988                                 NFSATTRBM_CASEINSENSITIVE |             \
  989                                 NFSATTRBM_CASEPRESERVING |              \
  990                                 NFSATTRBM_CHOWNRESTRICTED |             \
  991                                 NFSATTRBM_MAXLINK |                     \
  992                                 NFSATTRBM_MAXNAME)
  993 
  994 /*
  995  * NFSGETATTRBIT_PATHCONF1 - bits 32<->63
  996  */
  997 #define NFSGETATTRBIT_PATHCONF1 (NFSATTRBIT_GETATTR1 |                  \
  998                                 NFSATTRBM_NOTRUNC)
  999 
 1000 /*
 1001  * Sets of attributes required by readdir and readdirplus.
 1002  * NFSATTRBIT_READDIRPLUS0      (NFSATTRBIT_GETATTR0 | NFSATTRBIT_FILEHANDLE |
 1003  *                               NFSATTRBIT_RDATTRERROR)
 1004  */
 1005 #define NFSATTRBIT_READDIRPLUS0 (NFSATTRBIT_GETATTR0 | NFSATTRBM_FILEHANDLE | \
 1006                                 NFSATTRBM_RDATTRERROR)
 1007 #define NFSATTRBIT_READDIRPLUS1 NFSATTRBIT_GETATTR1
 1008 
 1009 /*
 1010  * Set of attributes supported by Referral vnodes.
 1011  */
 1012 #define NFSATTRBIT_REFERRAL0    (NFSATTRBM_TYPE | NFSATTRBM_FSID |      \
 1013         NFSATTRBM_RDATTRERROR | NFSATTRBM_FSLOCATIONS)
 1014 #define NFSATTRBIT_REFERRAL1    NFSATTRBM_MOUNTEDONFILEID
 1015 
 1016 /*
 1017  * Structure for data handled by the statfs rpc. Since some fields are
 1018  * u_int64_t, this cannot be used for copying data on/off the wire, due
 1019  * to alignment concerns.
 1020  */
 1021 struct nfsstatfs {
 1022         union {
 1023                 struct {
 1024                         u_int32_t nfsv2sf_tsize;
 1025                         u_int32_t nfsv2sf_bsize;
 1026                         u_int32_t nfsv2sf_blocks;
 1027                         u_int32_t nfsv2sf_bfree;
 1028                         u_int32_t nfsv2sf_bavail;
 1029                 } sf_nfsv2;
 1030                 struct {
 1031                         u_int64_t nfsv3sf_tbytes;
 1032                         u_int64_t nfsv3sf_fbytes;
 1033                         u_int64_t nfsv3sf_abytes;
 1034                         u_int64_t nfsv3sf_tfiles;
 1035                         u_int64_t nfsv3sf_ffiles;
 1036                         u_int64_t nfsv3sf_afiles;
 1037                         u_int32_t nfsv3sf_invarsec;
 1038                 } sf_nfsv3;
 1039         } sf_un;
 1040 };
 1041 
 1042 #define sf_tsize        sf_un.sf_nfsv2.nfsv2sf_tsize
 1043 #define sf_bsize        sf_un.sf_nfsv2.nfsv2sf_bsize
 1044 #define sf_blocks       sf_un.sf_nfsv2.nfsv2sf_blocks
 1045 #define sf_bfree        sf_un.sf_nfsv2.nfsv2sf_bfree
 1046 #define sf_bavail       sf_un.sf_nfsv2.nfsv2sf_bavail
 1047 #define sf_tbytes       sf_un.sf_nfsv3.nfsv3sf_tbytes
 1048 #define sf_fbytes       sf_un.sf_nfsv3.nfsv3sf_fbytes
 1049 #define sf_abytes       sf_un.sf_nfsv3.nfsv3sf_abytes
 1050 #define sf_tfiles       sf_un.sf_nfsv3.nfsv3sf_tfiles
 1051 #define sf_ffiles       sf_un.sf_nfsv3.nfsv3sf_ffiles
 1052 #define sf_afiles       sf_un.sf_nfsv3.nfsv3sf_afiles
 1053 #define sf_invarsec     sf_un.sf_nfsv3.nfsv3sf_invarsec
 1054 
 1055 /*
 1056  * Now defined using u_int64_t for the 64 bit field(s).
 1057  * (Cannot be used to move data on/off the wire, due to alignment concerns.)
 1058  */
 1059 struct nfsfsinfo {
 1060         u_int32_t fs_rtmax;
 1061         u_int32_t fs_rtpref;
 1062         u_int32_t fs_rtmult;
 1063         u_int32_t fs_wtmax;
 1064         u_int32_t fs_wtpref;
 1065         u_int32_t fs_wtmult;
 1066         u_int32_t fs_dtpref;
 1067         u_int64_t fs_maxfilesize;
 1068         struct timespec fs_timedelta;
 1069         u_int32_t fs_properties;
 1070 };
 1071 
 1072 /*
 1073  * Bits for fs_properties
 1074  */
 1075 #define NFSV3_FSFLINK           0x1
 1076 #define NFSV3_FSFSYMLINK        0x2
 1077 #define NFSV3_FSFHOMOGENEOUS    0x4
 1078 #define NFSV3_FSFCANSETTIME     0x8
 1079 
 1080 /*
 1081  * Yikes, overload fs_rtmult as fs_maxname for V4.
 1082  */
 1083 #define fs_maxname      fs_rtmult
 1084 
 1085 struct nfsv3_pathconf {
 1086         u_int32_t pc_linkmax;
 1087         u_int32_t pc_namemax;
 1088         u_int32_t pc_notrunc;
 1089         u_int32_t pc_chownrestricted;
 1090         u_int32_t pc_caseinsensitive;
 1091         u_int32_t pc_casepreserving;
 1092 };
 1093 
 1094 /*
 1095  * NFS V4 data structures.
 1096  */
 1097 struct nfsv4stateid {
 1098         u_int32_t       seqid;
 1099         u_int32_t       other[NFSX_STATEIDOTHER / NFSX_UNSIGNED];
 1100 };
 1101 typedef struct nfsv4stateid nfsv4stateid_t;
 1102 
 1103 #endif  /* _NFS_NFSPROTO_H_ */

Cache object: a5dbdd472968785ecd1743efabdfbc49


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.