mirror of
https://github.com/aaru-dps/fstester.git
synced 2025-12-16 19:24:39 +00:00
Add support for printing Darwin's statfs(2) flags.
This commit is contained in:
@@ -349,50 +349,6 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
#define _XIAFS_SUPER_MAGIC 0x012fd16d
|
||||
#endif
|
||||
|
||||
#ifndef ST_RDONLY
|
||||
#define ST_RDONLY 1
|
||||
#endif
|
||||
|
||||
#ifndef ST_NOSUID
|
||||
#define ST_NOSUID 2
|
||||
#endif
|
||||
|
||||
#ifndef ST_NODEV
|
||||
#define ST_NODEV 4
|
||||
#endif
|
||||
|
||||
#ifndef ST_NOEXEC
|
||||
#define ST_NOEXEC 8
|
||||
#endif
|
||||
|
||||
#ifndef ST_SYNCHRONOUS
|
||||
#define ST_SYNCHRONOUS 16
|
||||
#endif
|
||||
|
||||
#ifndef ST_MANDLOCK
|
||||
#define ST_MANDLOCK 64
|
||||
#endif
|
||||
|
||||
#ifndef ST_WRITE
|
||||
#define ST_WRITE 128
|
||||
#endif
|
||||
|
||||
#ifndef ST_APPEND
|
||||
#define ST_APPEND 256
|
||||
#endif
|
||||
|
||||
#ifndef ST_IMMUTABLE
|
||||
#define ST_IMMUTABLE 512
|
||||
#endif
|
||||
|
||||
#ifndef ST_NOATIME
|
||||
#define ST_NOATIME 1024
|
||||
#endif
|
||||
|
||||
#ifndef ST_NODIRATIME
|
||||
#define ST_NODIRATIME 2048
|
||||
#endif
|
||||
|
||||
#define DATETIME_FORMAT "This file is dated %s for %s\n"
|
||||
#define LESSDATETIME "2106/02/07 06:28:15 or unknown"
|
||||
#define MAXDATETIME "2038/01/19 03:14:07"
|
||||
|
||||
@@ -26,7 +26,7 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#ifdef HAVE_SYS_STATFS_H
|
||||
#include <sys/statfs.h>
|
||||
#endif
|
||||
|
||||
@@ -39,6 +39,12 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
#include "../log.h"
|
||||
#include "unix.h"
|
||||
|
||||
#if defined(__linux__) || defined(__LINUX__) || defined(__gnu_linux)
|
||||
#include "../linux/linux.h"
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
#include "../darwin/darwin.h"
|
||||
#endif
|
||||
|
||||
void GetVolumeInfo(const char* path, size_t* clusterSize)
|
||||
{
|
||||
struct statfs buf;
|
||||
@@ -159,75 +165,13 @@ void GetVolumeInfo(const char* path, size_t* clusterSize)
|
||||
|
||||
if(buf.f_flags)
|
||||
{
|
||||
log_write("\tFlags:\n");
|
||||
|
||||
if(buf.f_flags & ST_RDONLY)
|
||||
{
|
||||
log_write("\t\tVolume is read-only.\n");
|
||||
buf.f_flags -= ST_RDONLY;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_NOSUID)
|
||||
{
|
||||
log_write("\t\tVolume ignores suid and sgid bits.\n");
|
||||
buf.f_flags -= ST_NOSUID;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_NODEV)
|
||||
{
|
||||
log_write("\t\tVolume disallows access to device special files.\n");
|
||||
buf.f_flags -= ST_NODEV;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_NOEXEC)
|
||||
{
|
||||
log_write("\t\tVolume disallows program execution.\n");
|
||||
buf.f_flags -= ST_NOEXEC;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_SYNCHRONOUS)
|
||||
{
|
||||
log_write("\t\tVolume writes are synced at once.\n");
|
||||
buf.f_flags -= ST_SYNCHRONOUS;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_MANDLOCK)
|
||||
{
|
||||
log_write("\t\tVolume allows mandatory locks.\n");
|
||||
buf.f_flags -= ST_MANDLOCK;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_WRITE)
|
||||
{
|
||||
log_write("\t\tVolume writes on file/directory/symlink.\n");
|
||||
buf.f_flags -= ST_WRITE;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_APPEND)
|
||||
{
|
||||
log_write("\t\tVolume appends.\n");
|
||||
buf.f_flags -= ST_APPEND;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_IMMUTABLE)
|
||||
{
|
||||
log_write("\t\tVolume is immutable.\n");
|
||||
buf.f_flags -= ST_IMMUTABLE;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_NOATIME)
|
||||
{
|
||||
log_write("\t\tVolume does not update access times.\n");
|
||||
buf.f_flags -= ST_NOATIME;
|
||||
}
|
||||
|
||||
if(buf.f_flags & ST_NODIRATIME)
|
||||
{
|
||||
log_write("\t\tVolume does not update directory access times.\n");
|
||||
buf.f_flags -= ST_NODIRATIME;
|
||||
}
|
||||
|
||||
if(buf.f_flags) { log_write("\t\tRemaining flags: 0x%08lX\n", buf.f_flags); }
|
||||
#if defined(__linux__) || defined(__LINUX__) || defined(__gnu_linux)
|
||||
LinuxPrintStatfsFlags(buf.f_flags);
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
DarwinPrintStatfsFlags(buf.f_flags);
|
||||
#else
|
||||
log_write("\tFlags: 0x%08lX\n", buf.f_flags);
|
||||
#endif
|
||||
}
|
||||
|
||||
*clusterSize = buf.f_bsize;
|
||||
|
||||
Reference in New Issue
Block a user