/* $NetBSD: nfsproto.h,v 1.1.1.2 2016/11/18 07:49:13 pgoyette Exp $ */
/*-
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Rick Macklem at The University of Guelph.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* FreeBSD: head/sys/fs/nfs/nfsproto.h 304026 2016-08-12 22:44:59Z rmacklem
* $NetBSD: nfsproto.h,v 1.1.1.2 2016/11/18 07:49:13 pgoyette Exp $
*/
#ifndef _NFS_NFSPROTO_H_
#define _NFS_NFSPROTO_H_
/*
* nfs definitions as per the Version 2, 3 and 4 specs
*/
/*
* Constants as defined in the NFS Version 2, 3 and 4 specs.
* "NFS: Network File System Protocol Specification" RFC1094
* and in the "NFS: Network File System Version 3 Protocol
* Specification"
*/
#define NFS_PORT 2049
#define NFS_PROG 100003
#define NFS_CALLBCKPROG 0x40000000 /* V4 only */
#define NFS_VER2 2
#define NFS_VER3 3
#define NFS_VER4 4
#define NFS_V2MAXDATA 8192
#define NFS_MAXDGRAMDATA 16384
#define NFS_MAXPATHLEN 1024
#define NFS_MAXNAMLEN 255
#define NFS_MAXPKTHDR 404
#define NFS_MAXPACKET (NFS_SRVMAXIO + 2048)
#define NFS_MINPACKET 20
#define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */
#define NFSV4_MINORVERSION 0 /* V4 Minor version */
#define NFSV41_MINORVERSION 1 /* V4 Minor version */
#define NFSV4_CBVERS 1 /* V4 CB Version */
#define NFSV41_CBVERS 4 /* V4.1 CB Version */
#define NFSV4_SMALLSTR 50 /* Strings small enough for stack */
/*
* This value isn't a fixed value in the RFCs.
* It is the maximum data size supported by NFSv3 or NFSv4 over TCP for
* the server. It should be set to the I/O size preferred by ZFS or
* MAXBSIZE, whichever is greater.
* ZFS currently prefers 128K.
* It used to be called NFS_MAXDATA, but has been renamed to clarify that
* it refers to server side only and doesn't conflict with the NFS_MAXDATA
* defined in rpcsvc/nfs_prot.h for userland.
*/
#define NFS_SRVMAXIO (128 * 1024)
/* Stat numbers for rpc returns (version 2, 3 and 4) */
/*
* These numbers are hard-wired in the RFCs, so they can't be changed.
* The code currently assumes that the ones < 10000 are the same as
* sys/errno.h and that sys/errno.h will never go as high as 10000.
* If the value in sys/errno.h of any entry listed below is changed,
* the NFS code must be modified to do the mapping between them.
* (You can ignore NFSERR_WFLUSH, since it is never actually used.)
*/
#define NFSERR_OK 0
#define NFSERR_PERM 1
#define NFSERR_NOENT 2
#define NFSERR_IO 5
#define NFSERR_NXIO 6
#define NFSERR_ACCES 13
#define NFSERR_EXIST 17
#define NFSERR_XDEV 18 /* Version 3, 4 only */
#define NFSERR_NODEV 19
#define NFSERR_NOTDIR 20
#define NFSERR_ISDIR 21
#define NFSERR_INVAL 22 /* Version 3, 4 only */
#define NFSERR_FBIG 27
#define NFSERR_NOSPC 28
#define NFSERR_ROFS 30
#define NFSERR_MLINK 31 /* Version 3, 4 only */
#define NFSERR_NAMETOL 63
#define NFSERR_NOTEMPTY 66
#define NFSERR_DQUOT 69
#define NFSERR_STALE 70
#define NFSERR_REMOTE 71 /* Version 3 only */
#define NFSERR_WFLUSH 99 /* Version 2 only */
#define NFSERR_BADHANDLE 10001 /* These are Version 3, 4 only */
#define NFSERR_NOT_SYNC 10002 /* Version 3 Only */
#define NFSERR_BAD_COOKIE 10003
#define NFSERR_NOTSUPP 10004
#define NFSERR_TOOSMALL 10005
#define NFSERR_SERVERFAULT 10006
#define NFSERR_BADTYPE 10007
#define NFSERR_DELAY 10008 /* Called NFSERR_JUKEBOX for V3 */
#define NFSERR_SAME 10009 /* These are Version 4 only */
#define NFSERR_DENIED 10010
#define NFSERR_EXPIRED 10011
#define NFSERR_LOCKED 10012
#define NFSERR_GRACE 10013
#define NFSERR_FHEXPIRED 10014
#define NFSERR_SHAREDENIED 10015
#define NFSERR_WRONGSEC 10016
#define NFSERR_CLIDINUSE 10017
#define NFSERR_RESOURCE 10018
#define NFSERR_MOVED 10019
#define NFSERR_NOFILEHANDLE 10020
#define NFSERR_MINORVERMISMATCH 10021
#define NFSERR_STALECLIENTID 10022
#define NFSERR_STALESTATEID 10023
#define NFSERR_OLDSTATEID 10024
#define NFSERR_BADSTATEID 10025
#define NFSERR_BADSEQID 10026
#define NFSERR_NOTSAME 10027
#define NFSERR_LOCKRANGE 10028
#define NFSERR_SYMLINK 10029
#define NFSERR_RESTOREFH 10030
#define NFSERR_LEASEMOVED 10031
#define NFSERR_ATTRNOTSUPP 10032
#define NFSERR_NOGRACE 10033
#define NFSERR_RECLAIMBAD 10034
#define NFSERR_RECLAIMCONFLICT 10035
#define NFSERR_BADXDR 10036
#define NFSERR_LOCKSHELD 10037
#define NFSERR_OPENMODE 10038
#define NFSERR_BADOWNER 10039
#define NFSERR_BADCHAR 10040
#define NFSERR_BADNAME 10041
#define NFSERR_BADRANGE 10042
#define NFSERR_LOCKNOTSUPP 10043
#define NFSERR_OPILLEGAL 10044
#define NFSERR_DEADLOCK 10045
#define NFSERR_FILEOPEN 10046
#define NFSERR_ADMINREVOKED 10047
#define NFSERR_CBPATHDOWN 10048
/*
* The lower numbers -> 21 are used by NFSv2 and v3. These define higher
* numbers used by NFSv4.
* NFS_V3NPROCS is one greater than the last V3 op and NFS_NPROCS is
* one greater than the last number.
*/
#ifndef NFS_V3NPROCS
#define NFS_V3NPROCS 22
/*
* Must be defined as one higher than the last NFSv4.1 Proc# above.
*/
#define NFSV41_NPROCS 54
#endif /* NFS_V3NPROCS */
/*
* Define NFS_NPROCS as NFSV4_NPROCS for the experimental kernel code.
*/
#ifndef NFS_NPROCS
#define NFS_NPROCS NFSV4_NPROCS
#endif
/*
* NFSPROC_NOOP is a fake op# that can't be the same as any V2/3/4 Procedure
* or Operation#. Since the NFS V4 Op #s go higher, use NFSV42_NOPS, which
* is one greater than the highest Op#.
*/
#define NFSPROC_NOOP NFSV42_NOPS
/*
* Constants used by the Version 3 and 4 protocols for various RPCs
*/
#define NFSV3SATTRTIME_DONTCHANGE 0
#define NFSV3SATTRTIME_TOSERVER 1
#define NFSV3SATTRTIME_TOCLIENT 2
/*
* Here are the mappings between mode bits and acl mask bits for
* directories and other files.
* (Named attributes have not been included, since named attributes are
* not yet supported.)
* The mailing list seems to indicate that NFSV4ACE_EXECUTE refers to
* searching a directory, although I can't find a statement of that in
* the RFC.
*/
#define NFSV4ACE_ALLFILESMASK (NFSV4ACE_READATTRIBUTES | NFSV4ACE_READACL)
#define NFSV4ACE_OWNERMASK (NFSV4ACE_WRITEATTRIBUTES | NFSV4ACE_WRITEACL)
#define NFSV4ACE_DIRREADMASK NFSV4ACE_LISTDIRECTORY
#define NFSV4ACE_DIREXECUTEMASK NFSV4ACE_EXECUTE
#define NFSV4ACE_DIRWRITEMASK (NFSV4ACE_ADDFILE | \
NFSV4ACE_ADDSUBDIRECTORY | NFSV4ACE_DELETECHILD)
#define NFSV4ACE_READMASK NFSV4ACE_READDATA
#define NFSV4ACE_WRITEMASK (NFSV4ACE_WRITEDATA | NFSV4ACE_APPENDDATA)
#define NFSV4ACE_EXECUTEMASK NFSV4ACE_EXECUTE
#define NFSV4ACE_ALLFILEBITS (NFSV4ACE_READMASK | NFSV4ACE_WRITEMASK | \
NFSV4ACE_EXECUTEMASK | NFSV4ACE_SYNCHRONIZE)
#define NFSV4ACE_ALLDIRBITS (NFSV4ACE_DIRREADMASK | \
NFSV4ACE_DIRWRITEMASK | NFSV4ACE_DIREXECUTEMASK)
#define NFSV4ACE_AUDITMASK 0x0
/*
* These GENERIC masks are not used and are no longer believed to be useful.
*/
#define NFSV4ACE_GENERICREAD 0x00120081
#define NFSV4ACE_GENERICWRITE 0x00160106
#define NFSV4ACE_GENERICEXECUTE 0x001200a0
/*
* Maximum size of V4 opaque strings.
*/
#define NFSV4_OPAQUELIMIT 1024
/*
* These are the same for V3 and V4.
*/
#define NFSACCESS_READ 0x01
#define NFSACCESS_LOOKUP 0x02
#define NFSACCESS_MODIFY 0x04
#define NFSACCESS_EXTEND 0x08
#define NFSACCESS_DELETE 0x10
#define NFSACCESS_EXECUTE 0x20
/*
* Quads are defined as arrays of 2 longs to ensure dense packing for the
* protocol and to facilitate xdr conversion.
*/
struct nfs_uquad {
u_int32_t nfsuquad[2];
};
typedef struct nfs_uquad nfsuint64;
/*
* Used to convert between two u_longs and a u_quad_t.
*/
union nfs_quadconvert {
u_int32_t lval[2];
u_quad_t qval;
};
typedef union nfs_quadconvert nfsquad_t;
/*
* File attributes and setable attributes. These structures cover both
* NFS version 2 and the version 3 protocol. Note that the union is only
* used so that one pointer can refer to both variants. These structures
* go out on the wire and must be densely packed, so no quad data types
* are used. (all fields are longs or u_longs or structures of same)
* NB: You can't do sizeof(struct nfs_fattr), you must use the
* NFSX_FATTR(v3) macro.
*/
struct nfs_fattr {
u_int32_t fa_type;
u_int32_t fa_mode;
u_int32_t fa_nlink;
u_int32_t fa_uid;
u_int32_t fa_gid;
union {
struct {
u_int32_t nfsv2fa_size;
u_int32_t nfsv2fa_blocksize;
u_int32_t nfsv2fa_rdev;
u_int32_t nfsv2fa_blocks;
u_int32_t nfsv2fa_fsid;
u_int32_t nfsv2fa_fileid;
nfstime2 nfsv2fa_atime;
nfstime2 nfsv2fa_mtime;
nfstime2 nfsv2fa_ctime;
} fa_nfsv2;
struct {
nfsuint64 nfsv3fa_size;
nfsuint64 nfsv3fa_used;
nfsv3spec nfsv3fa_rdev;
nfsuint64 nfsv3fa_fsid;
nfsuint64 nfsv3fa_fileid;
nfstime3 nfsv3fa_atime;
nfstime3 nfsv3fa_mtime;
nfstime3 nfsv3fa_ctime;
} fa_nfsv3;
} fa_un;
};
/*
* NFSATTRBIT_SUPPSETONLY is the OR of NFSATTRBIT_TIMEACCESSSET and
* NFSATTRBIT_TIMEMODIFYSET.
*/
#define NFSATTRBIT_SUPPSETONLY (NFSATTRBM_TIMEACCESSSET | \
NFSATTRBM_TIMEMODIFYSET)
/*
* Set of attributes that the getattr vnode op needs.
* OR of the following bits.
* NFSATTRBIT_GETATTR0 - bits 0<->31
*/
#define NFSATTRBIT_GETATTR0 \
(NFSATTRBM_SUPPORTEDATTRS | \
NFSATTRBM_TYPE | \
NFSATTRBM_CHANGE | \
NFSATTRBM_SIZE | \
NFSATTRBM_FSID | \
NFSATTRBM_FILEID | \
NFSATTRBM_MAXREAD)
/*
* Set of attributes that the wccattr operation op needs.
* OR of the following bits.
* NFSATTRBIT_WCCATTR0 - bits 0<->31
*/
#define NFSATTRBIT_WCCATTR0 0
/*
* Set of attributes supported by Referral vnodes.
*/
#define NFSATTRBIT_REFERRAL0 (NFSATTRBM_TYPE | NFSATTRBM_FSID | \
NFSATTRBM_RDATTRERROR | NFSATTRBM_FSLOCATIONS)
#define NFSATTRBIT_REFERRAL1 NFSATTRBM_MOUNTEDONFILEID
#define NFSATTRBIT_REFERRAL2 0
/*
* Structure for data handled by the statfs rpc. Since some fields are
* u_int64_t, this cannot be used for copying data on/off the wire, due
* to alignment concerns.
*/
struct nfsstatfs {
union {
struct {
u_int32_t nfsv2sf_tsize;
u_int32_t nfsv2sf_bsize;
u_int32_t nfsv2sf_blocks;
u_int32_t nfsv2sf_bfree;
u_int32_t nfsv2sf_bavail;
} sf_nfsv2;
struct {
u_int64_t nfsv3sf_tbytes;
u_int64_t nfsv3sf_fbytes;
u_int64_t nfsv3sf_abytes;
u_int64_t nfsv3sf_tfiles;
u_int64_t nfsv3sf_ffiles;
u_int64_t nfsv3sf_afiles;
u_int32_t nfsv3sf_invarsec;
} sf_nfsv3;
} sf_un;
};
/*
* Now defined using u_int64_t for the 64 bit field(s).
* (Cannot be used to move data on/off the wire, due to alignment concerns.)
*/
struct nfsfsinfo {
u_int32_t fs_rtmax;
u_int32_t fs_rtpref;
u_int32_t fs_rtmult;
u_int32_t fs_wtmax;
u_int32_t fs_wtpref;
u_int32_t fs_wtmult;
u_int32_t fs_dtpref;
u_int64_t fs_maxfilesize;
struct timespec fs_timedelta;
u_int32_t fs_properties;
};