diff options
author | Steve Dickson <steved@redhat.com> | 2013-05-22 12:50:40 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2013-06-08 16:20:14 -0400 |
commit | e058f70b8070608fedfd3e39c2ead935beecb552 (patch) | |
tree | 7edaeed13f64d0218d8541321e2a6c780ee59986 | |
parent | e64a4210f69010d0ff349d5889b50fed51f8bdd0 (diff) |
NFSv4: Introduce new label structure
In order to mimic the way that NFSv4 ACLs are implemented we have created a
structure to be used to pass label data up and down the call chain. This patch
adds the new structure and new members to the required NFSv4 call structures.
Signed-off-by: Matthew N. Dodd <Matthew.Dodd@sparta.com>
Signed-off-by: Miguel Rodel Felipe <Rodel_FM@dsi.a-star.edu.sg>
Signed-off-by: Phua Eu Gene <PHUA_Eu_Gene@dsi.a-star.edu.sg>
Signed-off-by: Khin Mi Mi Aung <Mi_Mi_AUNG@dsi.a-star.edu.sg>
Signed-off-by: Steve Dickson <steved@redhat.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/nfs/inode.c | 28 | ||||
-rw-r--r-- | include/linux/nfs4.h | 9 | ||||
-rw-r--r-- | include/linux/nfs_fs.h | 18 | ||||
-rw-r--r-- | include/linux/nfs_xdr.h | 10 |
4 files changed, 65 insertions, 0 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index c1c7a9d78722..07fcf0b90669 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -257,6 +257,34 @@ nfs_init_locked(struct inode *inode, void *opaque) | |||
257 | return 0; | 257 | return 0; |
258 | } | 258 | } |
259 | 259 | ||
260 | #ifdef CONFIG_NFS_V4_SECURITY_LABEL | ||
261 | struct nfs4_label *nfs4_label_alloc(struct nfs_server *server, gfp_t flags) | ||
262 | { | ||
263 | struct nfs4_label *label = NULL; | ||
264 | int minor_version = server->nfs_client->cl_minorversion; | ||
265 | |||
266 | if (minor_version < 2) | ||
267 | return label; | ||
268 | |||
269 | if (!(server->caps & NFS_CAP_SECURITY_LABEL)) | ||
270 | return label; | ||
271 | |||
272 | label = kzalloc(sizeof(struct nfs4_label), flags); | ||
273 | if (label == NULL) | ||
274 | return ERR_PTR(-ENOMEM); | ||
275 | |||
276 | label->label = kzalloc(NFS4_MAXLABELLEN, flags); | ||
277 | if (label->label == NULL) { | ||
278 | kfree(label); | ||
279 | return ERR_PTR(-ENOMEM); | ||
280 | } | ||
281 | label->len = NFS4_MAXLABELLEN; | ||
282 | |||
283 | return label; | ||
284 | } | ||
285 | EXPORT_SYMBOL_GPL(nfs4_label_alloc); | ||
286 | #endif | ||
287 | |||
260 | /* | 288 | /* |
261 | * This is our front-end to iget that looks up inodes by file handle | 289 | * This is our front-end to iget that looks up inodes by file handle |
262 | * instead of inode number. | 290 | * instead of inode number. |
diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index 42046004a2f6..e36dee52f224 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h | |||
@@ -32,6 +32,15 @@ struct nfs4_acl { | |||
32 | struct nfs4_ace aces[0]; | 32 | struct nfs4_ace aces[0]; |
33 | }; | 33 | }; |
34 | 34 | ||
35 | #define NFS4_MAXLABELLEN 2048 | ||
36 | |||
37 | struct nfs4_label { | ||
38 | uint32_t lfs; | ||
39 | uint32_t pi; | ||
40 | u32 len; | ||
41 | char *label; | ||
42 | }; | ||
43 | |||
35 | typedef struct { char data[NFS4_VERIFIER_SIZE]; } nfs4_verifier; | 44 | typedef struct { char data[NFS4_VERIFIER_SIZE]; } nfs4_verifier; |
36 | 45 | ||
37 | struct nfs_stateid4 { | 46 | struct nfs_stateid4 { |
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index fc01d5cb4cf1..39b24041a4c7 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h | |||
@@ -497,6 +497,24 @@ extern int nfs_mountpoint_expiry_timeout; | |||
497 | extern void nfs_release_automount_timer(void); | 497 | extern void nfs_release_automount_timer(void); |
498 | 498 | ||
499 | /* | 499 | /* |
500 | * linux/fs/nfs/nfs4proc.c | ||
501 | */ | ||
502 | #ifdef CONFIG_NFS_V4_SECURITY_LABEL | ||
503 | extern struct nfs4_label *nfs4_label_alloc(struct nfs_server *server, gfp_t flags); | ||
504 | static inline void nfs4_label_free(struct nfs4_label *label) | ||
505 | { | ||
506 | if (label) { | ||
507 | kfree(label->label); | ||
508 | kfree(label); | ||
509 | } | ||
510 | return; | ||
511 | } | ||
512 | #else | ||
513 | static inline struct nfs4_label *nfs4_label_alloc(struct nfs_server *server, gfp_t flags) { return NULL; } | ||
514 | static inline void nfs4_label_free(void *label) {} | ||
515 | #endif | ||
516 | |||
517 | /* | ||
500 | * linux/fs/nfs/unlink.c | 518 | * linux/fs/nfs/unlink.c |
501 | */ | 519 | */ |
502 | extern void nfs_complete_unlink(struct dentry *dentry, struct inode *); | 520 | extern void nfs_complete_unlink(struct dentry *dentry, struct inode *); |
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index bfdf6e042838..d799b9f86820 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h | |||
@@ -349,6 +349,7 @@ struct nfs_openargs { | |||
349 | const u32 * open_bitmap; | 349 | const u32 * open_bitmap; |
350 | __u32 claim; | 350 | __u32 claim; |
351 | enum createmode4 createmode; | 351 | enum createmode4 createmode; |
352 | const struct nfs4_label *label; | ||
352 | }; | 353 | }; |
353 | 354 | ||
354 | struct nfs_openres { | 355 | struct nfs_openres { |
@@ -358,6 +359,7 @@ struct nfs_openres { | |||
358 | struct nfs4_change_info cinfo; | 359 | struct nfs4_change_info cinfo; |
359 | __u32 rflags; | 360 | __u32 rflags; |
360 | struct nfs_fattr * f_attr; | 361 | struct nfs_fattr * f_attr; |
362 | struct nfs4_label *f_label; | ||
361 | struct nfs_seqid * seqid; | 363 | struct nfs_seqid * seqid; |
362 | const struct nfs_server *server; | 364 | const struct nfs_server *server; |
363 | fmode_t delegation_type; | 365 | fmode_t delegation_type; |
@@ -600,6 +602,7 @@ struct nfs_entry { | |||
600 | int eof; | 602 | int eof; |
601 | struct nfs_fh * fh; | 603 | struct nfs_fh * fh; |
602 | struct nfs_fattr * fattr; | 604 | struct nfs_fattr * fattr; |
605 | struct nfs4_label *label; | ||
603 | unsigned char d_type; | 606 | unsigned char d_type; |
604 | struct nfs_server * server; | 607 | struct nfs_server * server; |
605 | }; | 608 | }; |
@@ -632,6 +635,7 @@ struct nfs_setattrargs { | |||
632 | struct iattr * iap; | 635 | struct iattr * iap; |
633 | const struct nfs_server * server; /* Needed for name mapping */ | 636 | const struct nfs_server * server; /* Needed for name mapping */ |
634 | const u32 * bitmask; | 637 | const u32 * bitmask; |
638 | const struct nfs4_label *label; | ||
635 | }; | 639 | }; |
636 | 640 | ||
637 | struct nfs_setaclargs { | 641 | struct nfs_setaclargs { |
@@ -667,6 +671,7 @@ struct nfs_getaclres { | |||
667 | struct nfs_setattrres { | 671 | struct nfs_setattrres { |
668 | struct nfs4_sequence_res seq_res; | 672 | struct nfs4_sequence_res seq_res; |
669 | struct nfs_fattr * fattr; | 673 | struct nfs_fattr * fattr; |
674 | struct nfs4_label *label; | ||
670 | const struct nfs_server * server; | 675 | const struct nfs_server * server; |
671 | }; | 676 | }; |
672 | 677 | ||
@@ -864,6 +869,7 @@ struct nfs4_create_arg { | |||
864 | const struct iattr * attrs; | 869 | const struct iattr * attrs; |
865 | const struct nfs_fh * dir_fh; | 870 | const struct nfs_fh * dir_fh; |
866 | const u32 * bitmask; | 871 | const u32 * bitmask; |
872 | const struct nfs4_label *label; | ||
867 | }; | 873 | }; |
868 | 874 | ||
869 | struct nfs4_create_res { | 875 | struct nfs4_create_res { |
@@ -871,6 +877,7 @@ struct nfs4_create_res { | |||
871 | const struct nfs_server * server; | 877 | const struct nfs_server * server; |
872 | struct nfs_fh * fh; | 878 | struct nfs_fh * fh; |
873 | struct nfs_fattr * fattr; | 879 | struct nfs_fattr * fattr; |
880 | struct nfs4_label *label; | ||
874 | struct nfs4_change_info dir_cinfo; | 881 | struct nfs4_change_info dir_cinfo; |
875 | }; | 882 | }; |
876 | 883 | ||
@@ -895,6 +902,7 @@ struct nfs4_getattr_res { | |||
895 | struct nfs4_sequence_res seq_res; | 902 | struct nfs4_sequence_res seq_res; |
896 | const struct nfs_server * server; | 903 | const struct nfs_server * server; |
897 | struct nfs_fattr * fattr; | 904 | struct nfs_fattr * fattr; |
905 | struct nfs4_label *label; | ||
898 | }; | 906 | }; |
899 | 907 | ||
900 | struct nfs4_link_arg { | 908 | struct nfs4_link_arg { |
@@ -909,6 +917,7 @@ struct nfs4_link_res { | |||
909 | struct nfs4_sequence_res seq_res; | 917 | struct nfs4_sequence_res seq_res; |
910 | const struct nfs_server * server; | 918 | const struct nfs_server * server; |
911 | struct nfs_fattr * fattr; | 919 | struct nfs_fattr * fattr; |
920 | struct nfs4_label *label; | ||
912 | struct nfs4_change_info cinfo; | 921 | struct nfs4_change_info cinfo; |
913 | struct nfs_fattr * dir_attr; | 922 | struct nfs_fattr * dir_attr; |
914 | }; | 923 | }; |
@@ -926,6 +935,7 @@ struct nfs4_lookup_res { | |||
926 | const struct nfs_server * server; | 935 | const struct nfs_server * server; |
927 | struct nfs_fattr * fattr; | 936 | struct nfs_fattr * fattr; |
928 | struct nfs_fh * fh; | 937 | struct nfs_fh * fh; |
938 | struct nfs4_label *label; | ||
929 | }; | 939 | }; |
930 | 940 | ||
931 | struct nfs4_lookup_root_arg { | 941 | struct nfs4_lookup_root_arg { |