* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2013, Intel Corporation.
+ * Copyright (c) 2011, 2014, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#define DEBUG_SUBSYSTEM S_LLITE
#include <obd_support.h>
-#include <lustre_lite.h>
#include <lustre_dlm.h>
#include <lustre_ver.h>
#include <lustre_eacl.h>
if (rc)
RETURN(rc);
+ if ((xattr_type == XATTR_ACL_ACCESS_T ||
+ xattr_type == XATTR_ACL_DEFAULT_T) &&
+#ifdef HAVE_INODE_OWNER_OR_CAPABLE
+ !inode_owner_or_capable(inode))
+#else
+ !is_owner_or_cap(inode))
+#endif
+ return -EPERM;
+
/* b10667: ignore lustre special xattr for now */
if ((xattr_type == XATTR_TRUSTED_T && strcmp(name, "trusted.lov") == 0) ||
(xattr_type == XATTR_LUSTRE_T && strcmp(name, "lustre.lov") == 0))
(strncmp(name, XATTR_LUSTRE_PREFIX,
sizeof(XATTR_LUSTRE_PREFIX) - 1) == 0 &&
strcmp(name + sizeof(XATTR_LUSTRE_PREFIX) - 1, "lov") == 0)) {
- struct lov_user_md *lump = (struct lov_user_md *)value;
- int rc = 0;
+ struct lov_user_md *lump = (struct lov_user_md *)value;
+ int rc = 0;
/* Attributes that are saved via getxattr will always have
* the stripe_offset as 0. Instead, the MDS should be
if (lump != NULL && S_ISREG(inode->i_mode)) {
struct file f;
__u64 it_flags = FMODE_WRITE;
- int lum_size = (lump->lmm_magic == LOV_USER_MAGIC_V1) ?
- sizeof(*lump) : sizeof(struct lov_user_md_v3);
+ int lum_size;
+
+ lum_size = ll_lov_user_md_size(lump);
+ if (lum_size < 0 || size < lum_size)
+ return 0; /* b=10667: ignore error */
+ memset(&f, 0, sizeof(f)); /* f.f_flags is used below */
f.f_dentry = dentry;
rc = ll_lov_setstripe_ea_info(inode, &f, it_flags, lump,
lum_size);
- /* b10667: rc always be 0 here for now */
+ /* b=10667: rc always be 0 here for now */
rc = 0;
} else if (S_ISDIR(inode->i_mode)) {
rc = ll_dir_setstripe(inode, lump, 0);
OBD_MD_FLXATTRRM);
}
-static
int ll_getxattr_common(struct inode *inode, const char *name,
void *buffer, size_t size, __u64 valid)
{
/* only detect the xattr size */
if (size == 0)
- GOTO(out, rc = body->eadatasize);
+ GOTO(out, rc = body->mbo_eadatasize);
- if (size < body->eadatasize) {
+ if (size < body->mbo_eadatasize) {
CERROR("server bug: replied size %u > %u\n",
- body->eadatasize, (int)size);
+ body->mbo_eadatasize, (int)size);
GOTO(out, rc = -ERANGE);
}
- if (body->eadatasize == 0)
+ if (body->mbo_eadatasize == 0)
GOTO(out, rc = -ENODATA);
/* do not need swab xattr data */
xdata = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA,
- body->eadatasize);
+ body->mbo_eadatasize);
if (!xdata)
GOTO(out, rc = -EFAULT);
- memcpy(buffer, xdata, body->eadatasize);
- rc = body->eadatasize;
+ memcpy(buffer, xdata, body->mbo_eadatasize);
+ rc = body->mbo_eadatasize;
}
#ifdef CONFIG_FS_POSIX_ACL
if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
return -ENODATA;
- if (size == 0 && S_ISDIR(inode->i_mode)) {
- /* XXX directory EA is fix for now, optimize to save
- * RPC transfer */
- GOTO(out, rc = sizeof(struct lov_user_md));
- }
-
lsm = ccc_inode_lsm_get(inode);
if (lsm == NULL) {
if (S_ISDIR(inode->i_mode)) {