diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /fs/reiserfs/xattr_user.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'fs/reiserfs/xattr_user.c')
-rw-r--r-- | fs/reiserfs/xattr_user.c | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/fs/reiserfs/xattr_user.c b/fs/reiserfs/xattr_user.c new file mode 100644 index 000000000000..0772806466a8 --- /dev/null +++ b/fs/reiserfs/xattr_user.c | |||
@@ -0,0 +1,99 @@ | |||
1 | #include <linux/reiserfs_fs.h> | ||
2 | #include <linux/errno.h> | ||
3 | #include <linux/fs.h> | ||
4 | #include <linux/pagemap.h> | ||
5 | #include <linux/xattr.h> | ||
6 | #include <linux/reiserfs_xattr.h> | ||
7 | #include <asm/uaccess.h> | ||
8 | |||
9 | #ifdef CONFIG_REISERFS_FS_POSIX_ACL | ||
10 | # include <linux/reiserfs_acl.h> | ||
11 | #endif | ||
12 | |||
13 | #define XATTR_USER_PREFIX "user." | ||
14 | |||
15 | static int | ||
16 | user_get (struct inode *inode, const char *name, void *buffer, size_t size) | ||
17 | { | ||
18 | |||
19 | int error; | ||
20 | |||
21 | if (strlen(name) < sizeof(XATTR_USER_PREFIX)) | ||
22 | return -EINVAL; | ||
23 | |||
24 | if (!reiserfs_xattrs_user (inode->i_sb)) | ||
25 | return -EOPNOTSUPP; | ||
26 | |||
27 | error = reiserfs_permission_locked (inode, MAY_READ, NULL); | ||
28 | if (error) | ||
29 | return error; | ||
30 | |||
31 | return reiserfs_xattr_get (inode, name, buffer, size); | ||
32 | } | ||
33 | |||
34 | static int | ||
35 | user_set (struct inode *inode, const char *name, const void *buffer, | ||
36 | size_t size, int flags) | ||
37 | { | ||
38 | |||
39 | int error; | ||
40 | |||
41 | if (strlen(name) < sizeof(XATTR_USER_PREFIX)) | ||
42 | return -EINVAL; | ||
43 | |||
44 | if (!reiserfs_xattrs_user (inode->i_sb)) | ||
45 | return -EOPNOTSUPP; | ||
46 | |||
47 | if (!S_ISREG (inode->i_mode) && | ||
48 | (!S_ISDIR (inode->i_mode) || inode->i_mode & S_ISVTX)) | ||
49 | return -EPERM; | ||
50 | |||
51 | error = reiserfs_permission_locked (inode, MAY_WRITE, NULL); | ||
52 | if (error) | ||
53 | return error; | ||
54 | |||
55 | return reiserfs_xattr_set (inode, name, buffer, size, flags); | ||
56 | } | ||
57 | |||
58 | static int | ||
59 | user_del (struct inode *inode, const char *name) | ||
60 | { | ||
61 | int error; | ||
62 | |||
63 | if (strlen(name) < sizeof(XATTR_USER_PREFIX)) | ||
64 | return -EINVAL; | ||
65 | |||
66 | if (!reiserfs_xattrs_user (inode->i_sb)) | ||
67 | return -EOPNOTSUPP; | ||
68 | |||
69 | if (!S_ISREG (inode->i_mode) && | ||
70 | (!S_ISDIR (inode->i_mode) || inode->i_mode & S_ISVTX)) | ||
71 | return -EPERM; | ||
72 | |||
73 | error = reiserfs_permission_locked (inode, MAY_WRITE, NULL); | ||
74 | if (error) | ||
75 | return error; | ||
76 | |||
77 | return 0; | ||
78 | } | ||
79 | |||
80 | static int | ||
81 | user_list (struct inode *inode, const char *name, int namelen, char *out) | ||
82 | { | ||
83 | int len = namelen; | ||
84 | if (!reiserfs_xattrs_user (inode->i_sb)) | ||
85 | return 0; | ||
86 | |||
87 | if (out) | ||
88 | memcpy (out, name, len); | ||
89 | |||
90 | return len; | ||
91 | } | ||
92 | |||
93 | struct reiserfs_xattr_handler user_handler = { | ||
94 | .prefix = XATTR_USER_PREFIX, | ||
95 | .get = user_get, | ||
96 | .set = user_set, | ||
97 | .del = user_del, | ||
98 | .list = user_list, | ||
99 | }; | ||