nfs-ganesha 1.4
|
00001 /* 00002 * Copyright (C) 2010 The Linx Box Corporation 00003 * Contributor : Adam C. Emerson 00004 * 00005 * Some Portions Copyright CEA/DAM/DIF (2008) 00006 * contributeur : Philippe DENIEL philippe.deniel@cea.fr 00007 * Thomas LEIBOVICI thomas.leibovici@cea.fr 00008 * 00009 * 00010 * This program is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU Lesser General Public 00012 * License as published by the Free Software Foundation; either 00013 * version 3 of the License, or (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public 00021 * License along with this library; if not, write to the Free Software 00022 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00023 * 00024 * --------------------------------------- 00025 */ 00026 00033 #ifdef HAVE_CONFIG_H 00034 #include "config.h" 00035 #endif 00036 00037 #include "fsal.h" 00038 #include "fsal_internal.h" 00039 #include "fsal_convert.h" 00040 00060 fsal_status_t CEPHFSAL_dynamic_fsinfo(fsal_handle_t * exthandle, 00061 fsal_op_context_t * extcontext, 00062 fsal_dynamicfsinfo_t * dynamicinfo) 00063 { 00064 int rc; 00065 struct statvfs st; 00066 cephfsal_handle_t* handle = (cephfsal_handle_t*) exthandle; 00067 cephfsal_op_context_t* context = (cephfsal_op_context_t*) extcontext; 00068 00069 /* sanity checks. */ 00070 if(!handle || !dynamicinfo || !extcontext) 00071 Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_dynamic_fsinfo); 00072 00073 TakeTokenFSCall(); 00074 00075 rc = ceph_ll_statfs(context->export_context->cmount, VINODE(handle), &st); 00076 00077 ReleaseTokenFSCall(); 00078 00079 if (rc < 0) 00080 Return(posix2fsal_error(rc), 0, INDEX_FSAL_dynamic_fsinfo); 00081 00082 memset(dynamicinfo, sizeof(fsal_dynamicfsinfo_t), 0); 00083 dynamicinfo->total_bytes = st.f_frsize*st.f_blocks; 00084 dynamicinfo->free_bytes = st.f_frsize*st.f_bfree; 00085 dynamicinfo->avail_bytes = st.f_frsize*st.f_bavail; 00086 dynamicinfo->total_files = st.f_files; 00087 dynamicinfo->free_files = st.f_ffree; 00088 dynamicinfo->avail_files = st.f_favail; 00089 dynamicinfo->time_delta.seconds=1; 00090 dynamicinfo->time_delta.nseconds=0; 00091 00092 Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_dynamic_fsinfo); 00093 }