Home | History | Annotate | Line # | Download | only in server
      1  1.4  pgoyette /*	$NetBSD: nfs_nfsdsubs.c,v 1.4 2016/12/13 21:50:32 pgoyette Exp $	*/
      2  1.1  dholland /*-
      3  1.1  dholland  * Copyright (c) 1989, 1993
      4  1.1  dholland  *	The Regents of the University of California.  All rights reserved.
      5  1.1  dholland  *
      6  1.1  dholland  * This code is derived from software contributed to Berkeley by
      7  1.1  dholland  * Rick Macklem at The University of Guelph.
      8  1.1  dholland  *
      9  1.1  dholland  * Redistribution and use in source and binary forms, with or without
     10  1.1  dholland  * modification, are permitted provided that the following conditions
     11  1.1  dholland  * are met:
     12  1.1  dholland  * 1. Redistributions of source code must retain the above copyright
     13  1.1  dholland  *    notice, this list of conditions and the following disclaimer.
     14  1.1  dholland  * 2. Redistributions in binary form must reproduce the above copyright
     15  1.1  dholland  *    notice, this list of conditions and the following disclaimer in the
     16  1.1  dholland  *    documentation and/or other materials provided with the distribution.
     17  1.1  dholland  * 4. Neither the name of the University nor the names of its contributors
     18  1.1  dholland  *    may be used to endorse or promote products derived from this software
     19  1.1  dholland  *    without specific prior written permission.
     20  1.1  dholland  *
     21  1.1  dholland  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     22  1.1  dholland  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     23  1.1  dholland  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     24  1.1  dholland  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     25  1.1  dholland  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     26  1.1  dholland  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     27  1.1  dholland  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     28  1.1  dholland  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     29  1.1  dholland  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     30  1.1  dholland  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     31  1.1  dholland  * SUCH DAMAGE.
     32  1.1  dholland  *
     33  1.1  dholland  */
     34  1.1  dholland 
     35  1.1  dholland #include <sys/cdefs.h>
     36  1.3  pgoyette /* __FBSDID("FreeBSD: head/sys/fs/nfsserver/nfs_nfsdsubs.c 298523 2016-04-23 21:18:45Z rmacklem "); */
     37  1.4  pgoyette __RCSID("$NetBSD: nfs_nfsdsubs.c,v 1.4 2016/12/13 21:50:32 pgoyette Exp $");
     38  1.1  dholland 
     39  1.1  dholland #ifndef APPLEKEXT
     40  1.4  pgoyette 
     41  1.4  pgoyette #ifdef _KERNEL_OPT
     42  1.4  pgoyette #include "opt_newnfs.h"
     43  1.4  pgoyette #endif
     44  1.4  pgoyette 
     45  1.1  dholland /*
     46  1.1  dholland  * These functions support the macros and help fiddle mbuf chains for
     47  1.1  dholland  * the nfs op functions. They do things like create the rpc header and
     48  1.1  dholland  * copy data between mbuf chains and uio lists.
     49  1.1  dholland  */
     50  1.4  pgoyette #include <fs/nfs/common/nfsport.h>
     51  1.1  dholland 
     52  1.1  dholland extern u_int32_t newnfs_true, newnfs_false;
     53  1.1  dholland extern int nfs_pubfhset;
     54  1.3  pgoyette extern struct nfsclienthashhead *nfsclienthash;
     55  1.3  pgoyette extern int nfsrv_clienthashsize;
     56  1.3  pgoyette extern struct nfslockhashhead *nfslockhash;
     57  1.3  pgoyette extern int nfsrv_lockhashsize;
     58  1.3  pgoyette extern struct nfssessionhash *nfssessionhash;
     59  1.3  pgoyette extern int nfsrv_sessionhashsize;
     60  1.1  dholland extern int nfsrv_useacl;
     61  1.1  dholland extern uid_t nfsrv_defaultuid;
     62  1.1  dholland extern gid_t nfsrv_defaultgid;
     63  1.1  dholland 
     64  1.1  dholland char nfs_v2pubfh[NFSX_V2FH];
     65  1.1  dholland static nfstype newnfsv2_type[9] = { NFNON, NFREG, NFDIR, NFBLK, NFCHR, NFLNK,
     66  1.1  dholland     NFNON, NFCHR, NFNON };
     67  1.1  dholland extern nfstype nfsv34_type[9];
     68  1.1  dholland #endif	/* !APPLEKEXT */
     69  1.1  dholland 
     70  1.3  pgoyette static u_int32_t nfsrv_isannfserr(u_int32_t);
     71  1.3  pgoyette 
     72  1.1  dholland SYSCTL_DECL(_vfs_nfsd);
     73  1.1  dholland 
     74  1.3  pgoyette static int	enable_checkutf8 = 1;
     75  1.3  pgoyette SYSCTL_INT(_vfs_nfsd, OID_AUTO, enable_checkutf8, CTLFLAG_RW,
     76  1.3  pgoyette     &enable_checkutf8, 0,
     77  1.3  pgoyette     "Enable the NFSv4 check for the UTF8 compliant name required by rfc3530");
     78  1.3  pgoyette 
     79  1.3  pgoyette static int    enable_nobodycheck = 1;
     80  1.3  pgoyette SYSCTL_INT(_vfs_nfsd, OID_AUTO, enable_nobodycheck, CTLFLAG_RW,
     81  1.3  pgoyette     &enable_nobodycheck, 0,
     82  1.3  pgoyette     "Enable the NFSv4 check when setting user nobody as owner");
     83  1.3  pgoyette 
     84  1.3  pgoyette static int    enable_nogroupcheck = 1;
     85  1.3  pgoyette SYSCTL_INT(_vfs_nfsd, OID_AUTO, enable_nogroupcheck, CTLFLAG_RW,
     86  1.3  pgoyette     &enable_nogroupcheck, 0,
     87  1.3  pgoyette     "Enable the NFSv4 check when setting group nogroup as owner");
     88  1.1  dholland 
     89  1.1  dholland static char nfsrv_hexdigit(char, int *);
     90  1.1  dholland 
     91  1.1  dholland /*
     92  1.1  dholland  * Maps errno values to nfs error numbers.
     93  1.1  dholland  * Use NFSERR_IO as the catch all for ones not specifically defined in
     94  1.3  pgoyette  * RFC 1094. (It now includes the errors added for NFSv3.)
     95  1.1  dholland  */
     96  1.3  pgoyette static u_char nfsrv_v2errmap[NFSERR_REMOTE] = {
     97  1.1  dholland   NFSERR_PERM,	NFSERR_NOENT,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,
     98  1.1  dholland   NFSERR_NXIO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,
     99  1.1  dholland   NFSERR_IO,	NFSERR_IO,	NFSERR_ACCES,	NFSERR_IO,	NFSERR_IO,
    100  1.3  pgoyette   NFSERR_IO,	NFSERR_EXIST,	NFSERR_XDEV,	NFSERR_NODEV,	NFSERR_NOTDIR,
    101  1.3  pgoyette   NFSERR_ISDIR,	NFSERR_INVAL,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,
    102  1.1  dholland   NFSERR_IO,	NFSERR_FBIG,	NFSERR_NOSPC,	NFSERR_IO,	NFSERR_ROFS,
    103  1.3  pgoyette   NFSERR_MLINK,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,
    104  1.1  dholland   NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,
    105  1.1  dholland   NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,
    106  1.1  dholland   NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,
    107  1.1  dholland   NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,
    108  1.1  dholland   NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,
    109  1.1  dholland   NFSERR_IO,	NFSERR_IO,	NFSERR_NAMETOL,	NFSERR_IO,	NFSERR_IO,
    110  1.1  dholland   NFSERR_NOTEMPTY, NFSERR_IO,	NFSERR_IO,	NFSERR_DQUOT,	NFSERR_STALE,
    111  1.3  pgoyette   NFSERR_REMOTE,
    112  1.1  dholland };
    113  1.1  dholland 
    114  1.1  dholland /*
    115  1.1  dholland  * Maps errno values to nfs error numbers.
    116  1.1  dholland  * Although it is not obvious whether or not NFS clients really care if
    117  1.1  dholland  * a returned error value is in the specified list for the procedure, the
    118  1.1  dholland  * safest thing to do is filter them appropriately. For Version 2, the
    119  1.1  dholland  * X/Open XNFS document is the only specification that defines error values
    120  1.1  dholland  * for each RPC (The RFC simply lists all possible error values for all RPCs),
    121  1.1  dholland  * so I have decided to not do this for Version 2.
    122  1.1  dholland  * The first entry is the default error return and the rest are the valid
    123  1.1  dholland  * errors for that RPC in increasing numeric order.
    124  1.1  dholland  */
    125  1.1  dholland static short nfsv3err_null[] = {
    126  1.1  dholland 	0,
    127  1.1  dholland 	0,
    128  1.1  dholland };
    129  1.1  dholland 
    130  1.1  dholland static short nfsv3err_getattr[] = {
    131  1.1  dholland 	NFSERR_IO,
    132  1.1  dholland 	NFSERR_IO,
    133  1.1  dholland 	NFSERR_STALE,
    134  1.1  dholland 	NFSERR_BADHANDLE,
    135  1.1  dholland 	NFSERR_SERVERFAULT,
    136  1.1  dholland 	NFSERR_DELAY,
    137  1.1  dholland 	0,
    138  1.1  dholland };
    139  1.1  dholland 
    140  1.1  dholland static short nfsv3err_setattr[] = {
    141  1.1  dholland 	NFSERR_IO,
    142  1.1  dholland 	NFSERR_ACCES,
    143  1.1  dholland 	NFSERR_PERM,
    144  1.1  dholland 	NFSERR_IO,
    145  1.1  dholland 	NFSERR_INVAL,
    146  1.1  dholland 	NFSERR_NOSPC,
    147  1.1  dholland 	NFSERR_ROFS,
    148  1.1  dholland 	NFSERR_DQUOT,
    149  1.1  dholland 	NFSERR_STALE,
    150  1.1  dholland 	NFSERR_BADHANDLE,
    151  1.1  dholland 	NFSERR_NOT_SYNC,
    152  1.1  dholland 	NFSERR_SERVERFAULT,
    153  1.1  dholland 	NFSERR_DELAY,
    154  1.1  dholland 	0,
    155  1.1  dholland };
    156  1.1  dholland 
    157  1.1  dholland static short nfsv3err_lookup[] = {
    158  1.1  dholland 	NFSERR_IO,
    159  1.1  dholland 	NFSERR_NOENT,
    160  1.1  dholland 	NFSERR_ACCES,
    161  1.1  dholland 	NFSERR_NAMETOL,
    162  1.1  dholland 	NFSERR_IO,
    163  1.1  dholland 	NFSERR_NOTDIR,
    164  1.1  dholland 	NFSERR_STALE,
    165  1.1  dholland 	NFSERR_BADHANDLE,
    166  1.1  dholland 	NFSERR_SERVERFAULT,
    167  1.1  dholland 	NFSERR_DELAY,
    168  1.1  dholland 	0,
    169  1.1  dholland };
    170  1.1  dholland 
    171  1.1  dholland static short nfsv3err_access[] = {
    172  1.1  dholland 	NFSERR_IO,
    173  1.1  dholland 	NFSERR_IO,
    174  1.1  dholland 	NFSERR_STALE,
    175  1.1  dholland 	NFSERR_BADHANDLE,
    176  1.1  dholland 	NFSERR_SERVERFAULT,
    177  1.1  dholland 	NFSERR_DELAY,
    178  1.1  dholland 	0,
    179  1.1  dholland };
    180  1.1  dholland 
    181  1.1  dholland static short nfsv3err_readlink[] = {
    182  1.1  dholland 	NFSERR_IO,
    183  1.1  dholland 	NFSERR_IO,
    184  1.1  dholland 	NFSERR_ACCES,
    185  1.1  dholland 	NFSERR_INVAL,
    186  1.1  dholland 	NFSERR_STALE,
    187  1.1  dholland 	NFSERR_BADHANDLE,
    188  1.1  dholland 	NFSERR_NOTSUPP,
    189  1.1  dholland 	NFSERR_SERVERFAULT,
    190  1.1  dholland 	NFSERR_DELAY,
    191  1.1  dholland 	0,
    192  1.1  dholland };
    193  1.1  dholland 
    194  1.1  dholland static short nfsv3err_read[] = {
    195  1.1  dholland 	NFSERR_IO,
    196  1.1  dholland 	NFSERR_IO,
    197  1.1  dholland 	NFSERR_NXIO,
    198  1.1  dholland 	NFSERR_ACCES,
    199  1.1  dholland 	NFSERR_INVAL,
    200  1.1  dholland 	NFSERR_STALE,
    201  1.1  dholland 	NFSERR_BADHANDLE,
    202  1.1  dholland 	NFSERR_SERVERFAULT,
    203  1.1  dholland 	NFSERR_DELAY,
    204  1.1  dholland 	0,
    205  1.1  dholland };
    206  1.1  dholland 
    207  1.1  dholland static short nfsv3err_write[] = {
    208  1.1  dholland 	NFSERR_IO,
    209  1.1  dholland 	NFSERR_IO,
    210  1.1  dholland 	NFSERR_ACCES,
    211  1.1  dholland 	NFSERR_NOSPC,
    212  1.1  dholland 	NFSERR_INVAL,
    213  1.1  dholland 	NFSERR_FBIG,
    214  1.1  dholland 	NFSERR_ROFS,
    215  1.1  dholland 	NFSERR_DQUOT,
    216  1.1  dholland 	NFSERR_STALE,
    217  1.1  dholland 	NFSERR_BADHANDLE,
    218  1.1  dholland 	NFSERR_SERVERFAULT,
    219  1.1  dholland 	NFSERR_DELAY,
    220  1.1  dholland 	0,
    221  1.1  dholland };
    222  1.1  dholland 
    223  1.1  dholland static short nfsv3err_create[] = {
    224  1.1  dholland 	NFSERR_IO,
    225  1.1  dholland 	NFSERR_EXIST,
    226  1.1  dholland 	NFSERR_NAMETOL,
    227  1.1  dholland 	NFSERR_ACCES,
    228  1.1  dholland 	NFSERR_IO,
    229  1.1  dholland 	NFSERR_NOTDIR,
    230  1.1  dholland 	NFSERR_NOSPC,
    231  1.1  dholland 	NFSERR_ROFS,
    232  1.1  dholland 	NFSERR_DQUOT,
    233  1.1  dholland 	NFSERR_STALE,
    234  1.1  dholland 	NFSERR_BADHANDLE,
    235  1.1  dholland 	NFSERR_NOTSUPP,
    236  1.1  dholland 	NFSERR_SERVERFAULT,
    237  1.1  dholland 	NFSERR_DELAY,
    238  1.1  dholland 	0,
    239  1.1  dholland };
    240  1.1  dholland 
    241  1.1  dholland static short nfsv3err_mkdir[] = {
    242  1.1  dholland 	NFSERR_IO,
    243  1.1  dholland 	NFSERR_EXIST,
    244  1.1  dholland 	NFSERR_ACCES,
    245  1.1  dholland 	NFSERR_NAMETOL,
    246  1.1  dholland 	NFSERR_IO,
    247  1.1  dholland 	NFSERR_NOTDIR,
    248  1.1  dholland 	NFSERR_NOSPC,
    249  1.1  dholland 	NFSERR_ROFS,
    250  1.1  dholland 	NFSERR_DQUOT,
    251  1.1  dholland 	NFSERR_STALE,
    252  1.1  dholland 	NFSERR_BADHANDLE,
    253  1.1  dholland 	NFSERR_NOTSUPP,
    254  1.1  dholland 	NFSERR_SERVERFAULT,
    255  1.1  dholland 	NFSERR_DELAY,
    256  1.1  dholland 	0,
    257  1.1  dholland };
    258  1.1  dholland 
    259  1.1  dholland static short nfsv3err_symlink[] = {
    260  1.1  dholland 	NFSERR_IO,
    261  1.1  dholland 	NFSERR_ACCES,
    262  1.1  dholland 	NFSERR_EXIST,
    263  1.1  dholland 	NFSERR_NAMETOL,
    264  1.1  dholland 	NFSERR_NOSPC,
    265  1.1  dholland 	NFSERR_IO,
    266  1.1  dholland 	NFSERR_NOTDIR,
    267  1.1  dholland 	NFSERR_ROFS,
    268  1.1  dholland 	NFSERR_DQUOT,
    269  1.1  dholland 	NFSERR_STALE,
    270  1.1  dholland 	NFSERR_BADHANDLE,
    271  1.1  dholland 	NFSERR_NOTSUPP,
    272  1.1  dholland 	NFSERR_SERVERFAULT,
    273  1.1  dholland 	NFSERR_DELAY,
    274  1.1  dholland 	0,
    275  1.1  dholland };
    276  1.1  dholland 
    277  1.1  dholland static short nfsv3err_mknod[] = {
    278  1.1  dholland 	NFSERR_IO,
    279  1.1  dholland 	NFSERR_ACCES,
    280  1.1  dholland 	NFSERR_EXIST,
    281  1.1  dholland 	NFSERR_NAMETOL,
    282  1.1  dholland 	NFSERR_NOSPC,
    283  1.1  dholland 	NFSERR_IO,
    284  1.1  dholland 	NFSERR_NOTDIR,
    285  1.1  dholland 	NFSERR_ROFS,
    286  1.1  dholland 	NFSERR_DQUOT,
    287  1.1  dholland 	NFSERR_STALE,
    288  1.1  dholland 	NFSERR_BADHANDLE,
    289  1.1  dholland 	NFSERR_NOTSUPP,
    290  1.1  dholland 	NFSERR_SERVERFAULT,
    291  1.1  dholland 	NFSERR_DELAY,
    292  1.1  dholland 	NFSERR_BADTYPE,
    293  1.1  dholland 	0,
    294  1.1  dholland };
    295  1.1  dholland 
    296  1.1  dholland static short nfsv3err_remove[] = {
    297  1.1  dholland 	NFSERR_IO,
    298  1.1  dholland 	NFSERR_NOENT,
    299  1.1  dholland 	NFSERR_ACCES,
    300  1.1  dholland 	NFSERR_NAMETOL,
    301  1.1  dholland 	NFSERR_IO,
    302  1.1  dholland 	NFSERR_NOTDIR,
    303  1.1  dholland 	NFSERR_ROFS,
    304  1.1  dholland 	NFSERR_STALE,
    305  1.1  dholland 	NFSERR_BADHANDLE,
    306  1.1  dholland 	NFSERR_SERVERFAULT,
    307  1.1  dholland 	NFSERR_DELAY,
    308  1.1  dholland 	0,
    309  1.1  dholland };
    310  1.1  dholland 
    311  1.1  dholland static short nfsv3err_rmdir[] = {
    312  1.1  dholland 	NFSERR_IO,
    313  1.1  dholland 	NFSERR_NOENT,
    314  1.1  dholland 	NFSERR_ACCES,
    315  1.1  dholland 	NFSERR_NOTDIR,
    316  1.1  dholland 	NFSERR_NAMETOL,
    317  1.1  dholland 	NFSERR_IO,
    318  1.1  dholland 	NFSERR_EXIST,
    319  1.1  dholland 	NFSERR_INVAL,
    320  1.1  dholland 	NFSERR_ROFS,
    321  1.1  dholland 	NFSERR_NOTEMPTY,
    322  1.1  dholland 	NFSERR_STALE,
    323  1.1  dholland 	NFSERR_BADHANDLE,
    324  1.1  dholland 	NFSERR_NOTSUPP,
    325  1.1  dholland 	NFSERR_SERVERFAULT,
    326  1.1  dholland 	NFSERR_DELAY,
    327  1.1  dholland 	0,
    328  1.1  dholland };
    329  1.1  dholland 
    330  1.1  dholland static short nfsv3err_rename[] = {
    331  1.1  dholland 	NFSERR_IO,
    332  1.1  dholland 	NFSERR_NOENT,
    333  1.1  dholland 	NFSERR_ACCES,
    334  1.1  dholland 	NFSERR_EXIST,
    335  1.1  dholland 	NFSERR_NAMETOL,
    336  1.1  dholland 	NFSERR_XDEV,
    337  1.1  dholland 	NFSERR_IO,
    338  1.1  dholland 	NFSERR_NOTDIR,
    339  1.1  dholland 	NFSERR_ISDIR,
    340  1.1  dholland 	NFSERR_INVAL,
    341  1.1  dholland 	NFSERR_NOSPC,
    342  1.1  dholland 	NFSERR_ROFS,
    343  1.1  dholland 	NFSERR_MLINK,
    344  1.1  dholland 	NFSERR_NOTEMPTY,
    345  1.1  dholland 	NFSERR_DQUOT,
    346  1.1  dholland 	NFSERR_STALE,
    347  1.1  dholland 	NFSERR_BADHANDLE,
    348  1.1  dholland 	NFSERR_NOTSUPP,
    349  1.1  dholland 	NFSERR_SERVERFAULT,
    350  1.1  dholland 	NFSERR_DELAY,
    351  1.1  dholland 	0,
    352  1.1  dholland };
    353  1.1  dholland 
    354  1.1  dholland static short nfsv3err_link[] = {
    355  1.1  dholland 	NFSERR_IO,
    356  1.1  dholland 	NFSERR_ACCES,
    357  1.1  dholland 	NFSERR_EXIST,
    358  1.1  dholland 	NFSERR_NAMETOL,
    359  1.1  dholland 	NFSERR_IO,
    360  1.1  dholland 	NFSERR_XDEV,
    361  1.1  dholland 	NFSERR_NOTDIR,
    362  1.1  dholland 	NFSERR_INVAL,
    363  1.1  dholland 	NFSERR_NOSPC,
    364  1.1  dholland 	NFSERR_ROFS,
    365  1.1  dholland 	NFSERR_MLINK,
    366  1.1  dholland 	NFSERR_DQUOT,
    367  1.1  dholland 	NFSERR_STALE,
    368  1.1  dholland 	NFSERR_BADHANDLE,
    369  1.1  dholland 	NFSERR_NOTSUPP,
    370  1.1  dholland 	NFSERR_SERVERFAULT,
    371  1.1  dholland 	NFSERR_DELAY,
    372  1.1  dholland 	0,
    373  1.1  dholland };
    374  1.1  dholland 
    375  1.1  dholland static short nfsv3err_readdir[] = {
    376  1.1  dholland 	NFSERR_IO,
    377  1.1  dholland 	NFSERR_ACCES,
    378  1.1  dholland 	NFSERR_NOTDIR,
    379  1.1  dholland 	NFSERR_IO,
    380  1.1  dholland 	NFSERR_STALE,
    381  1.1  dholland 	NFSERR_BADHANDLE,
    382  1.1  dholland 	NFSERR_BAD_COOKIE,
    383  1.1  dholland 	NFSERR_TOOSMALL,
    384  1.1  dholland 	NFSERR_SERVERFAULT,
    385  1.1  dholland 	NFSERR_DELAY,
    386  1.1  dholland 	0,
    387  1.1  dholland };
    388  1.1  dholland 
    389  1.1  dholland static short nfsv3err_readdirplus[] = {
    390  1.1  dholland 	NFSERR_IO,
    391  1.1  dholland 	NFSERR_ACCES,
    392  1.1  dholland 	NFSERR_NOTDIR,
    393  1.1  dholland 	NFSERR_IO,
    394  1.1  dholland 	NFSERR_STALE,
    395  1.1  dholland 	NFSERR_BADHANDLE,
    396  1.1  dholland 	NFSERR_BAD_COOKIE,
    397  1.1  dholland 	NFSERR_NOTSUPP,
    398  1.1  dholland 	NFSERR_TOOSMALL,
    399  1.1  dholland 	NFSERR_SERVERFAULT,
    400  1.1  dholland 	NFSERR_DELAY,
    401  1.1  dholland 	0,
    402  1.1  dholland };
    403  1.1  dholland 
    404  1.1  dholland static short nfsv3err_fsstat[] = {
    405  1.1  dholland 	NFSERR_IO,
    406  1.1  dholland 	NFSERR_IO,
    407  1.1  dholland 	NFSERR_STALE,
    408  1.1  dholland 	NFSERR_BADHANDLE,
    409  1.1  dholland 	NFSERR_SERVERFAULT,
    410  1.1  dholland 	NFSERR_DELAY,
    411  1.1  dholland 	0,
    412  1.1  dholland };
    413  1.1  dholland 
    414  1.1  dholland static short nfsv3err_fsinfo[] = {
    415  1.1  dholland 	NFSERR_STALE,
    416  1.1  dholland 	NFSERR_STALE,
    417  1.1  dholland 	NFSERR_BADHANDLE,
    418  1.1  dholland 	NFSERR_SERVERFAULT,
    419  1.1  dholland 	NFSERR_DELAY,
    420  1.1  dholland 	0,
    421  1.1  dholland };
    422  1.1  dholland 
    423  1.1  dholland static short nfsv3err_pathconf[] = {
    424  1.1  dholland 	NFSERR_STALE,
    425  1.1  dholland 	NFSERR_STALE,
    426  1.1  dholland 	NFSERR_BADHANDLE,
    427  1.1  dholland 	NFSERR_SERVERFAULT,
    428  1.1  dholland 	NFSERR_DELAY,
    429  1.1  dholland 	0,
    430  1.1  dholland };
    431  1.1  dholland 
    432  1.1  dholland static short nfsv3err_commit[] = {
    433  1.1  dholland 	NFSERR_IO,
    434  1.1  dholland 	NFSERR_IO,
    435  1.1  dholland 	NFSERR_STALE,
    436  1.1  dholland 	NFSERR_BADHANDLE,
    437  1.1  dholland 	NFSERR_SERVERFAULT,
    438  1.1  dholland 	NFSERR_DELAY,
    439  1.1  dholland 	0,
    440  1.1  dholland };
    441  1.1  dholland 
    442  1.1  dholland static short *nfsrv_v3errmap[] = {
    443  1.1  dholland 	nfsv3err_null,
    444  1.1  dholland 	nfsv3err_getattr,
    445  1.1  dholland 	nfsv3err_setattr,
    446  1.1  dholland 	nfsv3err_lookup,
    447  1.1  dholland 	nfsv3err_access,
    448  1.1  dholland 	nfsv3err_readlink,
    449  1.1  dholland 	nfsv3err_read,
    450  1.1  dholland 	nfsv3err_write,
    451  1.1  dholland 	nfsv3err_create,
    452  1.1  dholland 	nfsv3err_mkdir,
    453  1.1  dholland 	nfsv3err_symlink,
    454  1.1  dholland 	nfsv3err_mknod,
    455  1.1  dholland 	nfsv3err_remove,
    456  1.1  dholland 	nfsv3err_rmdir,
    457  1.1  dholland 	nfsv3err_rename,
    458  1.1  dholland 	nfsv3err_link,
    459  1.1  dholland 	nfsv3err_readdir,
    460  1.1  dholland 	nfsv3err_readdirplus,
    461  1.1  dholland 	nfsv3err_fsstat,
    462  1.1  dholland 	nfsv3err_fsinfo,
    463  1.1  dholland 	nfsv3err_pathconf,
    464  1.1  dholland 	nfsv3err_commit,
    465  1.1  dholland };
    466  1.1  dholland 
    467  1.1  dholland /*
    468  1.1  dholland  * And the same for V4.
    469  1.1  dholland  */
    470  1.1  dholland static short nfsv4err_null[] = {
    471  1.1  dholland 	0,
    472  1.1  dholland 	0,
    473  1.1  dholland };
    474  1.1  dholland 
    475  1.1  dholland static short nfsv4err_access[] = {
    476  1.1  dholland 	NFSERR_IO,
    477  1.1  dholland 	NFSERR_ACCES,
    478  1.1  dholland 	NFSERR_BADHANDLE,
    479  1.1  dholland 	NFSERR_BADXDR,
    480  1.1  dholland 	NFSERR_DELAY,
    481  1.1  dholland 	NFSERR_FHEXPIRED,
    482  1.1  dholland 	NFSERR_INVAL,
    483  1.1  dholland 	NFSERR_IO,
    484  1.1  dholland 	NFSERR_MOVED,
    485  1.1  dholland 	NFSERR_NOFILEHANDLE,
    486  1.1  dholland 	NFSERR_RESOURCE,
    487  1.1  dholland 	NFSERR_SERVERFAULT,
    488  1.1  dholland 	NFSERR_STALE,
    489  1.1  dholland 	0,
    490  1.1  dholland };
    491  1.1  dholland 
    492  1.1  dholland static short nfsv4err_close[] = {
    493  1.1  dholland 	NFSERR_EXPIRED,
    494  1.1  dholland 	NFSERR_ADMINREVOKED,
    495  1.1  dholland 	NFSERR_BADHANDLE,
    496  1.1  dholland 	NFSERR_BADSEQID,
    497  1.1  dholland 	NFSERR_BADSTATEID,
    498  1.1  dholland 	NFSERR_BADXDR,
    499  1.1  dholland 	NFSERR_DELAY,
    500  1.1  dholland 	NFSERR_EXPIRED,
    501  1.1  dholland 	NFSERR_FHEXPIRED,
    502  1.1  dholland 	NFSERR_INVAL,
    503  1.1  dholland 	NFSERR_ISDIR,
    504  1.1  dholland 	NFSERR_LEASEMOVED,
    505  1.1  dholland 	NFSERR_LOCKSHELD,
    506  1.1  dholland 	NFSERR_MOVED,
    507  1.1  dholland 	NFSERR_NOFILEHANDLE,
    508  1.1  dholland 	NFSERR_OLDSTATEID,
    509  1.1  dholland 	NFSERR_RESOURCE,
    510  1.1  dholland 	NFSERR_SERVERFAULT,
    511  1.1  dholland 	NFSERR_STALE,
    512  1.1  dholland 	NFSERR_STALESTATEID,
    513  1.1  dholland 	0,
    514  1.1  dholland };
    515  1.1  dholland 
    516  1.1  dholland static short nfsv4err_commit[] = {
    517  1.1  dholland 	NFSERR_IO,
    518  1.1  dholland 	NFSERR_ACCES,
    519  1.1  dholland 	NFSERR_BADHANDLE,
    520  1.1  dholland 	NFSERR_BADXDR,
    521  1.1  dholland 	NFSERR_FHEXPIRED,
    522  1.1  dholland 	NFSERR_INVAL,
    523  1.1  dholland 	NFSERR_IO,
    524  1.1  dholland 	NFSERR_ISDIR,
    525  1.1  dholland 	NFSERR_MOVED,
    526  1.1  dholland 	NFSERR_NOFILEHANDLE,
    527  1.1  dholland 	NFSERR_RESOURCE,
    528  1.1  dholland 	NFSERR_ROFS,
    529  1.1  dholland 	NFSERR_SERVERFAULT,
    530  1.1  dholland 	NFSERR_STALE,
    531  1.1  dholland 	0,
    532  1.1  dholland };
    533  1.1  dholland 
    534  1.1  dholland static short nfsv4err_create[] = {
    535  1.1  dholland 	NFSERR_IO,
    536  1.1  dholland 	NFSERR_ACCES,
    537  1.1  dholland 	NFSERR_ATTRNOTSUPP,
    538  1.1  dholland 	NFSERR_BADCHAR,
    539  1.1  dholland 	NFSERR_BADHANDLE,
    540  1.1  dholland 	NFSERR_BADNAME,
    541  1.1  dholland 	NFSERR_BADOWNER,
    542  1.1  dholland 	NFSERR_BADTYPE,
    543  1.1  dholland 	NFSERR_BADXDR,
    544  1.1  dholland 	NFSERR_DELAY,
    545  1.1  dholland 	NFSERR_DQUOT,
    546  1.1  dholland 	NFSERR_EXIST,
    547  1.1  dholland 	NFSERR_FHEXPIRED,
    548  1.1  dholland 	NFSERR_INVAL,
    549  1.1  dholland 	NFSERR_IO,
    550  1.1  dholland 	NFSERR_MOVED,
    551  1.1  dholland 	NFSERR_NAMETOL,
    552  1.1  dholland 	NFSERR_NOFILEHANDLE,
    553  1.1  dholland 	NFSERR_NOSPC,
    554  1.1  dholland 	NFSERR_NOTDIR,
    555  1.1  dholland 	NFSERR_PERM,
    556  1.1  dholland 	NFSERR_RESOURCE,
    557  1.1  dholland 	NFSERR_ROFS,
    558  1.1  dholland 	NFSERR_SERVERFAULT,
    559  1.1  dholland 	NFSERR_STALE,
    560  1.1  dholland 	0,
    561  1.1  dholland };
    562  1.1  dholland 
    563  1.1  dholland static short nfsv4err_delegpurge[] = {
    564  1.1  dholland 	NFSERR_SERVERFAULT,
    565  1.1  dholland 	NFSERR_BADXDR,
    566  1.1  dholland 	NFSERR_NOTSUPP,
    567  1.1  dholland 	NFSERR_LEASEMOVED,
    568  1.1  dholland 	NFSERR_MOVED,
    569  1.1  dholland 	NFSERR_RESOURCE,
    570  1.1  dholland 	NFSERR_SERVERFAULT,
    571  1.1  dholland 	NFSERR_STALECLIENTID,
    572  1.1  dholland 	0,
    573  1.1  dholland };
    574  1.1  dholland 
    575  1.1  dholland static short nfsv4err_delegreturn[] = {
    576  1.1  dholland 	NFSERR_SERVERFAULT,
    577  1.1  dholland 	NFSERR_ADMINREVOKED,
    578  1.1  dholland 	NFSERR_BADSTATEID,
    579  1.1  dholland 	NFSERR_BADXDR,
    580  1.1  dholland 	NFSERR_EXPIRED,
    581  1.1  dholland 	NFSERR_INVAL,
    582  1.1  dholland 	NFSERR_LEASEMOVED,
    583  1.1  dholland 	NFSERR_MOVED,
    584  1.1  dholland 	NFSERR_NOFILEHANDLE,
    585  1.1  dholland 	NFSERR_NOTSUPP,
    586  1.1  dholland 	NFSERR_OLDSTATEID,
    587  1.1  dholland 	NFSERR_RESOURCE,
    588  1.1  dholland 	NFSERR_SERVERFAULT,
    589  1.1  dholland 	NFSERR_STALE,
    590  1.1  dholland 	NFSERR_STALESTATEID,
    591  1.1  dholland 	0,
    592  1.1  dholland };
    593  1.1  dholland 
    594  1.1  dholland static short nfsv4err_getattr[] = {
    595  1.1  dholland 	NFSERR_IO,
    596  1.1  dholland 	NFSERR_ACCES,
    597  1.1  dholland 	NFSERR_BADHANDLE,
    598  1.1  dholland 	NFSERR_BADXDR,
    599  1.1  dholland 	NFSERR_DELAY,
    600  1.1  dholland 	NFSERR_FHEXPIRED,
    601  1.1  dholland 	NFSERR_INVAL,
    602  1.1  dholland 	NFSERR_IO,
    603  1.1  dholland 	NFSERR_MOVED,
    604  1.1  dholland 	NFSERR_NOFILEHANDLE,
    605  1.1  dholland 	NFSERR_RESOURCE,
    606  1.1  dholland 	NFSERR_SERVERFAULT,
    607  1.1  dholland 	NFSERR_STALE,
    608  1.1  dholland 	0,
    609  1.1  dholland };
    610  1.1  dholland 
    611  1.1  dholland static short nfsv4err_getfh[] = {
    612  1.1  dholland 	NFSERR_BADHANDLE,
    613  1.1  dholland 	NFSERR_BADHANDLE,
    614  1.1  dholland 	NFSERR_FHEXPIRED,
    615  1.1  dholland 	NFSERR_MOVED,
    616  1.1  dholland 	NFSERR_NOFILEHANDLE,
    617  1.1  dholland 	NFSERR_RESOURCE,
    618  1.1  dholland 	NFSERR_SERVERFAULT,
    619  1.1  dholland 	NFSERR_STALE,
    620  1.1  dholland 	0,
    621  1.1  dholland };
    622  1.1  dholland 
    623  1.1  dholland static short nfsv4err_link[] = {
    624  1.1  dholland 	NFSERR_IO,
    625  1.1  dholland 	NFSERR_ACCES,
    626  1.1  dholland 	NFSERR_BADCHAR,
    627  1.1  dholland 	NFSERR_BADHANDLE,
    628  1.1  dholland 	NFSERR_BADNAME,
    629  1.1  dholland 	NFSERR_BADXDR,
    630  1.1  dholland 	NFSERR_DELAY,
    631  1.1  dholland 	NFSERR_DQUOT,
    632  1.1  dholland 	NFSERR_EXIST,
    633  1.1  dholland 	NFSERR_FHEXPIRED,
    634  1.1  dholland 	NFSERR_FILEOPEN,
    635  1.1  dholland 	NFSERR_INVAL,
    636  1.1  dholland 	NFSERR_IO,
    637  1.1  dholland 	NFSERR_ISDIR,
    638  1.1  dholland 	NFSERR_MLINK,
    639  1.1  dholland 	NFSERR_MOVED,
    640  1.1  dholland 	NFSERR_NAMETOL,
    641  1.1  dholland 	NFSERR_NOENT,
    642  1.1  dholland 	NFSERR_NOFILEHANDLE,
    643  1.1  dholland 	NFSERR_NOSPC,
    644  1.1  dholland 	NFSERR_NOTDIR,
    645  1.1  dholland 	NFSERR_NOTSUPP,
    646  1.1  dholland 	NFSERR_RESOURCE,
    647  1.1  dholland 	NFSERR_ROFS,
    648  1.1  dholland 	NFSERR_SERVERFAULT,
    649  1.1  dholland 	NFSERR_STALE,
    650  1.1  dholland 	NFSERR_WRONGSEC,
    651  1.1  dholland 	NFSERR_XDEV,
    652  1.1  dholland 	0,
    653  1.1  dholland };
    654  1.1  dholland 
    655  1.1  dholland static short nfsv4err_lock[] = {
    656  1.1  dholland 	NFSERR_SERVERFAULT,
    657  1.1  dholland 	NFSERR_ACCES,
    658  1.1  dholland 	NFSERR_ADMINREVOKED,
    659  1.1  dholland 	NFSERR_BADHANDLE,
    660  1.1  dholland 	NFSERR_BADRANGE,
    661  1.1  dholland 	NFSERR_BADSEQID,
    662  1.1  dholland 	NFSERR_BADSTATEID,
    663  1.1  dholland 	NFSERR_BADXDR,
    664  1.1  dholland 	NFSERR_DEADLOCK,
    665  1.1  dholland 	NFSERR_DELAY,
    666  1.1  dholland 	NFSERR_DENIED,
    667  1.1  dholland 	NFSERR_EXPIRED,
    668  1.1  dholland 	NFSERR_FHEXPIRED,
    669  1.1  dholland 	NFSERR_GRACE,
    670  1.1  dholland 	NFSERR_INVAL,
    671  1.1  dholland 	NFSERR_ISDIR,
    672  1.1  dholland 	NFSERR_LEASEMOVED,
    673  1.1  dholland 	NFSERR_LOCKNOTSUPP,
    674  1.1  dholland 	NFSERR_LOCKRANGE,
    675  1.1  dholland 	NFSERR_MOVED,
    676  1.1  dholland 	NFSERR_NOFILEHANDLE,
    677  1.1  dholland 	NFSERR_NOGRACE,
    678  1.1  dholland 	NFSERR_OLDSTATEID,
    679  1.1  dholland 	NFSERR_OPENMODE,
    680  1.1  dholland 	NFSERR_RECLAIMBAD,
    681  1.1  dholland 	NFSERR_RECLAIMCONFLICT,
    682  1.1  dholland 	NFSERR_RESOURCE,
    683  1.1  dholland 	NFSERR_SERVERFAULT,
    684  1.1  dholland 	NFSERR_STALE,
    685  1.1  dholland 	NFSERR_STALECLIENTID,
    686  1.1  dholland 	NFSERR_STALESTATEID,
    687  1.1  dholland 	0,
    688  1.1  dholland };
    689  1.1  dholland 
    690  1.1  dholland static short nfsv4err_lockt[] = {
    691  1.1  dholland 	NFSERR_SERVERFAULT,
    692  1.1  dholland 	NFSERR_ACCES,
    693  1.1  dholland 	NFSERR_BADHANDLE,
    694  1.1  dholland 	NFSERR_BADRANGE,
    695  1.1  dholland 	NFSERR_BADXDR,
    696  1.1  dholland 	NFSERR_DELAY,
    697  1.1  dholland 	NFSERR_DENIED,
    698  1.1  dholland 	NFSERR_FHEXPIRED,
    699  1.1  dholland 	NFSERR_GRACE,
    700  1.1  dholland 	NFSERR_INVAL,
    701  1.1  dholland 	NFSERR_ISDIR,
    702  1.1  dholland 	NFSERR_LEASEMOVED,
    703  1.1  dholland 	NFSERR_LOCKRANGE,
    704  1.1  dholland 	NFSERR_MOVED,
    705  1.1  dholland 	NFSERR_NOFILEHANDLE,
    706  1.1  dholland 	NFSERR_RESOURCE,
    707  1.1  dholland 	NFSERR_SERVERFAULT,
    708  1.1  dholland 	NFSERR_STALE,
    709  1.1  dholland 	NFSERR_STALECLIENTID,
    710  1.1  dholland 	0,
    711  1.1  dholland };
    712  1.1  dholland 
    713  1.1  dholland static short nfsv4err_locku[] = {
    714  1.1  dholland 	NFSERR_SERVERFAULT,
    715  1.1  dholland 	NFSERR_ACCES,
    716  1.1  dholland 	NFSERR_ADMINREVOKED,
    717  1.1  dholland 	NFSERR_BADHANDLE,
    718  1.1  dholland 	NFSERR_BADRANGE,
    719  1.1  dholland 	NFSERR_BADSEQID,
    720  1.1  dholland 	NFSERR_BADSTATEID,
    721  1.1  dholland 	NFSERR_BADXDR,
    722  1.1  dholland 	NFSERR_EXPIRED,
    723  1.1  dholland 	NFSERR_FHEXPIRED,
    724  1.1  dholland 	NFSERR_GRACE,
    725  1.1  dholland 	NFSERR_INVAL,
    726  1.1  dholland 	NFSERR_ISDIR,
    727  1.1  dholland 	NFSERR_LEASEMOVED,
    728  1.1  dholland 	NFSERR_LOCKRANGE,
    729  1.1  dholland 	NFSERR_MOVED,
    730  1.1  dholland 	NFSERR_NOFILEHANDLE,
    731  1.1  dholland 	NFSERR_OLDSTATEID,
    732  1.1  dholland 	NFSERR_RESOURCE,
    733  1.1  dholland 	NFSERR_SERVERFAULT,
    734  1.1  dholland 	NFSERR_STALE,
    735  1.1  dholland 	NFSERR_STALESTATEID,
    736  1.1  dholland 	0,
    737  1.1  dholland };
    738  1.1  dholland 
    739  1.1  dholland static short nfsv4err_lookup[] = {
    740  1.1  dholland 	NFSERR_IO,
    741  1.1  dholland 	NFSERR_ACCES,
    742  1.1  dholland 	NFSERR_BADCHAR,
    743  1.1  dholland 	NFSERR_BADHANDLE,
    744  1.1  dholland 	NFSERR_BADNAME,
    745  1.1  dholland 	NFSERR_BADXDR,
    746  1.1  dholland 	NFSERR_FHEXPIRED,
    747  1.1  dholland 	NFSERR_INVAL,
    748  1.1  dholland 	NFSERR_IO,
    749  1.1  dholland 	NFSERR_MOVED,
    750  1.1  dholland 	NFSERR_NAMETOL,
    751  1.1  dholland 	NFSERR_NOENT,
    752  1.1  dholland 	NFSERR_NOFILEHANDLE,
    753  1.1  dholland 	NFSERR_NOTDIR,
    754  1.1  dholland 	NFSERR_RESOURCE,
    755  1.1  dholland 	NFSERR_SERVERFAULT,
    756  1.1  dholland 	NFSERR_STALE,
    757  1.1  dholland 	NFSERR_SYMLINK,
    758  1.1  dholland 	NFSERR_WRONGSEC,
    759  1.1  dholland 	0,
    760  1.1  dholland };
    761  1.1  dholland 
    762  1.1  dholland static short nfsv4err_lookupp[] = {
    763  1.1  dholland 	NFSERR_IO,
    764  1.1  dholland 	NFSERR_ACCES,
    765  1.1  dholland 	NFSERR_BADHANDLE,
    766  1.1  dholland 	NFSERR_FHEXPIRED,
    767  1.1  dholland 	NFSERR_IO,
    768  1.1  dholland 	NFSERR_MOVED,
    769  1.1  dholland 	NFSERR_NOENT,
    770  1.1  dholland 	NFSERR_NOFILEHANDLE,
    771  1.1  dholland 	NFSERR_NOTDIR,
    772  1.1  dholland 	NFSERR_RESOURCE,
    773  1.1  dholland 	NFSERR_SERVERFAULT,
    774  1.1  dholland 	NFSERR_STALE,
    775  1.1  dholland 	0,
    776  1.1  dholland };
    777  1.1  dholland 
    778  1.1  dholland static short nfsv4err_nverify[] = {
    779  1.1  dholland 	NFSERR_IO,
    780  1.1  dholland 	NFSERR_ACCES,
    781  1.1  dholland 	NFSERR_ATTRNOTSUPP,
    782  1.1  dholland 	NFSERR_BADCHAR,
    783  1.1  dholland 	NFSERR_BADHANDLE,
    784  1.1  dholland 	NFSERR_BADXDR,
    785  1.1  dholland 	NFSERR_DELAY,
    786  1.1  dholland 	NFSERR_FHEXPIRED,
    787  1.1  dholland 	NFSERR_INVAL,
    788  1.1  dholland 	NFSERR_IO,
    789  1.1  dholland 	NFSERR_MOVED,
    790  1.1  dholland 	NFSERR_NOFILEHANDLE,
    791  1.1  dholland 	NFSERR_RESOURCE,
    792  1.1  dholland 	NFSERR_SAME,
    793  1.1  dholland 	NFSERR_SERVERFAULT,
    794  1.1  dholland 	NFSERR_STALE,
    795  1.1  dholland 	0,
    796  1.1  dholland };
    797  1.1  dholland 
    798  1.1  dholland static short nfsv4err_open[] = {
    799  1.1  dholland 	NFSERR_IO,
    800  1.1  dholland 	NFSERR_ACCES,
    801  1.1  dholland 	NFSERR_ADMINREVOKED,
    802  1.1  dholland 	NFSERR_ATTRNOTSUPP,
    803  1.1  dholland 	NFSERR_BADCHAR,
    804  1.1  dholland 	NFSERR_BADHANDLE,
    805  1.1  dholland 	NFSERR_BADNAME,
    806  1.1  dholland 	NFSERR_BADOWNER,
    807  1.1  dholland 	NFSERR_BADSEQID,
    808  1.1  dholland 	NFSERR_BADXDR,
    809  1.1  dholland 	NFSERR_DELAY,
    810  1.1  dholland 	NFSERR_DQUOT,
    811  1.1  dholland 	NFSERR_EXIST,
    812  1.1  dholland 	NFSERR_EXPIRED,
    813  1.1  dholland 	NFSERR_FHEXPIRED,
    814  1.1  dholland 	NFSERR_GRACE,
    815  1.1  dholland 	NFSERR_IO,
    816  1.1  dholland 	NFSERR_INVAL,
    817  1.1  dholland 	NFSERR_ISDIR,
    818  1.1  dholland 	NFSERR_LEASEMOVED,
    819  1.1  dholland 	NFSERR_MOVED,
    820  1.1  dholland 	NFSERR_NAMETOL,
    821  1.1  dholland 	NFSERR_NOENT,
    822  1.1  dholland 	NFSERR_NOFILEHANDLE,
    823  1.1  dholland 	NFSERR_NOGRACE,
    824  1.1  dholland 	NFSERR_NOSPC,
    825  1.1  dholland 	NFSERR_NOTDIR,
    826  1.1  dholland 	NFSERR_NOTSUPP,
    827  1.1  dholland 	NFSERR_PERM,
    828  1.1  dholland 	NFSERR_RECLAIMBAD,
    829  1.1  dholland 	NFSERR_RECLAIMCONFLICT,
    830  1.1  dholland 	NFSERR_RESOURCE,
    831  1.1  dholland 	NFSERR_ROFS,
    832  1.1  dholland 	NFSERR_SERVERFAULT,
    833  1.1  dholland 	NFSERR_SHAREDENIED,
    834  1.1  dholland 	NFSERR_STALE,
    835  1.1  dholland 	NFSERR_STALECLIENTID,
    836  1.1  dholland 	NFSERR_SYMLINK,
    837  1.1  dholland 	NFSERR_WRONGSEC,
    838  1.1  dholland 	0,
    839  1.1  dholland };
    840  1.1  dholland 
    841  1.1  dholland static short nfsv4err_openattr[] = {
    842  1.1  dholland 	NFSERR_IO,
    843  1.1  dholland 	NFSERR_ACCES,
    844  1.1  dholland 	NFSERR_BADHANDLE,
    845  1.1  dholland 	NFSERR_BADXDR,
    846  1.1  dholland 	NFSERR_DELAY,
    847  1.1  dholland 	NFSERR_DQUOT,
    848  1.1  dholland 	NFSERR_FHEXPIRED,
    849  1.1  dholland 	NFSERR_IO,
    850  1.1  dholland 	NFSERR_MOVED,
    851  1.1  dholland 	NFSERR_NOENT,
    852  1.1  dholland 	NFSERR_NOFILEHANDLE,
    853  1.1  dholland 	NFSERR_NOSPC,
    854  1.1  dholland 	NFSERR_NOTSUPP,
    855  1.1  dholland 	NFSERR_RESOURCE,
    856  1.1  dholland 	NFSERR_ROFS,
    857  1.1  dholland 	NFSERR_SERVERFAULT,
    858  1.1  dholland 	NFSERR_STALE,
    859  1.1  dholland 	0,
    860  1.1  dholland };
    861  1.1  dholland 
    862  1.1  dholland static short nfsv4err_openconfirm[] = {
    863  1.1  dholland 	NFSERR_SERVERFAULT,
    864  1.1  dholland 	NFSERR_ADMINREVOKED,
    865  1.1  dholland 	NFSERR_BADHANDLE,
    866  1.1  dholland 	NFSERR_BADSEQID,
    867  1.1  dholland 	NFSERR_BADSTATEID,
    868  1.1  dholland 	NFSERR_BADXDR,
    869  1.1  dholland 	NFSERR_EXPIRED,
    870  1.1  dholland 	NFSERR_FHEXPIRED,
    871  1.1  dholland 	NFSERR_INVAL,
    872  1.1  dholland 	NFSERR_ISDIR,
    873  1.1  dholland 	NFSERR_MOVED,
    874  1.1  dholland 	NFSERR_NOFILEHANDLE,
    875  1.1  dholland 	NFSERR_OLDSTATEID,
    876  1.1  dholland 	NFSERR_RESOURCE,
    877  1.1  dholland 	NFSERR_SERVERFAULT,
    878  1.1  dholland 	NFSERR_STALE,
    879  1.1  dholland 	NFSERR_STALESTATEID,
    880  1.1  dholland 	0,
    881  1.1  dholland };
    882  1.1  dholland 
    883  1.1  dholland static short nfsv4err_opendowngrade[] = {
    884  1.1  dholland 	NFSERR_SERVERFAULT,
    885  1.1  dholland 	NFSERR_ADMINREVOKED,
    886  1.1  dholland 	NFSERR_BADHANDLE,
    887  1.1  dholland 	NFSERR_BADSEQID,
    888  1.1  dholland 	NFSERR_BADSTATEID,
    889  1.1  dholland 	NFSERR_BADXDR,
    890  1.1  dholland 	NFSERR_EXPIRED,
    891  1.1  dholland 	NFSERR_FHEXPIRED,
    892  1.1  dholland 	NFSERR_INVAL,
    893  1.1  dholland 	NFSERR_MOVED,
    894  1.1  dholland 	NFSERR_NOFILEHANDLE,
    895  1.1  dholland 	NFSERR_OLDSTATEID,
    896  1.1  dholland 	NFSERR_RESOURCE,
    897  1.1  dholland 	NFSERR_SERVERFAULT,
    898  1.1  dholland 	NFSERR_STALE,
    899  1.1  dholland 	NFSERR_STALESTATEID,
    900  1.1  dholland 	0,
    901  1.1  dholland };
    902  1.1  dholland 
    903  1.1  dholland static short nfsv4err_putfh[] = {
    904  1.1  dholland 	NFSERR_SERVERFAULT,
    905  1.1  dholland 	NFSERR_BADHANDLE,
    906  1.1  dholland 	NFSERR_BADXDR,
    907  1.1  dholland 	NFSERR_FHEXPIRED,
    908  1.1  dholland 	NFSERR_MOVED,
    909  1.1  dholland 	NFSERR_RESOURCE,
    910  1.1  dholland 	NFSERR_SERVERFAULT,
    911  1.1  dholland 	NFSERR_STALE,
    912  1.1  dholland 	NFSERR_WRONGSEC,
    913  1.1  dholland 	0,
    914  1.1  dholland };
    915  1.1  dholland 
    916  1.1  dholland static short nfsv4err_putpubfh[] = {
    917  1.1  dholland 	NFSERR_SERVERFAULT,
    918  1.1  dholland 	NFSERR_RESOURCE,
    919  1.1  dholland 	NFSERR_SERVERFAULT,
    920  1.1  dholland 	NFSERR_WRONGSEC,
    921  1.1  dholland 	0,
    922  1.1  dholland };
    923  1.1  dholland 
    924  1.1  dholland static short nfsv4err_putrootfh[] = {
    925  1.1  dholland 	NFSERR_SERVERFAULT,
    926  1.1  dholland 	NFSERR_RESOURCE,
    927  1.1  dholland 	NFSERR_SERVERFAULT,
    928  1.1  dholland 	NFSERR_WRONGSEC,
    929  1.1  dholland 	0,
    930  1.1  dholland };
    931  1.1  dholland 
    932  1.1  dholland static short nfsv4err_read[] = {
    933  1.1  dholland 	NFSERR_IO,
    934  1.1  dholland 	NFSERR_ACCES,
    935  1.1  dholland 	NFSERR_ADMINREVOKED,
    936  1.1  dholland 	NFSERR_BADHANDLE,
    937  1.1  dholland 	NFSERR_BADSTATEID,
    938  1.1  dholland 	NFSERR_BADXDR,
    939  1.1  dholland 	NFSERR_DELAY,
    940  1.1  dholland 	NFSERR_EXPIRED,
    941  1.1  dholland 	NFSERR_FHEXPIRED,
    942  1.1  dholland 	NFSERR_GRACE,
    943  1.1  dholland 	NFSERR_IO,
    944  1.1  dholland 	NFSERR_INVAL,
    945  1.1  dholland 	NFSERR_ISDIR,
    946  1.1  dholland 	NFSERR_LEASEMOVED,
    947  1.1  dholland 	NFSERR_LOCKED,
    948  1.1  dholland 	NFSERR_MOVED,
    949  1.1  dholland 	NFSERR_NOFILEHANDLE,
    950  1.1  dholland 	NFSERR_NXIO,
    951  1.1  dholland 	NFSERR_OLDSTATEID,
    952  1.1  dholland 	NFSERR_OPENMODE,
    953  1.1  dholland 	NFSERR_RESOURCE,
    954  1.1  dholland 	NFSERR_SERVERFAULT,
    955  1.1  dholland 	NFSERR_STALE,
    956  1.1  dholland 	NFSERR_STALESTATEID,
    957  1.1  dholland 	0,
    958  1.1  dholland };
    959  1.1  dholland 
    960  1.1  dholland static short nfsv4err_readdir[] = {
    961  1.1  dholland 	NFSERR_IO,
    962  1.1  dholland 	NFSERR_ACCES,
    963  1.1  dholland 	NFSERR_BADHANDLE,
    964  1.1  dholland 	NFSERR_BAD_COOKIE,
    965  1.1  dholland 	NFSERR_BADXDR,
    966  1.1  dholland 	NFSERR_DELAY,
    967  1.1  dholland 	NFSERR_FHEXPIRED,
    968  1.1  dholland 	NFSERR_INVAL,
    969  1.1  dholland 	NFSERR_IO,
    970  1.1  dholland 	NFSERR_MOVED,
    971  1.1  dholland 	NFSERR_NOFILEHANDLE,
    972  1.1  dholland 	NFSERR_NOTDIR,
    973  1.1  dholland 	NFSERR_NOTSAME,
    974  1.1  dholland 	NFSERR_RESOURCE,
    975  1.1  dholland 	NFSERR_SERVERFAULT,
    976  1.1  dholland 	NFSERR_STALE,
    977  1.1  dholland 	NFSERR_TOOSMALL,
    978  1.1  dholland 	0,
    979  1.1  dholland };
    980  1.1  dholland 
    981  1.1  dholland static short nfsv4err_readlink[] = {
    982  1.1  dholland 	NFSERR_IO,
    983  1.1  dholland 	NFSERR_ACCES,
    984  1.1  dholland 	NFSERR_BADHANDLE,
    985  1.1  dholland 	NFSERR_DELAY,
    986  1.1  dholland 	NFSERR_FHEXPIRED,
    987  1.1  dholland 	NFSERR_INVAL,
    988  1.1  dholland 	NFSERR_IO,
    989  1.1  dholland 	NFSERR_ISDIR,
    990  1.1  dholland 	NFSERR_MOVED,
    991  1.1  dholland 	NFSERR_NOFILEHANDLE,
    992  1.1  dholland 	NFSERR_NOTSUPP,
    993  1.1  dholland 	NFSERR_RESOURCE,
    994  1.1  dholland 	NFSERR_SERVERFAULT,
    995  1.1  dholland 	NFSERR_STALE,
    996  1.1  dholland 	0,
    997  1.1  dholland };
    998  1.1  dholland 
    999  1.1  dholland static short nfsv4err_remove[] = {
   1000  1.1  dholland 	NFSERR_IO,
   1001  1.1  dholland 	NFSERR_ACCES,
   1002  1.1  dholland 	NFSERR_BADCHAR,
   1003  1.1  dholland 	NFSERR_BADHANDLE,
   1004  1.1  dholland 	NFSERR_BADNAME,
   1005  1.1  dholland 	NFSERR_BADXDR,
   1006  1.1  dholland 	NFSERR_DELAY,
   1007  1.1  dholland 	NFSERR_FHEXPIRED,
   1008  1.1  dholland 	NFSERR_FILEOPEN,
   1009  1.1  dholland 	NFSERR_INVAL,
   1010  1.1  dholland 	NFSERR_IO,
   1011  1.1  dholland 	NFSERR_MOVED,
   1012  1.1  dholland 	NFSERR_NAMETOL,
   1013  1.1  dholland 	NFSERR_NOENT,
   1014  1.1  dholland 	NFSERR_NOFILEHANDLE,
   1015  1.1  dholland 	NFSERR_NOTDIR,
   1016  1.1  dholland 	NFSERR_NOTEMPTY,
   1017  1.1  dholland 	NFSERR_RESOURCE,
   1018  1.1  dholland 	NFSERR_ROFS,
   1019  1.1  dholland 	NFSERR_SERVERFAULT,
   1020  1.1  dholland 	NFSERR_STALE,
   1021  1.1  dholland 	0,
   1022  1.1  dholland };
   1023  1.1  dholland 
   1024  1.1  dholland static short nfsv4err_rename[] = {
   1025  1.1  dholland 	NFSERR_IO,
   1026  1.1  dholland 	NFSERR_ACCES,
   1027  1.1  dholland 	NFSERR_BADCHAR,
   1028  1.1  dholland 	NFSERR_BADHANDLE,
   1029  1.1  dholland 	NFSERR_BADNAME,
   1030  1.1  dholland 	NFSERR_BADXDR,
   1031  1.1  dholland 	NFSERR_DELAY,
   1032  1.1  dholland 	NFSERR_DQUOT,
   1033  1.1  dholland 	NFSERR_EXIST,
   1034  1.1  dholland 	NFSERR_FHEXPIRED,
   1035  1.1  dholland 	NFSERR_FILEOPEN,
   1036  1.1  dholland 	NFSERR_INVAL,
   1037  1.1  dholland 	NFSERR_IO,
   1038  1.1  dholland 	NFSERR_MOVED,
   1039  1.1  dholland 	NFSERR_NAMETOL,
   1040  1.1  dholland 	NFSERR_NOENT,
   1041  1.1  dholland 	NFSERR_NOFILEHANDLE,
   1042  1.1  dholland 	NFSERR_NOSPC,
   1043  1.1  dholland 	NFSERR_NOTDIR,
   1044  1.1  dholland 	NFSERR_NOTEMPTY,
   1045  1.1  dholland 	NFSERR_RESOURCE,
   1046  1.1  dholland 	NFSERR_ROFS,
   1047  1.1  dholland 	NFSERR_SERVERFAULT,
   1048  1.1  dholland 	NFSERR_STALE,
   1049  1.1  dholland 	NFSERR_WRONGSEC,
   1050  1.1  dholland 	NFSERR_XDEV,
   1051  1.1  dholland 	0,
   1052  1.1  dholland };
   1053  1.1  dholland 
   1054  1.1  dholland static short nfsv4err_renew[] = {
   1055  1.1  dholland 	NFSERR_SERVERFAULT,
   1056  1.1  dholland 	NFSERR_ACCES,
   1057  1.1  dholland 	NFSERR_ADMINREVOKED,
   1058  1.1  dholland 	NFSERR_BADXDR,
   1059  1.1  dholland 	NFSERR_CBPATHDOWN,
   1060  1.1  dholland 	NFSERR_EXPIRED,
   1061  1.1  dholland 	NFSERR_LEASEMOVED,
   1062  1.1  dholland 	NFSERR_RESOURCE,
   1063  1.1  dholland 	NFSERR_SERVERFAULT,
   1064  1.1  dholland 	NFSERR_STALECLIENTID,
   1065  1.1  dholland 	0,
   1066  1.1  dholland };
   1067  1.1  dholland 
   1068  1.1  dholland static short nfsv4err_restorefh[] = {
   1069  1.1  dholland 	NFSERR_SERVERFAULT,
   1070  1.1  dholland 	NFSERR_BADHANDLE,
   1071  1.1  dholland 	NFSERR_FHEXPIRED,
   1072  1.1  dholland 	NFSERR_MOVED,
   1073  1.1  dholland 	NFSERR_RESOURCE,
   1074  1.1  dholland 	NFSERR_RESTOREFH,
   1075  1.1  dholland 	NFSERR_SERVERFAULT,
   1076  1.1  dholland 	NFSERR_STALE,
   1077  1.1  dholland 	NFSERR_WRONGSEC,
   1078  1.1  dholland 	0,
   1079  1.1  dholland };
   1080  1.1  dholland 
   1081  1.1  dholland static short nfsv4err_savefh[] = {
   1082  1.1  dholland 	NFSERR_SERVERFAULT,
   1083  1.1  dholland 	NFSERR_BADHANDLE,
   1084  1.1  dholland 	NFSERR_FHEXPIRED,
   1085  1.1  dholland 	NFSERR_MOVED,
   1086  1.1  dholland 	NFSERR_NOFILEHANDLE,
   1087  1.1  dholland 	NFSERR_RESOURCE,
   1088  1.1  dholland 	NFSERR_SERVERFAULT,
   1089  1.1  dholland 	NFSERR_STALE,
   1090  1.1  dholland 	0,
   1091  1.1  dholland };
   1092  1.1  dholland 
   1093  1.1  dholland static short nfsv4err_secinfo[] = {
   1094  1.1  dholland 	NFSERR_SERVERFAULT,
   1095  1.1  dholland 	NFSERR_ACCES,
   1096  1.1  dholland 	NFSERR_BADCHAR,
   1097  1.1  dholland 	NFSERR_BADHANDLE,
   1098  1.1  dholland 	NFSERR_BADNAME,
   1099  1.1  dholland 	NFSERR_BADXDR,
   1100  1.1  dholland 	NFSERR_FHEXPIRED,
   1101  1.1  dholland 	NFSERR_INVAL,
   1102  1.1  dholland 	NFSERR_MOVED,
   1103  1.1  dholland 	NFSERR_NAMETOL,
   1104  1.1  dholland 	NFSERR_NOENT,
   1105  1.1  dholland 	NFSERR_NOFILEHANDLE,
   1106  1.1  dholland 	NFSERR_NOTDIR,
   1107  1.1  dholland 	NFSERR_RESOURCE,
   1108  1.1  dholland 	NFSERR_SERVERFAULT,
   1109  1.1  dholland 	NFSERR_STALE,
   1110  1.1  dholland 	0,
   1111  1.1  dholland };
   1112  1.1  dholland 
   1113  1.1  dholland static short nfsv4err_setattr[] = {
   1114  1.1  dholland 	NFSERR_IO,
   1115  1.1  dholland 	NFSERR_ACCES,
   1116  1.1  dholland 	NFSERR_ADMINREVOKED,
   1117  1.1  dholland 	NFSERR_ATTRNOTSUPP,
   1118  1.1  dholland 	NFSERR_BADCHAR,
   1119  1.1  dholland 	NFSERR_BADHANDLE,
   1120  1.1  dholland 	NFSERR_BADOWNER,
   1121  1.1  dholland 	NFSERR_BADSTATEID,
   1122  1.1  dholland 	NFSERR_BADXDR,
   1123  1.1  dholland 	NFSERR_DELAY,
   1124  1.1  dholland 	NFSERR_DQUOT,
   1125  1.1  dholland 	NFSERR_EXPIRED,
   1126  1.1  dholland 	NFSERR_FBIG,
   1127  1.1  dholland 	NFSERR_FHEXPIRED,
   1128  1.1  dholland 	NFSERR_GRACE,
   1129  1.1  dholland 	NFSERR_INVAL,
   1130  1.1  dholland 	NFSERR_IO,
   1131  1.1  dholland 	NFSERR_ISDIR,
   1132  1.1  dholland 	NFSERR_LOCKED,
   1133  1.1  dholland 	NFSERR_MOVED,
   1134  1.1  dholland 	NFSERR_NOFILEHANDLE,
   1135  1.1  dholland 	NFSERR_NOSPC,
   1136  1.1  dholland 	NFSERR_OLDSTATEID,
   1137  1.1  dholland 	NFSERR_OPENMODE,
   1138  1.1  dholland 	NFSERR_PERM,
   1139  1.1  dholland 	NFSERR_RESOURCE,
   1140  1.1  dholland 	NFSERR_ROFS,
   1141  1.1  dholland 	NFSERR_SERVERFAULT,
   1142  1.1  dholland 	NFSERR_STALE,
   1143  1.1  dholland 	NFSERR_STALESTATEID,
   1144  1.1  dholland 	0,
   1145  1.1  dholland };
   1146  1.1  dholland 
   1147  1.1  dholland static short nfsv4err_setclientid[] = {
   1148  1.1  dholland 	NFSERR_SERVERFAULT,
   1149  1.1  dholland 	NFSERR_BADXDR,
   1150  1.1  dholland 	NFSERR_CLIDINUSE,
   1151  1.1  dholland 	NFSERR_INVAL,
   1152  1.1  dholland 	NFSERR_RESOURCE,
   1153  1.1  dholland 	NFSERR_SERVERFAULT,
   1154  1.3  pgoyette 	NFSERR_WRONGSEC,
   1155  1.1  dholland 	0,
   1156  1.1  dholland };
   1157  1.1  dholland 
   1158  1.1  dholland static short nfsv4err_setclientidconfirm[] = {
   1159  1.1  dholland 	NFSERR_SERVERFAULT,
   1160  1.1  dholland 	NFSERR_BADXDR,
   1161  1.1  dholland 	NFSERR_CLIDINUSE,
   1162  1.1  dholland 	NFSERR_RESOURCE,
   1163  1.1  dholland 	NFSERR_SERVERFAULT,
   1164  1.1  dholland 	NFSERR_STALECLIENTID,
   1165  1.1  dholland 	0,
   1166  1.1  dholland };
   1167  1.1  dholland 
   1168  1.1  dholland static short nfsv4err_verify[] = {
   1169  1.1  dholland 	NFSERR_SERVERFAULT,
   1170  1.1  dholland 	NFSERR_ACCES,
   1171  1.1  dholland 	NFSERR_ATTRNOTSUPP,
   1172  1.1  dholland 	NFSERR_BADCHAR,
   1173  1.1  dholland 	NFSERR_BADHANDLE,
   1174  1.1  dholland 	NFSERR_BADXDR,
   1175  1.1  dholland 	NFSERR_DELAY,
   1176  1.1  dholland 	NFSERR_FHEXPIRED,
   1177  1.1  dholland 	NFSERR_INVAL,
   1178  1.1  dholland 	NFSERR_MOVED,
   1179  1.1  dholland 	NFSERR_NOFILEHANDLE,
   1180  1.1  dholland 	NFSERR_NOTSAME,
   1181  1.1  dholland 	NFSERR_RESOURCE,
   1182  1.1  dholland 	NFSERR_SERVERFAULT,
   1183  1.1  dholland 	NFSERR_STALE,
   1184  1.1  dholland 	0,
   1185  1.1  dholland };
   1186  1.1  dholland 
   1187  1.1  dholland static short nfsv4err_write[] = {
   1188  1.1  dholland 	NFSERR_IO,
   1189  1.1  dholland 	NFSERR_ACCES,
   1190  1.1  dholland 	NFSERR_ADMINREVOKED,
   1191  1.1  dholland 	NFSERR_BADHANDLE,
   1192  1.1  dholland 	NFSERR_BADSTATEID,
   1193  1.1  dholland 	NFSERR_BADXDR,
   1194  1.1  dholland 	NFSERR_DELAY,
   1195  1.1  dholland 	NFSERR_DQUOT,
   1196  1.1  dholland 	NFSERR_EXPIRED,
   1197  1.1  dholland 	NFSERR_FBIG,
   1198  1.1  dholland 	NFSERR_FHEXPIRED,
   1199  1.1  dholland 	NFSERR_GRACE,
   1200  1.1  dholland 	NFSERR_INVAL,
   1201  1.1  dholland 	NFSERR_IO,
   1202  1.1  dholland 	NFSERR_ISDIR,
   1203  1.1  dholland 	NFSERR_LEASEMOVED,
   1204  1.1  dholland 	NFSERR_LOCKED,
   1205  1.1  dholland 	NFSERR_MOVED,
   1206  1.1  dholland 	NFSERR_NOFILEHANDLE,
   1207  1.1  dholland 	NFSERR_NOSPC,
   1208  1.1  dholland 	NFSERR_NXIO,
   1209  1.1  dholland 	NFSERR_OLDSTATEID,
   1210  1.1  dholland 	NFSERR_OPENMODE,
   1211  1.1  dholland 	NFSERR_RESOURCE,
   1212  1.1  dholland 	NFSERR_ROFS,
   1213  1.1  dholland 	NFSERR_SERVERFAULT,
   1214  1.1  dholland 	NFSERR_STALE,
   1215  1.1  dholland 	NFSERR_STALESTATEID,
   1216  1.1  dholland 	0,
   1217  1.1  dholland };
   1218  1.1  dholland 
   1219  1.1  dholland static short nfsv4err_releaselockowner[] = {
   1220  1.1  dholland 	NFSERR_SERVERFAULT,
   1221  1.1  dholland 	NFSERR_ADMINREVOKED,
   1222  1.1  dholland 	NFSERR_BADXDR,
   1223  1.1  dholland 	NFSERR_EXPIRED,
   1224  1.1  dholland 	NFSERR_LEASEMOVED,
   1225  1.1  dholland 	NFSERR_LOCKSHELD,
   1226  1.1  dholland 	NFSERR_RESOURCE,
   1227  1.1  dholland 	NFSERR_SERVERFAULT,
   1228  1.1  dholland 	NFSERR_STALECLIENTID,
   1229  1.1  dholland 	0,
   1230  1.1  dholland };
   1231  1.1  dholland 
   1232  1.1  dholland static short *nfsrv_v4errmap[] = {
   1233  1.1  dholland 	nfsv4err_null,
   1234  1.1  dholland 	nfsv4err_null,
   1235  1.1  dholland 	nfsv4err_null,
   1236  1.1  dholland 	nfsv4err_access,
   1237  1.1  dholland 	nfsv4err_close,
   1238  1.1  dholland 	nfsv4err_commit,
   1239  1.1  dholland 	nfsv4err_create,
   1240  1.1  dholland 	nfsv4err_delegpurge,
   1241  1.1  dholland 	nfsv4err_delegreturn,
   1242  1.1  dholland 	nfsv4err_getattr,
   1243  1.1  dholland 	nfsv4err_getfh,
   1244  1.1  dholland 	nfsv4err_link,
   1245  1.1  dholland 	nfsv4err_lock,
   1246  1.1  dholland 	nfsv4err_lockt,
   1247  1.1  dholland 	nfsv4err_locku,
   1248  1.1  dholland 	nfsv4err_lookup,
   1249  1.1  dholland 	nfsv4err_lookupp,
   1250  1.1  dholland 	nfsv4err_nverify,
   1251  1.1  dholland 	nfsv4err_open,
   1252  1.1  dholland 	nfsv4err_openattr,
   1253  1.1  dholland 	nfsv4err_openconfirm,
   1254  1.1  dholland 	nfsv4err_opendowngrade,
   1255  1.1  dholland 	nfsv4err_putfh,
   1256  1.1  dholland 	nfsv4err_putpubfh,
   1257  1.1  dholland 	nfsv4err_putrootfh,
   1258  1.1  dholland 	nfsv4err_read,
   1259  1.1  dholland 	nfsv4err_readdir,
   1260  1.1  dholland 	nfsv4err_readlink,
   1261  1.1  dholland 	nfsv4err_remove,
   1262  1.1  dholland 	nfsv4err_rename,
   1263  1.1  dholland 	nfsv4err_renew,
   1264  1.1  dholland 	nfsv4err_restorefh,
   1265  1.1  dholland 	nfsv4err_savefh,
   1266  1.1  dholland 	nfsv4err_secinfo,
   1267  1.1  dholland 	nfsv4err_setattr,
   1268  1.1  dholland 	nfsv4err_setclientid,
   1269  1.1  dholland 	nfsv4err_setclientidconfirm,
   1270  1.1  dholland 	nfsv4err_verify,
   1271  1.1  dholland 	nfsv4err_write,
   1272  1.1  dholland 	nfsv4err_releaselockowner,
   1273  1.1  dholland };
   1274  1.1  dholland 
   1275  1.1  dholland /*
   1276  1.1  dholland  * A fiddled version of m_adj() that ensures null fill to a long
   1277  1.1  dholland  * boundary and only trims off the back end
   1278  1.1  dholland  */
   1279  1.1  dholland APPLESTATIC void
   1280  1.1  dholland nfsrv_adj(mbuf_t mp, int len, int nul)
   1281  1.1  dholland {
   1282  1.1  dholland 	mbuf_t m;
   1283  1.1  dholland 	int count, i;
   1284  1.1  dholland 	char *cp;
   1285  1.1  dholland 
   1286  1.1  dholland 	/*
   1287  1.1  dholland 	 * Trim from tail.  Scan the mbuf chain,
   1288  1.1  dholland 	 * calculating its length and finding the last mbuf.
   1289  1.1  dholland 	 * If the adjustment only affects this mbuf, then just
   1290  1.1  dholland 	 * adjust and return.  Otherwise, rescan and truncate
   1291  1.1  dholland 	 * after the remaining size.
   1292  1.1  dholland 	 */
   1293  1.1  dholland 	count = 0;
   1294  1.1  dholland 	m = mp;
   1295  1.1  dholland 	for (;;) {
   1296  1.1  dholland 		count += mbuf_len(m);
   1297  1.1  dholland 		if (mbuf_next(m) == NULL)
   1298  1.1  dholland 			break;
   1299  1.1  dholland 		m = mbuf_next(m);
   1300  1.1  dholland 	}
   1301  1.1  dholland 	if (mbuf_len(m) > len) {
   1302  1.1  dholland 		mbuf_setlen(m, mbuf_len(m) - len);
   1303  1.1  dholland 		if (nul > 0) {
   1304  1.1  dholland 			cp = NFSMTOD(m, caddr_t) + mbuf_len(m) - nul;
   1305  1.1  dholland 			for (i = 0; i < nul; i++)
   1306  1.1  dholland 				*cp++ = '\0';
   1307  1.1  dholland 		}
   1308  1.1  dholland 		return;
   1309  1.1  dholland 	}
   1310  1.1  dholland 	count -= len;
   1311  1.1  dholland 	if (count < 0)
   1312  1.1  dholland 		count = 0;
   1313  1.1  dholland 	/*
   1314  1.1  dholland 	 * Correct length for chain is "count".
   1315  1.1  dholland 	 * Find the mbuf with last data, adjust its length,
   1316  1.1  dholland 	 * and toss data from remaining mbufs on chain.
   1317  1.1  dholland 	 */
   1318  1.1  dholland 	for (m = mp; m; m = mbuf_next(m)) {
   1319  1.1  dholland 		if (mbuf_len(m) >= count) {
   1320  1.1  dholland 			mbuf_setlen(m, count);
   1321  1.1  dholland 			if (nul > 0) {
   1322  1.1  dholland 				cp = NFSMTOD(m, caddr_t) + mbuf_len(m) - nul;
   1323  1.1  dholland 				for (i = 0; i < nul; i++)
   1324  1.1  dholland 					*cp++ = '\0';
   1325  1.1  dholland 			}
   1326  1.1  dholland 			break;
   1327  1.1  dholland 		}
   1328  1.1  dholland 		count -= mbuf_len(m);
   1329  1.1  dholland 	}
   1330  1.1  dholland 	for (m = mbuf_next(m); m; m = mbuf_next(m))
   1331  1.1  dholland 		mbuf_setlen(m, 0);
   1332  1.1  dholland }
   1333  1.1  dholland 
   1334  1.1  dholland /*
   1335  1.1  dholland  * Make these functions instead of macros, so that the kernel text size
   1336  1.1  dholland  * doesn't get too big...
   1337  1.1  dholland  */
   1338  1.1  dholland APPLESTATIC void
   1339  1.1  dholland nfsrv_wcc(struct nfsrv_descript *nd, int before_ret,
   1340  1.1  dholland     struct nfsvattr *before_nvap, int after_ret, struct nfsvattr *after_nvap)
   1341  1.1  dholland {
   1342  1.1  dholland 	u_int32_t *tl;
   1343  1.1  dholland 
   1344  1.1  dholland 	if (before_ret) {
   1345  1.1  dholland 		NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
   1346  1.1  dholland 		*tl = newnfs_false;
   1347  1.1  dholland 	} else {
   1348  1.1  dholland 		NFSM_BUILD(tl, u_int32_t *, 7 * NFSX_UNSIGNED);
   1349  1.1  dholland 		*tl++ = newnfs_true;
   1350  1.1  dholland 		txdr_hyper(before_nvap->na_size, tl);
   1351  1.1  dholland 		tl += 2;
   1352  1.1  dholland 		txdr_nfsv3time(&(before_nvap->na_mtime), tl);
   1353  1.1  dholland 		tl += 2;
   1354  1.1  dholland 		txdr_nfsv3time(&(before_nvap->na_ctime), tl);
   1355  1.1  dholland 	}
   1356  1.1  dholland 	nfsrv_postopattr(nd, after_ret, after_nvap);
   1357  1.1  dholland }
   1358  1.1  dholland 
   1359  1.1  dholland APPLESTATIC void
   1360  1.1  dholland nfsrv_postopattr(struct nfsrv_descript *nd, int after_ret,
   1361  1.1  dholland     struct nfsvattr *after_nvap)
   1362  1.1  dholland {
   1363  1.1  dholland 	u_int32_t *tl;
   1364  1.1  dholland 
   1365  1.1  dholland 	NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
   1366  1.1  dholland 	if (after_ret)
   1367  1.1  dholland 		*tl = newnfs_false;
   1368  1.1  dholland 	else {
   1369  1.1  dholland 		*tl = newnfs_true;
   1370  1.1  dholland 		nfsrv_fillattr(nd, after_nvap);
   1371  1.1  dholland 	}
   1372  1.1  dholland }
   1373  1.1  dholland 
   1374  1.1  dholland /*
   1375  1.1  dholland  * Fill in file attributes for V2 and 3. For V4, call a separate
   1376  1.1  dholland  * routine that sifts through all the attribute bits.
   1377  1.1  dholland  */
   1378  1.1  dholland APPLESTATIC void
   1379  1.1  dholland nfsrv_fillattr(struct nfsrv_descript *nd, struct nfsvattr *nvap)
   1380  1.1  dholland {
   1381  1.1  dholland 	struct nfs_fattr *fp;
   1382  1.1  dholland 	int fattr_size;
   1383  1.1  dholland 
   1384  1.1  dholland 	/*
   1385  1.1  dholland 	 * Build space for the attribute structure.
   1386  1.1  dholland 	 */
   1387  1.1  dholland 	if (nd->nd_flag & ND_NFSV3)
   1388  1.1  dholland 		fattr_size = NFSX_V3FATTR;
   1389  1.1  dholland 	else
   1390  1.1  dholland 		fattr_size = NFSX_V2FATTR;
   1391  1.1  dholland 	NFSM_BUILD(fp, struct nfs_fattr *, fattr_size);
   1392  1.1  dholland 
   1393  1.1  dholland 	/*
   1394  1.1  dholland 	 * Now just fill it all in.
   1395  1.1  dholland 	 */
   1396  1.1  dholland 	fp->fa_nlink = txdr_unsigned(nvap->na_nlink);
   1397  1.1  dholland 	fp->fa_uid = txdr_unsigned(nvap->na_uid);
   1398  1.1  dholland 	fp->fa_gid = txdr_unsigned(nvap->na_gid);
   1399  1.1  dholland 	if (nd->nd_flag & ND_NFSV3) {
   1400  1.1  dholland 		fp->fa_type = vtonfsv34_type(nvap->na_type);
   1401  1.1  dholland 		fp->fa_mode = vtonfsv34_mode(nvap->na_mode);
   1402  1.1  dholland 		txdr_hyper(nvap->na_size, &fp->fa3_size);
   1403  1.1  dholland 		txdr_hyper(nvap->na_bytes, &fp->fa3_used);
   1404  1.1  dholland 		fp->fa3_rdev.specdata1 = txdr_unsigned(NFSMAJOR(nvap->na_rdev));
   1405  1.1  dholland 		fp->fa3_rdev.specdata2 = txdr_unsigned(NFSMINOR(nvap->na_rdev));
   1406  1.1  dholland 		fp->fa3_fsid.nfsuquad[0] = 0;
   1407  1.1  dholland 		fp->fa3_fsid.nfsuquad[1] = txdr_unsigned(nvap->na_fsid);
   1408  1.1  dholland 		fp->fa3_fileid.nfsuquad[0] = 0;
   1409  1.1  dholland 		fp->fa3_fileid.nfsuquad[1] = txdr_unsigned(nvap->na_fileid);
   1410  1.1  dholland 		txdr_nfsv3time(&nvap->na_atime, &fp->fa3_atime);
   1411  1.1  dholland 		txdr_nfsv3time(&nvap->na_mtime, &fp->fa3_mtime);
   1412  1.1  dholland 		txdr_nfsv3time(&nvap->na_ctime, &fp->fa3_ctime);
   1413  1.1  dholland 	} else {
   1414  1.1  dholland 		fp->fa_type = vtonfsv2_type(nvap->na_type);
   1415  1.1  dholland 		fp->fa_mode = vtonfsv2_mode(nvap->na_type, nvap->na_mode);
   1416  1.1  dholland 		fp->fa2_size = txdr_unsigned(nvap->na_size);
   1417  1.1  dholland 		fp->fa2_blocksize = txdr_unsigned(nvap->na_blocksize);
   1418  1.1  dholland 		if (nvap->na_type == VFIFO)
   1419  1.1  dholland 			fp->fa2_rdev = 0xffffffff;
   1420  1.1  dholland 		else
   1421  1.1  dholland 			fp->fa2_rdev = txdr_unsigned(nvap->na_rdev);
   1422  1.1  dholland 		fp->fa2_blocks = txdr_unsigned(nvap->na_bytes / NFS_FABLKSIZE);
   1423  1.1  dholland 		fp->fa2_fsid = txdr_unsigned(nvap->na_fsid);
   1424  1.1  dholland 		fp->fa2_fileid = txdr_unsigned(nvap->na_fileid);
   1425  1.1  dholland 		txdr_nfsv2time(&nvap->na_atime, &fp->fa2_atime);
   1426  1.1  dholland 		txdr_nfsv2time(&nvap->na_mtime, &fp->fa2_mtime);
   1427  1.1  dholland 		txdr_nfsv2time(&nvap->na_ctime, &fp->fa2_ctime);
   1428  1.1  dholland 	}
   1429  1.1  dholland }
   1430  1.1  dholland 
   1431  1.1  dholland /*
   1432  1.1  dholland  * This function gets a file handle out of an mbuf list.
   1433  1.1  dholland  * It returns 0 for success, EBADRPC otherwise.
   1434  1.1  dholland  * If sets the third flagp argument to 1 if the file handle is
   1435  1.1  dholland  * the public file handle.
   1436  1.1  dholland  * For NFSv4, if the length is incorrect, set nd_repstat == NFSERR_BADHANDLE
   1437  1.1  dholland  */
   1438  1.1  dholland APPLESTATIC int
   1439  1.1  dholland nfsrv_mtofh(struct nfsrv_descript *nd, struct nfsrvfh *fhp)
   1440  1.1  dholland {
   1441  1.1  dholland 	u_int32_t *tl;
   1442  1.1  dholland 	int error = 0, len, copylen;
   1443  1.1  dholland 
   1444  1.1  dholland 	if (nd->nd_flag & (ND_NFSV3 | ND_NFSV4)) {
   1445  1.1  dholland 		NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED);
   1446  1.1  dholland 		len = fxdr_unsigned(int, *tl);
   1447  1.1  dholland 		if (len == 0 && nfs_pubfhset && (nd->nd_flag & ND_NFSV3) &&
   1448  1.1  dholland 		    nd->nd_procnum == NFSPROC_LOOKUP) {
   1449  1.1  dholland 			nd->nd_flag |= ND_PUBLOOKUP;
   1450  1.1  dholland 			goto nfsmout;
   1451  1.1  dholland 		}
   1452  1.1  dholland 		if (len < NFSRV_MINFH || len > NFSRV_MAXFH) {
   1453  1.1  dholland 			if (nd->nd_flag & ND_NFSV4) {
   1454  1.1  dholland 			    if (len > 0 && len <= NFSX_V4FHMAX) {
   1455  1.1  dholland 				error = nfsm_advance(nd, NFSM_RNDUP(len), -1);
   1456  1.1  dholland 				if (error)
   1457  1.1  dholland 					goto nfsmout;
   1458  1.1  dholland 				nd->nd_repstat = NFSERR_BADHANDLE;
   1459  1.1  dholland 				goto nfsmout;
   1460  1.1  dholland 			    } else {
   1461  1.1  dholland 				    error = EBADRPC;
   1462  1.1  dholland 				    goto nfsmout;
   1463  1.1  dholland 			    }
   1464  1.1  dholland 			} else {
   1465  1.1  dholland 				error = EBADRPC;
   1466  1.1  dholland 				goto nfsmout;
   1467  1.1  dholland 			}
   1468  1.1  dholland 		}
   1469  1.1  dholland 		copylen = len;
   1470  1.1  dholland 	} else {
   1471  1.1  dholland 		/*
   1472  1.1  dholland 		 * For NFSv2, the file handle is always 32 bytes on the
   1473  1.1  dholland 		 * wire, but this server only cares about the first
   1474  1.1  dholland 		 * NFSRV_MAXFH bytes.
   1475  1.1  dholland 		 */
   1476  1.1  dholland 		len = NFSX_V2FH;
   1477  1.1  dholland 		copylen = NFSRV_MAXFH;
   1478  1.1  dholland 	}
   1479  1.1  dholland 	NFSM_DISSECT(tl, u_int32_t *, len);
   1480  1.1  dholland 	if ((nd->nd_flag & ND_NFSV2) && nfs_pubfhset &&
   1481  1.1  dholland 	    nd->nd_procnum == NFSPROC_LOOKUP &&
   1482  1.1  dholland 	    !NFSBCMP((caddr_t)tl, nfs_v2pubfh, NFSX_V2FH)) {
   1483  1.1  dholland 		nd->nd_flag |= ND_PUBLOOKUP;
   1484  1.1  dholland 		goto nfsmout;
   1485  1.1  dholland 	}
   1486  1.1  dholland 	NFSBCOPY(tl, (caddr_t)fhp->nfsrvfh_data, copylen);
   1487  1.1  dholland 	fhp->nfsrvfh_len = copylen;
   1488  1.1  dholland nfsmout:
   1489  1.1  dholland 	NFSEXITCODE2(error, nd);
   1490  1.1  dholland 	return (error);
   1491  1.1  dholland }
   1492  1.1  dholland 
   1493  1.1  dholland /*
   1494  1.1  dholland  * Map errnos to NFS error numbers. For Version 3 and 4 also filter out error
   1495  1.1  dholland  * numbers not specified for the associated procedure.
   1496  1.1  dholland  * NFSPROC_NOOP is a special case, where the high order bits of nd_repstat
   1497  1.1  dholland  * should be cleared. NFSPROC_NOOP is used to return errors when a valid
   1498  1.1  dholland  * RPC procedure is not involved.
   1499  1.1  dholland  * Returns the error number in XDR.
   1500  1.1  dholland  */
   1501  1.1  dholland APPLESTATIC int
   1502  1.1  dholland nfsd_errmap(struct nfsrv_descript *nd)
   1503  1.1  dholland {
   1504  1.1  dholland 	short *defaulterrp, *errp;
   1505  1.1  dholland 
   1506  1.1  dholland 	if (!nd->nd_repstat)
   1507  1.1  dholland 		return (0);
   1508  1.1  dholland 	if (nd->nd_flag & (ND_NFSV3 | ND_NFSV4)) {
   1509  1.1  dholland 		if (nd->nd_procnum == NFSPROC_NOOP)
   1510  1.1  dholland 			return (txdr_unsigned(nd->nd_repstat & 0xffff));
   1511  1.1  dholland 		if (nd->nd_flag & ND_NFSV3)
   1512  1.1  dholland 		    errp = defaulterrp = nfsrv_v3errmap[nd->nd_procnum];
   1513  1.1  dholland 		else if (nd->nd_repstat == EBADRPC)
   1514  1.1  dholland 			return (txdr_unsigned(NFSERR_BADXDR));
   1515  1.1  dholland 		else if (nd->nd_repstat == NFSERR_MINORVERMISMATCH ||
   1516  1.1  dholland 			 nd->nd_repstat == NFSERR_OPILLEGAL)
   1517  1.1  dholland 			return (txdr_unsigned(nd->nd_repstat));
   1518  1.3  pgoyette 		else if ((nd->nd_flag & ND_NFSV41) != 0) {
   1519  1.3  pgoyette 			if (nd->nd_repstat == EOPNOTSUPP)
   1520  1.3  pgoyette 				nd->nd_repstat = NFSERR_NOTSUPP;
   1521  1.3  pgoyette 			nd->nd_repstat = nfsrv_isannfserr(nd->nd_repstat);
   1522  1.3  pgoyette 			return (txdr_unsigned(nd->nd_repstat));
   1523  1.3  pgoyette 		} else
   1524  1.1  dholland 		    errp = defaulterrp = nfsrv_v4errmap[nd->nd_procnum];
   1525  1.1  dholland 		while (*++errp)
   1526  1.1  dholland 			if (*errp == nd->nd_repstat)
   1527  1.1  dholland 				return (txdr_unsigned(nd->nd_repstat));
   1528  1.1  dholland 		return (txdr_unsigned(*defaulterrp));
   1529  1.1  dholland 	}
   1530  1.3  pgoyette 	if (nd->nd_repstat <= NFSERR_REMOTE)
   1531  1.1  dholland 		return (txdr_unsigned(nfsrv_v2errmap[nd->nd_repstat - 1]));
   1532  1.1  dholland 	return (txdr_unsigned(NFSERR_IO));
   1533  1.1  dholland }
   1534  1.1  dholland 
   1535  1.1  dholland /*
   1536  1.3  pgoyette  * Check to see if the error is a valid NFS one. If not, replace it with
   1537  1.3  pgoyette  * NFSERR_IO.
   1538  1.3  pgoyette  */
   1539  1.3  pgoyette static u_int32_t
   1540  1.3  pgoyette nfsrv_isannfserr(u_int32_t errval)
   1541  1.3  pgoyette {
   1542  1.3  pgoyette 
   1543  1.3  pgoyette 	if (errval == NFSERR_OK)
   1544  1.3  pgoyette 		return (errval);
   1545  1.3  pgoyette 	if (errval >= NFSERR_BADHANDLE && errval <= NFSERR_DELEGREVOKED)
   1546  1.3  pgoyette 		return (errval);
   1547  1.3  pgoyette 	if (errval > 0 && errval <= NFSERR_REMOTE)
   1548  1.3  pgoyette 		return (nfsrv_v2errmap[errval - 1]);
   1549  1.3  pgoyette 	return (NFSERR_IO);
   1550  1.3  pgoyette }
   1551  1.3  pgoyette 
   1552  1.3  pgoyette /*
   1553  1.1  dholland  * Check to see if setting a uid/gid is permitted when creating a new
   1554  1.1  dholland  * file object. (Called when uid and/or gid is specified in the
   1555  1.1  dholland  * settable attributes for V4.
   1556  1.1  dholland  */
   1557  1.1  dholland APPLESTATIC int
   1558  1.1  dholland nfsrv_checkuidgid(struct nfsrv_descript *nd, struct nfsvattr *nvap)
   1559  1.1  dholland {
   1560  1.1  dholland 	int error = 0;
   1561  1.1  dholland 
   1562  1.1  dholland 	/*
   1563  1.1  dholland 	 * If not setting either uid nor gid, it's OK.
   1564  1.1  dholland 	 */
   1565  1.1  dholland 	if (NFSVNO_NOTSETUID(nvap) && NFSVNO_NOTSETGID(nvap))
   1566  1.1  dholland 		goto out;
   1567  1.3  pgoyette 	if ((NFSVNO_ISSETUID(nvap) && nvap->na_uid == nfsrv_defaultuid &&
   1568  1.3  pgoyette            enable_nobodycheck == 1)
   1569  1.3  pgoyette 	    || (NFSVNO_ISSETGID(nvap) && nvap->na_gid == nfsrv_defaultgid &&
   1570  1.3  pgoyette            enable_nogroupcheck == 1)) {
   1571  1.1  dholland 		error = NFSERR_BADOWNER;
   1572  1.1  dholland 		goto out;
   1573  1.1  dholland 	}
   1574  1.1  dholland 	if (nd->nd_cred->cr_uid == 0)
   1575  1.1  dholland 		goto out;
   1576  1.1  dholland 	if ((NFSVNO_ISSETUID(nvap) && nvap->na_uid != nd->nd_cred->cr_uid) ||
   1577  1.1  dholland 	    (NFSVNO_ISSETGID(nvap) && nvap->na_gid != nd->nd_cred->cr_gid &&
   1578  1.1  dholland 	    !groupmember(nvap->na_gid, nd->nd_cred)))
   1579  1.1  dholland 		error = NFSERR_PERM;
   1580  1.1  dholland 
   1581  1.1  dholland out:
   1582  1.1  dholland 	NFSEXITCODE2(error, nd);
   1583  1.1  dholland 	return (error);
   1584  1.1  dholland }
   1585  1.1  dholland 
   1586  1.1  dholland /*
   1587  1.1  dholland  * and this routine fixes up the settable attributes for V4 if allowed
   1588  1.1  dholland  * by nfsrv_checkuidgid().
   1589  1.1  dholland  */
   1590  1.1  dholland APPLESTATIC void
   1591  1.1  dholland nfsrv_fixattr(struct nfsrv_descript *nd, vnode_t vp,
   1592  1.1  dholland     struct nfsvattr *nvap, NFSACL_T *aclp, NFSPROC_T *p, nfsattrbit_t *attrbitp,
   1593  1.1  dholland     struct nfsexstuff *exp)
   1594  1.1  dholland {
   1595  1.1  dholland 	int change = 0;
   1596  1.1  dholland 	struct nfsvattr nva;
   1597  1.1  dholland 	uid_t tuid;
   1598  1.1  dholland 	int error;
   1599  1.1  dholland 	nfsattrbit_t nattrbits;
   1600  1.1  dholland 
   1601  1.1  dholland 	/*
   1602  1.1  dholland 	 * Maybe this should be done for V2 and 3 but it never has been
   1603  1.1  dholland 	 * and nobody seems to be upset, so I think it's best not to change
   1604  1.1  dholland 	 * the V2 and 3 semantics.
   1605  1.1  dholland 	 */
   1606  1.1  dholland 	if ((nd->nd_flag & ND_NFSV4) == 0)
   1607  1.1  dholland 		goto out;
   1608  1.1  dholland 	NFSVNO_ATTRINIT(&nva);
   1609  1.1  dholland 	NFSZERO_ATTRBIT(&nattrbits);
   1610  1.1  dholland 	tuid = nd->nd_cred->cr_uid;
   1611  1.1  dholland 	if (NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_OWNER) &&
   1612  1.1  dholland 	    NFSVNO_ISSETUID(nvap) &&
   1613  1.1  dholland 	    nvap->na_uid != nd->nd_cred->cr_uid) {
   1614  1.1  dholland 		if (nd->nd_cred->cr_uid == 0) {
   1615  1.1  dholland 			nva.na_uid = nvap->na_uid;
   1616  1.1  dholland 			change++;
   1617  1.1  dholland 			NFSSETBIT_ATTRBIT(&nattrbits, NFSATTRBIT_OWNER);
   1618  1.1  dholland 		} else {
   1619  1.1  dholland 			NFSCLRBIT_ATTRBIT(attrbitp, NFSATTRBIT_OWNER);
   1620  1.1  dholland 		}
   1621  1.1  dholland 	}
   1622  1.1  dholland 	if (NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_TIMEACCESSSET) &&
   1623  1.1  dholland 	    NFSVNO_ISSETATIME(nvap)) {
   1624  1.1  dholland 		nva.na_atime = nvap->na_atime;
   1625  1.1  dholland 		change++;
   1626  1.1  dholland 		NFSSETBIT_ATTRBIT(&nattrbits, NFSATTRBIT_TIMEACCESSSET);
   1627  1.1  dholland 	}
   1628  1.1  dholland 	if (NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_TIMEMODIFYSET) &&
   1629  1.1  dholland 	    NFSVNO_ISSETMTIME(nvap)) {
   1630  1.1  dholland 		nva.na_mtime = nvap->na_mtime;
   1631  1.1  dholland 		change++;
   1632  1.1  dholland 		NFSSETBIT_ATTRBIT(&nattrbits, NFSATTRBIT_TIMEMODIFYSET);
   1633  1.1  dholland 	}
   1634  1.1  dholland 	if (NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_OWNERGROUP) &&
   1635  1.1  dholland 	    NFSVNO_ISSETGID(nvap)) {
   1636  1.1  dholland 		if (nvap->na_gid == nd->nd_cred->cr_gid ||
   1637  1.1  dholland 		    groupmember(nvap->na_gid, nd->nd_cred)) {
   1638  1.1  dholland 			nd->nd_cred->cr_uid = 0;
   1639  1.1  dholland 			nva.na_gid = nvap->na_gid;
   1640  1.1  dholland 			change++;
   1641  1.1  dholland 			NFSSETBIT_ATTRBIT(&nattrbits, NFSATTRBIT_OWNERGROUP);
   1642  1.1  dholland 		} else {
   1643  1.1  dholland 			NFSCLRBIT_ATTRBIT(attrbitp, NFSATTRBIT_OWNERGROUP);
   1644  1.1  dholland 		}
   1645  1.1  dholland 	}
   1646  1.1  dholland 	if (change) {
   1647  1.1  dholland 		error = nfsvno_setattr(vp, &nva, nd->nd_cred, p, exp);
   1648  1.1  dholland 		if (error) {
   1649  1.1  dholland 			NFSCLRALL_ATTRBIT(attrbitp, &nattrbits);
   1650  1.1  dholland 		}
   1651  1.1  dholland 	}
   1652  1.1  dholland 	if (NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_SIZE) &&
   1653  1.1  dholland 	    NFSVNO_ISSETSIZE(nvap) && nvap->na_size != (u_quad_t)0) {
   1654  1.1  dholland 		NFSCLRBIT_ATTRBIT(attrbitp, NFSATTRBIT_SIZE);
   1655  1.1  dholland 	}
   1656  1.1  dholland #ifdef NFS4_ACL_EXTATTR_NAME
   1657  1.1  dholland 	if (NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_ACL) &&
   1658  1.1  dholland 	    nfsrv_useacl != 0 && aclp != NULL) {
   1659  1.1  dholland 		if (aclp->acl_cnt > 0) {
   1660  1.1  dholland 			error = nfsrv_setacl(vp, aclp, nd->nd_cred, p);
   1661  1.1  dholland 			if (error) {
   1662  1.1  dholland 				NFSCLRBIT_ATTRBIT(attrbitp, NFSATTRBIT_ACL);
   1663  1.1  dholland 			}
   1664  1.1  dholland 		}
   1665  1.1  dholland 	} else
   1666  1.1  dholland #endif
   1667  1.1  dholland 	NFSCLRBIT_ATTRBIT(attrbitp, NFSATTRBIT_ACL);
   1668  1.1  dholland 	nd->nd_cred->cr_uid = tuid;
   1669  1.1  dholland 
   1670  1.1  dholland out:
   1671  1.1  dholland 	NFSEXITCODE2(0, nd);
   1672  1.1  dholland }
   1673  1.1  dholland 
   1674  1.1  dholland /*
   1675  1.2       snj  * Translate an ASCII hex digit to its binary value. Return -1 if the
   1676  1.1  dholland  * char isn't a hex digit.
   1677  1.1  dholland  */
   1678  1.1  dholland static char
   1679  1.1  dholland nfsrv_hexdigit(char c, int *err)
   1680  1.1  dholland {
   1681  1.1  dholland 
   1682  1.1  dholland 	*err = 0;
   1683  1.1  dholland 	if (c >= '0' && c <= '9')
   1684  1.1  dholland 		return (c - '0');
   1685  1.1  dholland 	if (c >= 'a' && c <= 'f')
   1686  1.1  dholland 		return (c - 'a' + ((char)10));
   1687  1.1  dholland 	if (c >= 'A' && c <= 'F')
   1688  1.1  dholland 		return (c - 'A' + ((char)10));
   1689  1.1  dholland 	/* Not valid ! */
   1690  1.1  dholland 	*err = 1;
   1691  1.1  dholland 	return (1);	/* BOGUS */
   1692  1.1  dholland }
   1693  1.1  dholland 
   1694  1.1  dholland /*
   1695  1.1  dholland  * Check to see if NFSERR_MOVED can be returned for this op. Return 1 iff
   1696  1.1  dholland  * it can be.
   1697  1.1  dholland  */
   1698  1.1  dholland APPLESTATIC int
   1699  1.1  dholland nfsrv_errmoved(int op)
   1700  1.1  dholland {
   1701  1.1  dholland 	short *errp;
   1702  1.1  dholland 
   1703  1.1  dholland 	errp = nfsrv_v4errmap[op];
   1704  1.1  dholland 	while (*errp != 0) {
   1705  1.1  dholland 		if (*errp == NFSERR_MOVED)
   1706  1.1  dholland 			return (1);
   1707  1.1  dholland 		errp++;
   1708  1.1  dholland 	}
   1709  1.1  dholland 	return (0);
   1710  1.1  dholland }
   1711  1.1  dholland 
   1712  1.1  dholland /*
   1713  1.1  dholland  * Fill in attributes for a Referral.
   1714  1.1  dholland  * (Return the number of bytes of XDR created.)
   1715  1.1  dholland  */
   1716  1.1  dholland APPLESTATIC int
   1717  1.1  dholland nfsrv_putreferralattr(struct nfsrv_descript *nd, nfsattrbit_t *retbitp,
   1718  1.1  dholland     struct nfsreferral *refp, int getattr, int *reterrp)
   1719  1.1  dholland {
   1720  1.1  dholland 	u_int32_t *tl, *retnump;
   1721  1.1  dholland 	u_char *cp, *cp2;
   1722  1.1  dholland 	int prefixnum, retnum = 0, i, len, bitpos, rderrbit = 0, nonrefbit = 0;
   1723  1.1  dholland 	int fslocationsbit = 0;
   1724  1.1  dholland 	nfsattrbit_t tmpbits, refbits;
   1725  1.1  dholland 
   1726  1.1  dholland 	NFSREFERRAL_ATTRBIT(&refbits);
   1727  1.1  dholland 	if (getattr)
   1728  1.1  dholland 		NFSCLRBIT_ATTRBIT(&refbits, NFSATTRBIT_RDATTRERROR);
   1729  1.1  dholland 	else if (NFSISSET_ATTRBIT(retbitp, NFSATTRBIT_RDATTRERROR))
   1730  1.1  dholland 		rderrbit = 1;
   1731  1.1  dholland 	if (NFSISSET_ATTRBIT(retbitp, NFSATTRBIT_FSLOCATIONS))
   1732  1.1  dholland 		fslocationsbit = 1;
   1733  1.1  dholland 
   1734  1.1  dholland 	/*
   1735  1.1  dholland 	 * Check for the case where unsupported referral attributes are
   1736  1.1  dholland 	 * requested.
   1737  1.1  dholland 	 */
   1738  1.1  dholland 	NFSSET_ATTRBIT(&tmpbits, retbitp);
   1739  1.1  dholland 	NFSCLRALL_ATTRBIT(&tmpbits, &refbits);
   1740  1.1  dholland 	if (NFSNONZERO_ATTRBIT(&tmpbits))
   1741  1.1  dholland 		nonrefbit = 1;
   1742  1.1  dholland 
   1743  1.1  dholland 	if (nonrefbit && !fslocationsbit && (getattr || !rderrbit)) {
   1744  1.1  dholland 		*reterrp = NFSERR_MOVED;
   1745  1.1  dholland 		return (0);
   1746  1.1  dholland 	}
   1747  1.1  dholland 
   1748  1.1  dholland 	/*
   1749  1.1  dholland 	 * Now we can fill in the attributes.
   1750  1.1  dholland 	 */
   1751  1.1  dholland 	NFSSET_ATTRBIT(&tmpbits, retbitp);
   1752  1.1  dholland 	NFSCLRNOT_ATTRBIT(&tmpbits, &refbits);
   1753  1.1  dholland 
   1754  1.1  dholland 	/*
   1755  1.1  dholland 	 * Put out the attribute bitmap for the ones being filled in
   1756  1.1  dholland 	 * and get the field for the number of attributes returned.
   1757  1.1  dholland 	 */
   1758  1.1  dholland 	prefixnum = nfsrv_putattrbit(nd, &tmpbits);
   1759  1.1  dholland 	NFSM_BUILD(retnump, u_int32_t *, NFSX_UNSIGNED);
   1760  1.1  dholland 	prefixnum += NFSX_UNSIGNED;
   1761  1.1  dholland 
   1762  1.1  dholland 	/*
   1763  1.1  dholland 	 * Now, loop around filling in the attributes for each bit set.
   1764  1.1  dholland 	 */
   1765  1.1  dholland 	for (bitpos = 0; bitpos < NFSATTRBIT_MAX; bitpos++) {
   1766  1.1  dholland 	    if (NFSISSET_ATTRBIT(&tmpbits, bitpos)) {
   1767  1.1  dholland 		switch (bitpos) {
   1768  1.1  dholland 		case NFSATTRBIT_TYPE:
   1769  1.1  dholland 			NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
   1770  1.1  dholland 			*tl = txdr_unsigned(NFDIR);
   1771  1.1  dholland 			retnum += NFSX_UNSIGNED;
   1772  1.1  dholland 			break;
   1773  1.1  dholland 		case NFSATTRBIT_FSID:
   1774  1.1  dholland 			NFSM_BUILD(tl, u_int32_t *, NFSX_V4FSID);
   1775  1.1  dholland 			*tl++ = 0;
   1776  1.1  dholland 			*tl++ = txdr_unsigned(NFSV4ROOT_FSID0);
   1777  1.1  dholland 			*tl++ = 0;
   1778  1.1  dholland 			*tl = txdr_unsigned(NFSV4ROOT_REFERRAL);
   1779  1.1  dholland 			retnum += NFSX_V4FSID;
   1780  1.1  dholland 			break;
   1781  1.1  dholland 		case NFSATTRBIT_RDATTRERROR:
   1782  1.1  dholland 			NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
   1783  1.1  dholland 			if (nonrefbit)
   1784  1.1  dholland 				*tl = txdr_unsigned(NFSERR_MOVED);
   1785  1.1  dholland 			else
   1786  1.1  dholland 				*tl = 0;
   1787  1.1  dholland 			retnum += NFSX_UNSIGNED;
   1788  1.1  dholland 			break;
   1789  1.1  dholland 		case NFSATTRBIT_FSLOCATIONS:
   1790  1.1  dholland 			retnum += nfsm_strtom(nd, "/", 1);
   1791  1.1  dholland 			NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
   1792  1.1  dholland 			*tl = txdr_unsigned(refp->nfr_srvcnt);
   1793  1.1  dholland 			retnum += NFSX_UNSIGNED;
   1794  1.1  dholland 			cp = refp->nfr_srvlist;
   1795  1.1  dholland 			for (i = 0; i < refp->nfr_srvcnt; i++) {
   1796  1.1  dholland 				NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED);
   1797  1.1  dholland 				*tl = txdr_unsigned(1);
   1798  1.1  dholland 				retnum += NFSX_UNSIGNED;
   1799  1.1  dholland 				cp2 = STRCHR(cp, ':');
   1800  1.1  dholland 				if (cp2 != NULL)
   1801  1.1  dholland 					len = cp2 - cp;
   1802  1.1  dholland 				else
   1803  1.1  dholland 					len = 1;
   1804  1.1  dholland 				retnum += nfsm_strtom(nd, cp, len);
   1805  1.1  dholland 				if (cp2 != NULL)
   1806  1.1  dholland 					cp = cp2 + 1;
   1807  1.1  dholland 				cp2 = STRCHR(cp, ',');
   1808  1.1  dholland 				if (cp2 != NULL)
   1809  1.1  dholland 					len = cp2 - cp;
   1810  1.1  dholland 				else
   1811  1.1  dholland 					len = strlen(cp);
   1812  1.1  dholland 				retnum += nfsm_strtom(nd, cp, len);
   1813  1.1  dholland 				if (cp2 != NULL)
   1814  1.1  dholland 					cp = cp2 + 1;
   1815  1.1  dholland 			}
   1816  1.1  dholland 			break;
   1817  1.1  dholland 		case NFSATTRBIT_MOUNTEDONFILEID:
   1818  1.1  dholland 			NFSM_BUILD(tl, u_int32_t *, NFSX_HYPER);
   1819  1.1  dholland 			*tl++ = 0;
   1820  1.1  dholland 			*tl = txdr_unsigned(refp->nfr_dfileno);
   1821  1.1  dholland 			retnum += NFSX_HYPER;
   1822  1.1  dholland 			break;
   1823  1.1  dholland 		default:
   1824  1.1  dholland 			printf("EEK! Bad V4 refattr bitpos=%d\n", bitpos);
   1825  1.3  pgoyette 		}
   1826  1.1  dholland 	    }
   1827  1.1  dholland 	}
   1828  1.1  dholland 	*retnump = txdr_unsigned(retnum);
   1829  1.1  dholland 	return (retnum + prefixnum);
   1830  1.1  dholland }
   1831  1.1  dholland 
   1832  1.1  dholland /*
   1833  1.1  dholland  * Parse a file name out of a request.
   1834  1.1  dholland  */
   1835  1.1  dholland APPLESTATIC int
   1836  1.1  dholland nfsrv_parsename(struct nfsrv_descript *nd, char *bufp, u_long *hashp,
   1837  1.1  dholland     NFSPATHLEN_T *outlenp)
   1838  1.1  dholland {
   1839  1.1  dholland 	char *fromcp, *tocp, val = '\0';
   1840  1.1  dholland 	mbuf_t md;
   1841  1.1  dholland 	int i;
   1842  1.1  dholland 	int rem, len, error = 0, pubtype = 0, outlen = 0, percent = 0;
   1843  1.1  dholland 	char digit;
   1844  1.1  dholland 	u_int32_t *tl;
   1845  1.1  dholland 	u_long hash = 0;
   1846  1.1  dholland 
   1847  1.1  dholland 	if (hashp != NULL)
   1848  1.1  dholland 		*hashp = 0;
   1849  1.1  dholland 	tocp = bufp;
   1850  1.1  dholland 	/*
   1851  1.1  dholland 	 * For V4, check for lookup parent.
   1852  1.1  dholland 	 * Otherwise, get the component name.
   1853  1.1  dholland 	 */
   1854  1.1  dholland 	if ((nd->nd_flag & ND_NFSV4) && nd->nd_procnum == NFSV4OP_LOOKUPP) {
   1855  1.1  dholland 	    *tocp++ = '.';
   1856  1.1  dholland 	    hash += ((u_char)'.');
   1857  1.1  dholland 	    *tocp++ = '.';
   1858  1.1  dholland 	    hash += ((u_char)'.');
   1859  1.1  dholland 	    outlen = 2;
   1860  1.1  dholland 	} else {
   1861  1.1  dholland 	    /*
   1862  1.1  dholland 	     * First, get the name length.
   1863  1.1  dholland 	     */
   1864  1.1  dholland 	    NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED);
   1865  1.1  dholland 	    len = fxdr_unsigned(int, *tl);
   1866  1.1  dholland 	    if (len > NFS_MAXNAMLEN) {
   1867  1.1  dholland 		nd->nd_repstat = NFSERR_NAMETOL;
   1868  1.1  dholland 		error = 0;
   1869  1.1  dholland 		goto nfsmout;
   1870  1.1  dholland 	    } else if (len <= 0) {
   1871  1.1  dholland 		nd->nd_repstat = NFSERR_INVAL;
   1872  1.1  dholland 		error = 0;
   1873  1.1  dholland 		goto nfsmout;
   1874  1.1  dholland 	    }
   1875  1.1  dholland 
   1876  1.1  dholland 	    /*
   1877  1.1  dholland 	     * Now, copy the component name into the buffer.
   1878  1.1  dholland 	     */
   1879  1.1  dholland 	    fromcp = nd->nd_dpos;
   1880  1.1  dholland 	    md = nd->nd_md;
   1881  1.1  dholland 	    rem = NFSMTOD(md, caddr_t) + mbuf_len(md) - fromcp;
   1882  1.1  dholland 	    for (i = 0; i < len; i++) {
   1883  1.1  dholland 		while (rem == 0) {
   1884  1.1  dholland 			md = mbuf_next(md);
   1885  1.1  dholland 			if (md == NULL) {
   1886  1.1  dholland 				error = EBADRPC;
   1887  1.1  dholland 				goto nfsmout;
   1888  1.1  dholland 			}
   1889  1.1  dholland 			fromcp = NFSMTOD(md, caddr_t);
   1890  1.1  dholland 			rem = mbuf_len(md);
   1891  1.1  dholland 		}
   1892  1.1  dholland 		if (*fromcp == '\0') {
   1893  1.1  dholland 			nd->nd_repstat = EACCES;
   1894  1.1  dholland 			error = 0;
   1895  1.1  dholland 			goto nfsmout;
   1896  1.1  dholland 		}
   1897  1.1  dholland 		/*
   1898  1.1  dholland 		 * For lookups on the public filehandle, do some special
   1899  1.1  dholland 		 * processing on the name. (The public file handle is the
   1900  1.1  dholland 		 * root of the public file system for this server.)
   1901  1.1  dholland 		 */
   1902  1.1  dholland 		if (nd->nd_flag & ND_PUBLOOKUP) {
   1903  1.1  dholland 			/*
   1904  1.1  dholland 			 * If the first char is ASCII, it is a canonical
   1905  1.1  dholland 			 * path, otherwise it is a native path. (RFC2054
   1906  1.1  dholland 			 * doesn't actually state what it is if the first
   1907  1.1  dholland 			 * char isn't ASCII or 0x80, so I assume native.)
   1908  1.1  dholland 			 * pubtype == 1 -> native path
   1909  1.1  dholland 			 * pubtype == 2 -> canonical path
   1910  1.1  dholland 			 */
   1911  1.1  dholland 			if (i == 0) {
   1912  1.1  dholland 				if (*fromcp & 0x80) {
   1913  1.1  dholland 					/*
   1914  1.1  dholland 					 * Since RFC2054 doesn't indicate
   1915  1.1  dholland 					 * that a native path of just 0x80
   1916  1.1  dholland 					 * isn't allowed, I'll replace the
   1917  1.1  dholland 					 * 0x80 with '/' instead of just
   1918  1.1  dholland 					 * throwing it away.
   1919  1.1  dholland 					 */
   1920  1.1  dholland 					*fromcp = '/';
   1921  1.1  dholland 					pubtype = 1;
   1922  1.1  dholland 				} else {
   1923  1.1  dholland 					pubtype = 2;
   1924  1.1  dholland 				}
   1925  1.1  dholland 			}
   1926  1.1  dholland 			/*
   1927  1.1  dholland 			 * '/' only allowed in a native path
   1928  1.1  dholland 			 */
   1929  1.1  dholland 			if (*fromcp == '/' && pubtype != 1) {
   1930  1.1  dholland 				nd->nd_repstat = EACCES;
   1931  1.1  dholland 				error = 0;
   1932  1.1  dholland 				goto nfsmout;
   1933  1.1  dholland 			}
   1934  1.1  dholland 
   1935  1.1  dholland 			/*
   1936  1.1  dholland 			 * For the special case of 2 hex digits after a
   1937  1.1  dholland 			 * '%' in an absolute path, calculate the value.
   1938  1.1  dholland 			 * percent == 1 -> indicates "get first hex digit"
   1939  1.1  dholland 			 * percent == 2 -> indicates "get second hex digit"
   1940  1.1  dholland 			 */
   1941  1.1  dholland 			if (percent > 0) {
   1942  1.1  dholland 				digit = nfsrv_hexdigit(*fromcp, &error);
   1943  1.1  dholland 				if (error) {
   1944  1.1  dholland 					nd->nd_repstat = EACCES;
   1945  1.1  dholland 					error = 0;
   1946  1.1  dholland 					goto nfsmout;
   1947  1.1  dholland 				}
   1948  1.1  dholland 				if (percent == 1) {
   1949  1.1  dholland 					val = (digit << 4);
   1950  1.1  dholland 					percent = 2;
   1951  1.1  dholland 				} else {
   1952  1.1  dholland 					val += digit;
   1953  1.1  dholland 					percent = 0;
   1954  1.1  dholland 					*tocp++ = val;
   1955  1.1  dholland 					hash += ((u_char)val);
   1956  1.1  dholland 					outlen++;
   1957  1.1  dholland 				}
   1958  1.1  dholland 			} else {
   1959  1.1  dholland 				if (*fromcp == '%' && pubtype == 2) {
   1960  1.1  dholland 					/*
   1961  1.1  dholland 					 * Must be followed by 2 hex digits
   1962  1.1  dholland 					 */
   1963  1.1  dholland 					if ((len - i) < 3) {
   1964  1.1  dholland 						nd->nd_repstat = EACCES;
   1965  1.1  dholland 						error = 0;
   1966  1.1  dholland 						goto nfsmout;
   1967  1.1  dholland 					}
   1968  1.1  dholland 					percent = 1;
   1969  1.1  dholland 				} else {
   1970  1.1  dholland 					*tocp++ = *fromcp;
   1971  1.1  dholland 					hash += ((u_char)*fromcp);
   1972  1.1  dholland 					outlen++;
   1973  1.1  dholland 				}
   1974  1.1  dholland 			}
   1975  1.1  dholland 		} else {
   1976  1.1  dholland 			/*
   1977  1.1  dholland 			 * Normal, non lookup on public, name.
   1978  1.1  dholland 			 */
   1979  1.1  dholland 			if (*fromcp == '/') {
   1980  1.1  dholland 				if (nd->nd_flag & ND_NFSV4)
   1981  1.1  dholland 					nd->nd_repstat = NFSERR_BADNAME;
   1982  1.1  dholland 				else
   1983  1.1  dholland 					nd->nd_repstat = EACCES;
   1984  1.1  dholland 				error = 0;
   1985  1.1  dholland 				goto nfsmout;
   1986  1.1  dholland 			}
   1987  1.1  dholland 			hash += ((u_char)*fromcp);
   1988  1.1  dholland 			*tocp++ = *fromcp;
   1989  1.1  dholland 			outlen++;
   1990  1.1  dholland 		}
   1991  1.1  dholland 		fromcp++;
   1992  1.1  dholland 		rem--;
   1993  1.1  dholland 	    }
   1994  1.1  dholland 	    nd->nd_md = md;
   1995  1.1  dholland 	    nd->nd_dpos = fromcp;
   1996  1.1  dholland 	    i = NFSM_RNDUP(len) - len;
   1997  1.1  dholland 	    if (i > 0) {
   1998  1.1  dholland 		if (rem >= i) {
   1999  1.1  dholland 			nd->nd_dpos += i;
   2000  1.1  dholland 		} else {
   2001  1.1  dholland 			error = nfsm_advance(nd, i, rem);
   2002  1.1  dholland 			if (error)
   2003  1.1  dholland 				goto nfsmout;
   2004  1.1  dholland 		}
   2005  1.1  dholland 	    }
   2006  1.1  dholland 
   2007  1.1  dholland 	    /*
   2008  1.1  dholland 	     * For v4, don't allow lookups of '.' or '..' and
   2009  1.1  dholland 	     * also check for non-utf8 strings.
   2010  1.1  dholland 	     */
   2011  1.1  dholland 	    if (nd->nd_flag & ND_NFSV4) {
   2012  1.1  dholland 		if ((outlen == 1 && bufp[0] == '.') ||
   2013  1.1  dholland 		    (outlen == 2 && bufp[0] == '.' &&
   2014  1.1  dholland 		     bufp[1] == '.')) {
   2015  1.1  dholland 		    nd->nd_repstat = NFSERR_BADNAME;
   2016  1.1  dholland 		    error = 0;
   2017  1.1  dholland 		    goto nfsmout;
   2018  1.1  dholland 		}
   2019  1.3  pgoyette 		if (enable_checkutf8 == 1 &&
   2020  1.1  dholland 		    nfsrv_checkutf8((u_int8_t *)bufp, outlen)) {
   2021  1.1  dholland 		    nd->nd_repstat = NFSERR_INVAL;
   2022  1.1  dholland 		    error = 0;
   2023  1.1  dholland 		    goto nfsmout;
   2024  1.1  dholland 		}
   2025  1.1  dholland 	    }
   2026  1.1  dholland 	}
   2027  1.1  dholland 	*tocp = '\0';
   2028  1.1  dholland 	*outlenp = (size_t)outlen;
   2029  1.1  dholland 	if (hashp != NULL)
   2030  1.1  dholland 		*hashp = hash;
   2031  1.1  dholland nfsmout:
   2032  1.1  dholland 	NFSEXITCODE2(error, nd);
   2033  1.1  dholland 	return (error);
   2034  1.1  dholland }
   2035  1.1  dholland 
   2036  1.1  dholland void
   2037  1.1  dholland nfsd_init(void)
   2038  1.1  dholland {
   2039  1.1  dholland 	int i;
   2040  1.1  dholland 	static int inited = 0;
   2041  1.1  dholland 
   2042  1.1  dholland 	if (inited)
   2043  1.1  dholland 		return;
   2044  1.1  dholland 	inited = 1;
   2045  1.1  dholland 
   2046  1.1  dholland 	/*
   2047  1.1  dholland 	 * Initialize client queues. Don't free/reinitialize
   2048  1.1  dholland 	 * them when nfsds are restarted.
   2049  1.1  dholland 	 */
   2050  1.3  pgoyette 	nfsclienthash = malloc(sizeof(struct nfsclienthashhead) *
   2051  1.3  pgoyette 	    nfsrv_clienthashsize, M_NFSDCLIENT, M_WAITOK | M_ZERO);
   2052  1.3  pgoyette 	for (i = 0; i < nfsrv_clienthashsize; i++)
   2053  1.1  dholland 		LIST_INIT(&nfsclienthash[i]);
   2054  1.3  pgoyette 	nfslockhash = malloc(sizeof(struct nfslockhashhead) *
   2055  1.3  pgoyette 	    nfsrv_lockhashsize, M_NFSDLOCKFILE, M_WAITOK | M_ZERO);
   2056  1.3  pgoyette 	for (i = 0; i < nfsrv_lockhashsize; i++)
   2057  1.1  dholland 		LIST_INIT(&nfslockhash[i]);
   2058  1.3  pgoyette 	nfssessionhash = malloc(sizeof(struct nfssessionhash) *
   2059  1.3  pgoyette 	    nfsrv_sessionhashsize, M_NFSDSESSION, M_WAITOK | M_ZERO);
   2060  1.3  pgoyette 	for (i = 0; i < nfsrv_sessionhashsize; i++) {
   2061  1.3  pgoyette 		mtx_init(&nfssessionhash[i].mtx, "nfssm", NULL, MTX_DEF);
   2062  1.3  pgoyette 		LIST_INIT(&nfssessionhash[i].list);
   2063  1.3  pgoyette 	}
   2064  1.1  dholland 
   2065  1.1  dholland 	/* and the v2 pubfh should be all zeros */
   2066  1.1  dholland 	NFSBZERO(nfs_v2pubfh, NFSX_V2FH);
   2067  1.1  dholland }
   2068  1.1  dholland 
   2069  1.1  dholland /*
   2070  1.1  dholland  * Check the v4 root exports.
   2071  1.1  dholland  * Return 0 if ok, 1 otherwise.
   2072  1.1  dholland  */
   2073  1.1  dholland int
   2074  1.1  dholland nfsd_checkrootexp(struct nfsrv_descript *nd)
   2075  1.1  dholland {
   2076  1.1  dholland 
   2077  1.1  dholland 	if ((nd->nd_flag & (ND_GSS | ND_EXAUTHSYS)) == ND_EXAUTHSYS)
   2078  1.1  dholland 		return (0);
   2079  1.1  dholland 	if ((nd->nd_flag & (ND_GSSINTEGRITY | ND_EXGSSINTEGRITY)) ==
   2080  1.1  dholland 	    (ND_GSSINTEGRITY | ND_EXGSSINTEGRITY))
   2081  1.1  dholland 		return (0);
   2082  1.1  dholland 	if ((nd->nd_flag & (ND_GSSPRIVACY | ND_EXGSSPRIVACY)) ==
   2083  1.1  dholland 	    (ND_GSSPRIVACY | ND_EXGSSPRIVACY))
   2084  1.1  dholland 		return (0);
   2085  1.1  dholland 	if ((nd->nd_flag & (ND_GSS | ND_GSSINTEGRITY | ND_GSSPRIVACY |
   2086  1.1  dholland 	     ND_EXGSS)) == (ND_GSS | ND_EXGSS))
   2087  1.1  dholland 		return (0);
   2088  1.1  dholland 	return (1);
   2089  1.1  dholland }
   2090  1.1  dholland 
   2091  1.3  pgoyette /*
   2092  1.3  pgoyette  * Parse the first part of an NFSv4 compound to find out what the minor
   2093  1.3  pgoyette  * version# is.
   2094  1.3  pgoyette  */
   2095  1.3  pgoyette void
   2096  1.3  pgoyette nfsd_getminorvers(struct nfsrv_descript *nd, u_char *tag, u_char **tagstrp,
   2097  1.3  pgoyette     int *taglenp, u_int32_t *minversp)
   2098  1.3  pgoyette {
   2099  1.3  pgoyette 	uint32_t *tl;
   2100  1.3  pgoyette 	int error = 0, taglen = -1;
   2101  1.3  pgoyette 	u_char *tagstr = NULL;
   2102  1.3  pgoyette 
   2103  1.3  pgoyette 	NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED);
   2104  1.3  pgoyette 	taglen = fxdr_unsigned(int, *tl);
   2105  1.3  pgoyette 	if (taglen < 0 || taglen > NFSV4_OPAQUELIMIT) {
   2106  1.3  pgoyette 		error = EBADRPC;
   2107  1.3  pgoyette 		goto nfsmout;
   2108  1.3  pgoyette 	}
   2109  1.3  pgoyette 	if (taglen <= NFSV4_SMALLSTR)
   2110  1.3  pgoyette 		tagstr = tag;
   2111  1.3  pgoyette 	else
   2112  1.3  pgoyette 		tagstr = malloc(taglen + 1, M_TEMP, M_WAITOK);
   2113  1.3  pgoyette 	error = nfsrv_mtostr(nd, tagstr, taglen);
   2114  1.3  pgoyette 	if (error != 0)
   2115  1.3  pgoyette 		goto nfsmout;
   2116  1.3  pgoyette 	NFSM_DISSECT(tl, uint32_t *, NFSX_UNSIGNED);
   2117  1.3  pgoyette 	*minversp = fxdr_unsigned(u_int32_t, *tl);
   2118  1.3  pgoyette 	*tagstrp = tagstr;
   2119  1.3  pgoyette 	if (*minversp == NFSV41_MINORVERSION)
   2120  1.3  pgoyette 		nd->nd_flag |= ND_NFSV41;
   2121  1.3  pgoyette nfsmout:
   2122  1.3  pgoyette 	if (error != 0) {
   2123  1.3  pgoyette 		if (tagstr != NULL && taglen > NFSV4_SMALLSTR)
   2124  1.3  pgoyette 			free(tagstr, M_TEMP);
   2125  1.3  pgoyette 		taglen = -1;
   2126  1.3  pgoyette 	}
   2127  1.3  pgoyette 	*taglenp = taglen;
   2128  1.3  pgoyette }
   2129  1.3  pgoyette 
   2130