cregit-Linux how code gets into the kernel

Release 4.10 fs/xfs/xfs_xattr.c

Directory: fs/xfs
/*
 * Copyright (C) 2008 Christoph Hellwig.
 * Portions Copyright (C) 2000-2008 Silicon Graphics, Inc.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU 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.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write the Free Software Foundation,
 * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include "xfs.h"
#include "xfs_format.h"
#include "xfs_log_format.h"
#include "xfs_trans_resv.h"
#include "xfs_mount.h"
#include "xfs_da_format.h"
#include "xfs_inode.h"
#include "xfs_attr.h"
#include "xfs_attr_leaf.h"
#include "xfs_acl.h"

#include <linux/posix_acl_xattr.h>
#include <linux/xattr.h>



static int xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused, struct inode *inode, const char *name, void *value, size_t size) { int xflags = handler->flags; struct xfs_inode *ip = XFS_I(inode); int error, asize = size; /* Convert Linux syscall to XFS internal ATTR flags */ if (!size) { xflags |= ATTR_KERNOVAL; value = NULL; } error = xfs_attr_get(ip, (unsigned char *)name, value, &asize, xflags); if (error) return error; return asize; }

Contributors

PersonTokensPropCommitsCommitProp
lachlan mcilroylachlan mcilroy7874.29%120.00%
andreas gruenbacherandreas gruenbacher1312.38%120.00%
al viroal viro76.67%120.00%
david chinnerdavid chinner54.76%120.00%
christoph hellwigchristoph hellwig21.90%120.00%
Total105100.00%5100.00%


void xfs_forget_acl( struct inode *inode, const char *name, int xflags) { /* * Invalidate any cached ACLs if the user has bypassed the ACL * interface. We don't validate the content whatsoever so it is caller * responsibility to provide data in valid format and ensure i_mode is * consistent. */ if (xflags & ATTR_ROOT) { #ifdef CONFIG_XFS_POSIX_ACL if (!strcmp(name, SGI_ACL_FILE)) forget_cached_acl(inode, ACL_TYPE_ACCESS); else if (!strcmp(name, SGI_ACL_DEFAULT)) forget_cached_acl(inode, ACL_TYPE_DEFAULT); #endif } }

Contributors

PersonTokensPropCommitsCommitProp
andreas gruenbacherandreas gruenbacher67100.00%1100.00%
Total67100.00%1100.00%


static int xfs_xattr_set(const struct xattr_handler *handler, struct dentry *unused, struct inode *inode, const char *name, const void *value, size_t size, int flags) { int xflags = handler->flags; struct xfs_inode *ip = XFS_I(inode); int error; /* Convert Linux syscall to XFS internal ATTR flags */ if (flags & XATTR_CREATE) xflags |= ATTR_CREATE; if (flags & XATTR_REPLACE) xflags |= ATTR_REPLACE; if (!value) return xfs_attr_remove(ip, (unsigned char *)name, xflags); error = xfs_attr_set(ip, (unsigned char *)name, (void *)value, size, xflags); if (!error) xfs_forget_acl(inode, name, xflags); return error; }

Contributors

PersonTokensPropCommitsCommitProp
lachlan mcilroylachlan mcilroy8661.43%114.29%
brian fosterbrian foster1913.57%114.29%
andreas gruenbacherandreas gruenbacher1510.71%228.57%
david chinnerdavid chinner107.14%114.29%
al viroal viro85.71%114.29%
christoph hellwigchristoph hellwig21.43%114.29%
Total140100.00%7100.00%

static const struct xattr_handler xfs_xattr_user_handler = { .prefix = XATTR_USER_PREFIX, .flags = 0, /* no flags implies user namespace */ .get = xfs_xattr_get, .set = xfs_xattr_set, }; static const struct xattr_handler xfs_xattr_trusted_handler = { .prefix = XATTR_TRUSTED_PREFIX, .flags = ATTR_ROOT, .get = xfs_xattr_get, .set = xfs_xattr_set, }; static const struct xattr_handler xfs_xattr_security_handler = { .prefix = XATTR_SECURITY_PREFIX, .flags = ATTR_SECURE, .get = xfs_xattr_get, .set = xfs_xattr_set, }; const struct xattr_handler *xfs_xattr_handlers[] = { &xfs_xattr_user_handler, &xfs_xattr_trusted_handler, &xfs_xattr_security_handler, #ifdef CONFIG_XFS_POSIX_ACL &posix_acl_access_xattr_handler, &posix_acl_default_xattr_handler, #endif NULL };
static void __xfs_xattr_put_listent( struct xfs_attr_list_context *context, char *prefix, int prefix_len, unsigned char *name, int namelen) { char *offset; int arraytop; if (!context->alist) goto compute_size; arraytop = context->count + prefix_len + namelen + 1; if (arraytop > context->firstu) { context->count = -1; /* insufficient space */ context->seen_enough = 1; return; } offset = (char *)context->alist + context->count; strncpy(offset, prefix, prefix_len); offset += prefix_len; strncpy(offset, (char *)name, namelen); /* real name */ offset += namelen; *offset = '\0'; compute_size: context->count += prefix_len + namelen + 1; return; }

Contributors

PersonTokensPropCommitsCommitProp
lachlan mcilroylachlan mcilroy11479.72%120.00%
andreas gruenbacherandreas gruenbacher1510.49%120.00%
artem savkovartem savkov64.20%120.00%
david chinnerdavid chinner53.50%120.00%
eric sandeeneric sandeen32.10%120.00%
Total143100.00%5100.00%


static void xfs_xattr_put_listent( struct xfs_attr_list_context *context, int flags, unsigned char *name, int namelen, int valuelen) { char *prefix; int prefix_len; ASSERT(context->count >= 0); if (flags & XFS_ATTR_ROOT) { #ifdef CONFIG_XFS_POSIX_ACL if (namelen == SGI_ACL_FILE_SIZE && strncmp(name, SGI_ACL_FILE, SGI_ACL_FILE_SIZE) == 0) { __xfs_xattr_put_listent( context, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN, XATTR_POSIX_ACL_ACCESS, strlen(XATTR_POSIX_ACL_ACCESS)); } else if (namelen == SGI_ACL_DEFAULT_SIZE && strncmp(name, SGI_ACL_DEFAULT, SGI_ACL_DEFAULT_SIZE) == 0) { __xfs_xattr_put_listent( context, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN, XATTR_POSIX_ACL_DEFAULT, strlen(XATTR_POSIX_ACL_DEFAULT)); } #endif /* * Only show root namespace entries if we are actually allowed to * see them. */ if (!capable(CAP_SYS_ADMIN)) return; prefix = XATTR_TRUSTED_PREFIX; prefix_len = XATTR_TRUSTED_PREFIX_LEN; } else if (flags & XFS_ATTR_SECURE) { prefix = XATTR_SECURITY_PREFIX; prefix_len = XATTR_SECURITY_PREFIX_LEN; } else { prefix = XATTR_USER_PREFIX; prefix_len = XATTR_USER_PREFIX_LEN; } __xfs_xattr_put_listent(context, prefix, prefix_len, name, namelen); return; }

Contributors

PersonTokensPropCommitsCommitProp
andreas gruenbacherandreas gruenbacher13673.51%125.00%
lachlan mcilroylachlan mcilroy4222.70%125.00%
eric sandeeneric sandeen63.24%125.00%
david chinnerdavid chinner10.54%125.00%
Total185100.00%4100.00%


ssize_t xfs_vn_listxattr( struct dentry *dentry, char *data, size_t size) { struct xfs_attr_list_context context; struct attrlist_cursor_kern cursor = { 0 }; struct inode *inode = d_inode(dentry); int error; /* * First read the regular on-disk attributes. */ memset(&context, 0, sizeof(context)); context.dp = XFS_I(inode); context.cursor = &cursor; context.resynch = 1; context.alist = size ? data : NULL; context.bufsize = size; context.firstu = context.bufsize; context.put_listent = xfs_xattr_put_listent; error = xfs_attr_list_int(&context); if (error) return error; if (context.count < 0) return -ERANGE; return context.count; }

Contributors

PersonTokensPropCommitsCommitProp
lachlan mcilroylachlan mcilroy12186.43%125.00%
eric sandeeneric sandeen128.57%125.00%
andreas gruenbacherandreas gruenbacher42.86%125.00%
david howellsdavid howells32.14%125.00%
Total140100.00%4100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
lachlan mcilroylachlan mcilroy54658.52%15.00%
andreas gruenbacherandreas gruenbacher25026.80%315.00%
christoph hellwigchristoph hellwig353.75%315.00%
david chinnerdavid chinner212.25%15.00%
eric sandeeneric sandeen212.25%210.00%
brian fosterbrian foster192.04%15.00%
al viroal viro151.61%210.00%
dave chinnerdave chinner131.39%420.00%
artem savkovartem savkov60.64%15.00%
stephen hemmingerstephen hemminger40.43%15.00%
david howellsdavid howells30.32%15.00%
Total933100.00%20100.00%
Directory: fs/xfs
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.