Add support for printing Darwin's statfs(2) flags.

This commit is contained in:
2021-03-15 04:01:36 +00:00
parent 5eba1d374b
commit 962ffbcfbf
10 changed files with 508 additions and 116 deletions

View File

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

View File

@@ -25,9 +25,12 @@ Copyright (C) 2011-2021 Natalia Portillo
#ifndef AARU_FSTESTER_SETTER_LINUX_H
#define AARU_FSTESTER_SETTER_LINUX_H
#include <sys/types.h>
void LinuxExtendedAttributes(const char* path);
void LinuxSparse(const char* path);
void LinuxFileAttributes(const char* path);
void LinuxPrintStatfsFlags(__fsword_t flags);
static unsigned char CommentsEA[72] = {
0x45, 0x00, 0x00, 0x00, 0x00, 0x09, 0x33, 0x00, 0x2E, 0x43, 0x4F, 0x4D, 0x4D, 0x45, 0x4E, 0x54, 0x53, 0x00,

102
setter/src/linux/volume.c Normal file
View File

@@ -0,0 +1,102 @@
/****************************************************************************
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
*****************************************************************************/
#include <sys/statfs.h>
#include "volume.h"
#include "../log.h"
void LinuxPrintStatfsFlags(__fsword_t 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_MANDLOCK)
{
log_write("\t\tVolume allows mandatory locks.\n");
flags -= ST_MANDLOCK;
}
if(flags & ST_WRITE)
{
log_write("\t\tVolume writes on file/directory/symlink.\n");
flags -= ST_WRITE;
}
if(flags & ST_APPEND)
{
log_write("\t\tVolume appends.\n");
flags -= ST_APPEND;
}
if(flags & ST_IMMUTABLE)
{
log_write("\t\tVolume is immutable.\n");
flags -= ST_IMMUTABLE;
}
if(flags & ST_NOATIME)
{
log_write("\t\tVolume does not update access times.\n");
flags -= ST_NOATIME;
}
if(flags & ST_NODIRATIME)
{
log_write("\t\tVolume does not update directory access times.\n");
flags -= ST_NODIRATIME;
}
if(flags) { log_write("\t\tRemaining flags: 0x%08lX\n", flags); }
}

72
setter/src/linux/volume.h Normal file
View File

@@ -0,0 +1,72 @@
/****************************************************************************
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_LINUX_VOLUME_H_
#define AARU_FSTESTER_SETTER_SRC_LINUX_VOLUME_H_
#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
#endif // AARU_FSTESTER_SETTER_SRC_LINUX_VOLUME_H_