diff options
author | Mark Fasheh <mfasheh@suse.com> | 2008-10-07 17:52:59 -0400 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2008-10-13 20:02:44 -0400 |
commit | 99219aea68b5bff4f182858372b43181ad3bdb34 (patch) | |
tree | fbe3c16322ecc658e2c432dc7700bb1b19d00d54 /fs | |
parent | 40daa16a3441abe822bfcc748150116a77aee2ea (diff) |
ocfs2: Move trusted and user attribute support into xattr.c
Per Christoph Hellwig's suggestion - don't split these up. It's not like we
gained much by having the two tiny files around.
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ocfs2/Makefile | 4 | ||||
-rw-r--r-- | fs/ocfs2/xattr.c | 110 | ||||
-rw-r--r-- | fs/ocfs2/xattr_trusted.c | 82 | ||||
-rw-r--r-- | fs/ocfs2/xattr_user.c | 94 |
4 files changed, 111 insertions, 179 deletions
diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile index 21323da40855..589dcdfdfe3c 100644 --- a/fs/ocfs2/Makefile +++ b/fs/ocfs2/Makefile | |||
@@ -35,9 +35,7 @@ ocfs2-objs := \ | |||
35 | sysfile.o \ | 35 | sysfile.o \ |
36 | uptodate.o \ | 36 | uptodate.o \ |
37 | ver.o \ | 37 | ver.o \ |
38 | xattr.o \ | 38 | xattr.o |
39 | xattr_user.o \ | ||
40 | xattr_trusted.o | ||
41 | 39 | ||
42 | ocfs2_stackglue-objs := stackglue.o | 40 | ocfs2_stackglue-objs := stackglue.o |
43 | ocfs2_stack_o2cb-objs := stack_o2cb.o | 41 | ocfs2_stack_o2cb-objs := stack_o2cb.o |
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index e21a1a8b4257..0f556b00235e 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
@@ -37,6 +37,9 @@ | |||
37 | #include <linux/writeback.h> | 37 | #include <linux/writeback.h> |
38 | #include <linux/falloc.h> | 38 | #include <linux/falloc.h> |
39 | #include <linux/sort.h> | 39 | #include <linux/sort.h> |
40 | #include <linux/init.h> | ||
41 | #include <linux/module.h> | ||
42 | #include <linux/string.h> | ||
40 | 43 | ||
41 | #define MLOG_MASK_PREFIX ML_XATTR | 44 | #define MLOG_MASK_PREFIX ML_XATTR |
42 | #include <cluster/masklog.h> | 45 | #include <cluster/masklog.h> |
@@ -4740,3 +4743,110 @@ static int ocfs2_delete_xattr_index_block(struct inode *inode, | |||
4740 | out: | 4743 | out: |
4741 | return ret; | 4744 | return ret; |
4742 | } | 4745 | } |
4746 | |||
4747 | /* | ||
4748 | * 'trusted' attributes support | ||
4749 | */ | ||
4750 | |||
4751 | #define XATTR_TRUSTED_PREFIX "trusted." | ||
4752 | |||
4753 | static size_t ocfs2_xattr_trusted_list(struct inode *inode, char *list, | ||
4754 | size_t list_size, const char *name, | ||
4755 | size_t name_len) | ||
4756 | { | ||
4757 | const size_t prefix_len = sizeof(XATTR_TRUSTED_PREFIX) - 1; | ||
4758 | const size_t total_len = prefix_len + name_len + 1; | ||
4759 | |||
4760 | if (list && total_len <= list_size) { | ||
4761 | memcpy(list, XATTR_TRUSTED_PREFIX, prefix_len); | ||
4762 | memcpy(list + prefix_len, name, name_len); | ||
4763 | list[prefix_len + name_len] = '\0'; | ||
4764 | } | ||
4765 | return total_len; | ||
4766 | } | ||
4767 | |||
4768 | static int ocfs2_xattr_trusted_get(struct inode *inode, const char *name, | ||
4769 | void *buffer, size_t size) | ||
4770 | { | ||
4771 | if (strcmp(name, "") == 0) | ||
4772 | return -EINVAL; | ||
4773 | return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_TRUSTED, name, | ||
4774 | buffer, size); | ||
4775 | } | ||
4776 | |||
4777 | static int ocfs2_xattr_trusted_set(struct inode *inode, const char *name, | ||
4778 | const void *value, size_t size, int flags) | ||
4779 | { | ||
4780 | if (strcmp(name, "") == 0) | ||
4781 | return -EINVAL; | ||
4782 | |||
4783 | return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_TRUSTED, name, value, | ||
4784 | size, flags); | ||
4785 | } | ||
4786 | |||
4787 | struct xattr_handler ocfs2_xattr_trusted_handler = { | ||
4788 | .prefix = XATTR_TRUSTED_PREFIX, | ||
4789 | .list = ocfs2_xattr_trusted_list, | ||
4790 | .get = ocfs2_xattr_trusted_get, | ||
4791 | .set = ocfs2_xattr_trusted_set, | ||
4792 | }; | ||
4793 | |||
4794 | |||
4795 | /* | ||
4796 | * 'user' attributes support | ||
4797 | */ | ||
4798 | |||
4799 | #define XATTR_USER_PREFIX "user." | ||
4800 | |||
4801 | static size_t ocfs2_xattr_user_list(struct inode *inode, char *list, | ||
4802 | size_t list_size, const char *name, | ||
4803 | size_t name_len) | ||
4804 | { | ||
4805 | const size_t prefix_len = sizeof(XATTR_USER_PREFIX) - 1; | ||
4806 | const size_t total_len = prefix_len + name_len + 1; | ||
4807 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
4808 | |||
4809 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | ||
4810 | return 0; | ||
4811 | |||
4812 | if (list && total_len <= list_size) { | ||
4813 | memcpy(list, XATTR_USER_PREFIX, prefix_len); | ||
4814 | memcpy(list + prefix_len, name, name_len); | ||
4815 | list[prefix_len + name_len] = '\0'; | ||
4816 | } | ||
4817 | return total_len; | ||
4818 | } | ||
4819 | |||
4820 | static int ocfs2_xattr_user_get(struct inode *inode, const char *name, | ||
4821 | void *buffer, size_t size) | ||
4822 | { | ||
4823 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
4824 | |||
4825 | if (strcmp(name, "") == 0) | ||
4826 | return -EINVAL; | ||
4827 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | ||
4828 | return -EOPNOTSUPP; | ||
4829 | return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_USER, name, | ||
4830 | buffer, size); | ||
4831 | } | ||
4832 | |||
4833 | static int ocfs2_xattr_user_set(struct inode *inode, const char *name, | ||
4834 | const void *value, size_t size, int flags) | ||
4835 | { | ||
4836 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
4837 | |||
4838 | if (strcmp(name, "") == 0) | ||
4839 | return -EINVAL; | ||
4840 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | ||
4841 | return -EOPNOTSUPP; | ||
4842 | |||
4843 | return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_USER, name, value, | ||
4844 | size, flags); | ||
4845 | } | ||
4846 | |||
4847 | struct xattr_handler ocfs2_xattr_user_handler = { | ||
4848 | .prefix = XATTR_USER_PREFIX, | ||
4849 | .list = ocfs2_xattr_user_list, | ||
4850 | .get = ocfs2_xattr_user_get, | ||
4851 | .set = ocfs2_xattr_user_set, | ||
4852 | }; | ||
diff --git a/fs/ocfs2/xattr_trusted.c b/fs/ocfs2/xattr_trusted.c deleted file mode 100644 index 4c589c447aaf..000000000000 --- a/fs/ocfs2/xattr_trusted.c +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
1 | /* -*- mode: c; c-basic-offset: 8; -*- | ||
2 | * vim: noexpandtab sw=8 ts=8 sts=0: | ||
3 | * | ||
4 | * xattr_trusted.c | ||
5 | * | ||
6 | * Copyright (C) 2008 Oracle. All rights reserved. | ||
7 | * | ||
8 | * CREDITS: | ||
9 | * Lots of code in this file is taken from ext3. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU General Public | ||
13 | * License as published by the Free Software Foundation; either | ||
14 | * version 2 of the License, or (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
19 | * General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public | ||
22 | * License along with this program; if not, write to the | ||
23 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
24 | * Boston, MA 021110-1307, USA. | ||
25 | */ | ||
26 | |||
27 | #include <linux/init.h> | ||
28 | #include <linux/module.h> | ||
29 | #include <linux/string.h> | ||
30 | |||
31 | #define MLOG_MASK_PREFIX ML_INODE | ||
32 | #include <cluster/masklog.h> | ||
33 | |||
34 | #include "ocfs2.h" | ||
35 | #include "alloc.h" | ||
36 | #include "dlmglue.h" | ||
37 | #include "file.h" | ||
38 | #include "ocfs2_fs.h" | ||
39 | #include "xattr.h" | ||
40 | |||
41 | #define XATTR_TRUSTED_PREFIX "trusted." | ||
42 | |||
43 | static size_t ocfs2_xattr_trusted_list(struct inode *inode, char *list, | ||
44 | size_t list_size, const char *name, | ||
45 | size_t name_len) | ||
46 | { | ||
47 | const size_t prefix_len = sizeof(XATTR_TRUSTED_PREFIX) - 1; | ||
48 | const size_t total_len = prefix_len + name_len + 1; | ||
49 | |||
50 | if (list && total_len <= list_size) { | ||
51 | memcpy(list, XATTR_TRUSTED_PREFIX, prefix_len); | ||
52 | memcpy(list + prefix_len, name, name_len); | ||
53 | list[prefix_len + name_len] = '\0'; | ||
54 | } | ||
55 | return total_len; | ||
56 | } | ||
57 | |||
58 | static int ocfs2_xattr_trusted_get(struct inode *inode, const char *name, | ||
59 | void *buffer, size_t size) | ||
60 | { | ||
61 | if (strcmp(name, "") == 0) | ||
62 | return -EINVAL; | ||
63 | return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_TRUSTED, name, | ||
64 | buffer, size); | ||
65 | } | ||
66 | |||
67 | static int ocfs2_xattr_trusted_set(struct inode *inode, const char *name, | ||
68 | const void *value, size_t size, int flags) | ||
69 | { | ||
70 | if (strcmp(name, "") == 0) | ||
71 | return -EINVAL; | ||
72 | |||
73 | return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_TRUSTED, name, value, | ||
74 | size, flags); | ||
75 | } | ||
76 | |||
77 | struct xattr_handler ocfs2_xattr_trusted_handler = { | ||
78 | .prefix = XATTR_TRUSTED_PREFIX, | ||
79 | .list = ocfs2_xattr_trusted_list, | ||
80 | .get = ocfs2_xattr_trusted_get, | ||
81 | .set = ocfs2_xattr_trusted_set, | ||
82 | }; | ||
diff --git a/fs/ocfs2/xattr_user.c b/fs/ocfs2/xattr_user.c deleted file mode 100644 index 93ba71637788..000000000000 --- a/fs/ocfs2/xattr_user.c +++ /dev/null | |||
@@ -1,94 +0,0 @@ | |||
1 | /* -*- mode: c; c-basic-offset: 8; -*- | ||
2 | * vim: noexpandtab sw=8 ts=8 sts=0: | ||
3 | * | ||
4 | * xattr_user.c | ||
5 | * | ||
6 | * Copyright (C) 2008 Oracle. All rights reserved. | ||
7 | * | ||
8 | * CREDITS: | ||
9 | * Lots of code in this file is taken from ext3. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU General Public | ||
13 | * License as published by the Free Software Foundation; either | ||
14 | * version 2 of the License, or (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
19 | * General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public | ||
22 | * License along with this program; if not, write to the | ||
23 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
24 | * Boston, MA 021110-1307, USA. | ||
25 | */ | ||
26 | |||
27 | #include <linux/init.h> | ||
28 | #include <linux/module.h> | ||
29 | #include <linux/string.h> | ||
30 | |||
31 | #define MLOG_MASK_PREFIX ML_INODE | ||
32 | #include <cluster/masklog.h> | ||
33 | |||
34 | #include "ocfs2.h" | ||
35 | #include "alloc.h" | ||
36 | #include "dlmglue.h" | ||
37 | #include "file.h" | ||
38 | #include "ocfs2_fs.h" | ||
39 | #include "xattr.h" | ||
40 | |||
41 | #define XATTR_USER_PREFIX "user." | ||
42 | |||
43 | static size_t ocfs2_xattr_user_list(struct inode *inode, char *list, | ||
44 | size_t list_size, const char *name, | ||
45 | size_t name_len) | ||
46 | { | ||
47 | const size_t prefix_len = sizeof(XATTR_USER_PREFIX) - 1; | ||
48 | const size_t total_len = prefix_len + name_len + 1; | ||
49 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
50 | |||
51 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | ||
52 | return 0; | ||
53 | |||
54 | if (list && total_len <= list_size) { | ||
55 | memcpy(list, XATTR_USER_PREFIX, prefix_len); | ||
56 | memcpy(list + prefix_len, name, name_len); | ||
57 | list[prefix_len + name_len] = '\0'; | ||
58 | } | ||
59 | return total_len; | ||
60 | } | ||
61 | |||
62 | static int ocfs2_xattr_user_get(struct inode *inode, const char *name, | ||
63 | void *buffer, size_t size) | ||
64 | { | ||
65 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
66 | |||
67 | if (strcmp(name, "") == 0) | ||
68 | return -EINVAL; | ||
69 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | ||
70 | return -EOPNOTSUPP; | ||
71 | return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_USER, name, | ||
72 | buffer, size); | ||
73 | } | ||
74 | |||
75 | static int ocfs2_xattr_user_set(struct inode *inode, const char *name, | ||
76 | const void *value, size_t size, int flags) | ||
77 | { | ||
78 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
79 | |||
80 | if (strcmp(name, "") == 0) | ||
81 | return -EINVAL; | ||
82 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | ||
83 | return -EOPNOTSUPP; | ||
84 | |||
85 | return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_USER, name, value, | ||
86 | size, flags); | ||
87 | } | ||
88 | |||
89 | struct xattr_handler ocfs2_xattr_user_handler = { | ||
90 | .prefix = XATTR_USER_PREFIX, | ||
91 | .list = ocfs2_xattr_user_list, | ||
92 | .get = ocfs2_xattr_user_get, | ||
93 | .set = ocfs2_xattr_user_set, | ||
94 | }; | ||