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 VFSFSAL_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 
00049   /* sanity checks. */
00050   if(!p_filehandle || !p_dynamicinfo || !p_context)
00051     Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_dynamic_fsinfo);
00052 
00053   TakeTokenFSCall();
00054   rc = fstatvfs(((vfsfsal_op_context_t *)p_context)->export_context->mount_root_fd,
00055                 &buffstatvfs);
00056   errsv = errno;
00057   ReleaseTokenFSCall();
00058   if(rc)
00059     Return(posix2fsal_error(errsv), errsv, INDEX_FSAL_dynamic_fsinfo);
00060 
00061   p_dynamicinfo->total_bytes = buffstatvfs.f_frsize * buffstatvfs.f_blocks;
00062   p_dynamicinfo->free_bytes = buffstatvfs.f_frsize * buffstatvfs.f_bfree;
00063   p_dynamicinfo->avail_bytes = buffstatvfs.f_frsize * buffstatvfs.f_bavail;
00064 
00065   p_dynamicinfo->total_files = buffstatvfs.f_files;
00066   p_dynamicinfo->free_files = buffstatvfs.f_ffree;
00067   p_dynamicinfo->avail_files = buffstatvfs.f_favail;
00068 
00069   p_dynamicinfo->time_delta.seconds = 1;
00070   p_dynamicinfo->time_delta.nseconds = 0;
00071 
00072   Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_dynamic_fsinfo);
00073 
00074 }