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/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  * 3. All advertising materials mentioning features or use of this software
   17  *    must display the following acknowledgement:
   18  *      This product includes software developed by the University of
   19  *      California, Berkeley and its contributors.
   20  * 4. Neither the name of the University nor the names of its contributors
   21  *    may be used to endorse or promote products derived from this software
   22  *    without specific prior written permission.
   23  *
   24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   34  * SUCH DAMAGE.
   35  *
   36  *      @(#)nfsproto.h  8.2 (Berkeley) 3/30/95
   37  * $FreeBSD: releng/5.0/sys/nfs/nfsproto.h 83651 2001-09-18 23:32:09Z peter $
   38  */
   39 
   40 #ifndef _NFS_NFSPROTO_H_
   41 #define _NFS_NFSPROTO_H_
   42 
   43 /*
   44  * nfs definitions as per the Version 2 and 3 specs
   45  */
   46 
   47 /*
   48  * Constants as defined in the Sun NFS Version 2 and 3 specs.
   49  * "NFS: Network File System Protocol Specification" RFC1094
   50  * and in the "NFS: Network File System Version 3 Protocol
   51  * Specification"
   52  */
   53 
   54 #define NFS_PORT        2049
   55 #define NFS_PROG        100003
   56 #define NFS_VER2        2
   57 #define NFS_VER3        3
   58 #define NFS_V2MAXDATA   8192
   59 #define NFS_MAXDGRAMDATA 16384
   60 #define NFS_MAXDATA     32768
   61 #define NFS_MAXPATHLEN  1024
   62 #define NFS_MAXNAMLEN   255
   63 #define NFS_MAXPKTHDR   404
   64 #define NFS_MAXPACKET   (NFS_MAXPKTHDR + NFS_MAXDATA)
   65 #define NFS_MINPACKET   20
   66 #define NFS_FABLKSIZE   512     /* Size in bytes of a block wrt fa_blocks */
   67 
   68 /* Stat numbers for rpc returns (version 2 and 3) */
   69 #define NFS_OK                  0
   70 #define NFSERR_PERM             1
   71 #define NFSERR_NOENT            2
   72 #define NFSERR_IO               5
   73 #define NFSERR_NXIO             6
   74 #define NFSERR_ACCES            13
   75 #define NFSERR_EXIST            17
   76 #define NFSERR_XDEV             18      /* Version 3 only */
   77 #define NFSERR_NODEV            19
   78 #define NFSERR_NOTDIR           20
   79 #define NFSERR_ISDIR            21
   80 #define NFSERR_INVAL            22      /* Version 3 only */
   81 #define NFSERR_FBIG             27
   82 #define NFSERR_NOSPC            28
   83 #define NFSERR_ROFS             30
   84 #define NFSERR_MLINK            31      /* Version 3 only */
   85 #define NFSERR_NAMETOL          63
   86 #define NFSERR_NOTEMPTY         66
   87 #define NFSERR_DQUOT            69
   88 #define NFSERR_STALE            70
   89 #define NFSERR_REMOTE           71      /* Version 3 only */
   90 #define NFSERR_WFLUSH           99      /* Version 2 only */
   91 #define NFSERR_BADHANDLE        10001   /* The rest Version 3 only */
   92 #define NFSERR_NOT_SYNC         10002
   93 #define NFSERR_BAD_COOKIE       10003
   94 #define NFSERR_NOTSUPP          10004
   95 #define NFSERR_TOOSMALL         10005
   96 #define NFSERR_SERVERFAULT      10006
   97 #define NFSERR_BADTYPE          10007
   98 #define NFSERR_JUKEBOX          10008
   99 #define NFSERR_TRYLATER         NFSERR_JUKEBOX
  100 #define NFSERR_STALEWRITEVERF   30001   /* Fake return for nfs_commit() */
  101 
  102 #define NFSERR_RETVOID          0x20000000 /* Return void, not error */
  103 #define NFSERR_AUTHERR          0x40000000 /* Mark an authentication error */
  104 #define NFSERR_RETERR           0x80000000 /* Mark an error return for V3 */
  105 
  106 /* Sizes in bytes of various nfs rpc components */
  107 #define NFSX_UNSIGNED   4
  108 
  109 /* specific to NFS Version 2 */
  110 #define NFSX_V2FH       32
  111 #define NFSX_V2FATTR    68
  112 #define NFSX_V2SATTR    32
  113 #define NFSX_V2COOKIE   4
  114 #define NFSX_V2STATFS   20
  115 
  116 /* specific to NFS Version 3 */
  117 #define NFSX_V3FH               (sizeof (fhandle_t)) /* size this server uses */
  118 #define NFSX_V3FHMAX            64      /* max. allowed by protocol */
  119 #define NFSX_V3FATTR            84
  120 #define NFSX_V3SATTR            60      /* max. all fields filled in */
  121 #define NFSX_V3SRVSATTR         (sizeof (struct nfsv3_sattr))
  122 #define NFSX_V3POSTOPATTR       (NFSX_V3FATTR + NFSX_UNSIGNED)
  123 #define NFSX_V3WCCDATA          (NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED)
  124 #define NFSX_V3COOKIEVERF       8
  125 #define NFSX_V3WRITEVERF        8
  126 #define NFSX_V3CREATEVERF       8
  127 #define NFSX_V3STATFS           52
  128 #define NFSX_V3FSINFO           48
  129 #define NFSX_V3PATHCONF         24
  130 
  131 /* variants for both versions */
  132 #define NFSX_FH(v3)             ((v3) ? (NFSX_V3FHMAX + NFSX_UNSIGNED) : \
  133                                         NFSX_V2FH)
  134 #define NFSX_SRVFH(v3)          ((v3) ? NFSX_V3FH : NFSX_V2FH)
  135 #define NFSX_FATTR(v3)          ((v3) ? NFSX_V3FATTR : NFSX_V2FATTR)
  136 #define NFSX_PREOPATTR(v3)      ((v3) ? (7 * NFSX_UNSIGNED) : 0)
  137 #define NFSX_POSTOPATTR(v3)     ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : 0)
  138 #define NFSX_POSTOPORFATTR(v3)  ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : \
  139                                         NFSX_V2FATTR)
  140 #define NFSX_WCCDATA(v3)        ((v3) ? NFSX_V3WCCDATA : 0)
  141 #define NFSX_WCCORFATTR(v3)     ((v3) ? NFSX_V3WCCDATA : NFSX_V2FATTR)
  142 #define NFSX_SATTR(v3)          ((v3) ? NFSX_V3SATTR : NFSX_V2SATTR)
  143 #define NFSX_COOKIEVERF(v3)     ((v3) ? NFSX_V3COOKIEVERF : 0)
  144 #define NFSX_WRITEVERF(v3)      ((v3) ? NFSX_V3WRITEVERF : 0)
  145 #define NFSX_READDIR(v3)        ((v3) ? (5 * NFSX_UNSIGNED) : \
  146                                         (2 * NFSX_UNSIGNED))
  147 #define NFSX_STATFS(v3)         ((v3) ? NFSX_V3STATFS : NFSX_V2STATFS)
  148 
  149 /* nfs rpc procedure numbers (before version mapping) */
  150 #define NFSPROC_NULL            0
  151 #define NFSPROC_GETATTR         1
  152 #define NFSPROC_SETATTR         2
  153 #define NFSPROC_LOOKUP          3
  154 #define NFSPROC_ACCESS          4
  155 #define NFSPROC_READLINK        5
  156 #define NFSPROC_READ            6
  157 #define NFSPROC_WRITE           7
  158 #define NFSPROC_CREATE          8
  159 #define NFSPROC_MKDIR           9
  160 #define NFSPROC_SYMLINK         10
  161 #define NFSPROC_MKNOD           11
  162 #define NFSPROC_REMOVE          12
  163 #define NFSPROC_RMDIR           13
  164 #define NFSPROC_RENAME          14
  165 #define NFSPROC_LINK            15
  166 #define NFSPROC_READDIR         16
  167 #define NFSPROC_READDIRPLUS     17
  168 #define NFSPROC_FSSTAT          18
  169 #define NFSPROC_FSINFO          19
  170 #define NFSPROC_PATHCONF        20
  171 #define NFSPROC_COMMIT          21
  172 #define NFSPROC_NOOP            22
  173 #define NFS_NPROCS              23
  174 
  175 /* Actual Version 2 procedure numbers */
  176 #define NFSV2PROC_NULL          0
  177 #define NFSV2PROC_GETATTR       1
  178 #define NFSV2PROC_SETATTR       2
  179 #define NFSV2PROC_NOOP          3
  180 #define NFSV2PROC_ROOT          NFSV2PROC_NOOP  /* Obsolete */
  181 #define NFSV2PROC_LOOKUP        4
  182 #define NFSV2PROC_READLINK      5
  183 #define NFSV2PROC_READ          6
  184 #define NFSV2PROC_WRITECACHE    NFSV2PROC_NOOP  /* Obsolete */
  185 #define NFSV2PROC_WRITE         8
  186 #define NFSV2PROC_CREATE        9
  187 #define NFSV2PROC_REMOVE        10
  188 #define NFSV2PROC_RENAME        11
  189 #define NFSV2PROC_LINK          12
  190 #define NFSV2PROC_SYMLINK       13
  191 #define NFSV2PROC_MKDIR         14
  192 #define NFSV2PROC_RMDIR         15
  193 #define NFSV2PROC_READDIR       16
  194 #define NFSV2PROC_STATFS        17
  195 
  196 /*
  197  * Constants used by the Version 3 protocol for various RPCs
  198  */
  199 #define NFSV3SATTRTIME_DONTCHANGE       0
  200 #define NFSV3SATTRTIME_TOSERVER         1
  201 #define NFSV3SATTRTIME_TOCLIENT         2
  202 
  203 #define NFSV3ACCESS_READ                0x01
  204 #define NFSV3ACCESS_LOOKUP              0x02
  205 #define NFSV3ACCESS_MODIFY              0x04
  206 #define NFSV3ACCESS_EXTEND              0x08
  207 #define NFSV3ACCESS_DELETE              0x10
  208 #define NFSV3ACCESS_EXECUTE             0x20
  209 
  210 #define NFSV3WRITE_UNSTABLE             0
  211 #define NFSV3WRITE_DATASYNC             1
  212 #define NFSV3WRITE_FILESYNC             2
  213 
  214 #define NFSV3CREATE_UNCHECKED           0
  215 #define NFSV3CREATE_GUARDED             1
  216 #define NFSV3CREATE_EXCLUSIVE           2
  217 
  218 #define NFSV3FSINFO_LINK                0x01
  219 #define NFSV3FSINFO_SYMLINK             0x02
  220 #define NFSV3FSINFO_HOMOGENEOUS         0x08
  221 #define NFSV3FSINFO_CANSETTIME          0x10
  222 
  223 /* File types */
  224 typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5,
  225         NFSOCK=6, NFFIFO=7 } nfstype;
  226 
  227 /* Structs for common parts of the rpc's */
  228 /*
  229  * File Handle (32 bytes for version 2), variable up to 64 for version 3.
  230  * File Handles of up to NFS_SMALLFH in size are stored directly in the
  231  * nfs node, whereas larger ones are malloc'd. (This never happens when
  232  * NFS_SMALLFH is set to 64.)
  233  * NFS_SMALLFH should be in the range of 32 to 64 and be divisible by 4.
  234  */
  235 #ifndef NFS_SMALLFH
  236 #define NFS_SMALLFH     64
  237 #endif
  238 union nfsfh {
  239         fhandle_t       fh_generic;
  240         u_char          fh_bytes[NFS_SMALLFH];
  241 };
  242 typedef union nfsfh nfsfh_t;
  243 
  244 struct nfsv2_time {
  245         u_int32_t       nfsv2_sec;
  246         u_int32_t       nfsv2_usec;
  247 };
  248 typedef struct nfsv2_time       nfstime2;
  249 
  250 struct nfsv3_time {
  251         u_int32_t       nfsv3_sec;
  252         u_int32_t       nfsv3_nsec;
  253 };
  254 typedef struct nfsv3_time       nfstime3;
  255 
  256 /*
  257  * Quads are defined as arrays of 2 longs to ensure dense packing for the
  258  * protocol and to facilitate xdr conversion.
  259  */
  260 struct nfs_uquad {
  261         u_int32_t       nfsuquad[2];
  262 };
  263 typedef struct nfs_uquad        nfsuint64;
  264 
  265 /*
  266  * Used to convert between two u_longs and a u_quad_t.
  267  */
  268 union nfs_quadconvert {
  269         u_int32_t       lval[2];
  270         u_quad_t        qval;
  271 };
  272 typedef union nfs_quadconvert   nfsquad_t;
  273 
  274 /*
  275  * NFS Version 3 special file number.
  276  */
  277 struct nfsv3_spec {
  278         u_int32_t       specdata1;
  279         u_int32_t       specdata2;
  280 };
  281 typedef struct nfsv3_spec       nfsv3spec;
  282 
  283 /*
  284  * File attributes and setable attributes. These structures cover both
  285  * NFS version 2 and the version 3 protocol. Note that the union is only
  286  * used so that one pointer can refer to both variants. These structures
  287  * go out on the wire and must be densely packed, so no quad data types
  288  * are used. (all fields are longs or u_longs or structures of same)
  289  * NB: You can't do sizeof(struct nfs_fattr), you must use the
  290  *     NFSX_FATTR(v3) macro.
  291  */
  292 struct nfs_fattr {
  293         u_int32_t       fa_type;
  294         u_int32_t       fa_mode;
  295         u_int32_t       fa_nlink;
  296         u_int32_t       fa_uid;
  297         u_int32_t       fa_gid;
  298         union {
  299                 struct {
  300                         u_int32_t       nfsv2fa_size;
  301                         u_int32_t       nfsv2fa_blocksize;
  302                         u_int32_t       nfsv2fa_rdev;
  303                         u_int32_t       nfsv2fa_blocks;
  304                         u_int32_t       nfsv2fa_fsid;
  305                         u_int32_t       nfsv2fa_fileid;
  306                         nfstime2        nfsv2fa_atime;
  307                         nfstime2        nfsv2fa_mtime;
  308                         nfstime2        nfsv2fa_ctime;
  309                 } fa_nfsv2;
  310                 struct {
  311                         nfsuint64       nfsv3fa_size;
  312                         nfsuint64       nfsv3fa_used;
  313                         nfsv3spec       nfsv3fa_rdev;
  314                         nfsuint64       nfsv3fa_fsid;
  315                         nfsuint64       nfsv3fa_fileid;
  316                         nfstime3        nfsv3fa_atime;
  317                         nfstime3        nfsv3fa_mtime;
  318                         nfstime3        nfsv3fa_ctime;
  319                 } fa_nfsv3;
  320         } fa_un;
  321 };
  322 
  323 /* and some ugly defines for accessing union components */
  324 #define fa2_size                fa_un.fa_nfsv2.nfsv2fa_size
  325 #define fa2_blocksize           fa_un.fa_nfsv2.nfsv2fa_blocksize
  326 #define fa2_rdev                fa_un.fa_nfsv2.nfsv2fa_rdev
  327 #define fa2_blocks              fa_un.fa_nfsv2.nfsv2fa_blocks
  328 #define fa2_fsid                fa_un.fa_nfsv2.nfsv2fa_fsid
  329 #define fa2_fileid              fa_un.fa_nfsv2.nfsv2fa_fileid
  330 #define fa2_atime               fa_un.fa_nfsv2.nfsv2fa_atime
  331 #define fa2_mtime               fa_un.fa_nfsv2.nfsv2fa_mtime
  332 #define fa2_ctime               fa_un.fa_nfsv2.nfsv2fa_ctime
  333 #define fa3_size                fa_un.fa_nfsv3.nfsv3fa_size
  334 #define fa3_used                fa_un.fa_nfsv3.nfsv3fa_used
  335 #define fa3_rdev                fa_un.fa_nfsv3.nfsv3fa_rdev
  336 #define fa3_fsid                fa_un.fa_nfsv3.nfsv3fa_fsid
  337 #define fa3_fileid              fa_un.fa_nfsv3.nfsv3fa_fileid
  338 #define fa3_atime               fa_un.fa_nfsv3.nfsv3fa_atime
  339 #define fa3_mtime               fa_un.fa_nfsv3.nfsv3fa_mtime
  340 #define fa3_ctime               fa_un.fa_nfsv3.nfsv3fa_ctime
  341 
  342 struct nfsv2_sattr {
  343         u_int32_t       sa_mode;
  344         u_int32_t       sa_uid;
  345         u_int32_t       sa_gid;
  346         u_int32_t       sa_size;
  347         nfstime2        sa_atime;
  348         nfstime2        sa_mtime;
  349 };
  350 
  351 /*
  352  * NFS Version 3 sattr structure for the new node creation case.
  353  */
  354 struct nfsv3_sattr {
  355         u_int32_t       sa_modetrue;
  356         u_int32_t       sa_mode;
  357         u_int32_t       sa_uidfalse;
  358         u_int32_t       sa_gidfalse;
  359         u_int32_t       sa_sizefalse;
  360         u_int32_t       sa_atimetype;
  361         nfstime3        sa_atime;
  362         u_int32_t       sa_mtimetype;
  363         nfstime3        sa_mtime;
  364 };
  365 
  366 struct nfs_statfs {
  367         union {
  368                 struct {
  369                         u_int32_t       nfsv2sf_tsize;
  370                         u_int32_t       nfsv2sf_bsize;
  371                         u_int32_t       nfsv2sf_blocks;
  372                         u_int32_t       nfsv2sf_bfree;
  373                         u_int32_t       nfsv2sf_bavail;
  374                 } sf_nfsv2;
  375                 struct {
  376                         nfsuint64       nfsv3sf_tbytes;
  377                         nfsuint64       nfsv3sf_fbytes;
  378                         nfsuint64       nfsv3sf_abytes;
  379                         nfsuint64       nfsv3sf_tfiles;
  380                         nfsuint64       nfsv3sf_ffiles;
  381                         nfsuint64       nfsv3sf_afiles;
  382                         u_int32_t       nfsv3sf_invarsec;
  383                 } sf_nfsv3;
  384         } sf_un;
  385 };
  386 
  387 #define sf_tsize        sf_un.sf_nfsv2.nfsv2sf_tsize
  388 #define sf_bsize        sf_un.sf_nfsv2.nfsv2sf_bsize
  389 #define sf_blocks       sf_un.sf_nfsv2.nfsv2sf_blocks
  390 #define sf_bfree        sf_un.sf_nfsv2.nfsv2sf_bfree
  391 #define sf_bavail       sf_un.sf_nfsv2.nfsv2sf_bavail
  392 #define sf_tbytes       sf_un.sf_nfsv3.nfsv3sf_tbytes
  393 #define sf_fbytes       sf_un.sf_nfsv3.nfsv3sf_fbytes
  394 #define sf_abytes       sf_un.sf_nfsv3.nfsv3sf_abytes
  395 #define sf_tfiles       sf_un.sf_nfsv3.nfsv3sf_tfiles
  396 #define sf_ffiles       sf_un.sf_nfsv3.nfsv3sf_ffiles
  397 #define sf_afiles       sf_un.sf_nfsv3.nfsv3sf_afiles
  398 #define sf_invarsec     sf_un.sf_nfsv3.nfsv3sf_invarsec
  399 
  400 struct nfsv3_fsinfo {
  401         u_int32_t       fs_rtmax;
  402         u_int32_t       fs_rtpref;
  403         u_int32_t       fs_rtmult;
  404         u_int32_t       fs_wtmax;
  405         u_int32_t       fs_wtpref;
  406         u_int32_t       fs_wtmult;
  407         u_int32_t       fs_dtpref;
  408         nfsuint64       fs_maxfilesize;
  409         nfstime3        fs_timedelta;
  410         u_int32_t       fs_properties;
  411 };
  412 
  413 struct nfsv3_pathconf {
  414         u_int32_t       pc_linkmax;
  415         u_int32_t       pc_namemax;
  416         u_int32_t       pc_notrunc;
  417         u_int32_t       pc_chownrestricted;
  418         u_int32_t       pc_caseinsensitive;
  419         u_int32_t       pc_casepreserving;
  420 };
  421 
  422 #endif

Cache object: a00d7565f2ee5954033051ae227aa531


[ 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.