Version française
Home     About     Download     Resources     Contact us    
Browse thread
How to find out free diskspace?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Bernd Kuhls <bernd.kuhls@i...>
Subject: Re: How to find out free diskspace?
Richard Jones wrote:
> ---------------------------------------------------------------- statfs_c.c

Hi Richard,

thanks for you code. It is working nicely here. I made some adjustments
to it so it works now on Linux, Solaris/Sparc, FreeBSD and OpenBSD.

The only thing missing is how to return "-1" values to Ocaml when the 
stats functions are not available on that machine?

#ifdef HAVE_SYS_PARAM_H
#  include <sys/param.h>
#  if (defined(__FreeBSD__) && __FreeBSD_version >= 503001) || 
defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
#    include <sys/mount.h>
#    define HAVE_STATS 1
#  endif
#endif
#ifdef HAVE_SYS_VFS_H
#  include <sys/vfs.h>
#  define HAVE_STATS 1
#endif

#ifdef HAVE_STATS
static value
#if ((defined (sun) || defined (__sun__)))
copy_statfs (struct statvfs *buf)
#else
copy_statfs (struct statfs *buf)
#endif

{
+  CAMLparam0 ();
+  CAMLlocal2 (bufv, v);
+  bufv = caml_alloc (11, 0);
... (lots of your code)
#endif

The code for "ifndef HAVE_STATS" is still lacking, how should it look like?

When this is finished and working I will post the complete code here.

Greetings, Bernd