Build on more Unix-like OSes (BSD, illumos, etc)

Signed-off-by: Nia Alarie <nia@NetBSD.org>
This commit is contained in:
nia 2024-10-25 10:39:25 +02:00
parent b9c5c4d8d3
commit e33c207043
2 changed files with 3 additions and 5 deletions

View file

@ -8,7 +8,7 @@
#if defined(__APPLE__)
#include <sys/disk.h>
#include <sys/stat.h>
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__)
#else
#include <unistd.h>
#include <sys/statvfs.h>
#endif
@ -29,15 +29,13 @@ CVolumeStream::CVolumeStream(const char* volumePath)
{
throw std::runtime_error("Can't get sector size.");
}
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__)
#else
struct statvfs s;
if(fstatvfs(m_fd, &s))
{
throw std::runtime_error("Can't get sector size.");
}
m_sectorSize = s.f_bsize;
#else
#error Unsupported
#endif
m_cache = malloc(m_sectorSize);
m_cacheSector = m_sectorSize - 1;