nfs-ganesha 1.4

fsal_fsinfo.c

Go to the documentation of this file.
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 XFSFSAL_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   struct statvfs buffstatvfs;
00047   int rc, errsv;
00048   /* sanity checks. */
00049   if(!p_filehandle || !p_dynamicinfo || !p_context)
00050     Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_dynamic_fsinfo);
00051 
00052   TakeTokenFSCall();
00053   rc = statvfs(((xfsfsal_op_context_t *)p_context)->export_context->mount_point, &buffstatvfs);
00054   errsv = errno;
00055   ReleaseTokenFSCall();
00056   if(rc)
00057     Return(posix2fsal_error(errsv), errsv, INDEX_FSAL_dynamic_fsinfo);
00058 
00059   p_dynamicinfo->total_bytes = buffstatvfs.f_frsize * buffstatvfs.f_blocks;
00060   p_dynamicinfo->free_bytes = buffstatvfs.f_frsize * buffstatvfs.f_bfree;
00061   p_dynamicinfo->avail_bytes = buffstatvfs.f_frsize * buffstatvfs.f_bavail;
00062 
00063   p_dynamicinfo->total_files = buffstatvfs.f_files;
00064   p_dynamicinfo->free_files = buffstatvfs.f_ffree;
00065   p_dynamicinfo->avail_files = buffstatvfs.f_favail;
00066 
00067   p_dynamicinfo->time_delta.seconds = 1;
00068   p_dynamicinfo->time_delta.nseconds = 0;
00069 
00070   Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_dynamic_fsinfo);
00071 
00072 }