aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2011-02-22 18:44:31 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2011-03-11 15:39:26 -0500
commite4fd72a17d2703cfd626c55893ac4ca7e7d81ce9 (patch)
tree6e605693b5dbd9369b6dfc1ccd83cebcacfe9dc1 /fs/nfs
parentf0b851689a5da2354f19bcbbac30cd2cab45c4a1 (diff)
NFSv4: cleanup idmapper functions to take an nfs_server argument
...instead of the nfs_client. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/idmap.c24
-rw-r--r--fs/nfs/nfs4xdr.c18
2 files changed, 20 insertions, 22 deletions
diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c
index 8518573c3ff..e2d579d458f 100644
--- a/fs/nfs/idmap.c
+++ b/fs/nfs/idmap.c
@@ -241,21 +241,21 @@ static int nfs_idmap_lookup_id(const char *name, size_t namelen,
241 return ret; 241 return ret;
242} 242}
243 243
244int nfs_map_name_to_uid(struct nfs_client *clp, const char *name, size_t namelen, __u32 *uid) 244int nfs_map_name_to_uid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *uid)
245{ 245{
246 if (nfs_map_string_to_numeric(name, namelen, uid)) 246 if (nfs_map_string_to_numeric(name, namelen, uid))
247 return 0; 247 return 0;
248 return nfs_idmap_lookup_id(name, namelen, "uid", uid); 248 return nfs_idmap_lookup_id(name, namelen, "uid", uid);
249} 249}
250 250
251int nfs_map_group_to_gid(struct nfs_client *clp, const char *name, size_t namelen, __u32 *gid) 251int nfs_map_group_to_gid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *gid)
252{ 252{
253 if (nfs_map_string_to_numeric(name, namelen, gid)) 253 if (nfs_map_string_to_numeric(name, namelen, gid))
254 return 0; 254 return 0;
255 return nfs_idmap_lookup_id(name, namelen, "gid", gid); 255 return nfs_idmap_lookup_id(name, namelen, "gid", gid);
256} 256}
257 257
258int nfs_map_uid_to_name(struct nfs_client *clp, __u32 uid, char *buf, size_t buflen) 258int nfs_map_uid_to_name(const struct nfs_server *server, __u32 uid, char *buf, size_t buflen)
259{ 259{
260 int ret; 260 int ret;
261 ret = nfs_idmap_lookup_name(uid, "user", buf, buflen); 261 ret = nfs_idmap_lookup_name(uid, "user", buf, buflen);
@@ -263,7 +263,7 @@ int nfs_map_uid_to_name(struct nfs_client *clp, __u32 uid, char *buf, size_t buf
263 ret = nfs_map_numeric_to_string(uid, buf, buflen); 263 ret = nfs_map_numeric_to_string(uid, buf, buflen);
264 return ret; 264 return ret;
265} 265}
266int nfs_map_gid_to_group(struct nfs_client *clp, __u32 gid, char *buf, size_t buflen) 266int nfs_map_gid_to_group(const struct nfs_server *server, __u32 gid, char *buf, size_t buflen)
267{ 267{
268 int ret; 268 int ret;
269 269
@@ -729,27 +729,27 @@ static unsigned int fnvhash32(const void *buf, size_t buflen)
729 return hash; 729 return hash;
730} 730}
731 731
732int nfs_map_name_to_uid(struct nfs_client *clp, const char *name, size_t namelen, __u32 *uid) 732int nfs_map_name_to_uid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *uid)
733{ 733{
734 struct idmap *idmap = clp->cl_idmap; 734 struct idmap *idmap = server->nfs_client->cl_idmap;
735 735
736 if (nfs_map_string_to_numeric(name, namelen, uid)) 736 if (nfs_map_string_to_numeric(name, namelen, uid))
737 return 0; 737 return 0;
738 return nfs_idmap_id(idmap, &idmap->idmap_user_hash, name, namelen, uid); 738 return nfs_idmap_id(idmap, &idmap->idmap_user_hash, name, namelen, uid);
739} 739}
740 740
741int nfs_map_group_to_gid(struct nfs_client *clp, const char *name, size_t namelen, __u32 *uid) 741int nfs_map_group_to_gid(const struct nfs_server *server, const char *name, size_t namelen, __u32 *uid)
742{ 742{
743 struct idmap *idmap = clp->cl_idmap; 743 struct idmap *idmap = server->nfs_client->cl_idmap;
744 744
745 if (nfs_map_string_to_numeric(name, namelen, uid)) 745 if (nfs_map_string_to_numeric(name, namelen, uid))
746 return 0; 746 return 0;
747 return nfs_idmap_id(idmap, &idmap->idmap_group_hash, name, namelen, uid); 747 return nfs_idmap_id(idmap, &idmap->idmap_group_hash, name, namelen, uid);
748} 748}
749 749
750int nfs_map_uid_to_name(struct nfs_client *clp, __u32 uid, char *buf, size_t buflen) 750int nfs_map_uid_to_name(const struct nfs_server *server, __u32 uid, char *buf, size_t buflen)
751{ 751{
752 struct idmap *idmap = clp->cl_idmap; 752 struct idmap *idmap = server->nfs_client->cl_idmap;
753 int ret; 753 int ret;
754 754
755 ret = nfs_idmap_name(idmap, &idmap->idmap_user_hash, uid, buf); 755 ret = nfs_idmap_name(idmap, &idmap->idmap_user_hash, uid, buf);
@@ -757,9 +757,9 @@ int nfs_map_uid_to_name(struct nfs_client *clp, __u32 uid, char *buf, size_t buf
757 ret = nfs_map_numeric_to_string(uid, buf, buflen); 757 ret = nfs_map_numeric_to_string(uid, buf, buflen);
758 return ret; 758 return ret;
759} 759}
760int nfs_map_gid_to_group(struct nfs_client *clp, __u32 uid, char *buf, size_t buflen) 760int nfs_map_gid_to_group(const struct nfs_server *server, __u32 uid, char *buf, size_t buflen)
761{ 761{
762 struct idmap *idmap = clp->cl_idmap; 762 struct idmap *idmap = server->nfs_client->cl_idmap;
763 int ret; 763 int ret;
764 764
765 ret = nfs_idmap_name(idmap, &idmap->idmap_group_hash, uid, buf); 765 ret = nfs_idmap_name(idmap, &idmap->idmap_group_hash, uid, buf);
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 0f2dcfb41f2..686c21d8c52 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -844,7 +844,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const
844 if (iap->ia_valid & ATTR_MODE) 844 if (iap->ia_valid & ATTR_MODE)
845 len += 4; 845 len += 4;
846 if (iap->ia_valid & ATTR_UID) { 846 if (iap->ia_valid & ATTR_UID) {
847 owner_namelen = nfs_map_uid_to_name(server->nfs_client, iap->ia_uid, owner_name, IDMAP_NAMESZ); 847 owner_namelen = nfs_map_uid_to_name(server, iap->ia_uid, owner_name, IDMAP_NAMESZ);
848 if (owner_namelen < 0) { 848 if (owner_namelen < 0) {
849 dprintk("nfs: couldn't resolve uid %d to string\n", 849 dprintk("nfs: couldn't resolve uid %d to string\n",
850 iap->ia_uid); 850 iap->ia_uid);
@@ -856,7 +856,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const
856 len += 4 + (XDR_QUADLEN(owner_namelen) << 2); 856 len += 4 + (XDR_QUADLEN(owner_namelen) << 2);
857 } 857 }
858 if (iap->ia_valid & ATTR_GID) { 858 if (iap->ia_valid & ATTR_GID) {
859 owner_grouplen = nfs_map_gid_to_group(server->nfs_client, iap->ia_gid, owner_group, IDMAP_NAMESZ); 859 owner_grouplen = nfs_map_gid_to_group(server, iap->ia_gid, owner_group, IDMAP_NAMESZ);
860 if (owner_grouplen < 0) { 860 if (owner_grouplen < 0) {
861 dprintk("nfs: couldn't resolve gid %d to string\n", 861 dprintk("nfs: couldn't resolve gid %d to string\n",
862 iap->ia_gid); 862 iap->ia_gid);
@@ -3387,7 +3387,7 @@ out_overflow:
3387} 3387}
3388 3388
3389static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, 3389static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap,
3390 struct nfs_client *clp, uint32_t *uid, int may_sleep) 3390 const struct nfs_server *server, uint32_t *uid, int may_sleep)
3391{ 3391{
3392 uint32_t len; 3392 uint32_t len;
3393 __be32 *p; 3393 __be32 *p;
@@ -3407,7 +3407,7 @@ static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap,
3407 if (!may_sleep) { 3407 if (!may_sleep) {
3408 /* do nothing */ 3408 /* do nothing */
3409 } else if (len < XDR_MAX_NETOBJ) { 3409 } else if (len < XDR_MAX_NETOBJ) {
3410 if (nfs_map_name_to_uid(clp, (char *)p, len, uid) == 0) 3410 if (nfs_map_name_to_uid(server, (char *)p, len, uid) == 0)
3411 ret = NFS_ATTR_FATTR_OWNER; 3411 ret = NFS_ATTR_FATTR_OWNER;
3412 else 3412 else
3413 dprintk("%s: nfs_map_name_to_uid failed!\n", 3413 dprintk("%s: nfs_map_name_to_uid failed!\n",
@@ -3425,7 +3425,7 @@ out_overflow:
3425} 3425}
3426 3426
3427static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, 3427static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap,
3428 struct nfs_client *clp, uint32_t *gid, int may_sleep) 3428 const struct nfs_server *server, uint32_t *gid, int may_sleep)
3429{ 3429{
3430 uint32_t len; 3430 uint32_t len;
3431 __be32 *p; 3431 __be32 *p;
@@ -3445,7 +3445,7 @@ static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap,
3445 if (!may_sleep) { 3445 if (!may_sleep) {
3446 /* do nothing */ 3446 /* do nothing */
3447 } else if (len < XDR_MAX_NETOBJ) { 3447 } else if (len < XDR_MAX_NETOBJ) {
3448 if (nfs_map_group_to_gid(clp, (char *)p, len, gid) == 0) 3448 if (nfs_map_group_to_gid(server, (char *)p, len, gid) == 0)
3449 ret = NFS_ATTR_FATTR_GROUP; 3449 ret = NFS_ATTR_FATTR_GROUP;
3450 else 3450 else
3451 dprintk("%s: nfs_map_group_to_gid failed!\n", 3451 dprintk("%s: nfs_map_group_to_gid failed!\n",
@@ -3944,14 +3944,12 @@ static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap,
3944 goto xdr_error; 3944 goto xdr_error;
3945 fattr->valid |= status; 3945 fattr->valid |= status;
3946 3946
3947 status = decode_attr_owner(xdr, bitmap, server->nfs_client, 3947 status = decode_attr_owner(xdr, bitmap, server, &fattr->uid, may_sleep);
3948 &fattr->uid, may_sleep);
3949 if (status < 0) 3948 if (status < 0)
3950 goto xdr_error; 3949 goto xdr_error;
3951 fattr->valid |= status; 3950 fattr->valid |= status;
3952 3951
3953 status = decode_attr_group(xdr, bitmap, server->nfs_client, 3952 status = decode_attr_group(xdr, bitmap, server, &fattr->gid, may_sleep);
3954 &fattr->gid, may_sleep);
3955 if (status < 0) 3953 if (status < 0)
3956 goto xdr_error; 3954 goto xdr_error;
3957 fattr->valid |= status; 3955 fattr->valid |= status;