nfs-ganesha 1.4
|
00001 /* 00002 * vim:expandtab:shiftwidth=4:tabstop=4: 00003 */ 00004 00014 #ifdef HAVE_CONFIG_H 00015 #include "config.h" 00016 #endif 00017 00018 #include "fsal.h" 00019 #include "fsal_internal.h" 00020 #include "fsal_convert.h" 00021 #include <sys/statvfs.h> 00022 00041 fsal_status_t LUSTREFSAL_dynamic_fsinfo(fsal_handle_t * p_filehandle, /* IN */ 00042 fsal_op_context_t * p_context, /* IN */ 00043 fsal_dynamicfsinfo_t * p_dynamicinfo /* OUT */ 00044 ) 00045 { 00046 fsal_path_t pathfsal; 00047 fsal_status_t status; 00048 struct statvfs buffstatvfs; 00049 int rc, errsv; 00050 /* sanity checks. */ 00051 if(!p_filehandle || !p_dynamicinfo || !p_context) 00052 Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_dynamic_fsinfo); 00053 00054 status = fsal_internal_Handle2FidPath(p_context, p_filehandle, &pathfsal); 00055 if(FSAL_IS_ERROR(status)) 00056 Return(status.major, status.minor, INDEX_FSAL_dynamic_fsinfo); 00057 00058 TakeTokenFSCall(); 00059 rc = statvfs(pathfsal.path, &buffstatvfs); 00060 errsv = errno; 00061 ReleaseTokenFSCall(); 00062 if(rc) 00063 Return(posix2fsal_error(errsv), errsv, INDEX_FSAL_dynamic_fsinfo); 00064 00065 p_dynamicinfo->total_bytes = buffstatvfs.f_frsize * buffstatvfs.f_blocks; 00066 p_dynamicinfo->free_bytes = buffstatvfs.f_frsize * buffstatvfs.f_bfree; 00067 p_dynamicinfo->avail_bytes = buffstatvfs.f_frsize * buffstatvfs.f_bavail; 00068 00069 p_dynamicinfo->total_files = buffstatvfs.f_files; 00070 p_dynamicinfo->free_files = buffstatvfs.f_ffree; 00071 p_dynamicinfo->avail_files = buffstatvfs.f_favail; 00072 00073 p_dynamicinfo->time_delta.seconds = 1; 00074 p_dynamicinfo->time_delta.nseconds = 0; 00075 00076 Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_dynamic_fsinfo); 00077 00078 }