-/* $OpenBSD: nfs_socket.c,v 1.149 2024/04/30 17:04:23 miod Exp $ */
+/* $OpenBSD: nfs_socket.c,v 1.150 2024/04/30 17:05:20 miod Exp $ */
/* $NetBSD: nfs_socket.c,v 1.27 1996/04/15 20:20:00 thorpej Exp $ */
/*
rpc_auth_unix, rpc_msgaccepted, rpc_call, rpc_autherr;
extern u_int32_t nfs_prog;
extern struct nfsstats nfsstats;
-extern int nfsv3_procid[NFS_NPROCS];
+extern const int nfsv3_procid[NFS_NPROCS];
extern int nfs_ticks;
extern struct pool nfsrv_descript_pl;
*/
#define NFS_CWNDSCALE 256
#define NFS_MAXCWND (NFS_CWNDSCALE * 32)
-int nfs_backoff[8] = { 2, 4, 8, 16, 32, 64, 128, 256 };
+static const int nfs_backoff[8] = { 2, 4, 8, 16, 32, 64, 128, 256 };
/* RTT estimator */
-enum nfs_rto_timers nfs_ptimers[NFS_NPROCS] = {
+static const enum nfs_rto_timers nfs_ptimers[NFS_NPROCS] = {
NFS_DEFAULT_TIMER, /* NULL */
NFS_GETATTR_TIMER, /* GETATTR */
NFS_DEFAULT_TIMER, /* SETATTR */
-/* $OpenBSD: nfs_subs.c,v 1.147 2024/04/30 17:04:23 miod Exp $ */
+/* $OpenBSD: nfs_subs.c,v 1.148 2024/04/30 17:05:20 miod Exp $ */
/* $NetBSD: nfs_subs.c,v 1.27.4.3 1996/07/08 20:34:24 jtc Exp $ */
/*
u_int32_t nfs_prog, nfs_true, nfs_false;
/* And other global data */
-nfstype nfsv2_type[9] = { NFNON, NFREG, NFDIR, NFBLK, NFCHR, NFLNK, NFNON,
- NFCHR, NFNON };
-nfstype nfsv3_type[9] = { NFNON, NFREG, NFDIR, NFBLK, NFCHR, NFLNK, NFSOCK,
- NFFIFO, NFNON };
-enum vtype nv2tov_type[8] = { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VNON, VNON };
-enum vtype nv3tov_type[8]={ VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO };
+const nfstype nfsv2_type[9] =
+ { NFNON, NFREG, NFDIR, NFBLK, NFCHR, NFLNK, NFNON, NFCHR, NFNON };
+const nfstype nfsv3_type[9] =
+ { NFNON, NFREG, NFDIR, NFBLK, NFCHR, NFLNK, NFSOCK, NFFIFO, NFNON };
+const enum vtype nv2tov_type[8] =
+ { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VNON, VNON };
+const enum vtype nv3tov_type[8]=
+ { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO };
int nfs_ticks;
struct nfsstats nfsstats;
/*
* Mapping of old NFS Version 2 RPC numbers to generic numbers.
*/
-int nfsv3_procid[NFS_NPROCS] = {
+const int nfsv3_procid[NFS_NPROCS] = {
NFSPROC_NULL,
NFSPROC_GETATTR,
NFSPROC_SETATTR,
/*
* and the reverse mapping from generic to Version 2 procedure numbers
*/
-int nfsv2_procid[NFS_NPROCS] = {
+const int nfsv2_procid[NFS_NPROCS] = {
NFSV2PROC_NULL,
NFSV2PROC_GETATTR,
NFSV2PROC_SETATTR,
* Use NFSERR_IO as the catch all for ones not specifically defined in
* RFC 1094.
*/
-static u_char nfsrv_v2errmap[] = {
+static const u_char nfsrv_v2errmap[] = {
NFSERR_PERM, NFSERR_NOENT, NFSERR_IO, NFSERR_IO, NFSERR_IO,
NFSERR_NXIO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
NFSERR_IO, NFSERR_IO, NFSERR_ACCES, NFSERR_IO, NFSERR_IO,
* The first entry is the default error return and the rest are the valid
* errors for that RPC in increasing numeric order.
*/
-static short nfsv3err_null[] = {
+static const short nfsv3err_null[] = {
0,
0,
};
-static short nfsv3err_getattr[] = {
+static const short nfsv3err_getattr[] = {
NFSERR_IO,
NFSERR_IO,
NFSERR_STALE,
0,
};
-static short nfsv3err_setattr[] = {
+static const short nfsv3err_setattr[] = {
NFSERR_IO,
NFSERR_PERM,
NFSERR_IO,
0,
};
-static short nfsv3err_lookup[] = {
+static const short nfsv3err_lookup[] = {
NFSERR_IO,
NFSERR_NOENT,
NFSERR_IO,
0,
};
-static short nfsv3err_access[] = {
+static const short nfsv3err_access[] = {
NFSERR_IO,
NFSERR_IO,
NFSERR_STALE,
0,
};
-static short nfsv3err_readlink[] = {
+static const short nfsv3err_readlink[] = {
NFSERR_IO,
NFSERR_IO,
NFSERR_ACCES,
0,
};
-static short nfsv3err_read[] = {
+static const short nfsv3err_read[] = {
NFSERR_IO,
NFSERR_IO,
NFSERR_NXIO,
0,
};
-static short nfsv3err_write[] = {
+static const short nfsv3err_write[] = {
NFSERR_IO,
NFSERR_IO,
NFSERR_ACCES,
0,
};
-static short nfsv3err_create[] = {
+static const short nfsv3err_create[] = {
NFSERR_IO,
NFSERR_IO,
NFSERR_ACCES,
0,
};
-static short nfsv3err_mkdir[] = {
+static const short nfsv3err_mkdir[] = {
NFSERR_IO,
NFSERR_IO,
NFSERR_ACCES,
0,
};
-static short nfsv3err_symlink[] = {
+static const short nfsv3err_symlink[] = {
NFSERR_IO,
NFSERR_IO,
NFSERR_ACCES,
0,
};
-static short nfsv3err_mknod[] = {
+static const short nfsv3err_mknod[] = {
NFSERR_IO,
NFSERR_IO,
NFSERR_ACCES,
0,
};
-static short nfsv3err_remove[] = {
+static const short nfsv3err_remove[] = {
NFSERR_IO,
NFSERR_NOENT,
NFSERR_IO,
0,
};
-static short nfsv3err_rmdir[] = {
+static const short nfsv3err_rmdir[] = {
NFSERR_IO,
NFSERR_NOENT,
NFSERR_IO,
0,
};
-static short nfsv3err_rename[] = {
+static const short nfsv3err_rename[] = {
NFSERR_IO,
NFSERR_NOENT,
NFSERR_IO,
0,
};
-static short nfsv3err_link[] = {
+static const short nfsv3err_link[] = {
NFSERR_IO,
NFSERR_IO,
NFSERR_ACCES,
0,
};
-static short nfsv3err_readdir[] = {
+static const short nfsv3err_readdir[] = {
NFSERR_IO,
NFSERR_IO,
NFSERR_ACCES,
0,
};
-static short nfsv3err_readdirplus[] = {
+static const short nfsv3err_readdirplus[] = {
NFSERR_IO,
NFSERR_IO,
NFSERR_ACCES,
0,
};
-static short nfsv3err_fsstat[] = {
+static const short nfsv3err_fsstat[] = {
NFSERR_IO,
NFSERR_IO,
NFSERR_STALE,
0,
};
-static short nfsv3err_fsinfo[] = {
+static const short nfsv3err_fsinfo[] = {
NFSERR_STALE,
NFSERR_STALE,
NFSERR_BADHANDLE,
0,
};
-static short nfsv3err_pathconf[] = {
+static const short nfsv3err_pathconf[] = {
NFSERR_STALE,
NFSERR_STALE,
NFSERR_BADHANDLE,
0,
};
-static short nfsv3err_commit[] = {
+static const short nfsv3err_commit[] = {
NFSERR_IO,
NFSERR_IO,
NFSERR_STALE,
0,
};
-static short *nfsrv_v3errmap[] = {
+static const short *nfsrv_v3errmap[] = {
nfsv3err_null,
nfsv3err_getattr,
nfsv3err_setattr,
int
nfsrv_errmap(struct nfsrv_descript *nd, int err)
{
- short *defaulterrp, *errp;
+ const short *defaulterrp, *errp;
if (nd->nd_flag & ND_NFSV3) {
if (nd->nd_procnum <= NFSPROC_COMMIT) {