NFSD: Return NFSERR_ISDIR for NFSv2 READ and WRITE on a non-regular file
Subsystems (2)
Chuck Lever
maintainerPATCH 1/1 NFSD: Return NFSERR_ISDIR for NFSv2 READ and WRITE on a non-regular file
Commit 0ac903d1bfdc ("NFS: NFSERR_INVAL is not defined by NFSv2") changed the status NFSD returns for an NFSv2 READ or WRITE of a symlink or other non-regular file from NFSERR_INVAL to NFSERR_IO. RFC 1094 defines neither an INVAL nor a SYMLINK status.
U-Boot's NFS client follows a symlink only when READ fails with NFSERR_ISDIR or NFSERR_INVAL. Since that commit it cannot load a boot image through a symlink exported by a Linux NFS server: the load completes with zero bytes transferred.
Solaris returns NFSERR_ISDIR when the target of an NFSv2 READ or WRITE is not a regular file. Return the same status from NFSD. Other NFSv2 procedures continue to return NFSERR_IO.
--- fs/nfsd/nfsproc.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
fs/nfsd/nfsproc.c +17 -2
@@ -40,6 +40,21 @@ static __be32 nfsd_map_status(__be32 status)return status; } +/* +* Because NFSv2 does not have an NFSERR_SYMLINK, Solaris returns +* NFSERR_ISDIR when the target of a READ or WRITE is any object +* that is not a regular file. +*/ +static __be32 nfsd_map_io_status (__be32 status) +{ +switch (status) { +case nfserr_symlink: +case nfserr_wrong_type: +return nfserr_isdir; + } +return nfsd_map_status (status); +} +static __be32 nfsd_proc_null (struct svc_rqst *rqstp) {
@@ -238,7 +253,7 @@ nfsd_proc_read(struct svc_rqst *rqstp) resp->status =fh_getattr (&resp->fh, &resp->stat); else if (resp->status == nfserr_jukebox) set_bit(RQ_DROPME, &rqstp->rq_flags); - resp->status =nfsd_map_status (resp->status); + resp->status =nfsd_map_io_status (resp->status);return rpc_success; }
@@ -271,7 +286,7 @@ nfsd_proc_write(struct svc_rqst *rqstp) resp->status =fh_getattr (&resp->fh, &resp->stat); else if (resp->status == nfserr_jukebox) set_bit(RQ_DROPME, &rqstp->rq_flags); - resp->status =nfsd_map_status (resp->status); + resp->status =nfsd_map_io_status (resp->status);return rpc_success; }
Signature · 1 line
2.55.0
Quoted 58 lines · Chuck Lever
Commit
0ac903d1bfdc("NFS:NFSERR_INVALis not defined by NFSv2") changed the status NFSD returns for an NFSv2 READ or WRITE of a symlink or other non-regular file fromNFSERR_INVALtoNFSERR_IO. RFC 1094 defines neither an INVAL nor a SYMLINK status.U-Boot's NFS client follows a symlink only when READ fails with
NFSERR_ISDIRorNFSERR_INVAL. Since that commit it cannot load a boot image through a symlink exported by a Linux NFS server: the load completes with zero bytes transferred.Solaris returns
NFSERR_ISDIRwhen the target of an NFSv2 READ or WRITE is not a regular file. Return the same status from NFSD. Other NFSv2 procedures continue to returnNFSERR_IO.Fixes 0ac903d1bfdc ("NFS: NFSERR_INVAL is not defined by NFSv2")Reported-by Jörg Sommer <[email protected]>Signed-off-by Chuck Lever <[email protected]>--- fs/nfsd/nfsproc.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)fs/nfsd/nfsproc.c +16
-1@@ -40,6 +40,21 @@ static __be32 nfsd_map_status(__be32 status)return status; } +/* +* Because NFSv2 does not have an NFSERR_SYMLINK, Solaris returns +* NFSERR_ISDIR when the target of a READ or WRITE is any object +* that is not a regular file. +*/ +static __be32 nfsd_map_io_status (__be32 status) +{ +switch (status) { +case nfserr_symlink: +case nfserr_wrong_type: +return nfserr_isdir; + } +return nfsd_map_status (status); +} +static __be32 nfsd_proc_null (struct svc_rqst *rqstp) {@@ -238,7 +253,7 @@ nfsd_proc_read(struct svc_rqst *rqstp) resp->status =fh_getattr (&resp->fh, &resp->stat); else if (resp->status == nfserr_jukebox) set_bit(RQ_DROPME, &rqstp->rq_flags); - resp->status =nfsd_map_status (resp->status); + resp->status =nfsd_map_io_status (resp->status);return rpc_success; }
fs/nfsd/nfsproc.c nfsd_proc_write(struct svc_rqst *rqstp) · line 292
Quoted 8 lines
fs/nfsd/nfsproc.c +1
-1@@ -271,7 +286,7 @@ nfsd_proc_write(struct svc_rqst *rqstp) resp->status =fh_getattr (&resp->fh, &resp->stat); else if (resp->status == nfserr_jukebox) set_bit(RQ_DROPME, &rqstp->rq_flags); - resp->status =nfsd_map_status (resp->status); + resp->status =nfsd_map_io_status (resp->status);return rpc_success; }
Quoted 10 lines · Chuck Lever
Commit
0ac903d1bfdc("NFS:NFSERR_INVALis not defined by NFSv2") changed the status NFSD returns for an NFSv2 READ or WRITE of a symlink or other non-regular file fromNFSERR_INVALtoNFSERR_IO. RFC 1094 defines neither an INVAL nor a SYMLINK status.U-Boot's NFS client follows a symlink only when READ fails with
NFSERR_ISDIRorNFSERR_INVAL. Since that commit it cannot load a boot image through a symlink exported by a Linux NFS server: the load completes with zero bytes transferred.
Quoted 8 lines
Solaris returns
NFSERR_ISDIRwhen the target of an NFSv2 READ or WRITE is not a regular file. Return the same status from NFSD. Other NFSv2 procedures continue to returnNFSERR_IO.Fixes 0ac903d1bfdc ("NFS: NFSERR_INVAL is not defined by NFSv2")Reported-by Jörg Sommer <[email protected]>Signed-off-by Chuck Lever <[email protected]>
The only places that openSolaris returns NFSERR_ISDIR when the object might not be a directory are in rfs_read(), rfs_write(), and rfs_write_sync(), which is called for rfs_write().
So adding this special handling only for nfsd_proc_read() and nfsd_proc_write() makes sense.
Thanks,
NeilBrown
Quoted 52 lines
--- fs/nfsd/nfsproc.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)fs/nfsd/nfsproc.c +17
-2@@ -40,6 +40,21 @@ static __be32 nfsd_map_status(__be32 status)return status; } +/* +* Because NFSv2 does not have an NFSERR_SYMLINK, Solaris returns +* NFSERR_ISDIR when the target of a READ or WRITE is any object +* that is not a regular file. +*/ +static __be32 nfsd_map_io_status (__be32 status) +{ +switch (status) { +case nfserr_symlink: +case nfserr_wrong_type: +return nfserr_isdir; + } +return nfsd_map_status (status); +} +static __be32 nfsd_proc_null (struct svc_rqst *rqstp) {@@ -238,7 +253,7 @@ nfsd_proc_read(struct svc_rqst *rqstp) resp->status =fh_getattr (&resp->fh, &resp->stat); else if (resp->status == nfserr_jukebox) set_bit(RQ_DROPME, &rqstp->rq_flags); - resp->status =nfsd_map_status (resp->status); + resp->status =nfsd_map_io_status (resp->status);return rpc_success; }@@ -271,7 +286,7 @@ nfsd_proc_write(struct svc_rqst *rqstp) resp->status =fh_getattr (&resp->fh, &resp->stat); else if (resp->status == nfserr_jukebox) set_bit(RQ_DROPME, &rqstp->rq_flags); - resp->status =nfsd_map_status (resp->status); + resp->status =nfsd_map_io_status (resp->status);return rpc_success; }Signature · 1 line
2.55.0