diff --git a/setter/src/bsd/CMakeLists.txt b/setter/src/bsd/CMakeLists.txt
index 9ba0b6d..7056c25 100644
--- a/setter/src/bsd/CMakeLists.txt
+++ b/setter/src/bsd/CMakeLists.txt
@@ -31,7 +31,7 @@ project(
DESCRIPTION "Filesystem test creator for BSD"
LANGUAGES C)
-set(PLATFORM_SOURCES bsd.h xattr.c xattr.h)
+set(PLATFORM_SOURCES bsd.h xattr.c xattr.h attr.c attr.h)
set(EXECUTABLE_NAME "fssetter-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
diff --git a/setter/src/bsd/attr.c b/setter/src/bsd/attr.c
new file mode 100644
index 0000000..29e5d13
--- /dev/null
+++ b/setter/src/bsd/attr.c
@@ -0,0 +1,107 @@
+/****************************************************************************
+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 .
+
+-----------------------------------------------------------------------------
+Copyright (C) 2011-2021 Natalia Portillo
+*****************************************************************************/
+
+#include
+#include
+#include
+
+#include "attr.h"
+
+#include "../log.h"
+
+void BsdFileAttributes(const char* path)
+{
+ int ret;
+ int fd;
+ FILE* h;
+ int rc;
+ int wRc;
+ int sRc;
+ int cRc;
+ int i;
+
+ ret = chdir(path);
+
+ if(ret)
+ {
+ log_write("Error %d changing to specified path.\n", errno);
+ return;
+ }
+
+ ret = mkdir("ATTRS", 0755);
+
+ if(ret)
+ {
+ log_write("Error %d creating working directory.\n", errno);
+ return;
+ }
+
+ ret = chdir("ATTRS");
+
+ if(ret)
+ {
+ log_write("Error %d changing to working directory.\n", errno);
+ return;
+ }
+
+ log_write("Creating files with different flags (attributes).\n");
+
+ for(i = 0; i < KNOWN_BSD_ATTRS; i++)
+ {
+ h = fopen(darwin_attrs[i].filename, "w+");
+ rc = 0;
+ wRc = 0;
+ sRc = 0;
+ cRc = 0;
+
+ if(h == NULL) rc = errno;
+ else
+ {
+ fd = fileno(h);
+ ret = fchflags(fd, darwin_attrs[i].attr);
+
+ if(ret)
+ {
+ sRc = errno;
+ unlink(darwin_attrs[i].filename);
+ }
+ else
+ {
+ ret = fprintf(h, "%s", darwin_attrs[i].contents);
+
+ if(ret < 1)
+ {
+ wRc = errno;
+ unlink(darwin_attrs[i].filename);
+ }
+ }
+
+ ret = fclose(h);
+
+ if(ret) cRc = errno;
+ }
+
+ log_write("\t%s, rc = %d, wRc = %d, sRc = %d, cRc = %d\n", darwin_attrs[i].description, rc, wRc, sRc, cRc);
+ }
+}
diff --git a/setter/src/bsd/attr.h b/setter/src/bsd/attr.h
new file mode 100644
index 0000000..188a5dd
--- /dev/null
+++ b/setter/src/bsd/attr.h
@@ -0,0 +1,210 @@
+/****************************************************************************
+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 .
+
+-----------------------------------------------------------------------------
+Copyright (C) 2011-2021 Natalia Portillo
+*****************************************************************************/
+
+#ifndef AARU_FSTESTER_SETTER_SRC_BSD_ATTR_H_
+#define AARU_FSTESTER_SETTER_SRC_BSD_ATTR_H_
+
+#include
+
+typedef struct
+{
+ char filename[16];
+ char contents[256];
+ char description[256];
+ unsigned int attr;
+} bsd_attr_tests_t;
+
+#if defined(__FreeBSD__)
+#define KNOWN_BSD_ATTRS 17
+#elif defined(__DragonFly__)
+#define KNOWN_BSD_ATTRS 15
+#elif defined(__NetBSD__)
+#define KNOWN_BSD_ATTRS 10
+#else
+#define KNOWN_BSD_ATTRS 7
+#endif
+
+#ifndef UF_NODUMP
+#define UF_NODUMP 0x00000001 /* Do not dump the file. */
+#endif
+
+#ifndef UF_IMMUTABLE
+#define UF_IMMUTABLE 0x00000002 /* The file may not be changed. */
+#endif
+
+#ifndef UF_APPEND
+#define UF_APPEND 0x00000004 /* The file may only be appended to. */
+#endif
+
+#ifndef UF_OPAQUE
+#define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */
+#endif
+
+#ifndef SF_ARCHIVED
+#define SF_ARCHIVED 0x00010000 /* file is archived */
+#endif
+
+#ifndef SF_IMMUTABLE
+#define SF_IMMUTABLE 0x00020000 /* The file may not be changed. */
+#endif
+
+#ifndef SF_APPEND
+#define SF_APPEND 0x00040000 /* The file may only be appended to. */
+#endif
+
+#if defined(__FreeBSD__) || defined(__DragonFly__)
+#ifndef UF_NOUNLINK
+#define UF_NOUNLINK 0x00000010 /* file may not be removed or renamed */
+#endif
+
+#ifndef SF_NOUNLINK
+#define SF_NOUNLINK 0x00100000 /* file may not be removed or renamed */
+#endif
+#endif // FreeBSD or DragonFly BSD
+
+#if defined(__FreeBSD__) || defined(__NetBSD__)
+#ifndef SF_SNAPSHOT
+#define SF_SNAPSHOT 0x00200000 /* snapshot inode */
+#endif
+#endif // FreeBSD or NetBSD
+
+#if defined(__NetBSD__)
+#ifndef SF_LOG
+#define SF_LOG 0x00400000 /* WAPBL log file inode */
+#endif
+
+#ifndef SF_SNAPINVAL
+#define SF_SNAPINVAL 0x00800000 /* snapshot is invalid */
+#endif
+#endif // NetBSD
+
+#if defined(__FreeBSD__)
+#ifndef UF_SYSTEM
+#define UF_SYSTEM 0x00000080 /* Windows system file bit */
+#endif
+
+#ifndef UF_SPARSE
+#define UF_SPARSE 0x00000100 /* sparse file */
+#endif
+
+#ifndef UF_OFFLINE
+#define UF_OFFLINE 0x00000200 /* file is offline */
+#endif
+
+#ifndef UF_REPARSE
+#define UF_REPARSE 0x00000400 /* Windows reparse point file bit */
+#endif
+
+#ifndef UF_ARCHIVE
+#define UF_ARCHIVE 0x00000800 /* file needs to be archived */
+#endif
+
+#ifndef UF_READONLY
+#define UF_READONLY 0x00001000 /* Windows readonly file bit */
+#endif
+
+#ifndef UF_HIDDEN
+#define UF_HIDDEN 0x00008000 /* file is hidden */
+#endif
+#endif // FreeBSD
+
+#if defined(__DragonFly__)
+#ifndef UF_NOHISTORY
+#define UF_NOHISTORY 0x00000040 /* do not retain history/snapshots */
+#endif
+
+#ifndef UF_CACHE
+#define UF_CACHE 0x00000080 /* enable data swapcache */
+#endif
+
+#ifndef UF_XLINK
+#define UF_XLINK 0x00000100 /* cross-link (hardlink) boundary */
+#endif
+
+#ifndef SF_NOHISTORY
+#define SF_NOHISTORY 0x00400000 /* do not retain history/snapshots */
+#endif
+
+#ifndef SF_NOCACHE
+#define SF_NOCACHE 0x00800000 /* disable data swapcache */
+#endif
+
+#ifndef SF_XLINK
+#define SF_XLINK 0x01000000 /* cross-link (hardlink) boundary */
+#endif
+#endif // DragonFly BSD
+
+static const bsd_attr_tests_t darwin_attrs[KNOWN_BSD_ATTRS] = {
+ {"NODUMP", "This file is now not dumpable", "File with no dump flag", UF_NODUMP},
+ {"IMMUTABLE", "This file is now immutable", "File with immutable flag", UF_IMMUTABLE},
+ {"APPEND", "This file is now append only", "File with append only flag", UF_APPEND},
+ {"ARCHIVED", "This file is now archived", "File with archived flag", SF_ARCHIVED},
+ {"SF_IMMUTABLE",
+ "This file is now immutable, and only the super-user change change that",
+ "File with super-usr immutable flag",
+ SF_IMMUTABLE},
+ {"SF_APPEND",
+ "This file is now append only, and only the super-user change change that",
+ "File with super-user append only flag",
+ SF_APPEND},
+ {"OPAQUE", "This directory is opaque when viewed through a union stack", "File with opaque flag", UF_OPAQUE},
+
+#if defined(__FreeBSD__) || defined(__DragonFly__)
+ {"NOUNLINK", "This file may not be removed or renamed", "File with no unlink flag", UF_NOUNLINK},
+ {"SF_NOUNLINK", "This file may not be removed or renamed", "File with super-user no unlink flag", SF_NOUNLINK},
+#endif
+
+#if defined(__FreeBSD__) || defined(__NetBSD__)
+ {"SF_SNAPSHOT", "This file is a snapshot", "File with super-user snapshot flag", SF_SNAPSHOT},
+#endif
+
+#if defined(__NetBSD__)
+ {"SF_LOG", "This file is a WAPBL log file", "File with super-user log flag", SF_LOG},
+ {"SF_SNAPINVAL", "This file is an invalid snapshot", "File with super-user invalid snapshot flag", SF_SNAPINVAL},
+#endif
+
+#if defined(__FreeBSD__)
+ {"SYSTEM", "This file is a system file for Windows", "File with system flag", UF_SYSTEM},
+ {"SPARSE", "This file is sparse", "File with sparse flag", UF_SPARSE},
+ {"OFFLINE", "This file is available offline for Windows", "File with offline flag", UF_OFFLINE},
+ {"REPARSE", "This file is a Windows reparse point", "File with reparse flag", UF_REPARSE},
+ {"ARCHIVE", "This file is must be archived", "File with archive flag", UF_ARCHIVE},
+ {"READONLY", "This file is read-only for Windows", "File with read-only flag", UF_READONLY},
+ {"HIDDEN", "This file is hidden", "File with hidden flag", UF_HIDDEN},
+#endif
+
+#if defined(__DragonFly__)
+ {"NOHISTORY", "This file will not retain history/snapshots", "File with no history flag", UF_NOHISTORY},
+ {"CACHE", "This file has data swapcache enabled", "File with cache flag", UF_CACHE},
+ {"XLINK", "This file is a cross link boundary", "File with crosslink flag", UF_XLINK},
+ {"SF_NOHISTORY",
+ "This file will not retain history/snapshots",
+ "File with super-user no history flag",
+ SF_NOHISTORY},
+ {"SF_NOCACHE", "This file must not have data swapcache enabled", "File with super-user no cache flag", SF_NOCACHE},
+ {"SF_XLINK", "This file is a cross link boundary", "File with super-user crosslink flag", SF_XLINK},
+#endif
+};
+
+#endif // AARU_FSTESTER_SETTER_SRC_BSD_ATTR_H_
diff --git a/setter/src/bsd/bsd.h b/setter/src/bsd/bsd.h
index 9e35a54..ac21639 100644
--- a/setter/src/bsd/bsd.h
+++ b/setter/src/bsd/bsd.h
@@ -26,5 +26,6 @@ Copyright (C) 2011-2021 Natalia Portillo
#define SETTER_SRC_BSD_H_
void BsdExtendedAttributes(const char* path);
+void BsdFileAttributes(const char* path);
#endif // SETTER_SRC_BSD_H_
diff --git a/setter/src/unix/attr.c b/setter/src/unix/attr.c
index f31a2d2..5cf68c8 100644
--- a/setter/src/unix/attr.c
+++ b/setter/src/unix/attr.c
@@ -28,6 +28,8 @@ 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 FileAttributes(const char* path)
@@ -36,5 +38,7 @@ void FileAttributes(const char* path)
LinuxFileAttributes(path);
#elif defined(__APPLE__) && defined(__MACH__)
DarwinFileAttributes(path);
+#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
+ BsdFileAttributes(path);
#endif
}