~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/9p/xattr_user.c

Version: ~ [ linux-5.7 ] ~ [ linux-5.6.15 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.43 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.125 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.182 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.225 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.225 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.84 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright IBM Corporation, 2010
  3  * Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
  4  *
  5  * This program is free software; you can redistribute it and/or modify it
  6  * under the terms of version 2.1 of the GNU Lesser General Public License
  7  * as published by the Free Software Foundation.
  8  *
  9  * This program is distributed in the hope that it would be useful, but
 10  * WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 12  *
 13  */
 14 
 15 
 16 #include <linux/module.h>
 17 #include <linux/string.h>
 18 #include <linux/fs.h>
 19 #include <linux/slab.h>
 20 #include "xattr.h"
 21 
 22 static int v9fs_xattr_user_get(struct dentry *dentry, const char *name,
 23                         void *buffer, size_t size, int type)
 24 {
 25         int retval;
 26         char *full_name;
 27         size_t name_len;
 28         size_t prefix_len = XATTR_USER_PREFIX_LEN;
 29 
 30         if (name == NULL)
 31                 return -EINVAL;
 32 
 33         if (strcmp(name, "") == 0)
 34                 return -EINVAL;
 35 
 36         name_len = strlen(name);
 37         full_name = kmalloc(prefix_len + name_len + 1 , GFP_KERNEL);
 38         if (!full_name)
 39                 return -ENOMEM;
 40         memcpy(full_name, XATTR_USER_PREFIX, prefix_len);
 41         memcpy(full_name+prefix_len, name, name_len);
 42         full_name[prefix_len + name_len] = '\0';
 43 
 44         retval = v9fs_xattr_get(dentry, full_name, buffer, size);
 45         kfree(full_name);
 46         return retval;
 47 }
 48 
 49 static int v9fs_xattr_user_set(struct dentry *dentry, const char *name,
 50                         const void *value, size_t size, int flags, int type)
 51 {
 52         int retval;
 53         char *full_name;
 54         size_t name_len;
 55         size_t prefix_len = XATTR_USER_PREFIX_LEN;
 56 
 57         if (name == NULL)
 58                 return -EINVAL;
 59 
 60         if (strcmp(name, "") == 0)
 61                 return -EINVAL;
 62 
 63         name_len = strlen(name);
 64         full_name = kmalloc(prefix_len + name_len + 1 , GFP_KERNEL);
 65         if (!full_name)
 66                 return -ENOMEM;
 67         memcpy(full_name, XATTR_USER_PREFIX, prefix_len);
 68         memcpy(full_name + prefix_len, name, name_len);
 69         full_name[prefix_len + name_len] = '\0';
 70 
 71         retval = v9fs_xattr_set(dentry, full_name, value, size, flags);
 72         kfree(full_name);
 73         return retval;
 74 }
 75 
 76 struct xattr_handler v9fs_xattr_user_handler = {
 77         .prefix = XATTR_USER_PREFIX,
 78         .get    = v9fs_xattr_user_get,
 79         .set    = v9fs_xattr_user_set,
 80 };
 81 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp