160071Sps/* $FreeBSD$ */
238451Smsmith/*	$NetBSD: nfsv2.h,v 1.2 1996/02/26 23:05:23 gwr Exp $	*/
338451Smsmith
438451Smsmith/*
538451Smsmith * Copyright (c) 1989, 1993
638451Smsmith *	The Regents of the University of California.  All rights reserved.
738451Smsmith *
838451Smsmith * This code is derived from software contributed to Berkeley by
938451Smsmith * Rick Macklem at The University of Guelph.
1038451Smsmith *
1138451Smsmith * Redistribution and use in source and binary forms, with or without
1238451Smsmith * modification, are permitted provided that the following conditions
1338451Smsmith * are met:
1438451Smsmith * 1. Redistributions of source code must retain the above copyright
1538451Smsmith *    notice, this list of conditions and the following disclaimer.
1638451Smsmith * 2. Redistributions in binary form must reproduce the above copyright
1738451Smsmith *    notice, this list of conditions and the following disclaimer in the
1838451Smsmith *    documentation and/or other materials provided with the distribution.
1938451Smsmith * 4. Neither the name of the University nor the names of its contributors
2038451Smsmith *    may be used to endorse or promote products derived from this software
2138451Smsmith *    without specific prior written permission.
2238451Smsmith *
2338451Smsmith * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2438451Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2538451Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2638451Smsmith * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2738451Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2838451Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2938451Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3038451Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3138451Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3238451Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3338451Smsmith * SUCH DAMAGE.
3438451Smsmith *
3538451Smsmith *	@(#)nfsv2.h	8.1 (Berkeley) 6/10/93
3638451Smsmith */
3738451Smsmith
3838451Smsmith/*
3938451Smsmith * nfs definitions as per the version 2 specs
4038451Smsmith */
4138451Smsmith
4238451Smsmith/*
4338451Smsmith * Constants as defined in the Sun NFS Version 2 spec.
4438451Smsmith * "NFS: Network File System Protocol Specification" RFC1094
4538451Smsmith */
4638451Smsmith
4738451Smsmith#define NFS_PORT	2049
4838451Smsmith#define	NFS_PROG	100003
4938451Smsmith#define NFS_VER2	2
5038451Smsmith#define	NFS_MAXDGRAMDATA 8192
5138451Smsmith#define	NFS_MAXDATA	32768
5238451Smsmith#define	NFS_MAXPATHLEN	1024
5338451Smsmith#define	NFS_MAXNAMLEN	255
5438451Smsmith#define	NFS_FHSIZE	32
5538451Smsmith#define	NFS_MAXPKTHDR	404
5638451Smsmith#define NFS_MAXPACKET	(NFS_MAXPKTHDR+NFS_MAXDATA)
5738451Smsmith#define	NFS_MINPACKET	20
5838451Smsmith#define	NFS_FABLKSIZE	512	/* Size in bytes of a block wrt fa_blocks */
5959853Sps#define	NFS_READDIRSIZE	1024
6038451Smsmith
6138451Smsmith/* Stat numbers for rpc returns */
6238451Smsmith#define	NFS_OK		0
6338451Smsmith#define	NFSERR_PERM	1
6438451Smsmith#define	NFSERR_NOENT	2
6538451Smsmith#define	NFSERR_IO	5
6638451Smsmith#define	NFSERR_NXIO	6
6738451Smsmith#define	NFSERR_ACCES	13
6838451Smsmith#define	NFSERR_EXIST	17
6938451Smsmith#define	NFSERR_NODEV	19
7038451Smsmith#define	NFSERR_NOTDIR	20
7138451Smsmith#define	NFSERR_ISDIR	21
7238451Smsmith#define	NFSERR_FBIG	27
7338451Smsmith#define	NFSERR_NOSPC	28
7438451Smsmith#define	NFSERR_ROFS	30
7538451Smsmith#define	NFSERR_NAMETOL	63
7638451Smsmith#define	NFSERR_NOTEMPTY	66
7738451Smsmith#define	NFSERR_DQUOT	69
7838451Smsmith#define	NFSERR_STALE	70
7938451Smsmith#define	NFSERR_WFLUSH	99
8038451Smsmith
8138451Smsmith/* Sizes in bytes of various nfs rpc components */
8238451Smsmith#define	NFSX_FH		32
8338451Smsmith#define	NFSX_UNSIGNED	4
8438451Smsmith#define	NFSX_FATTR	68
8538451Smsmith#define	NFSX_SATTR	32
8638451Smsmith#define NFSX_STATFS	20
8738451Smsmith#define	NFSX_COOKIE	4
8838451Smsmith
8938451Smsmith/* nfs rpc procedure numbers */
9038451Smsmith#define	NFSPROC_NULL		0
9138451Smsmith#define	NFSPROC_GETATTR		1
9238451Smsmith#define	NFSPROC_SETATTR		2
9338451Smsmith#define	NFSPROC_NOOP		3
9438451Smsmith#define	NFSPROC_ROOT		NFSPROC_NOOP	/* Obsolete */
9538451Smsmith#define	NFSPROC_LOOKUP		4
9638451Smsmith#define	NFSPROC_READLINK	5
9738451Smsmith#define	NFSPROC_READ		6
9838451Smsmith#define	NFSPROC_WRITECACHE	NFSPROC_NOOP	/* Obsolete */
9938451Smsmith#define	NFSPROC_WRITE		8
10038451Smsmith#define	NFSPROC_CREATE		9
10138451Smsmith#define	NFSPROC_REMOVE		10
10238451Smsmith#define	NFSPROC_RENAME		11
10338451Smsmith#define	NFSPROC_LINK		12
10438451Smsmith#define	NFSPROC_SYMLINK		13
10538451Smsmith#define	NFSPROC_MKDIR		14
10638451Smsmith#define	NFSPROC_RMDIR		15
10738451Smsmith#define	NFSPROC_READDIR		16
10838451Smsmith#define	NFSPROC_STATFS		17
10938451Smsmith
11038451Smsmith#define	NFS_NPROCS		18
11138451Smsmith
11238451Smsmith
11338451Smsmith/* File types */
11438451Smsmithtypedef enum {
11538451Smsmith	NFNON=0,
11638451Smsmith	NFREG=1,
11738451Smsmith	NFDIR=2,
11838451Smsmith	NFBLK=3,
11938451Smsmith	NFCHR=4,
12038451Smsmith	NFLNK=5
12138451Smsmith} nfstype;
12238451Smsmith
12338451Smsmith/* Structs for common parts of the rpc's */
12438451Smsmithstruct nfsv2_time {
12538451Smsmith	n_long	nfs_sec;
12638451Smsmith	n_long	nfs_usec;
12738451Smsmith};
12838451Smsmith
12938451Smsmith/*
13038451Smsmith * File attributes and setable attributes.
13138451Smsmith */
13238451Smsmithstruct nfsv2_fattr {
13338451Smsmith	n_long	fa_type;
13438451Smsmith	n_long	fa_mode;
13538451Smsmith	n_long	fa_nlink;
13638451Smsmith	n_long	fa_uid;
13738451Smsmith	n_long	fa_gid;
13838451Smsmith	n_long	fa_size;
13938451Smsmith	n_long	fa_blocksize;
14038451Smsmith	n_long	fa_rdev;
14138451Smsmith	n_long	fa_blocks;
14238451Smsmith	n_long	fa_fsid;
14338451Smsmith	n_long	fa_fileid;
14438451Smsmith	struct nfsv2_time fa_atime;
14538451Smsmith	struct nfsv2_time fa_mtime;
14638451Smsmith	struct nfsv2_time fa_ctime;
14738451Smsmith};
14838451Smsmith
14938451Smsmithstruct nfsv2_sattr {
15038451Smsmith	n_long	sa_mode;
15138451Smsmith	n_long	sa_uid;
15238451Smsmith	n_long	sa_gid;
15338451Smsmith	n_long	sa_size;
15438451Smsmith	struct nfsv2_time sa_atime;
15538451Smsmith	struct nfsv2_time sa_mtime;
15638451Smsmith};
15738451Smsmith
15838451Smsmithstruct nfsv2_statfs {
15938451Smsmith	n_long	sf_tsize;
16038451Smsmith	n_long	sf_bsize;
16138451Smsmith	n_long	sf_blocks;
16238451Smsmith	n_long	sf_bfree;
16338451Smsmith	n_long	sf_bavail;
16438451Smsmith};
165