diff --git a/setter/src/dos/CMakeLists.txt b/setter/src/dos/CMakeLists.txt index 5ea32fe..a03a4f2 100644 --- a/setter/src/dos/CMakeLists.txt +++ b/setter/src/dos/CMakeLists.txt @@ -6,7 +6,7 @@ project(fssetter-dos DESCRIPTION "Filesystem test creator for DOS" LANGUAGES C) -set(PLATFORM_SOURCES attr.c deleted.c dirdepth.c filename.c files.c frag.c links.c os.c perms.c rsrcfork.c sparse.c time.c volume.c xattr.c dos.c) +set(PLATFORM_SOURCES attr.c deleted.c dirdepth.c filename.c files.c frag.c links.c os.c perms.c rsrcfork.c sparse.c time.c volume.c xattr.c dos.c attr.h) set(EXECUTABLE_NAME "fssetter") diff --git a/setter/src/dos/attr.c b/setter/src/dos/attr.c index 4a0c00d..f99d2da 100644 --- a/setter/src/dos/attr.c +++ b/setter/src/dos/attr.c @@ -40,7 +40,7 @@ Copyright (C) 2011-2021 Natalia Portillo #endif #include "../include/defs.h" -#include "../include/dosos2.h" +#include "attr.h" #include "dos.h" void FileAttributes(const char* path) @@ -48,6 +48,7 @@ void FileAttributes(const char* path) char driveNo = path[0] - '@'; unsigned total, actionTaken; int rc, wRc, cRc, handle; + int i; if(driveNo > 32) driveNo -= 32; @@ -66,243 +67,19 @@ void FileAttributes(const char* path) printf("Creating attributes files.\n"); - rc = _dos_creat("NONE", 0, &handle); - - if(!rc) + for(i = 0; i < KNOWN_DOS_ATTRS; i++) { - wRc = _dos_write(handle, (void*)noAttributeText, strlen(noAttributeText), &actionTaken); - cRc = _dos_close(handle); - rc = _dos_setfileattr("NONE", _A_NORMAL); + rc = _dos_creat(dos_attrs[i].filename, _A_NORMAL, &handle); + + if(!rc) + { + wRc = _dos_write(handle, (void*)dos_attrs[i].contents, strlen(dos_attrs[i].contents), &actionTaken); + cRc = _dos_close(handle); + rc = _dos_setfileattr(dos_attrs[i].filename, dos_attrs[i].attr); + } + + printf("\t%s: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", dos_attrs[i].description, dos_attrs[i].filename, rc, wRc, cRc); } - - printf("\tFile with no attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "NONE", rc, wRc, cRc); - - rc = _dos_creat("ARCHIVE", _A_NORMAL, &handle); - - if(!rc) - { - wRc = _dos_write(handle, (void*)archivedAttributeText, strlen(archivedAttributeText), &actionTaken); - cRc = _dos_close(handle); - rc = _dos_setfileattr("ARCHIVE", _A_ARCH); - } - - printf("\tFile with archived attribute: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "ARCHIVE", rc, wRc, cRc); - - rc = _dos_creat("SYSTEM", _A_NORMAL, &handle); - - if(!rc) - { - wRc = _dos_write(handle, (void*)systemAttributeText, strlen(systemAttributeText), &actionTaken); - cRc = _dos_close(handle); - rc = _dos_setfileattr("SYSTEM", _A_SYSTEM); - } - - printf("\tFile with system attribute: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "SYSTEM", rc, wRc, cRc); - - rc = _dos_creat("HIDDEN", _A_NORMAL, &handle); - - if(!rc) - { - wRc = _dos_write(handle, (void*)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken); - cRc = _dos_close(handle); - rc = _dos_setfileattr("HIDDEN", _A_HIDDEN); - } - - printf("\tFile with hidden attribute: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "HIDDEN", rc, wRc, cRc); - - rc = _dos_creat("READONLY", _A_NORMAL, &handle); - - if(!rc) - { - wRc = _dos_write(handle, (void*)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken); - cRc = _dos_close(handle); - rc = _dos_setfileattr("READONLY", _A_RDONLY); - } - - printf("\tFile with read-only attribute: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", "READONLY", rc, wRc, cRc); - - rc = _dos_creat("HIDDREAD", _A_NORMAL, &handle); - - if(!rc) - { - wRc = _dos_write(handle, (void*)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken); - wRc = _dos_write(handle, (void*)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken); - cRc = _dos_close(handle); - rc = _dos_setfileattr("HIDDREAD", _A_HIDDEN | _A_RDONLY); - } - - printf("\tFile with hidden, read-only attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", - "HIDDREAD", - rc, - wRc, - cRc); - - rc = _dos_creat("SYSTREAD", _A_NORMAL, &handle); - - if(!rc) - { - wRc = _dos_write(handle, (void*)systemAttributeText, strlen(systemAttributeText), &actionTaken); - wRc = _dos_write(handle, (void*)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken); - cRc = _dos_close(handle); - rc = _dos_setfileattr("SYSTREAD", _A_SYSTEM | _A_RDONLY); - } - - printf("\tFile with system, read-only attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", - "SYSTREAD", - rc, - wRc, - cRc); - - rc = _dos_creat("SYSTHIDD", _A_NORMAL, &handle); - - if(!rc) - { - wRc = _dos_write(handle, (void*)systemAttributeText, strlen(systemAttributeText), &actionTaken); - wRc = _dos_write(handle, (void*)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken); - cRc = _dos_close(handle); - rc = _dos_setfileattr("SYSTHIDD", _A_SYSTEM | _A_HIDDEN); - } - - printf("\tFile with system, hidden attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", - "SYSTHIDD", - rc, - wRc, - cRc); - - rc = _dos_creat("SYSRDYHD", _A_NORMAL, &handle); - - if(!rc) - { - wRc = _dos_write(handle, (void*)systemAttributeText, strlen(systemAttributeText), &actionTaken); - wRc = _dos_write(handle, (void*)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken); - wRc = _dos_write(handle, (void*)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken); - cRc = _dos_close(handle); - rc = _dos_setfileattr("SYSRDYHD", _A_SYSTEM | _A_RDONLY | _A_HIDDEN); - } - - printf("\tFile with system, read-only, hidden attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", - "SYSRDYHD", - rc, - wRc, - cRc); - - rc = _dos_creat("ARCHREAD", _A_NORMAL, &handle); - - if(!rc) - { - wRc = _dos_write(handle, (void*)archivedAttributeText, strlen(archivedAttributeText), &actionTaken); - wRc = _dos_write(handle, (void*)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken); - cRc = _dos_close(handle); - rc = _dos_setfileattr("ARCHREAD", _A_ARCH | _A_RDONLY); - } - - printf("\tFile with archived, read-only attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", - "ARCHREAD", - rc, - wRc, - cRc); - - rc = _dos_creat("ARCHHIDD", _A_NORMAL, &handle); - - if(!rc) - { - wRc = _dos_write(handle, (void*)archivedAttributeText, strlen(archivedAttributeText), &actionTaken); - wRc = _dos_write(handle, (void*)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken); - cRc = _dos_close(handle); - rc = _dos_setfileattr("ARCHHIDD", _A_ARCH | _A_HIDDEN); - } - - printf("\tFile with archived, hidden attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", - "ARCHHIDD", - rc, - wRc, - cRc); - - rc = _dos_creat("ARCHDRDY", _A_NORMAL, &handle); - - if(!rc) - { - wRc = _dos_write(handle, (void*)archivedAttributeText, strlen(archivedAttributeText), &actionTaken); - wRc = _dos_write(handle, (void*)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken); - wRc = _dos_write(handle, (void*)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken); - cRc = _dos_close(handle); - rc = _dos_setfileattr("ARCHDRDY", _A_ARCH | _A_HIDDEN | _A_RDONLY); - } - - printf("\tFile with archived, hidden, read-only attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", - "ARCHDRDY", - rc, - wRc, - cRc); - - rc = _dos_creat("ARCHSYST", _A_NORMAL, &handle); - - if(!rc) - { - wRc = _dos_write(handle, (void*)archivedAttributeText, strlen(archivedAttributeText), &actionTaken); - wRc = _dos_write(handle, (void*)systemAttributeText, strlen(systemAttributeText), &actionTaken); - cRc = _dos_close(handle); - rc = _dos_setfileattr("ARCHSYST", _A_ARCH | _A_SYSTEM); - } - - printf("\tFile with archived, system attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", - "ARCHSYST", - rc, - wRc, - cRc); - - rc = _dos_creat("ARSYSRDY", _A_NORMAL, &handle); - - if(!rc) - { - wRc = _dos_write(handle, (void*)archivedAttributeText, strlen(archivedAttributeText), &actionTaken); - wRc = _dos_write(handle, (void*)systemAttributeText, strlen(systemAttributeText), &actionTaken); - wRc = _dos_write(handle, (void*)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken); - cRc = _dos_close(handle); - rc = _dos_setfileattr("ARSYSRDY", _A_ARCH | _A_SYSTEM | _A_RDONLY); - } - - printf("\tFile with archived, system, read-only attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", - "ARSYSRDY", - rc, - wRc, - cRc); - - rc = _dos_creat("ARCSYSHD", _A_NORMAL, &handle); - - if(!rc) - { - wRc = _dos_write(handle, (void*)archivedAttributeText, strlen(archivedAttributeText), &actionTaken); - wRc = _dos_write(handle, (void*)systemAttributeText, strlen(systemAttributeText), &actionTaken); - wRc = _dos_write(handle, (void*)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken); - cRc = _dos_close(handle); - rc = _dos_setfileattr("ARCSYSHD", _A_ARCH | _A_SYSTEM | _A_HIDDEN); - } - - printf("\tFile with archived, system, hidden attributes: name = \"%s\", rc = %d, wRc = %d, cRc = %d\n", - "ARCSYSHD", - rc, - wRc, - cRc); - - rc = _dos_creat("ARSYHDRD", _A_NORMAL, &handle); - - if(!rc) - { - wRc = _dos_write(handle, (void*)archivedAttributeText, strlen(archivedAttributeText), &actionTaken); - wRc = _dos_write(handle, (void*)systemAttributeText, strlen(systemAttributeText), &actionTaken); - wRc = _dos_write(handle, (void*)hiddenAttributeText, strlen(hiddenAttributeText), &actionTaken); - wRc = _dos_write(handle, (void*)readonlyAttributeText, strlen(readonlyAttributeText), &actionTaken); - cRc = _dos_close(handle); - rc = _dos_setfileattr("ARSYHDRD", _A_ARCH | _A_SYSTEM | _A_HIDDEN | _A_RDONLY); - } - - printf("\tFile with all (archived, system, hidden, read-only) attributes: name = \"%s\", rc = %d, wRc = %d, cRc = " - "%d\n", - "ARSYHDRD", - rc, - wRc, - cRc); } #endif diff --git a/setter/src/dos/attr.h b/setter/src/dos/attr.h new file mode 100644 index 0000000..874691e --- /dev/null +++ b/setter/src/dos/attr.h @@ -0,0 +1,85 @@ +/**************************************************************************** +Aaru Data Preservation Suite +----------------------------------------------------------------------------- + +Filename : dos.h +Author(s) : Natalia Portillo + +--[ Description ] ----------------------------------------------------------- + +Contains DOS definitions + +--[ 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 defined(__DOS__) || defined(MSDOS) + +#ifndef SETTER_SRC_DOS_ATTR_H_ +#define SETTER_SRC_DOS_ATTR_H_ + +#include + +typedef struct +{ + char filename[9]; + char contents[170]; + char description[63]; + unsigned int attr; +} dos_attr_tests_t; + +#define KNOWN_DOS_ATTRS 16 + +static const dos_attr_tests_t dos_attrs[KNOWN_DOS_ATTRS] = { + {"NONE", "This file has no attribute set.\n", "File with no attributes", _A_NORMAL}, + {"ARCHIVE", "This file has the archived attribute set.\n", "File with archived attribute", _A_ARCH}, + {"SYSTEM", "This file has the system attribute set.\n", "File with system attribute", _A_SYSTEM}, + {"HIDDEN", "This file has the hidden attribute set.\n", "File with hidden attribute", _A_HIDDEN}, + {"READONLY", "This file has the read-only attribute set.\n", "File with read-only attribute", _A_RDONLY}, + {"HIDDREAD", "This file has the hidden attribute set.\n" + "This file has the read-only attribute set.\n", "File with hidden, read-only attributes", _A_HIDDEN | _A_RDONLY}, + {"SYSTREAD", "This file has the system attribute set.\n" + "This file has the read-only attribute set.\n", "File with system, read-only attributes", _A_SYSTEM | _A_RDONLY}, + {"SYSTHIDD", "This file has the system attribute set.\n" + "This file has the hidden attribute set.\n", "File with system, hidden attributes", _A_SYSTEM | _A_HIDDEN}, + {"SYSRDYHD", "This file has the system attribute set.\n" + "This file has the read-only attribute set.\n" + "This file has the hidden attribute set.\n", "File with system, read-only, hidden attributes", _A_SYSTEM | _A_RDONLY | _A_HIDDEN}, + {"ARCHREAD", "This file has the archived attribute set.\n" + "This file has the read-only attribute set.\n", "File with archived, read-only attributes", _A_ARCH | _A_RDONLY}, + {"ARCHHIDD", "This file has the archived attribute set.\n" + "This file has the hidden attribute set.\n", "File with archived, hidden attributes", _A_ARCH | _A_HIDDEN}, + {"ARCHDRDY", "This file has the archived attribute set.\n" + "This file has the hidden attribute set.\n" + "This file has the read-only attribute set.\n", "File with archived, hidden, read-only attributes", _A_ARCH | _A_HIDDEN | _A_RDONLY}, + {"ARCHSYST", "This file has the archived attribute set.\n" + "This file has the system attribute set.\n", "File with archived, system attributes", _A_ARCH | _A_SYSTEM}, + {"ARSYSRDY", "This file has the archived attribute set.\n" + "This file has the system attribute set.\n" + "This file has the read-only attribute set.\n", "File with archived, system, read-only attributes", _A_ARCH | _A_SYSTEM | _A_RDONLY}, + {"ARCSYSHD", "This file has the archived attribute set.\n" + "This file has the system attribute set.\n" + "This file has the hidden attribute set.\n", "File with archived, system, hidden attributes", _A_ARCH | _A_SYSTEM | _A_HIDDEN}, + {"ARSYHDRD", "This file has the archived attribute set.\n" + "This file has the system attribute set.\n" + "This file has the hidden attribute set.\n" + "This file has the read-only attribute set.\n", "File with all (archived, system, hidden, read-only) attributes", _A_ARCH | _A_SYSTEM | _A_HIDDEN | _A_RDONLY}, +}; + +#endif // SETTER_SRC_DOS_ATTR_H_ + +#endif \ No newline at end of file diff --git a/setter/src/dos/deleted.c b/setter/src/dos/deleted.c index 627fd8d..e932dae 100644 --- a/setter/src/dos/deleted.c +++ b/setter/src/dos/deleted.c @@ -40,7 +40,6 @@ Copyright (C) 2011-2021 Natalia Portillo #endif #include "../include/defs.h" -#include "../include/dosos2.h" #include "dos.h" void DeleteFiles(const char* path) diff --git a/setter/src/dos/dirdepth.c b/setter/src/dos/dirdepth.c index bce8260..0e780d5 100644 --- a/setter/src/dos/dirdepth.c +++ b/setter/src/dos/dirdepth.c @@ -29,12 +29,8 @@ Copyright (C) 2011-2021 Natalia Portillo #if defined(__DOS__) || defined(MSDOS) -#include #include -#include -#include #include -#include #include #if defined(__WATCOM__) @@ -45,7 +41,6 @@ Copyright (C) 2011-2021 Natalia Portillo #include "../include/consts.h" #include "../include/defs.h" -#include "../include/dosos2.h" #include "dos.h" void DirectoryDepth(const char* path) diff --git a/setter/src/dos/filename.c b/setter/src/dos/filename.c index 1fb008f..c70512e 100644 --- a/setter/src/dos/filename.c +++ b/setter/src/dos/filename.c @@ -41,7 +41,6 @@ Copyright (C) 2011-2021 Natalia Portillo #include "../include/consts.h" #include "../include/defs.h" -#include "../include/dosos2.h" #include "dos.h" void Filenames(const char* path) diff --git a/setter/src/dos/files.c b/setter/src/dos/files.c index 5a2d421..ff7cd72 100644 --- a/setter/src/dos/files.c +++ b/setter/src/dos/files.c @@ -40,7 +40,6 @@ Copyright (C) 2011-2021 Natalia Portillo #endif #include "../include/defs.h" -#include "../include/dosos2.h" #include "dos.h" void MillionFiles(const char* path) diff --git a/setter/src/dos/frag.c b/setter/src/dos/frag.c index a90572c..ed908ca 100644 --- a/setter/src/dos/frag.c +++ b/setter/src/dos/frag.c @@ -43,7 +43,6 @@ Copyright (C) 2011-2021 Natalia Portillo #include "../include/consts.h" #include "../include/defs.h" -#include "../include/dosos2.h" #include "dos.h" void Fragmentation(const char* path, size_t clusterSize) diff --git a/setter/src/dos/os.c b/setter/src/dos/os.c index a1a6356..02bc8f6 100644 --- a/setter/src/dos/os.c +++ b/setter/src/dos/os.c @@ -39,7 +39,6 @@ Copyright (C) 2011-2021 Natalia Portillo #endif #include "../include/defs.h" -#include "../include/dosos2.h" #include "dos.h" void GetOsInfo() diff --git a/setter/src/dos/time.c b/setter/src/dos/time.c index b0890f3..c967685 100644 --- a/setter/src/dos/time.c +++ b/setter/src/dos/time.c @@ -41,7 +41,6 @@ Copyright (C) 2011-2021 Natalia Portillo #endif #include "../include/defs.h" -#include "../include/dosos2.h" #include "dos.h" #define DATETIME_FORMAT "This file is dated %04d/%02d/%02d %02d:%02d:%02d for %s\n" diff --git a/setter/src/dos/volume.c b/setter/src/dos/volume.c index a7c6b8b..638a4cf 100644 --- a/setter/src/dos/volume.c +++ b/setter/src/dos/volume.c @@ -36,7 +36,6 @@ Copyright (C) 2011-2021 Natalia Portillo #include #include "../include/defs.h" -#include "../include/dosos2.h" #include "dos.h" void GetVolumeInfo(const char* path, size_t* clusterSize) diff --git a/setter/src/include/dosos2.h b/setter/src/include/dosos2.h deleted file mode 100644 index 75ac2cf..0000000 --- a/setter/src/include/dosos2.h +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -Aaru Data Preservation Suite ------------------------------------------------------------------------------ - -Filename : dosos2.h -Author(s) : Natalia Portillo - ---[ Description ] ----------------------------------------------------------- - -Contains definitions common to DOS and OS/2 - ---[ 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 defined(__OS2__) || defined(__os2__) || defined(__DOS__) || defined(MSDOS) - -#ifndef AARU_FSTESTER_SETTER_DOSOS2_H -#define AARU_FSTESTER_SETTER_DOSOS2_H - -const char *archivedAttributeText = "This file has the archived attribute set.\n"; -const char *systemAttributeText = "This file has the system attribute set.\n"; -const char *hiddenAttributeText = "This file has the hidden attribute set.\n"; -const char *readonlyAttributeText = "This file has the read-only attribute set.\n"; -const char *noAttributeText = "This file has no attribute set.\n"; - -#endif - -#endif diff --git a/setter/src/os2_16.c b/setter/src/os2_16.c index 0a1f368..a37cfd0 100644 --- a/setter/src/os2_16.c +++ b/setter/src/os2_16.c @@ -40,7 +40,6 @@ Copyright (C) 2011-2021 Natalia Portillo #include "os2_16.h" -#include "dosos2.h" #include "include/consts.h" #include "include/defs.h" diff --git a/setter/src/os2_16.h b/setter/src/os2_16.h index 2a6853b..9588f24 100644 --- a/setter/src/os2_16.h +++ b/setter/src/os2_16.h @@ -242,6 +242,12 @@ unsigned char IconEA[3516] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +const char *archivedAttributeText = "This file has the archived attribute set.\n"; +const char *systemAttributeText = "This file has the system attribute set.\n"; +const char *hiddenAttributeText = "This file has the hidden attribute set.\n"; +const char *readonlyAttributeText = "This file has the read-only attribute set.\n"; +const char *noAttributeText = "This file has no attribute set.\n"; + #endif #endif diff --git a/setter/src/os2_32.c b/setter/src/os2_32.c index 6373a8a..88b53c8 100644 --- a/setter/src/os2_32.c +++ b/setter/src/os2_32.c @@ -38,7 +38,6 @@ Copyright (C) 2011-2021 Natalia Portillo #include #include -#include "dosos2.h" #include "include/consts.h" #include "include/defs.h" #include "os2_16.h"