25 #include <linux/module.h>
26 #include <linux/string.h>
29 #include <linux/xattr.h>
30 #include <linux/slab.h>
37 static const struct xattr_handler *squashfs_xattr_handler(
int);
48 int count = squashfs_i(inode)->xattr_count;
49 size_t rest = buffer_size;
61 int name_size, prefix_size = 0;
71 prefix_size = handler->
list(d, buffer, rest,
NULL,
72 name_size, handler->
flags);
75 if (prefix_size + name_size + 1 > rest) {
79 buffer += prefix_size;
86 buffer[name_size] =
'\0';
87 buffer += name_size + 1;
89 rest -= prefix_size + name_size + 1;
110 err = buffer_size -
rest;
117 static int squashfs_xattr_get(
struct inode *
inode,
int name_index,
118 const char *
name,
void *
buffer,
size_t buffer_size)
125 int count = squashfs_i(inode)->xattr_count;
134 for (;
count; count--) {
148 if (prefix == name_index && name_size == name_len)
157 if (prefix == name_index && name_size == name_len &&
158 strncmp(target, name, name_size) == 0) {
165 &offset,
sizeof(
val));
169 &start, &offset,
sizeof(xattr_val));
185 if (vsize > buffer_size) {
207 err = count ? vsize : -
ENODATA;
218 static size_t squashfs_user_list(
struct dentry *
d,
char *
list,
size_t list_size,
219 const char *name,
size_t name_len,
int type)
226 static int squashfs_user_get(
struct dentry *d,
const char *name,
void *buffer,
227 size_t size,
int type)
236 static const struct xattr_handler squashfs_xattr_user_handler = {
238 .list = squashfs_user_list,
239 .get = squashfs_user_get
245 static size_t squashfs_trusted_list(
struct dentry *d,
char *list,
246 size_t list_size,
const char *name,
size_t name_len,
int type)
256 static int squashfs_trusted_get(
struct dentry *d,
const char *name,
257 void *buffer,
size_t size,
int type)
266 static const struct xattr_handler squashfs_xattr_trusted_handler = {
268 .list = squashfs_trusted_list,
269 .get = squashfs_trusted_get
275 static size_t squashfs_security_list(
struct dentry *d,
char *list,
276 size_t list_size,
const char *name,
size_t name_len,
int type)
283 static int squashfs_security_get(
struct dentry *d,
const char *name,
284 void *buffer,
size_t size,
int type)
293 static const struct xattr_handler squashfs_xattr_security_handler = {
295 .list = squashfs_security_list,
296 .get = squashfs_security_get
299 static const struct xattr_handler *squashfs_xattr_handler(
int type)
301 if (type & ~(SQUASHFS_XATTR_PREFIX_MASK | SQUASHFS_XATTR_VALUE_OOL))
305 switch (type & SQUASHFS_XATTR_PREFIX_MASK) {
307 return &squashfs_xattr_user_handler;
309 return &squashfs_xattr_trusted_handler;
311 return &squashfs_xattr_security_handler;
319 &squashfs_xattr_user_handler,
320 &squashfs_xattr_trusted_handler,
321 &squashfs_xattr_security_handler,