support diskfree option to "fix halt" also on BSD variants

This commit is contained in:
Axel Kohlmeyer
2020-05-03 02:34:40 -04:00
parent e8d4cc424e
commit 4bf9c47317
2 changed files with 4 additions and 4 deletions

View File

@ -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
"""""""""""""""" """"""""""""""""

View File

@ -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