mirror of
https://github.com/aaru-dps/fstester.git
synced 2025-12-16 19:24:39 +00:00
Use statvfs(2) if available instead of statfs(2).
This commit is contained in:
@@ -31,6 +31,15 @@ include(CheckStructHasMember)
|
||||
|
||||
CHECK_SYMBOL_EXISTS(statfs "sys/statfs.h" HAVE_SYS_STATFS)
|
||||
CHECK_SYMBOL_EXISTS(statfs "sys/mount.h" HAVE_SYS_MOUNT)
|
||||
CHECK_SYMBOL_EXISTS(statvfs "sys/statvfs.h" HAVE_SYS_STATVFS)
|
||||
|
||||
# NetBSD >= 3.0
|
||||
if(HAVE_SYS_STATVFS)
|
||||
message("-- Found statvfs in sys/statvfs.h")
|
||||
add_definitions(-DHAVE_SYS_STATVFS_H)
|
||||
CHECK_STRUCT_HAS_MEMBER("struct statvfs" "f_namemax" "sys/statvfs.h" HAVE_STATFS_NAMEMAX)
|
||||
CHECK_STRUCT_HAS_MEMBER("struct statvfs" "f_fstypename" "sys/statvfs.h" HAVE_STATFS_FTYPENAME)
|
||||
endif()
|
||||
|
||||
# Linux and FreeBSD
|
||||
if(HAVE_SYS_STATFS)
|
||||
|
||||
@@ -30,6 +30,10 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
#include <sys/statfs.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_STATVFS_H
|
||||
#include <sys/statvfs.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SYS_MOUNT_H)
|
||||
#include <sys/mount.h>
|
||||
#include <sys/param.h>
|
||||
@@ -43,14 +47,24 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
#include "../linux/linux.h"
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
#include "../darwin/darwin.h"
|
||||
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#include "../bsd/bsd.h"
|
||||
#endif
|
||||
|
||||
void GetVolumeInfo(const char* path, size_t* clusterSize)
|
||||
{
|
||||
#ifdef HAVE_SYS_STATVFS_H
|
||||
struct statvfs buf;
|
||||
#else
|
||||
struct statfs buf;
|
||||
int ret;
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
#ifdef HAVE_SYS_STATVFS_H
|
||||
ret = statvfs(path, &buf);
|
||||
#else
|
||||
ret = statfs(path, &buf);
|
||||
#endif
|
||||
|
||||
if(ret)
|
||||
{
|
||||
@@ -163,6 +177,16 @@ void GetVolumeInfo(const char* path, size_t* clusterSize)
|
||||
log_write("\tMaximum component length: %ld\n", buf.f_namemax);
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_STATVFS_H
|
||||
if(buf.f_flag)
|
||||
{
|
||||
#if defined(__NetBSD__)
|
||||
// TODO: NetBsdPrintStatfsFlags(buf.f_flag);
|
||||
#else
|
||||
log_write("\tFlags: 0x%08lX\n", buf.f_flag);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
if(buf.f_flags)
|
||||
{
|
||||
#if defined(__linux__) || defined(__LINUX__) || defined(__gnu_linux)
|
||||
@@ -173,6 +197,7 @@ void GetVolumeInfo(const char* path, size_t* clusterSize)
|
||||
log_write("\tFlags: 0x%08lX\n", buf.f_flags);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
*clusterSize = buf.f_bsize;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user