Decode NetBSD flags from statvfs(2).

This commit is contained in:
2021-03-31 03:02:39 +01:00
parent af4c7b33d2
commit 30a016430c
5 changed files with 355 additions and 2 deletions

View File

@@ -31,7 +31,7 @@ project(
DESCRIPTION "Filesystem test creator for BSD"
LANGUAGES C)
set(PLATFORM_SOURCES bsd.h xattr.c xattr.h attr.c attr.h)
set(PLATFORM_SOURCES bsd.h xattr.c xattr.h attr.c attr.h volume.c volume.h)
set(EXECUTABLE_NAME "fssetter-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")

View File

@@ -28,4 +28,8 @@ Copyright (C) 2011-2021 Natalia Portillo
void BsdExtendedAttributes(const char* path);
void BsdFileAttributes(const char* path);
#if defined(__NetBSD__)
void NetBsdPrintStatvfsFlags(unsigned long flags);
#endif
#endif // SETTER_SRC_BSD_H_

View File

@@ -0,0 +1,207 @@
/****************************************************************************
Aaru Data Preservation Suite
-----------------------------------------------------------------------------
Author(s) : Natalia Portillo
--[ License ] ---------------------------------------------------------------
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
Copyright (C) 2011-2021 Natalia Portillo
*****************************************************************************/
#ifdef HAVE_SYS_STATVFS_H
#include <sys/statvfs.h>
#endif
#include "../../log.h"
#include "volume.h"
#if defined(__NetBSD__)
void NetBsdPrintStatvfsFlags(unsigned long flags)
{
log_write("\tFlags:\n");
if(flags & ST_RDONLY)
{
log_write("\t\tVolume is read-only.\n");
flags -= ST_RDONLY;
}
if(flags & ST_NOSUID)
{
log_write("\t\tVolume ignores suid and sgid bits.\n");
flags -= ST_NOSUID;
}
if(flags & ST_NODEV)
{
log_write("\t\tVolume disallows access to device special files.\n");
flags -= ST_NODEV;
}
if(flags & ST_NOEXEC)
{
log_write("\t\tVolume disallows program execution.\n");
flags -= ST_NOEXEC;
}
if(flags & ST_SYNCHRONOUS)
{
log_write("\t\tVolume writes are synced at once.\n");
flags -= ST_SYNCHRONOUS;
}
if(flags & ST_NOATIME)
{
log_write("\t\tVolume does not update access times.\n");
flags -= ST_NOATIME;
}
if(flags & ST_UNION)
{
log_write("\t\tVolume is a union.\n");
flags -= ST_UNION;
}
if(flags & ST_ASYNC)
{
log_write("\t\tVolume is written asynchronously.\n");
flags -= ST_ASYNC;
}
if(flags & ST_NOCOREDUMP)
{
log_write("\t\tVolume shall not have core dumps written.\n");
flags -= ST_NOCOREDUMP;
}
if(flags & ST_RELATIME)
{
log_write("\t\tVolume only updates access time on changes.\n");
flags -= ST_RELATIME;
}
if(flags & ST_IGNORE)
{
log_write("\t\tVolume does not appear in df.\n");
flags -= ST_IGNORE;
}
if(flags & ST_SYMPERM)
{
log_write("\t\tVolume recognizes symbolic link permissions.\n");
flags -= ST_SYMPERM;
}
if(flags & ST_NODEVMTIME)
{
log_write("\t\tVolume does not update modification times for devices.\n");
flags -= ST_NODEVMTIME;
}
if(flags & ST_SOFTDEP)
{
log_write("\t\tVolume uses soft dependencies.\n");
flags -= ST_SOFTDEP;
}
if(flags & ST_LOG)
{
log_write("\t\tVolume uses logging.\n");
flags -= ST_LOG;
}
if(flags & ST_EXTATTR)
{
log_write("\t\tVolume has extended attributes enabled.\n");
flags -= ST_EXTATTR;
}
if(flags & ST_EXRDONLY)
{
log_write("\t\tVolume is exported read-only.\n");
flags -= ST_EXRDONLY;
}
if(flags & ST_EXPORTED)
{
log_write("\t\tVolume is exported.\n");
flags -= ST_EXPORTED;
}
if(flags & ST_DEFEXPORTED)
{
log_write("\t\tVolume is exported to the world.\n");
flags -= ST_DEFEXPORTED;
}
if(flags & ST_EXPORTANON)
{
log_write("\t\tVolume uses anon id.\n");
flags -= ST_EXPORTANON;
}
if(flags & ST_EXKERB)
{
log_write("\t\tVolume is exported with Kerberos ID.\n");
flags -= ST_EXKERB;
}
if(flags & ST_EXNORESPORT)
{
log_write("\t\tVolume export does not enforce reserved ports.\n");
flags -= ST_EXNORESPORT;
}
if(flags & ST_EXPUBLIC)
{
log_write("\t\tVolume is exported publicly.\n");
flags -= ST_EXPUBLIC;
}
if(flags & ST_LOCAL)
{
log_write("\t\tVolume is local.\n");
flags -= ST_LOCAL;
}
if(flags & ST_QUOTA)
{
log_write("\t\tVolume has quotas enabled.\n");
flags -= ST_QUOTA;
}
if(flags & ST_ROOTFS)
{
log_write("\t\tVolume is the root filesystem.\n");
flags -= ST_ROOTFS;
}
if(flags & ST_DISCARD)
{
log_write("\t\tVolume is TRIMmed/DISCARDed.\n");
flags -= ST_DISCARD;
}
if(flags & ST_AUTOMOUNTED)
{
log_write("\t\tVolume is automounted.\n");
flags -= ST_AUTOMOUNTED;
}
if(flags) { log_write("\t\tRemaining flags: 0x%08lX\n", flags); }
}
#endif

View File

@@ -0,0 +1,142 @@
/****************************************************************************
Aaru Data Preservation Suite
-----------------------------------------------------------------------------
Author(s) : Natalia Portillo
--[ License ] ---------------------------------------------------------------
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
Copyright (C) 2011-2021 Natalia Portillo
*****************************************************************************/
#ifndef AARU_FSTESTER_SETTER_SRC_BSD_VOLUME_H_
#define AARU_FSTESTER_SETTER_SRC_BSD_VOLUME_H_
#if defined(__NetBSD__)
#ifndef ST_RDONLY
#define ST_RDONLY 0x00000001 /* read only filesystem */
#endif
#ifndef ST_SYNCHRONOUS
#define ST_SYNCHRONOUS 0x00000002 /* file system written synchronously */
#endif
#ifndef ST_NOEXEC
#define ST_NOEXEC 0x00000004 /* can't exec from filesystem */
#endif
#ifndef ST_NOSUID
#define ST_NOSUID 0x00000008 /* don't honor setuid bits on fs */
#endif
#ifndef ST_NODEV
#define ST_NODEV 0x00000010 /* don't interpret special files */
#endif
#ifndef ST_UNION
#define ST_UNION 0x00000020 /* union with underlying filesystem */
#endif
#ifndef ST_ASYNC
#define ST_ASYNC 0x00000040 /* file system written asynchronously */
#endif
#ifndef ST_NOCOREDUMP
#define ST_NOCOREDUMP 0x00008000 /* don't write core dumps to this FS */
#endif
#ifndef ST_RELATIME
#define ST_RELATIME 0x00020000 /* only update access time if mod/ch */
#endif
#ifndef ST_IGNORE
#define ST_IGNORE 0x00100000 /* don't show entry in df */
#endif
#ifndef ST_DISCARD
#define ST_DISCARD 0x00800000 /* use DISCARD/TRIM if supported */
#endif
#ifndef ST_EXTATTR
#define ST_EXTATTR 0x01000000 /* enable extended attributes */
#endif
#ifndef ST_LOG
#define ST_LOG 0x02000000 /* Use logging */
#endif
#ifndef ST_NOATIME
#define ST_NOATIME 0x04000000 /* Never update access times in fs */
#endif
#ifndef ST_AUTOMOUNTED
#define ST_AUTOMOUNTED 0x10000000 /* mounted by automountd(8) */
#endif
#ifndef ST_SYMPERM
#define ST_SYMPERM 0x20000000 /* recognize symlink permission */
#endif
#ifndef ST_NODEVMTIME
#define ST_NODEVMTIME 0x40000000 /* Never update mod times for devs */
#endif
#ifndef ST_SOFTDEP
#define ST_SOFTDEP 0x80000000 /* Use soft dependencies */
#endif
#ifndef ST_EXRDONLY
#define ST_EXRDONLY 0x00000080 /* exported read only */
#endif
#ifndef ST_EXPORTED
#define ST_EXPORTED 0x00000100 /* file system is exported */
#endif
#ifndef ST_DEFEXPORTED
#define ST_DEFEXPORTED 0x00000200 /* exported to the world */
#endif
#ifndef ST_EXPORTANON
#define ST_EXPORTANON 0x00000400 /* use anon uid mapping for everyone */
#endif
#ifndef ST_EXKERB
#define ST_EXKERB 0x00000800 /* exported with Kerberos uid mapping */
#endif
#ifndef ST_EXNORESPORT
#define ST_EXNORESPORT 0x08000000 /* don't enforce reserved ports (NFS) */
#endif
#ifndef ST_EXPUBLIC
#define ST_EXPUBLIC 0x10000000 /* public export (WebNFS) */
#endif
#ifndef ST_LOCAL
#define ST_LOCAL 0x00001000 /* filesystem is stored locally */
#endif
#ifndef ST_QUOTA
#define ST_QUOTA 0x00002000 /* quotas are enabled on filesystem */
#endif
#ifndef ST_ROOTFS
#define ST_ROOTFS 0x00004000 /* identifies the root filesystem */
#endif
#endif // NetBSD
#endif // AARU_FSTESTER_SETTER_SRC_BSD_VOLUME_H_

View File

@@ -181,7 +181,7 @@ void GetVolumeInfo(const char* path, size_t* clusterSize)
if(buf.f_flag)
{
#if defined(__NetBSD__)
// TODO: NetBsdPrintStatfsFlags(buf.f_flag);
NetBsdPrintStatvfsFlags(buf.f_flag);
#else
log_write("\tFlags: 0x%08lX\n", buf.f_flag);
#endif