mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
NFSD: Add a helper that encodes NFSv3 directory offset cookies
Refactor: Add helper function similar to nfs3svc_encode_cookie3(). Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
@@ -595,8 +595,7 @@ nfsd_proc_readdir(struct svc_rqst *rqstp)
|
|||||||
&resp->common, nfssvc_encode_entry);
|
&resp->common, nfssvc_encode_entry);
|
||||||
|
|
||||||
resp->count = resp->buffer - buffer;
|
resp->count = resp->buffer - buffer;
|
||||||
if (resp->offset)
|
nfssvc_encode_nfscookie(resp, offset);
|
||||||
*resp->offset = htonl(offset);
|
|
||||||
|
|
||||||
fh_put(&argp->fh);
|
fh_put(&argp->fh);
|
||||||
return rpc_success;
|
return rpc_success;
|
||||||
|
@@ -614,6 +614,21 @@ nfssvc_encode_statfsres(struct svc_rqst *rqstp, __be32 *p)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nfssvc_encode_nfscookie - Encode a directory offset cookie
|
||||||
|
* @resp: readdir result context
|
||||||
|
* @offset: offset cookie to encode
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void nfssvc_encode_nfscookie(struct nfsd_readdirres *resp, u32 offset)
|
||||||
|
{
|
||||||
|
if (!resp->offset)
|
||||||
|
return;
|
||||||
|
|
||||||
|
*resp->offset = cpu_to_be32(offset);
|
||||||
|
resp->offset = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
nfssvc_encode_entry(void *ccdv, const char *name,
|
nfssvc_encode_entry(void *ccdv, const char *name,
|
||||||
int namlen, loff_t offset, u64 ino, unsigned int d_type)
|
int namlen, loff_t offset, u64 ino, unsigned int d_type)
|
||||||
@@ -632,8 +647,7 @@ nfssvc_encode_entry(void *ccdv, const char *name,
|
|||||||
cd->common.err = nfserr_fbig;
|
cd->common.err = nfserr_fbig;
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (cd->offset)
|
nfssvc_encode_nfscookie(cd, offset);
|
||||||
*cd->offset = htonl(offset);
|
|
||||||
|
|
||||||
/* truncate filename */
|
/* truncate filename */
|
||||||
namlen = min(namlen, NFS2_MAXNAMLEN);
|
namlen = min(namlen, NFS2_MAXNAMLEN);
|
||||||
|
@@ -157,6 +157,7 @@ int nfssvc_encode_readres(struct svc_rqst *, __be32 *);
|
|||||||
int nfssvc_encode_statfsres(struct svc_rqst *, __be32 *);
|
int nfssvc_encode_statfsres(struct svc_rqst *, __be32 *);
|
||||||
int nfssvc_encode_readdirres(struct svc_rqst *, __be32 *);
|
int nfssvc_encode_readdirres(struct svc_rqst *, __be32 *);
|
||||||
|
|
||||||
|
void nfssvc_encode_nfscookie(struct nfsd_readdirres *resp, u32 offset);
|
||||||
int nfssvc_encode_entry(void *, const char *name,
|
int nfssvc_encode_entry(void *, const char *name,
|
||||||
int namlen, loff_t offset, u64 ino, unsigned int);
|
int namlen, loff_t offset, u64 ino, unsigned int);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user