mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-30 19:15:14 +00:00
The xattr_handler operations are currently all passed a file system specific flags value which the operations can use to disambiguate between different handlers; some file systems use that to distinguish the xattr namespace, for example. In some oprations, it would be useful to also have access to the handler prefix. To allow that, pass a pointer to the handler to operations instead of the flags value alone. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
82 lines
2.1 KiB
C
82 lines
2.1 KiB
C
/*
|
|
* Copyright IBM Corporation, 2010
|
|
* Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of version 2.1 of the GNU Lesser General Public License
|
|
* as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it would be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
*
|
|
*/
|
|
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/string.h>
|
|
#include <linux/fs.h>
|
|
#include <linux/slab.h>
|
|
#include "xattr.h"
|
|
|
|
static int v9fs_xattr_security_get(const struct xattr_handler *handler,
|
|
struct dentry *dentry, const char *name,
|
|
void *buffer, size_t size)
|
|
{
|
|
int retval;
|
|
char *full_name;
|
|
size_t name_len;
|
|
size_t prefix_len = XATTR_SECURITY_PREFIX_LEN;
|
|
|
|
if (name == NULL)
|
|
return -EINVAL;
|
|
|
|
if (strcmp(name, "") == 0)
|
|
return -EINVAL;
|
|
|
|
name_len = strlen(name);
|
|
full_name = kmalloc(prefix_len + name_len + 1 , GFP_KERNEL);
|
|
if (!full_name)
|
|
return -ENOMEM;
|
|
memcpy(full_name, XATTR_SECURITY_PREFIX, prefix_len);
|
|
memcpy(full_name+prefix_len, name, name_len);
|
|
full_name[prefix_len + name_len] = '\0';
|
|
|
|
retval = v9fs_xattr_get(dentry, full_name, buffer, size);
|
|
kfree(full_name);
|
|
return retval;
|
|
}
|
|
|
|
static int v9fs_xattr_security_set(const struct xattr_handler *handler,
|
|
struct dentry *dentry, const char *name,
|
|
const void *value, size_t size, int flags)
|
|
{
|
|
int retval;
|
|
char *full_name;
|
|
size_t name_len;
|
|
size_t prefix_len = XATTR_SECURITY_PREFIX_LEN;
|
|
|
|
if (name == NULL)
|
|
return -EINVAL;
|
|
|
|
if (strcmp(name, "") == 0)
|
|
return -EINVAL;
|
|
|
|
name_len = strlen(name);
|
|
full_name = kmalloc(prefix_len + name_len + 1 , GFP_KERNEL);
|
|
if (!full_name)
|
|
return -ENOMEM;
|
|
memcpy(full_name, XATTR_SECURITY_PREFIX, prefix_len);
|
|
memcpy(full_name + prefix_len, name, name_len);
|
|
full_name[prefix_len + name_len] = '\0';
|
|
|
|
retval = v9fs_xattr_set(dentry, full_name, value, size, flags);
|
|
kfree(full_name);
|
|
return retval;
|
|
}
|
|
|
|
struct xattr_handler v9fs_xattr_security_handler = {
|
|
.prefix = XATTR_SECURITY_PREFIX,
|
|
.get = v9fs_xattr_security_get,
|
|
.set = v9fs_xattr_security_set,
|
|
};
|