diff options
author | Kinglong Mee <kinglongmee@gmail.com> | 2015-07-30 09:55:30 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2015-08-31 16:16:40 -0400 |
commit | 75976de6556f593f6c2a18bbbcfb1e594cc7598a (patch) | |
tree | ab6a354d65c2b44a470e9ee53486d975d312ecf5 /fs/nfsd/nfs4xdr.c | |
parent | ead8fb8c24411722b92198b3dccd102a76cdd050 (diff) |
NFSD: Return word2 bitmask if setting security label in OPEN/CREATE
Security label can be set in OPEN/CREATE request, nfsd should set
the bitmask in word2 if setting success.
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4xdr.c')
-rw-r--r-- | fs/nfsd/nfs4xdr.c | 95 |
1 files changed, 56 insertions, 39 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 565b69ca04cd..51c9e9ca39a4 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -2226,6 +2226,39 @@ static int get_parent_attributes(struct svc_export *exp, struct kstat *stat) | |||
2226 | return err; | 2226 | return err; |
2227 | } | 2227 | } |
2228 | 2228 | ||
2229 | static __be32 | ||
2230 | nfsd4_encode_bitmap(struct xdr_stream *xdr, u32 bmval0, u32 bmval1, u32 bmval2) | ||
2231 | { | ||
2232 | __be32 *p; | ||
2233 | |||
2234 | if (bmval2) { | ||
2235 | p = xdr_reserve_space(xdr, 16); | ||
2236 | if (!p) | ||
2237 | goto out_resource; | ||
2238 | *p++ = cpu_to_be32(3); | ||
2239 | *p++ = cpu_to_be32(bmval0); | ||
2240 | *p++ = cpu_to_be32(bmval1); | ||
2241 | *p++ = cpu_to_be32(bmval2); | ||
2242 | } else if (bmval1) { | ||
2243 | p = xdr_reserve_space(xdr, 12); | ||
2244 | if (!p) | ||
2245 | goto out_resource; | ||
2246 | *p++ = cpu_to_be32(2); | ||
2247 | *p++ = cpu_to_be32(bmval0); | ||
2248 | *p++ = cpu_to_be32(bmval1); | ||
2249 | } else { | ||
2250 | p = xdr_reserve_space(xdr, 8); | ||
2251 | if (!p) | ||
2252 | goto out_resource; | ||
2253 | *p++ = cpu_to_be32(1); | ||
2254 | *p++ = cpu_to_be32(bmval0); | ||
2255 | } | ||
2256 | |||
2257 | return 0; | ||
2258 | out_resource: | ||
2259 | return nfserr_resource; | ||
2260 | } | ||
2261 | |||
2229 | /* | 2262 | /* |
2230 | * Note: @fhp can be NULL; in this case, we might have to compose the filehandle | 2263 | * Note: @fhp can be NULL; in this case, we might have to compose the filehandle |
2231 | * ourselves. | 2264 | * ourselves. |
@@ -2322,28 +2355,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, | |||
2322 | } | 2355 | } |
2323 | #endif /* CONFIG_NFSD_V4_SECURITY_LABEL */ | 2356 | #endif /* CONFIG_NFSD_V4_SECURITY_LABEL */ |
2324 | 2357 | ||
2325 | if (bmval2) { | 2358 | status = nfsd4_encode_bitmap(xdr, bmval0, bmval1, bmval2); |
2326 | p = xdr_reserve_space(xdr, 16); | 2359 | if (status) |
2327 | if (!p) | 2360 | goto out; |
2328 | goto out_resource; | ||
2329 | *p++ = cpu_to_be32(3); | ||
2330 | *p++ = cpu_to_be32(bmval0); | ||
2331 | *p++ = cpu_to_be32(bmval1); | ||
2332 | *p++ = cpu_to_be32(bmval2); | ||
2333 | } else if (bmval1) { | ||
2334 | p = xdr_reserve_space(xdr, 12); | ||
2335 | if (!p) | ||
2336 | goto out_resource; | ||
2337 | *p++ = cpu_to_be32(2); | ||
2338 | *p++ = cpu_to_be32(bmval0); | ||
2339 | *p++ = cpu_to_be32(bmval1); | ||
2340 | } else { | ||
2341 | p = xdr_reserve_space(xdr, 8); | ||
2342 | if (!p) | ||
2343 | goto out_resource; | ||
2344 | *p++ = cpu_to_be32(1); | ||
2345 | *p++ = cpu_to_be32(bmval0); | ||
2346 | } | ||
2347 | 2361 | ||
2348 | attrlen_offset = xdr->buf->len; | 2362 | attrlen_offset = xdr->buf->len; |
2349 | p = xdr_reserve_space(xdr, 4); | 2363 | p = xdr_reserve_space(xdr, 4); |
@@ -2736,13 +2750,11 @@ out_acl: | |||
2736 | } | 2750 | } |
2737 | #endif /* CONFIG_NFSD_PNFS */ | 2751 | #endif /* CONFIG_NFSD_PNFS */ |
2738 | if (bmval2 & FATTR4_WORD2_SUPPATTR_EXCLCREAT) { | 2752 | if (bmval2 & FATTR4_WORD2_SUPPATTR_EXCLCREAT) { |
2739 | p = xdr_reserve_space(xdr, 16); | 2753 | status = nfsd4_encode_bitmap(xdr, NFSD_SUPPATTR_EXCLCREAT_WORD0, |
2740 | if (!p) | 2754 | NFSD_SUPPATTR_EXCLCREAT_WORD1, |
2741 | goto out_resource; | 2755 | NFSD_SUPPATTR_EXCLCREAT_WORD2); |
2742 | *p++ = cpu_to_be32(3); | 2756 | if (status) |
2743 | *p++ = cpu_to_be32(NFSD_SUPPATTR_EXCLCREAT_WORD0); | 2757 | goto out; |
2744 | *p++ = cpu_to_be32(NFSD_SUPPATTR_EXCLCREAT_WORD1); | ||
2745 | *p++ = cpu_to_be32(NFSD_SUPPATTR_EXCLCREAT_WORD2); | ||
2746 | } | 2758 | } |
2747 | 2759 | ||
2748 | if (bmval2 & FATTR4_WORD2_SECURITY_LABEL) { | 2760 | if (bmval2 & FATTR4_WORD2_SECURITY_LABEL) { |
@@ -3069,13 +3081,12 @@ nfsd4_encode_create(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_ | |||
3069 | __be32 *p; | 3081 | __be32 *p; |
3070 | 3082 | ||
3071 | if (!nfserr) { | 3083 | if (!nfserr) { |
3072 | p = xdr_reserve_space(xdr, 32); | 3084 | p = xdr_reserve_space(xdr, 20); |
3073 | if (!p) | 3085 | if (!p) |
3074 | return nfserr_resource; | 3086 | return nfserr_resource; |
3075 | p = encode_cinfo(p, &create->cr_cinfo); | 3087 | encode_cinfo(p, &create->cr_cinfo); |
3076 | *p++ = cpu_to_be32(2); | 3088 | nfserr = nfsd4_encode_bitmap(xdr, create->cr_bmval[0], |
3077 | *p++ = cpu_to_be32(create->cr_bmval[0]); | 3089 | create->cr_bmval[1], create->cr_bmval[2]); |
3078 | *p++ = cpu_to_be32(create->cr_bmval[1]); | ||
3079 | } | 3090 | } |
3080 | return nfserr; | 3091 | return nfserr; |
3081 | } | 3092 | } |
@@ -3215,16 +3226,22 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_op | |||
3215 | nfserr = nfsd4_encode_stateid(xdr, &open->op_stateid); | 3226 | nfserr = nfsd4_encode_stateid(xdr, &open->op_stateid); |
3216 | if (nfserr) | 3227 | if (nfserr) |
3217 | goto out; | 3228 | goto out; |
3218 | p = xdr_reserve_space(xdr, 40); | 3229 | p = xdr_reserve_space(xdr, 24); |
3219 | if (!p) | 3230 | if (!p) |
3220 | return nfserr_resource; | 3231 | return nfserr_resource; |
3221 | p = encode_cinfo(p, &open->op_cinfo); | 3232 | p = encode_cinfo(p, &open->op_cinfo); |
3222 | *p++ = cpu_to_be32(open->op_rflags); | 3233 | *p++ = cpu_to_be32(open->op_rflags); |
3223 | *p++ = cpu_to_be32(2); | ||
3224 | *p++ = cpu_to_be32(open->op_bmval[0]); | ||
3225 | *p++ = cpu_to_be32(open->op_bmval[1]); | ||
3226 | *p++ = cpu_to_be32(open->op_delegate_type); | ||
3227 | 3234 | ||
3235 | nfserr = nfsd4_encode_bitmap(xdr, open->op_bmval[0], open->op_bmval[1], | ||
3236 | open->op_bmval[2]); | ||
3237 | if (nfserr) | ||
3238 | goto out; | ||
3239 | |||
3240 | p = xdr_reserve_space(xdr, 4); | ||
3241 | if (!p) | ||
3242 | return nfserr_resource; | ||
3243 | |||
3244 | *p++ = cpu_to_be32(open->op_delegate_type); | ||
3228 | switch (open->op_delegate_type) { | 3245 | switch (open->op_delegate_type) { |
3229 | case NFS4_OPEN_DELEGATE_NONE: | 3246 | case NFS4_OPEN_DELEGATE_NONE: |
3230 | break; | 3247 | break; |