Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * JFFS2 -- Journalling Flash File System, Version 2.
0003  *
0004  * Copyright © 2006  NEC Corporation
0005  *
0006  * Created by KaiGai Kohei <kaigai@ak.jp.nec.com>
0007  *
0008  * For licensing information, see the file 'LICENCE' in this directory.
0009  *
0010  */
0011 
0012 #include <linux/kernel.h>
0013 #include <linux/slab.h>
0014 #include <linux/fs.h>
0015 #include <linux/time.h>
0016 #include <linux/pagemap.h>
0017 #include <linux/highmem.h>
0018 #include <linux/crc32.h>
0019 #include <linux/jffs2.h>
0020 #include <linux/xattr.h>
0021 #include <linux/mtd/mtd.h>
0022 #include <linux/security.h>
0023 #include "nodelist.h"
0024 
0025 /* ---- Initial Security Label(s) Attachment callback --- */
0026 static int jffs2_initxattrs(struct inode *inode,
0027                 const struct xattr *xattr_array, void *fs_info)
0028 {
0029     const struct xattr *xattr;
0030     int err = 0;
0031 
0032     for (xattr = xattr_array; xattr->name != NULL; xattr++) {
0033         err = do_jffs2_setxattr(inode, JFFS2_XPREFIX_SECURITY,
0034                     xattr->name, xattr->value,
0035                     xattr->value_len, 0);
0036         if (err < 0)
0037             break;
0038     }
0039     return err;
0040 }
0041 
0042 /* ---- Initial Security Label(s) Attachment ----------- */
0043 int jffs2_init_security(struct inode *inode, struct inode *dir,
0044             const struct qstr *qstr)
0045 {
0046     return security_inode_init_security(inode, dir, qstr,
0047                         &jffs2_initxattrs, NULL);
0048 }
0049 
0050 /* ---- XATTR Handler for "security.*" ----------------- */
0051 static int jffs2_security_getxattr(const struct xattr_handler *handler,
0052                    struct dentry *unused, struct inode *inode,
0053                    const char *name, void *buffer, size_t size)
0054 {
0055     return do_jffs2_getxattr(inode, JFFS2_XPREFIX_SECURITY,
0056                  name, buffer, size);
0057 }
0058 
0059 static int jffs2_security_setxattr(const struct xattr_handler *handler,
0060                    struct user_namespace *mnt_userns,
0061                    struct dentry *unused, struct inode *inode,
0062                    const char *name, const void *buffer,
0063                    size_t size, int flags)
0064 {
0065     return do_jffs2_setxattr(inode, JFFS2_XPREFIX_SECURITY,
0066                  name, buffer, size, flags);
0067 }
0068 
0069 const struct xattr_handler jffs2_security_xattr_handler = {
0070     .prefix = XATTR_SECURITY_PREFIX,
0071     .set = jffs2_security_setxattr,
0072     .get = jffs2_security_getxattr
0073 };