From 374e7ad083dbbf9bbb46f5b66ec16d49fe2fd86c Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 12 Oct 2010 10:00:19 -0400 Subject: [PATCH] symlink: nfs41_readlink() takes buf,len instead of nfs41_abs_path also changed nfs41_readlink_res.link from a buffer to a pointer to avoid the extra copy Signed-off-by: Casey Bodley --- daemon/nfs41_ops.c | 17 +++++++---------- daemon/nfs41_ops.h | 6 ++++-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c index 9a6a83a..2dc3b9a 100644 --- a/daemon/nfs41_ops.c +++ b/daemon/nfs41_ops.c @@ -1349,7 +1349,9 @@ out: int nfs41_readlink( IN nfs41_session *session, IN nfs41_path_fh *file, - OUT nfs41_abs_path *link_out) + IN uint32_t max_len, + OUT char *link_out, + OUT uint32_t *len_out) { int status; nfs41_compound compound; @@ -1373,7 +1375,8 @@ int nfs41_readlink( putfh_args.in_recovery = 0; compound_add_op(&compound, OP_READLINK, NULL, &readlink_res); - readlink_res.link_len = NFS4_OPAQUE_LIMIT; + readlink_res.link_len = max_len - 1; + readlink_res.link = link_out; status = compound_encode_send_decode(session, &compound, 0, 0); if (status) @@ -1382,14 +1385,8 @@ int nfs41_readlink( if (compound_error(status = compound.res.status)) goto out; - if (readlink_res.link_len >= NFS41_MAX_PATH_LEN) { - status = NFS4ERR_REP_TOO_BIG; - goto out; - } - AcquireSRWLockExclusive(&link_out->lock); - link_out->len = (unsigned short)readlink_res.link_len; - memcpy(link_out->path, readlink_res.link, readlink_res.link_len); - ReleaseSRWLockExclusive(&link_out->lock); + link_out[readlink_res.link_len] = '\0'; + *len_out = readlink_res.link_len; out: return status; } diff --git a/daemon/nfs41_ops.h b/daemon/nfs41_ops.h index ca50b57..56b941d 100644 --- a/daemon/nfs41_ops.h +++ b/daemon/nfs41_ops.h @@ -683,7 +683,7 @@ typedef struct __nfs41_readlink_res { uint32_t status; /* case NFS4_OK: */ uint32_t link_len; - char link[NFS4_OPAQUE_LIMIT]; + char *link; } nfs41_readlink_res; @@ -1023,7 +1023,9 @@ int nfs41_link( int nfs41_readlink( IN nfs41_session *session, IN nfs41_path_fh *file, - OUT nfs41_abs_path *link_out); + IN uint32_t max_len, + OUT char *link_out, + OUT uint32_t *len_out); int nfs41_access( IN nfs41_session *session,