support diskfree option to "fix halt" also on BSD variants
This commit is contained in:
@ -160,7 +160,7 @@ the :doc:`run <run>` command.
|
|||||||
|
|
||||||
Restrictions
|
Restrictions
|
||||||
""""""""""""
|
""""""""""""
|
||||||
The *diskfree* attribute is currently only supported on Linux and MacOS.
|
The *diskfree* attribute is currently only supported on Linux, MacOSX, and BSD.
|
||||||
|
|
||||||
Related commands
|
Related commands
|
||||||
""""""""""""""""
|
""""""""""""""""
|
||||||
|
|||||||
@ -306,12 +306,12 @@ double FixHalt::tlimit()
|
|||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
determine available disk space, if supported. Return -1 if not.
|
determine available disk space, if supported. Return -1 if not.
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
#if defined(__linux__) || defined(__APPLE__)
|
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
#endif
|
#endif
|
||||||
double FixHalt::diskfree()
|
double FixHalt::diskfree()
|
||||||
{
|
{
|
||||||
#if defined(__linux__) || defined(__APPLE__)
|
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
||||||
struct statvfs fs;
|
struct statvfs fs;
|
||||||
double disk_free = -1.0;
|
double disk_free = -1.0;
|
||||||
|
|
||||||
@ -321,7 +321,7 @@ double FixHalt::diskfree()
|
|||||||
if (rv == 0) {
|
if (rv == 0) {
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
disk_free = fs.f_bavail*fs.f_bsize/1048576.0;
|
disk_free = fs.f_bavail*fs.f_bsize/1048576.0;
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__NetBSD__)
|
||||||
disk_free = fs.f_bavail*fs.f_frsize/1048576.0;
|
disk_free = fs.f_bavail*fs.f_frsize/1048576.0;
|
||||||
#endif
|
#endif
|
||||||
} else
|
} else
|
||||||
|
|||||||
Reference in New Issue
Block a user