NFSD: Use xdrgen-generated NFSv2 protocol definitions

Switch the server's NFSv2 implementation to use the machine-
generated protocol definitions.

Acked-by: Jeff Layton <jlayton@kernel.org>
Link: https://patch.msgid.link/20260916162859.2051-6-cel@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
This commit is contained in:
Chuck Lever 2026-09-16 12:28:34 -04:00
parent f49b703d85
commit ffbf5434ee
6 changed files with 16 additions and 8 deletions

View File

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
#include <linux/module.h>
#include <uapi/linux/nfs.h>
#include <linux/nfs_common.h>
#include <linux/nfs4.h>
@ -53,12 +54,12 @@ static const struct {
* Returns a local errno value, or -EIO if the NFS status code is
* not recognized. This function is used jointly by NFSv2 and NFSv3.
*/
int nfs_stat_to_errno(enum nfs_stat status)
int nfs_stat_to_errno(int status)
{
int i;
for (i = 0; i < ARRAY_SIZE(nfs_errtbl); i++) {
if (nfs_errtbl[i].stat == (int)status)
if (nfs_errtbl[i].stat == status)
return nfs_errtbl[i].errno;
}
return -EIO;

View File

@ -12,8 +12,6 @@
#include <linux/types.h>
#include <linux/mount.h>
#include <linux/nfs.h>
#include <linux/nfs2.h>
#include <linux/sunrpc/svc.h>
#include <linux/sunrpc/svc_xprt.h>

View File

@ -10,7 +10,7 @@
#ifndef LINUX_NFSD_NFSERR_H
#define LINUX_NFSD_NFSERR_H
#include <linux/nfs.h>
#include <linux/sunrpc/xdrgen/nfs2.h>
#include <linux/nfs3.h>
#include <linux/nfs4.h>

View File

@ -6,7 +6,9 @@
*/
#include <linux/namei.h>
#include <linux/sunrpc/svc.h>
#include "nfs2xdr_gen.h"
#include "cache.h"
#include "xdr.h"
#include "vfs.h"

View File

@ -22,6 +22,13 @@
*/
#define NFS2_SATTR_SET_TO_SERVER_TIME (1000000)
/*
* Linux-internal ftype values for socket and unknown inodes, not
* in RFC 1094's wire enum; values match enum nfs_ftype.
*/
#define NFBAD (7)
#define NFSOCK (6)
/*
* Mapping of S_IF* types to NFS file types
*/
@ -599,7 +606,7 @@ svcxdr_encode_entry_common(struct nfsd_readdirres *resp, const char *name,
if (xdr_stream_encode_u32(xdr, (u32)ino) < 0)
return false;
/* name */
if (xdr_stream_encode_opaque(xdr, name, min(namlen, NFS2_MAXNAMLEN)) < 0)
if (xdr_stream_encode_opaque(xdr, name, min(namlen, NFS_MAXNAMLEN)) < 0)
return false;
/* cookie */
resp->cookie_offset = dirlist->len;

View File

@ -6,11 +6,11 @@
#define _LINUX_NFS_COMMON_H
#include <linux/errno.h>
#include <uapi/linux/nfs.h>
#include <linux/types.h>
/* Mapping from NFS error code to "errno" error code. */
int nfs_stat_to_errno(enum nfs_stat status);
int nfs_stat_to_errno(int status);
int nfs4_stat_to_errno(int stat);
__u32 nfs_localio_errno_to_nfs4_stat(int errno);