From f3a5ab87457ffa70a2f044b40dc3200fa0287cb7 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Wed, 31 Mar 2021 13:30:04 +0100 Subject: [PATCH] Copy supported POSIX APIs to BeOS. --- setter/src/CMakeLists.txt | 1 + setter/src/beos/CMakeLists.txt | 40 ++++ setter/src/beos/attr.c | 31 ++++ setter/src/beos/deleted.c | 78 ++++++++ setter/src/beos/dirdepth.c | 81 ++++++++ setter/src/beos/filename.c | 87 +++++++++ setter/src/beos/files.c | 80 ++++++++ setter/src/beos/frag.c | 327 +++++++++++++++++++++++++++++++++ setter/src/beos/links.c | 84 +++++++++ setter/src/beos/os.c | 30 +++ setter/src/beos/perms.c | 86 +++++++++ setter/src/beos/perms.h | 53 ++++++ setter/src/beos/rsrcfork.c | 30 +++ setter/src/beos/sparse.c | 133 ++++++++++++++ setter/src/beos/time.c | 98 ++++++++++ setter/src/beos/time.h | 64 +++++++ setter/src/beos/volume.c | 35 ++++ setter/src/beos/xattr.c | 30 +++ 18 files changed, 1368 insertions(+) create mode 100644 setter/src/beos/CMakeLists.txt create mode 100644 setter/src/beos/attr.c create mode 100644 setter/src/beos/deleted.c create mode 100644 setter/src/beos/dirdepth.c create mode 100644 setter/src/beos/filename.c create mode 100644 setter/src/beos/files.c create mode 100644 setter/src/beos/frag.c create mode 100644 setter/src/beos/links.c create mode 100644 setter/src/beos/os.c create mode 100644 setter/src/beos/perms.c create mode 100644 setter/src/beos/perms.h create mode 100644 setter/src/beos/rsrcfork.c create mode 100644 setter/src/beos/sparse.c create mode 100644 setter/src/beos/time.c create mode 100644 setter/src/beos/time.h create mode 100644 setter/src/beos/volume.c create mode 100644 setter/src/beos/xattr.c diff --git a/setter/src/CMakeLists.txt b/setter/src/CMakeLists.txt index 6ec8c1e..f3d0a9f 100644 --- a/setter/src/CMakeLists.txt +++ b/setter/src/CMakeLists.txt @@ -30,3 +30,4 @@ add_subdirectory(macos) add_subdirectory(dos) add_subdirectory(win32) add_subdirectory(unix) +add_subdirectory(beos) diff --git a/setter/src/beos/CMakeLists.txt b/setter/src/beos/CMakeLists.txt new file mode 100644 index 0000000..16424c0 --- /dev/null +++ b/setter/src/beos/CMakeLists.txt @@ -0,0 +1,40 @@ +# /**************************************************************************** +# 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 +# *****************************************************************************/ + +if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "BeOS" AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Haiku") + return() +endif() + +project( + fssetter-beos + DESCRIPTION "Filesystem test creator for BeOS and Haiku" + LANGUAGES C) + +set(PLATFORM_SOURCES attr.c deleted.c dirdepth.c filename.c files.c frag.c links.c os.c perms.c perms.h rsrcfork.c sparse.c time.c time.h volume.c xattr.c) + +set(EXECUTABLE_NAME "fssetter-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") + +add_executable(${EXECUTABLE_NAME} ${PLATFORM_SOURCES}) + +target_link_libraries(${EXECUTABLE_NAME} core) \ No newline at end of file diff --git a/setter/src/beos/attr.c b/setter/src/beos/attr.c new file mode 100644 index 0000000..18fa20f --- /dev/null +++ b/setter/src/beos/attr.c @@ -0,0 +1,31 @@ +/**************************************************************************** +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/defs.h" + + +void FileAttributes(const char* path) +{ + // Not supported +} diff --git a/setter/src/beos/deleted.c b/setter/src/beos/deleted.c new file mode 100644 index 0000000..eff6bed --- /dev/null +++ b/setter/src/beos/deleted.c @@ -0,0 +1,78 @@ +/**************************************************************************** +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 +#include +#include + +#include "../include/defs.h" +#include "../log.h" + +void DeleteFiles(const char* path) +{ + char filename[9]; + long pos; + FILE* h; + int ret; + + ret = chdir(path); + + if(ret) + { + log_write("Error %d changing to specified path.\n", errno); + return; + } + + ret = mkdir("DELETED", 0755); + + if(ret) + { + log_write("Error %d creating working directory.\n", errno); + return; + } + + ret = chdir("DELETED"); + + if(ret) + { + log_write("Error %d changing to working directory.\n", errno); + return; + } + + log_write("Creating and deleting files.\n"); + + for(pos = 0; pos < 64; pos++) + { + memset(filename, 0, 9); + sprintf(filename, "%lX", pos); + h = fopen(filename, "w+"); + if(h == NULL) { break; } + + fclose(h); + unlink(filename); + } +} diff --git a/setter/src/beos/dirdepth.c b/setter/src/beos/dirdepth.c new file mode 100644 index 0000000..4f48a22 --- /dev/null +++ b/setter/src/beos/dirdepth.c @@ -0,0 +1,81 @@ +/**************************************************************************** +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 +#include + +#include "../include/defs.h" +#include "../log.h" + +void DirectoryDepth(const char* path) +{ + int ret; + char filename[9]; + long pos = 2; + + ret = chdir(path); + + if(ret) + { + log_write("Error %d changing to specified path.\n", errno); + return; + } + + ret = mkdir("DEPTH", 0755); + + if(ret) + { + log_write("Error %d creating working directory.\n", errno); + return; + } + + ret = chdir("DEPTH"); + + if(ret) + { + log_write("Error %d changing to working directory.\n", errno); + return; + } + + log_write("Creating deepest directory tree.\n"); + + while(!ret) + { + memset(filename, 0, 9); + sprintf(filename, "%08ld", pos); + ret = mkdir(filename, 0755); + + if(!ret) ret = chdir(filename); + + pos++; + + // This can continue until the disk fills, the kernel crashes, or some other nasty success + if(pos >= 1000) break; + } + + log_write("\tCreated %ld levels of directory hierarchy\n", pos); +} diff --git a/setter/src/beos/filename.c b/setter/src/beos/filename.c new file mode 100644 index 0000000..d4b9985 --- /dev/null +++ b/setter/src/beos/filename.c @@ -0,0 +1,87 @@ +/**************************************************************************** +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 +#include + +#include "../include/consts.h" +#include "../include/defs.h" +#include "../log.h" + +void Filenames(const char* path) +{ + int ret; + FILE* h; + int rc, wRc, cRc; + int pos; + + ret = chdir(path); + + if(ret) + { + log_write("Error %d changing to specified path.\n", errno); + return; + } + + ret = mkdir("FILENAME", 0755); + + if(ret) + { + log_write("Error %d creating working directory.\n", errno); + return; + } + + ret = chdir("FILENAME"); + + if(ret) + { + log_write("Error %d changing to working directory.\n", errno); + return; + } + + log_write("Creating files with different filenames.\n"); + + for(pos = 0; filenames[pos]; pos++) + { + h = fopen(filenames[pos], "w+"); + rc = 0; + wRc = 0; + cRc = 0; + + if(!h) { rc = errno; } + else + { + ret = fprintf(h, FILENAME_FORMAT, filenames[pos]); + if(ret < 0) { wRc = errno; } + + ret = fclose(h); + if(ret) { cRc = errno; } + } + + log_write("\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", filenames[pos], rc, wRc, cRc); + } +} diff --git a/setter/src/beos/files.c b/setter/src/beos/files.c new file mode 100644 index 0000000..7dd3e40 --- /dev/null +++ b/setter/src/beos/files.c @@ -0,0 +1,80 @@ +/**************************************************************************** +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 +#include +#include + +#include "../include/defs.h" +#include "../log.h" + +void MillionFiles(const char* path) +{ + char filename[9]; + long pos = 0; + FILE* h; + int ret; + + ret = chdir(path); + + if(ret) + { + log_write("Error %d changing to specified path.\n", errno); + return; + } + + ret = mkdir("MILLION", 0755); + + if(ret) + { + log_write("Error %d creating working directory.\n", errno); + return; + } + + ret = chdir("MILLION"); + + if(ret) + { + log_write("Error %d changing to working directory.\n", errno); + return; + } + + log_write("Creating lots of files.\n"); + + for(pos = 0; pos < 1000; pos++) + { + memset(filename, 0, 9); + sprintf(filename, "%08ld", pos); + + h = fopen(filename, "w+"); + if(h == NULL) { break; } + + fclose(h); + } + + log_write("\tCreated %ld files\n", pos); +} diff --git a/setter/src/beos/frag.c b/setter/src/beos/frag.c new file mode 100644 index 0000000..a7b9e3f --- /dev/null +++ b/setter/src/beos/frag.c @@ -0,0 +1,327 @@ +/**************************************************************************** +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 +#include +#include +#include + +#include "../include/consts.h" +#include "../include/defs.h" +#include "../log.h" + +void Fragmentation(const char* path, size_t clusterSize) +{ + size_t halfCluster = clusterSize / 2; + size_t quarterCluster = clusterSize / 4; + size_t twoCluster = clusterSize * 2; + size_t threeQuartersCluster = halfCluster + quarterCluster; + size_t twoAndThreeQuartCluster = threeQuartersCluster + twoCluster; + unsigned char* buffer; + long i; + int ret; + FILE* h; + int rc, wRc, cRc; + + ret = chdir(path); + + if(ret) + { + log_write("Error %d changing to specified path.\n", errno); + return; + } + + ret = mkdir("FRAGS", 0755); + + if(ret) + { + log_write("Error %d creating working directory.\n", errno); + return; + } + + ret = chdir("FRAGS"); + + if(ret) + { + log_write("Error %d changing to working directory.\n", errno); + return; + } + + log_write("Writing fragmented files:\n"); + + h = fopen("HALFCLST", "w+"); + rc = 0; + wRc = 0; + cRc = 0; + if(h == NULL) { rc = errno; } + else + { + buffer = malloc(halfCluster); + memset(buffer, 0, halfCluster); + + for(i = 0; i < halfCluster; i++) buffer[i] = clauniaBytes[i % CLAUNIA_SIZE]; + + ret = fwrite(buffer, halfCluster, 1, h); + if(ret < 0) { wRc = errno; } + + ret = fclose(h); + if(ret) { cRc = errno; } + free(buffer); + } + + log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "HALFCLST", halfCluster, rc, wRc, cRc); + + h = fopen("QUARCLST", "w+"); + rc = 0; + wRc = 0; + cRc = 0; + if(h == NULL) { rc = errno; } + else + { + buffer = malloc(quarterCluster); + memset(buffer, 0, quarterCluster); + + for(i = 0; i < quarterCluster; i++) buffer[i] = clauniaBytes[i % CLAUNIA_SIZE]; + + ret = fwrite(buffer, quarterCluster, 1, h); + if(ret < 0) { wRc = errno; } + + ret = fclose(h); + if(ret) { cRc = errno; } + free(buffer); + } + + log_write( + "\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "QUARCLST", quarterCluster, rc, wRc, cRc); + + h = fopen("TWOCLST", "w+"); + rc = 0; + wRc = 0; + cRc = 0; + if(h == NULL) { rc = errno; } + else + { + buffer = malloc(twoCluster); + memset(buffer, 0, twoCluster); + + for(i = 0; i < twoCluster; i++) buffer[i] = clauniaBytes[i % CLAUNIA_SIZE]; + + ret = fwrite(buffer, twoCluster, 1, h); + if(ret < 0) { wRc = errno; } + + ret = fclose(h); + if(ret) { cRc = errno; } + free(buffer); + } + + log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "TWOCLST", twoCluster, rc, wRc, cRc); + + h = fopen("TRQTCLST", "w+"); + rc = 0; + wRc = 0; + cRc = 0; + if(h == NULL) { rc = errno; } + else + { + buffer = malloc(threeQuartersCluster); + memset(buffer, 0, threeQuartersCluster); + + for(i = 0; i < threeQuartersCluster; i++) buffer[i] = clauniaBytes[i % CLAUNIA_SIZE]; + + ret = fwrite(buffer, threeQuartersCluster, 1, h); + if(ret < 0) { wRc = errno; } + + ret = fclose(h); + if(ret) { cRc = errno; } + free(buffer); + } + + log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", + "TRQTCLST", + threeQuartersCluster, + rc, + wRc, + cRc); + + h = fopen("TWTQCLST", "w+"); + rc = 0; + wRc = 0; + cRc = 0; + if(h == NULL) { rc = errno; } + else + { + buffer = malloc(twoAndThreeQuartCluster); + memset(buffer, 0, twoAndThreeQuartCluster); + + for(i = 0; i < twoAndThreeQuartCluster; i++) buffer[i] = clauniaBytes[i % CLAUNIA_SIZE]; + + ret = fwrite(buffer, twoAndThreeQuartCluster, 1, h); + if(ret < 0) { wRc = errno; } + + ret = fclose(h); + if(ret) { cRc = errno; } + free(buffer); + } + + log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", + "TWTQCLST", + twoAndThreeQuartCluster, + rc, + wRc, + cRc); + + h = fopen("TWO1", "w+"); + rc = 0; + wRc = 0; + cRc = 0; + if(h == NULL) { rc = errno; } + else + { + buffer = malloc(twoCluster); + memset(buffer, 0, twoCluster); + + for(i = 0; i < twoCluster; i++) buffer[i] = clauniaBytes[i % CLAUNIA_SIZE]; + + ret = fwrite(buffer, twoCluster, 1, h); + if(ret < 0) { wRc = errno; } + + ret = fclose(h); + if(ret) { cRc = errno; } + free(buffer); + } + + log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "TWO1", twoCluster, rc, wRc, cRc); + + h = fopen("TWO2", "w+"); + rc = 0; + wRc = 0; + cRc = 0; + if(h == NULL) { rc = errno; } + else + { + buffer = malloc(twoCluster); + memset(buffer, 0, twoCluster); + + for(i = 0; i < twoCluster; i++) buffer[i] = clauniaBytes[i % CLAUNIA_SIZE]; + + ret = fwrite(buffer, twoCluster, 1, h); + if(ret < 0) { wRc = errno; } + + ret = fclose(h); + if(ret) { cRc = errno; } + free(buffer); + } + + log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "TWO2", twoCluster, rc, wRc, cRc); + + h = fopen("TWO3", "w+"); + rc = 0; + wRc = 0; + cRc = 0; + if(h == NULL) { rc = errno; } + else + { + buffer = malloc(twoCluster); + memset(buffer, 0, twoCluster); + + for(i = 0; i < twoCluster; i++) buffer[i] = clauniaBytes[i % CLAUNIA_SIZE]; + + ret = fwrite(buffer, twoCluster, 1, h); + if(ret < 0) { wRc = errno; } + + ret = fclose(h); + if(ret) { cRc = errno; } + free(buffer); + } + + log_write("\tDeleting \"TWO2\".\n"); + ret = unlink("TWO2"); + if(!ret) { rc = errno; } + + log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "TWO3", twoCluster, rc, wRc, cRc); + + h = fopen("FRAGTHRQ", "w+"); + rc = 0; + wRc = 0; + cRc = 0; + if(h == NULL) { rc = errno; } + else + { + buffer = malloc(threeQuartersCluster); + memset(buffer, 0, threeQuartersCluster); + + for(i = 0; i < threeQuartersCluster; i++) buffer[i] = clauniaBytes[i % CLAUNIA_SIZE]; + + ret = fwrite(buffer, threeQuartersCluster, 1, h); + if(ret < 0) { wRc = errno; } + + ret = fclose(h); + if(ret) { cRc = errno; } + free(buffer); + } + + log_write("\tDeleting \"TWO1\".\n"); + ret = unlink("TWO1"); + if(!ret) { rc = errno; } + log_write("\tDeleting \"TWO3\".\n"); + ret = unlink("TWO3"); + if(!ret) { rc = errno; } + + log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", + "FRAGTHRQ", + threeQuartersCluster, + rc, + wRc, + cRc); + + h = fopen("FRAGSIXQ", "w+"); + rc = 0; + wRc = 0; + cRc = 0; + if(h == NULL) { rc = errno; } + else + { + buffer = malloc(twoAndThreeQuartCluster); + memset(buffer, 0, twoAndThreeQuartCluster); + + for(i = 0; i < twoAndThreeQuartCluster; i++) buffer[i] = clauniaBytes[i % CLAUNIA_SIZE]; + + ret = fwrite(buffer, twoAndThreeQuartCluster, 1, h); + if(ret < 0) { wRc = errno; } + + ret = fclose(h); + if(ret) { cRc = errno; } + free(buffer); + } + + log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", + "FRAGSIXQ", + twoAndThreeQuartCluster, + rc, + wRc, + cRc); +} diff --git a/setter/src/beos/links.c b/setter/src/beos/links.c new file mode 100644 index 0000000..c06c29d --- /dev/null +++ b/setter/src/beos/links.c @@ -0,0 +1,84 @@ +/**************************************************************************** +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 +#include + +#include "../include/defs.h" +#include "../log.h" + +void Links(const char* path) +{ + FILE* h; + int ret; + + ret = chdir(path); + + if(ret) + { + log_write("Error %d changing to specified path.\n", errno); + return; + } + + ret = mkdir("LINKS", 0755); + + if(ret) + { + log_write("Error %d creating working directory.\n", errno); + return; + } + + ret = chdir("LINKS"); + + if(ret) + { + log_write("Error %d changing to working directory.\n", errno); + return; + } + + log_write("Creating links.\n"); + + h = fopen("TARGET", "w+"); + + if(h == NULL) + { + log_write("Error %d creating target file.\n", errno); + return; + } + + fprintf(h, "This is the target for the links.\n"); + + fclose(h); + + ret = link("TARGET", "HARD"); + + if(ret) { log_write("Error %d creating hard link.\n", errno); } + + ret = symlink("TARGET", "SYMBOLIC"); + + if(ret) { log_write("Error %d creating symbolic link.\n", errno); } +} diff --git a/setter/src/beos/os.c b/setter/src/beos/os.c new file mode 100644 index 0000000..f2bc711 --- /dev/null +++ b/setter/src/beos/os.c @@ -0,0 +1,30 @@ +/**************************************************************************** +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/defs.h" + +void GetOsInfo() +{ + // TODO +} diff --git a/setter/src/beos/perms.c b/setter/src/beos/perms.c new file mode 100644 index 0000000..7cbaf0f --- /dev/null +++ b/setter/src/beos/perms.c @@ -0,0 +1,86 @@ +/**************************************************************************** +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 + +#include "perms.h" + +#include "../include/defs.h" +#include "../log.h" + +void FilePermissions(const char* path) +{ + int ret; + FILE* file; + int rc; + int cRc; + int i; + + ret = chdir(path); + + if(ret) + { + log_write("Error %d changing to specified path.\n", errno); + return; + } + + ret = mkdir("PERMS", 0755); + + if(ret) + { + log_write("Error %d creating working directory.\n", errno); + return; + } + + ret = chdir("PERMS"); + + if(ret) + { + log_write("Error %d changing to working directory.\n", errno); + return; + } + + log_write("Creating attributes files.\n"); + + for(i = 0; i < KNOWN_BEOS_PERMS; i++) + { + file = fopen(beos_perms[i].filename, "w+"); + rc = 0; + cRc = 0; + + if(!file) rc = errno; + else + { + fprintf(file, "%s.\n", beos_perms[i].description); + fclose(file); + cRc = chmod(beos_perms[i].filename, beos_perms[i].mode); + } + + log_write( + "\t%s: name = \"%s\", rc = %d, cRc = %d\n", beos_perms[i].description, beos_perms[i].filename, rc, cRc); + } +} diff --git a/setter/src/beos/perms.h b/setter/src/beos/perms.h new file mode 100644 index 0000000..3df231d --- /dev/null +++ b/setter/src/beos/perms.h @@ -0,0 +1,53 @@ +/**************************************************************************** +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_BEOS_PERMS_H_ +#define AARU_FSTESTER_SETTER_SRC_BEOS_PERMS_H_ + +typedef struct +{ + char filename[256]; + char description[256]; + mode_t mode; +} beos_perms_tests_t; + +#define KNOWN_BEOS_PERMS 14 + +static const beos_perms_tests_t beos_perms[KNOWN_BEOS_PERMS] = { + {"NONE", "File with no permissions", 0}, + {"04000", "File with set-user-ID", 04000}, + {"02000", "File with set-group-ID", 02000}, + {"01000", "File with sticky bit", 01000}, + {"00400", "File with read by owner", 00400}, + {"00200", "File with write by owner", 00200}, + {"00100", "File with execute by owner", 00100}, + {"00040", "File with read by group", 00040}, + {"00020", "File with write by group", 00020}, + {"00010", "File with execute by group", 00010}, + {"00004", "File with read by others", 00004}, + {"00002", "File with write by others", 00002}, + {"00001", "File with execute by others", 00001}, +}; + +#endif // AARU_FSTESTER_SETTER_SRC_BEOS_PERMS_H_ diff --git a/setter/src/beos/rsrcfork.c b/setter/src/beos/rsrcfork.c new file mode 100644 index 0000000..bde6461 --- /dev/null +++ b/setter/src/beos/rsrcfork.c @@ -0,0 +1,30 @@ +/**************************************************************************** +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/defs.h" + +void ResourceFork(const char* path) +{ + // Not supported +} diff --git a/setter/src/beos/sparse.c b/setter/src/beos/sparse.c new file mode 100644 index 0000000..fa7f43f --- /dev/null +++ b/setter/src/beos/sparse.c @@ -0,0 +1,133 @@ +/**************************************************************************** +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 + +#include "../include/consts.h" +#include "../include/defs.h" +#include "../log.h" + +void Sparse(const char* path) +{ + int ret; + int rc, wRc, cRc; + FILE* h; + int i; + + ret = chdir(path); + + if(ret) + { + log_write("Error %d changing to specified path.\n", errno); + return; + } + + ret = mkdir("SPARSE", 0755); + + if(ret) + { + log_write("Error %d creating working directory.\n", errno); + return; + } + + ret = chdir("SPARSE"); + + if(ret) + { + log_write("Error %d changing to working directory.\n", errno); + return; + } + + log_write("Creating sparse files.\n"); + + h = fopen("SMALL", "w+"); + rc = 0; + wRc = 0; + cRc = 0; + if(h == NULL) { rc = errno; } + else + { + for(i = 0; i < 4096; i += CLAUNIA_SIZE) + { + ret = fwrite(clauniaBytes, CLAUNIA_SIZE, 1, h); + if(ret < 0) + { + wRc = errno; + break; + } + } + + fseek(h, 8192, SEEK_CUR); + + for(i = 4096 + 8192; i < 4096 * 4; i += CLAUNIA_SIZE) + { + ret = fwrite(clauniaBytes, CLAUNIA_SIZE, 1, h); + if(ret < 0) + { + wRc = errno; + break; + } + } + + ret = fclose(h); + if(ret) { cRc = errno; } + } + + log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "SMALL", 4096 * 4, rc, wRc, cRc); + + h = fopen("BIG", "w+"); + rc = 0; + wRc = 0; + cRc = 0; + if(h == NULL) { rc = errno; } + else + { + for(i = 0; i < 4096 * 8; i += CLAUNIA_SIZE) + { + ret = fwrite(clauniaBytes, CLAUNIA_SIZE, 1, h); + if(ret < 0) + { + wRc = errno; + break; + } + } + + fseek(h, 81920, SEEK_CUR); + + for(i = 32768 + 81920; i < 4096 * 30; i += CLAUNIA_SIZE) + { + ret = fwrite(clauniaBytes, CLAUNIA_SIZE, 1, h); + if(ret < 0) + { + wRc = errno; + break; + } + } + } + + log_write("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "BIG", 4096 * 30, rc, wRc, cRc); +} diff --git a/setter/src/beos/time.c b/setter/src/beos/time.c new file mode 100644 index 0000000..b8d4ba1 --- /dev/null +++ b/setter/src/beos/time.c @@ -0,0 +1,98 @@ +/**************************************************************************** +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 +#include +#include +#include + +#include "time.h" + +#include "../include/defs.h" +#include "../log.h" + +void Timestamps(const char* path) +{ + int ret; + FILE* h; + int rc, wRc, cRc, tRc; + struct utimbuf times; + int i; + + ret = chdir(path); + + if(ret) + { + log_write("Error %d changing to specified path.\n", errno); + return; + } + + ret = mkdir("TIMES", 0755); + + if(ret) + { + log_write("Error %d creating working directory.\n", errno); + return; + } + + ret = chdir("TIMES"); + + if(ret) + { + log_write("Error %d changing to working directory.\n", errno); + return; + } + + log_write("Creating timestamped files.\n"); + + for(i = 0; i < KNOWN_BEOS_TIMES; i++) + { + memset(×, 0, sizeof(struct utimbuf)); + h = fopen(beos_times[i].filename, "w+"); + rc = 0; + wRc = 0; + cRc = 0; + tRc = 0; + if(h == NULL) { rc = errno; } + else + { + times.actime = beos_times[i].access; + times.modtime = beos_times[i].modification; + + ret = fprintf(h, DATETIME_FORMAT, beos_times[i].message, beos_times[i].type); + if(ret < 0) { wRc = errno; } + + ret = fclose(h); + if(ret) { cRc = errno; } + + ret = utime(beos_times[i].filename, ×); + if(ret) { tRc = errno; } + } + log_write( + "\tFile name = \"%s\", rc = %d, wRc = %d, cRc = %d, tRc = %d\n", beos_times[i].filename, rc, wRc, cRc, tRc); + } +} diff --git a/setter/src/beos/time.h b/setter/src/beos/time.h new file mode 100644 index 0000000..154b7f2 --- /dev/null +++ b/setter/src/beos/time.h @@ -0,0 +1,64 @@ +/**************************************************************************** +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_BEOS_TIME_H_ +#define AARU_FSTESTER_SETTER_SRC_BEOS_TIME_H_ + +#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" +#define MINDATETIME "1970/01/01 00:00:00" +#define Y2KDATETIME "2000/01/01 00:00:00" +#define Y1KDATETIME "1999/12/31 23:59:59" +#define LESSTIMESTAMP 0xFFFFFFFF +#define MAXTIMESTAMP 0x7FFFFFFF +#define MINTIMESTAMP 0x00000000 +#define Y2KTIMESTAMP 0x386D4380 +#define Y1KTIMESTAMP 0x386D437F + +typedef struct +{ + char* filename; + time_t access; + time_t modification; + char type[13]; + char message[32]; +} beos_time_tests_t; + +#define KNOWN_BEOS_TIMES 10 + +static const beos_time_tests_t beos_times[KNOWN_BEOS_TIMES] = { + "MAXATIME", MAXTIMESTAMP, 0, "access", MAXDATETIME, + "MAXMTIME", 0, MAXTIMESTAMP, "modification", MAXDATETIME, + "MINATIME", MINTIMESTAMP, 0, "access", MINDATETIME, + "MINMTIME", 0, MINTIMESTAMP, "modification", MINDATETIME, + "Y1KATIME", Y1KTIMESTAMP, 0, "access", Y1KDATETIME, + "Y1KMTIME", 0, Y1KTIMESTAMP, "modification", Y1KDATETIME, + "Y2KATIME", Y2KTIMESTAMP, 0, "access", Y2KDATETIME, + "Y2KMTIME", 0, Y2KTIMESTAMP, "modification", Y2KDATETIME, + "LESSATIME", LESSTIMESTAMP, 0, "access", LESSDATETIME, + "LESSMTIME", 0, LESSTIMESTAMP, "modification", LESSDATETIME +}; + +#endif // AARU_FSTESTER_SETTER_SRC_BEOS_TIME_H_ diff --git a/setter/src/beos/volume.c b/setter/src/beos/volume.c new file mode 100644 index 0000000..00749e3 --- /dev/null +++ b/setter/src/beos/volume.c @@ -0,0 +1,35 @@ +/**************************************************************************** +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 "../include/defs.h" + +void GetVolumeInfo(const char* path, size_t* clusterSize) +{ + *clusterSize=0; + // TODO +} diff --git a/setter/src/beos/xattr.c b/setter/src/beos/xattr.c new file mode 100644 index 0000000..180852b --- /dev/null +++ b/setter/src/beos/xattr.c @@ -0,0 +1,30 @@ +/**************************************************************************** +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/defs.h" + +void ExtendedAttributes(const char* path) +{ + // TODO +}