-/* -*- MODE: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * mdd/mdd_handler.c
- * Lustre Metadata Server (mdd) routines
+ * GPL HEADER START
*
- * Copyright (C) 2006 Cluster File Systems, Inc.
- * Author: fangyong@clusterfs.com
- * lsy@clusterfs.com
- * This file is part of the Lustre file system, http://www.lustre.org
- * Lustre is a trademark of Cluster File Systems, Inc.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
- * You may have signed or agreed to another license before downloading
- * this software. If so, you are bound by the terms and conditions
- * of that agreement, and the following does not apply to you. See the
- * LICENSE file included with this distribution for more information.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
*
- * If you did not agree to a different license, then this copy of Lustre
- * is open source software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
+ * This program is distributed in the hope that it will 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 version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
*
- * In either case, Lustre is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * license text for more details.
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/mdd/mdd_permission.c
+ *
+ * Lustre Metadata Server (mdd) routines
+ *
+ * Author: fangyong@clusterfs.com
+ * Author: lsy@clusterfs.com
*/
#ifndef EXPORT_SYMTAB
# define EXPORT_SYMTAB
#define DEBUG_SUBSYSTEM S_MDS
#include <linux/module.h>
+#ifdef HAVE_EXT4_LDISKFS
+#include <ldiskfs/ldiskfs_jbd2.h>
+#else
#include <linux/jbd.h>
+#endif
#include <obd.h>
#include <obd_class.h>
#include <lustre_ver.h>
#include <obd_support.h>
#include <lprocfs_status.h>
+#ifdef HAVE_EXT4_LDISKFS
+#include <ldiskfs/ldiskfs.h>
+#else
#include <linux/ldiskfs_fs.h>
+#endif
#include <lustre_mds.h>
#include <lustre/lustre_idl.h>
* Get default acl EA only.
* Hold read_lock for mdd_obj.
*/
-int mdd_acl_def_get(const struct lu_env *env, struct mdd_object *mdd_obj,
+int mdd_def_acl_get(const struct lu_env *env, struct mdd_object *mdd_obj,
struct md_attr *ma)
{
struct lu_buf *buf;
if (ma->ma_valid & MA_ACL_DEF)
RETURN(0);
-
+
buf = mdd_buf_get(env, ma->ma_acl, ma->ma_acl_size);
rc = mdo_xattr_get(env, mdd_obj, buf, XATTR_NAME_ACL_DEFAULT,
BYPASS_CAPA);
/*
* Hold write_lock for o.
*/
-int mdd_acl_chmod(const struct lu_env *env, struct mdd_object *o, __u32 mode,
+int mdd_acl_chmod(const struct lu_env *env, struct mdd_object *o, __u32 mode,
struct thandle *handle)
{
struct lu_buf *buf;
ENTRY;
- buf = mdd_buf_get(env, mdd_env_info(env)->mti_xattr_buf,
+ buf = mdd_buf_get(env, mdd_env_info(env)->mti_xattr_buf,
sizeof(mdd_env_info(env)->mti_xattr_buf));
-
+
rc = mdo_xattr_get(env, o, buf, XATTR_NAME_ACL_ACCESS, BYPASS_CAPA);
if ((rc == -EOPNOTSUPP) || (rc == -ENODATA))
RETURN(0);
sizeof(posix_acl_xattr_entry);
if (entry_count <= 0)
RETURN(0);
-
+
rc = lustre_posix_acl_chmod_masq(entry, mode, entry_count);
if (rc)
RETURN(rc);
sizeof(posix_acl_xattr_entry);
if (entry_count <= 0)
RETURN(0);
-
- if (S_ISDIR(*mode)) {
- rc = mdo_xattr_set(env, obj, buf, XATTR_NAME_ACL_DEFAULT, 0,
+
+ if (S_ISDIR(*mode)) {
+ rc = mdo_xattr_set(env, obj, buf, XATTR_NAME_ACL_DEFAULT, 0,
handle, BYPASS_CAPA);
if (rc)
RETURN(rc);
- }
+ }
rc = lustre_posix_acl_create_masq(entry, mode, entry_count);
if (rc <= 0)
BYPASS_CAPA);
RETURN(rc);
}
-
-/*
- * Hold read_lock for pobj.
- * Hold write_lock for cobj.
- */
-int mdd_acl_init(const struct lu_env *env, struct mdd_object *pobj,
- struct mdd_object *cobj, __u32 *mode, struct thandle *handle)
-{
- struct lu_buf *buf;
- int rc;
- ENTRY;
-
- if (S_ISLNK(*mode))
- RETURN(0);
-
- buf = mdd_buf_get(env, mdd_env_info(env)->mti_xattr_buf,
- sizeof(mdd_env_info(env)->mti_xattr_buf));
- rc = mdo_xattr_get(env, pobj, buf, XATTR_NAME_ACL_DEFAULT, BYPASS_CAPA);
- if ((rc == -EOPNOTSUPP) || (rc == -ENODATA))
- RETURN(0);
- else if (rc <= 0)
- RETURN(rc);
-
- buf->lb_len = rc;
- rc = __mdd_acl_init(env, cobj, buf, mode, handle);
- RETURN(rc);
-}
#endif
/*
int rc;
ENTRY;
- buf = mdd_buf_get(env, mdd_env_info(env)->mti_xattr_buf,
+ buf = mdd_buf_get(env, mdd_env_info(env)->mti_xattr_buf,
sizeof(mdd_env_info(env)->mti_xattr_buf));
rc = mdo_xattr_get(env, obj, buf, XATTR_NAME_ACL_ACCESS,
mdd_object_capa(env, obj));
}
int __mdd_permission_internal(const struct lu_env *env, struct mdd_object *obj,
- struct lu_attr *la, int mask, int needlock)
+ struct lu_attr *la, int mask, int role)
{
struct md_ucred *uc = md_ucred(env);
__u32 mode;
mode >>= 6;
} else {
if (mode & S_IRWXG) {
- if (needlock)
- mdd_read_lock(env, obj);
+ if (role != -1)
+ mdd_read_lock(env, obj, role);
rc = mdd_check_acl(env, obj, la, mask);
- if (needlock)
+ if (role != -1)
mdd_read_unlock(env, obj);
if (rc == -EACCES)
goto check_capabilities;
check_capabilities:
if (!(mask & MAY_EXEC) ||
(la->la_mode & S_IXUGO) || S_ISDIR(la->la_mode))
- if (mdd_capable(uc, CAP_DAC_OVERRIDE))
+ if (mdd_capable(uc, CFS_CAP_DAC_OVERRIDE))
RETURN(0);
if ((mask == MAY_READ) ||
(S_ISDIR(la->la_mode) && !(mask & MAY_WRITE)))
- if (mdd_capable(uc, CAP_DAC_READ_SEARCH))
+ if (mdd_capable(uc, CFS_CAP_DAC_READ_SEARCH))
RETURN(0);
RETURN(-EACCES);
}
-int mdd_permission(const struct lu_env *env,
+int mdd_permission(const struct lu_env *env,
struct md_object *pobj, struct md_object *cobj,
struct md_attr *ma, int mask)
{
MAY_VTX_PART | MAY_VTX_FULL |
MAY_RGETFACL);
- rc = mdd_permission_internal_locked(env, mdd_cobj, NULL, mask);
+ rc = mdd_permission_internal_locked(env, mdd_cobj, NULL, mask,
+ MOR_TGT_CHILD);
if (!rc && (check_create || check_link))
rc = mdd_may_create(env, mdd_cobj, NULL, 1, check_link);
RETURN(rc);
}
- if (la->la_uid != uc->mu_fsuid && !mdd_capable(uc, CAP_FOWNER))
+ if (la->la_uid != uc->mu_fsuid &&
+ !mdd_capable(uc, CFS_CAP_FOWNER))
rc = -EPERM;
}
capa->lc_opc);
if (IS_ERR(oc)) {
rc = PTR_ERR(oc);
- } else {
+ } else if (likely(oc != NULL)) {
capa_cpy(capa, oc);
capa_put(oc);
}