Copy supported POSIX APIs to BeOS.

This commit is contained in:
2021-03-31 13:30:04 +01:00
parent d67d8e2dde
commit f3a5ab8745
18 changed files with 1368 additions and 0 deletions

View File

@@ -30,3 +30,4 @@ add_subdirectory(macos)
add_subdirectory(dos)
add_subdirectory(win32)
add_subdirectory(unix)
add_subdirectory(beos)

View File

@@ -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 <http://www.gnu.org/licenses/>.
#
# -----------------------------------------------------------------------------
# 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)

31
setter/src/beos/attr.c Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
Copyright (C) 2011-2021 Natalia Portillo
*****************************************************************************/
#include "../include/defs.h"
void FileAttributes(const char* path)
{
// Not supported
}

78
setter/src/beos/deleted.c Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
Copyright (C) 2011-2021 Natalia Portillo
*****************************************************************************/
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#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);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
Copyright (C) 2011-2021 Natalia Portillo
*****************************************************************************/
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#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);
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
Copyright (C) 2011-2021 Natalia Portillo
*****************************************************************************/
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#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);
}
}

80
setter/src/beos/files.c Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
Copyright (C) 2011-2021 Natalia Portillo
*****************************************************************************/
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#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);
}

327
setter/src/beos/frag.c Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
Copyright (C) 2011-2021 Natalia Portillo
*****************************************************************************/
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#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);
}

84
setter/src/beos/links.c Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
Copyright (C) 2011-2021 Natalia Portillo
*****************************************************************************/
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#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); }
}

30
setter/src/beos/os.c Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
Copyright (C) 2011-2021 Natalia Portillo
*****************************************************************************/
#include "../include/defs.h"
void GetOsInfo()
{
// TODO
}

86
setter/src/beos/perms.c Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
Copyright (C) 2011-2021 Natalia Portillo
*****************************************************************************/
#include <errno.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#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);
}
}

53
setter/src/beos/perms.h Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
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_

View File

@@ -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 <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
Copyright (C) 2011-2021 Natalia Portillo
*****************************************************************************/
#include "../include/defs.h"
void ResourceFork(const char* path)
{
// Not supported
}

133
setter/src/beos/sparse.c Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
Copyright (C) 2011-2021 Natalia Portillo
*****************************************************************************/
#include <errno.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#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);
}

98
setter/src/beos/time.c Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
Copyright (C) 2011-2021 Natalia Portillo
*****************************************************************************/
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <utime.h>
#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(&times, 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, &times);
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);
}
}

64
setter/src/beos/time.h Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
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_

35
setter/src/beos/volume.c Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
Copyright (C) 2011-2021 Natalia Portillo
*****************************************************************************/
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include "../include/defs.h"
void GetVolumeInfo(const char* path, size_t* clusterSize)
{
*clusterSize=0;
// TODO
}

30
setter/src/beos/xattr.c Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------------
Copyright (C) 2011-2021 Natalia Portillo
*****************************************************************************/
#include "../include/defs.h"
void ExtendedAttributes(const char* path)
{
// TODO
}