x86: convert cpuinfo_x86 array to a per_cpu array
[wrt350n-kernel.git] / fs / jffs2 / security.c
blob02c39c64ecb391e734d18362aa074b5ea2a401db
1 /*
2 * JFFS2 -- Journalling Flash File System, Version 2.
4 * Copyright © 2006 NEC Corporation
6 * Created by KaiGai Kohei <kaigai@ak.jp.nec.com>
8 * For licensing information, see the file 'LICENCE' in this directory.
12 #include <linux/kernel.h>
13 #include <linux/slab.h>
14 #include <linux/fs.h>
15 #include <linux/time.h>
16 #include <linux/pagemap.h>
17 #include <linux/highmem.h>
18 #include <linux/crc32.h>
19 #include <linux/jffs2.h>
20 #include <linux/xattr.h>
21 #include <linux/mtd/mtd.h>
22 #include <linux/security.h>
23 #include "nodelist.h"
25 /* ---- Initial Security Label Attachment -------------- */
26 int jffs2_init_security(struct inode *inode, struct inode *dir)
28 int rc;
29 size_t len;
30 void *value;
31 char *name;
33 rc = security_inode_init_security(inode, dir, &name, &value, &len);
34 if (rc) {
35 if (rc == -EOPNOTSUPP)
36 return 0;
37 return rc;
39 rc = do_jffs2_setxattr(inode, JFFS2_XPREFIX_SECURITY, name, value, len, 0);
41 kfree(name);
42 kfree(value);
43 return rc;
46 /* ---- XATTR Handler for "security.*" ----------------- */
47 static int jffs2_security_getxattr(struct inode *inode, const char *name,
48 void *buffer, size_t size)
50 if (!strcmp(name, ""))
51 return -EINVAL;
53 return do_jffs2_getxattr(inode, JFFS2_XPREFIX_SECURITY, name, buffer, size);
56 static int jffs2_security_setxattr(struct inode *inode, const char *name, const void *buffer,
57 size_t size, int flags)
59 if (!strcmp(name, ""))
60 return -EINVAL;
62 return do_jffs2_setxattr(inode, JFFS2_XPREFIX_SECURITY, name, buffer, size, flags);
65 static size_t jffs2_security_listxattr(struct inode *inode, char *list, size_t list_size,
66 const char *name, size_t name_len)
68 size_t retlen = XATTR_SECURITY_PREFIX_LEN + name_len + 1;
70 if (list && retlen <= list_size) {
71 strcpy(list, XATTR_SECURITY_PREFIX);
72 strcpy(list + XATTR_SECURITY_PREFIX_LEN, name);
75 return retlen;
78 struct xattr_handler jffs2_security_xattr_handler = {
79 .prefix = XATTR_SECURITY_PREFIX,
80 .list = jffs2_security_listxattr,
81 .set = jffs2_security_setxattr,
82 .get = jffs2_security_getxattr