Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / nfsd / nfsxdr.c
index 979b421069792abe517a5c210dd47d4418723b11..9c769a47ac5ab7efc9a2b939305ffbad45ed988f 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  */
 
+#include "vfs.h"
 #include "xdr.h"
 #include "auth.h"
 
@@ -100,12 +101,14 @@ decode_sattr(__be32 *p, struct iattr *iap)
                iap->ia_mode = tmp;
        }
        if ((tmp = ntohl(*p++)) != (u32)-1) {
-               iap->ia_valid |= ATTR_UID;
-               iap->ia_uid = tmp;
+               iap->ia_uid = make_kuid(&init_user_ns, tmp);
+               if (uid_valid(iap->ia_uid))
+                       iap->ia_valid |= ATTR_UID;
        }
        if ((tmp = ntohl(*p++)) != (u32)-1) {
-               iap->ia_valid |= ATTR_GID;
-               iap->ia_gid = tmp;
+               iap->ia_gid = make_kgid(&init_user_ns, tmp);
+               if (gid_valid(iap->ia_gid))
+                       iap->ia_valid |= ATTR_GID;
        }
        if ((tmp = ntohl(*p++)) != (u32)-1) {
                iap->ia_valid |= ATTR_SIZE;
@@ -151,8 +154,8 @@ encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
        *p++ = htonl(nfs_ftypes[type >> 12]);
        *p++ = htonl((u32) stat->mode);
        *p++ = htonl((u32) stat->nlink);
-       *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
-       *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
+       *p++ = htonl((u32) from_kuid(&init_user_ns, stat->uid));
+       *p++ = htonl((u32) from_kgid(&init_user_ns, stat->gid));
 
        if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
                *p++ = htonl(NFS_MAXPATHLEN);
@@ -194,11 +197,9 @@ encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
 }
 
 /* Helper function for NFSv2 ACL code */
-__be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
+__be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, struct kstat *stat)
 {
-       struct kstat stat;
-       vfs_getattr(fhp->fh_export->ex_path.mnt, fhp->fh_dentry, &stat);
-       return encode_fattr(rqstp, p, fhp, &stat);
+       return encode_fattr(rqstp, p, fhp, stat);
 }
 
 /*