diff options
Diffstat (limited to 'fs/f2fs/xattr.c')
-rw-r--r-- | fs/f2fs/xattr.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c index 5324d1e9d168..7d52e8dc0c59 100644 --- a/fs/f2fs/xattr.c +++ b/fs/f2fs/xattr.c | |||
@@ -102,6 +102,49 @@ static int f2fs_xattr_generic_set(struct dentry *dentry, const char *name, | |||
102 | return f2fs_setxattr(dentry->d_inode, type, name, value, size); | 102 | return f2fs_setxattr(dentry->d_inode, type, name, value, size); |
103 | } | 103 | } |
104 | 104 | ||
105 | static size_t f2fs_xattr_advise_list(struct dentry *dentry, char *list, | ||
106 | size_t list_size, const char *name, size_t name_len, int type) | ||
107 | { | ||
108 | const char *xname = F2FS_SYSTEM_ADVISE_PREFIX; | ||
109 | size_t size; | ||
110 | |||
111 | if (type != F2FS_XATTR_INDEX_ADVISE) | ||
112 | return 0; | ||
113 | |||
114 | size = strlen(xname) + 1; | ||
115 | if (list && size <= list_size) | ||
116 | memcpy(list, xname, size); | ||
117 | return size; | ||
118 | } | ||
119 | |||
120 | static int f2fs_xattr_advise_get(struct dentry *dentry, const char *name, | ||
121 | void *buffer, size_t size, int type) | ||
122 | { | ||
123 | struct inode *inode = dentry->d_inode; | ||
124 | |||
125 | if (strcmp(name, "") != 0) | ||
126 | return -EINVAL; | ||
127 | |||
128 | *((char *)buffer) = F2FS_I(inode)->i_advise; | ||
129 | return sizeof(char); | ||
130 | } | ||
131 | |||
132 | static int f2fs_xattr_advise_set(struct dentry *dentry, const char *name, | ||
133 | const void *value, size_t size, int flags, int type) | ||
134 | { | ||
135 | struct inode *inode = dentry->d_inode; | ||
136 | |||
137 | if (strcmp(name, "") != 0) | ||
138 | return -EINVAL; | ||
139 | if (!inode_owner_or_capable(inode)) | ||
140 | return -EPERM; | ||
141 | if (value == NULL) | ||
142 | return -EINVAL; | ||
143 | |||
144 | F2FS_I(inode)->i_advise |= *(char *)value; | ||
145 | return 0; | ||
146 | } | ||
147 | |||
105 | const struct xattr_handler f2fs_xattr_user_handler = { | 148 | const struct xattr_handler f2fs_xattr_user_handler = { |
106 | .prefix = XATTR_USER_PREFIX, | 149 | .prefix = XATTR_USER_PREFIX, |
107 | .flags = F2FS_XATTR_INDEX_USER, | 150 | .flags = F2FS_XATTR_INDEX_USER, |
@@ -118,6 +161,14 @@ const struct xattr_handler f2fs_xattr_trusted_handler = { | |||
118 | .set = f2fs_xattr_generic_set, | 161 | .set = f2fs_xattr_generic_set, |
119 | }; | 162 | }; |
120 | 163 | ||
164 | const struct xattr_handler f2fs_xattr_advise_handler = { | ||
165 | .prefix = F2FS_SYSTEM_ADVISE_PREFIX, | ||
166 | .flags = F2FS_XATTR_INDEX_ADVISE, | ||
167 | .list = f2fs_xattr_advise_list, | ||
168 | .get = f2fs_xattr_advise_get, | ||
169 | .set = f2fs_xattr_advise_set, | ||
170 | }; | ||
171 | |||
121 | static const struct xattr_handler *f2fs_xattr_handler_map[] = { | 172 | static const struct xattr_handler *f2fs_xattr_handler_map[] = { |
122 | [F2FS_XATTR_INDEX_USER] = &f2fs_xattr_user_handler, | 173 | [F2FS_XATTR_INDEX_USER] = &f2fs_xattr_user_handler, |
123 | #ifdef CONFIG_F2FS_FS_POSIX_ACL | 174 | #ifdef CONFIG_F2FS_FS_POSIX_ACL |