Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / mdt / mdt_lib.c
index 85ce484..b3dc462 100644 (file)
@@ -1,36 +1,49 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- *  lustre/mdt/mdt_lib.c
- *  Lustre Metadata Target (mdt) request unpacking helper.
+ * GPL HEADER START
  *
- *  Copyright (c) 2006 Cluster File Systems, Inc.
- *   Author: Peter Braam <braam@clusterfs.com>
- *   Author: Andreas Dilger <adilger@clusterfs.com>
- *   Author: Phil Schwan <phil@clusterfs.com>
- *   Author: Mike Shaver <shaver@clusterfs.com>
- *   Author: Nikita Danilov <nikita@clusterfs.com>
- *   Author: Huang Hua <huanghua@clusterfs.com>
- *   Author: Fan Yong <fanyong@clusterfs.com>
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
+ * 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.
  *
- *   This file is part of the Lustre file system, http://www.lustre.org
- *   Lustre is a trademark of Cluster File Systems, Inc.
+ * 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).
  *
- *   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.
+ * 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
  *
- *   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.
+ * 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.
  *
- *   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.
+ * GPL HEADER END
+ */
+/*
+ * Copyright  2008 Sun Microsystems, Inc. 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/mdt/mdt_lib.c
+ *
+ * Lustre Metadata Target (mdt) request unpacking helper.
+ *
+ * Author: Peter Braam <braam@clusterfs.com>
+ * Author: Andreas Dilger <adilger@clusterfs.com>
+ * Author: Phil Schwan <phil@clusterfs.com>
+ * Author: Mike Shaver <shaver@clusterfs.com>
+ * Author: Nikita Danilov <nikita@clusterfs.com>
+ * Author: Huang Hua <huanghua@clusterfs.com>
+ * Author: Fan Yong <fanyong@clusterfs.com>
  */
 
 
@@ -94,7 +107,7 @@ static int new_init_ucred(struct mdt_thread_info *info, ucred_init_type_t type,
         LASSERT(req->rq_auth_gss);
         LASSERT(!req->rq_auth_usr_mdt);
         LASSERT(req->rq_user_desc);
-        
+
         ucred->mu_valid = UCRED_INVALID;
 
         ucred->mu_o_uid   = pud->pud_uid;
@@ -230,7 +243,7 @@ static int new_init_ucred(struct mdt_thread_info *info, ucred_init_type_t type,
 
         /* remove fs privilege for non-root user */
         if (ucred->mu_fsuid)
-                ucred->mu_cap = pud->pud_cap & ~CAP_FS_MASK;
+                ucred->mu_cap = pud->pud_cap & ~CFS_CAP_FS_MASK;
         else
                 ucred->mu_cap = pud->pud_cap;
         ucred->mu_valid = UCRED_NEW;
@@ -393,7 +406,7 @@ static int old_init_ucred(struct mdt_thread_info *info,
 
         /* remove fs privilege for non-root user */
         if (uc->mu_fsuid)
-                uc->mu_cap = body->capability & ~CAP_FS_MASK;
+                uc->mu_cap = body->capability & ~CFS_CAP_FS_MASK;
         else
                 uc->mu_cap = body->capability;
         uc->mu_valid = UCRED_OLD;
@@ -433,7 +446,7 @@ static int old_init_ucred_reint(struct mdt_thread_info *info)
 
         /* remove fs privilege for non-root user */
         if (uc->mu_fsuid)
-                uc->mu_cap &= ~CAP_FS_MASK;
+                uc->mu_cap &= ~CFS_CAP_FS_MASK;
         uc->mu_valid = UCRED_OLD;
 
         RETURN(0);
@@ -512,7 +525,7 @@ void mdt_shrink_reply(struct mdt_thread_info *info)
 
         acl_size = body->aclsize;
 
-        CDEBUG(D_INFO, "Shrink to md_size = %d cookie/acl_size = %d" 
+        CDEBUG(D_INFO, "Shrink to md_size = %d cookie/acl_size = %d"
                         " MDSCAPA = "LPX64", OSSCAPA = "LPX64"\n",
                         md_size, acl_size,
                         body->valid & OBD_MD_FLMDSCAPA,
@@ -533,14 +546,14 @@ void mdt_shrink_reply(struct mdt_thread_info *info)
                 req_capsule_shrink(pill, &RMF_ACL, acl_size, RCL_SERVER);
         else if (req_capsule_has_field(pill, &RMF_LOGCOOKIES, RCL_SERVER))
                 req_capsule_shrink(pill, &RMF_LOGCOOKIES,
-                                            acl_size, RCL_SERVER);
+                                   acl_size, RCL_SERVER);
 
         if (req_capsule_has_field(pill, &RMF_CAPA1, RCL_SERVER) &&
-                    !(body->valid & OBD_MD_FLMDSCAPA))
+            !(body->valid & OBD_MD_FLMDSCAPA))
                 req_capsule_shrink(pill, &RMF_CAPA1, 0, RCL_SERVER);
 
         if (req_capsule_has_field(pill, &RMF_CAPA2, RCL_SERVER) &&
-                !(body->valid & OBD_MD_FLOSSCAPA))
+            !(body->valid & OBD_MD_FLOSSCAPA))
                 req_capsule_shrink(pill, &RMF_CAPA2, 0, RCL_SERVER);
 
         /*
@@ -630,8 +643,6 @@ static inline unsigned int attr_unpack(__u64 sa_valid) {
                 ia_valid |= ATTR_FROM_OPEN;
         if (sa_valid & MDS_ATTR_BLOCKS)
                 ia_valid |= ATTR_BLOCKS;
-        if (sa_valid & MDS_ATTR_TRUNC)
-                ia_valid |= ATTR_TRUNC;
         if (sa_valid & MDS_OPEN_OWNEROVERRIDE)
                 ia_valid |= MDS_OPEN_OWNEROVERRIDE;
         return ia_valid;
@@ -669,17 +680,17 @@ static __u64 mdt_attr_valid_xlate(__u64 in, struct mdt_reint_record *rr,
         if (in & ATTR_ATTR_FLAG)
                 out |= LA_FLAGS;
 
-        if (in & ATTR_TRUNC)
-                out |= LA_TRUNC;
-
         if (in & MDS_OPEN_OWNEROVERRIDE)
-                out |= MDS_OPEN_OWNEROVERRIDE;
+                ma->ma_attr_flags |= MDS_OPEN_OWNEROVERRIDE;
+
+        if (in & (ATTR_KILL_SUID|ATTR_KILL_SGID))
+                ma->ma_attr_flags |= MDS_PERM_BYPASS;
 
         /*XXX need ATTR_RAW?*/
         in &= ~(ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|ATTR_BLOCKS|
                 ATTR_ATIME|ATTR_MTIME|ATTR_CTIME|ATTR_FROM_OPEN|
                 ATTR_ATIME_SET|ATTR_CTIME_SET|ATTR_MTIME_SET|
-                ATTR_ATTR_FLAG|ATTR_RAW|ATTR_TRUNC|MDS_OPEN_OWNEROVERRIDE);
+                ATTR_ATTR_FLAG|ATTR_RAW|MDS_OPEN_OWNEROVERRIDE);
         if (in != 0)
                 CERROR("Unknown attr bits: %#llx\n", in);
         return out;
@@ -747,7 +758,7 @@ static inline int mdt_dlmreq_unpack(struct mdt_thread_info *info) {
                 if (info->mti_dlm_req == NULL)
                         RETURN(-EFAULT);
         }
-        
+
         RETURN(0);
 }
 
@@ -840,7 +851,7 @@ static int mdt_create_unpack(struct mdt_thread_info *info)
         rr->rr_name = req_capsule_client_get(pill, &RMF_NAME);
         rr->rr_namelen = req_capsule_get_size(pill, &RMF_NAME, RCL_CLIENT) - 1;
         LASSERT(rr->rr_name && rr->rr_namelen > 0);
-        
+
 #ifdef CONFIG_FS_POSIX_ACL
         if (sp->sp_cr_flags & MDS_CREATE_RMT_ACL) {
                 if (S_ISDIR(attr->la_mode))