nfs-ganesha 1.4
|
00001 /* 00002 * vim:expandtab:shiftwidth=8:tabstop=8: 00003 * 00004 * Copyright (C) 2010 The Linux Box, Inc. 00005 * Contributor : Adam C. Emerson <aemerson@linuxbox.com> 00006 * 00007 * Portions copyright CEA/DAM/DIF (2008) 00008 * contributeur : Philippe DENIEL philippe.deniel@cea.fr 00009 * Thomas LEIBOVICI thomas.leibovici@cea.fr 00010 * 00011 * 00012 * This program is free software; you can redistribute it and/or 00013 * modify it under the terms of the GNU Lesser General Public 00014 * License as published by the Free Software Foundation; either 00015 * version 3 of the License, or (at your option) any later version. 00016 * 00017 * This program is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 * Lesser General Public License for more details. 00021 * 00022 * You should have received a copy of the GNU Lesser General Public 00023 * License along with this library; if not, write to the Free Software 00024 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00025 * 00026 * ------------- 00027 */ 00028 00035 #ifdef HAVE_CONFIG_H 00036 #include "config.h" 00037 #endif 00038 00039 #include "fsal.h" 00040 #include "fsal_internal.h" 00041 #include "fsal_convert.h" 00042 00070 fsal_status_t CEPHFSAL_truncate(fsal_handle_t * exthandle, 00071 fsal_op_context_t * extcontext, 00072 fsal_size_t length, 00073 fsal_file_t * file_descriptor, 00074 fsal_attrib_list_t * object_attributes) 00075 { 00076 int rc; 00077 fsal_status_t status; 00078 cephfsal_handle_t* handle = (cephfsal_handle_t*) exthandle; 00079 cephfsal_op_context_t* context = (cephfsal_op_context_t*) extcontext; 00080 int uid = FSAL_OP_CONTEXT_TO_UID(context); 00081 int gid = FSAL_OP_CONTEXT_TO_GID(context); 00082 00083 /* sanity checks. 00084 * note : object_attributes is optional. 00085 */ 00086 if(!handle || !context) 00087 Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_truncate); 00088 00089 TakeTokenFSCall(); 00090 rc = ceph_ll_truncate(context->export_context->cmount, VINODE(handle), 00091 length, uid, gid); 00092 ReleaseTokenFSCall(); 00093 00094 if (rc < 0) 00095 Return(posix2fsal_error(rc), 0, INDEX_FSAL_create); 00096 00097 if(object_attributes) 00098 { 00099 status = CEPHFSAL_getattrs(exthandle, extcontext, object_attributes); 00100 00101 if(FSAL_IS_ERROR(status)) 00102 { 00103 FSAL_CLEAR_MASK(object_attributes->asked_attributes); 00104 FSAL_SET_MASK(object_attributes->asked_attributes, FSAL_ATTR_RDATTR_ERR); 00105 } 00106 } 00107 00108 /* No error occured */ 00109 Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_truncate); 00110 }