mirror of
https://github.com/aaru-dps/fstester.git
synced 2025-12-16 19:24:39 +00:00
Implement permissions for AmigaOS.
This commit is contained in:
@@ -27,5 +27,5 @@ Copyright (C) 2011-2021 Natalia Portillo
|
||||
|
||||
void FileAttributes(const char* path)
|
||||
{
|
||||
// TODO
|
||||
// Is in permissions
|
||||
}
|
||||
|
||||
@@ -22,9 +22,67 @@ Aaru Data Preservation Suite
|
||||
Copyright (C) 2011-2021 Natalia Portillo
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dos/dos.h>
|
||||
#include <proto/dos.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "perms.h"
|
||||
|
||||
#include "../include/defs.h"
|
||||
#include "../log.h"
|
||||
|
||||
void FilePermissions(const char* path)
|
||||
{
|
||||
// TODO
|
||||
BPTR pathLock;
|
||||
BPTR dirLock;
|
||||
int ret;
|
||||
BPTR file;
|
||||
int rc;
|
||||
int cRc;
|
||||
int i;
|
||||
char buffer[256];
|
||||
|
||||
pathLock = Lock((CONST_STRPTR)path, SHARED_LOCK);
|
||||
|
||||
if(!pathLock)
|
||||
{
|
||||
log_write("Error %d changing to specified path.\n", IoErr());
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentDir(pathLock);
|
||||
|
||||
dirLock = CreateDir((CONST_STRPTR) "PERMS");
|
||||
|
||||
if(!dirLock)
|
||||
{
|
||||
log_write("Error %d creating working directory.\n", IoErr());
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentDir(dirLock);
|
||||
|
||||
log_write("Creating permissions files.\n");
|
||||
|
||||
for(i = 0; i < KNOWN_AMIGA_PERMS; i++)
|
||||
{
|
||||
file = Open((CONST_STRPTR)amiga_perms[i].filename, MODE_NEWFILE);
|
||||
rc = 0;
|
||||
cRc = 0;
|
||||
|
||||
if(!file) rc = IoErr();
|
||||
else
|
||||
{
|
||||
memset(buffer, 0, 256);
|
||||
snprintf(buffer, 256, "%s.\n", amiga_perms[i].description);
|
||||
Write(file, buffer, 256);
|
||||
Close(file);
|
||||
cRc = SetProtection((CONST_STRPTR)amiga_perms[i].filename, amiga_perms[i].mode);
|
||||
if(!cRc) cRc = IoErr();
|
||||
}
|
||||
|
||||
log_write(
|
||||
"\t%s: name = \"%s\", rc = %d, cRc = %d\n", amiga_perms[i].description, amiga_perms[i].filename, rc, cRc);
|
||||
}
|
||||
}
|
||||
|
||||
58
setter/src/amiga/perms.h
Normal file
58
setter/src/amiga/perms.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/****************************************************************************
|
||||
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_AMIGA_PERMS_H_
|
||||
#define AARU_FSTESTER_SETTER_SRC_AMIGA_PERMS_H_
|
||||
|
||||
#include <dos/dos.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char filename[256];
|
||||
char description[256];
|
||||
mode_t mode;
|
||||
} amiga_perms_tests_t;
|
||||
|
||||
#define KNOWN_AMIGA_PERMS 16
|
||||
|
||||
static const amiga_perms_tests_t amiga_perms[KNOWN_AMIGA_PERMS] = {
|
||||
{"NONE", "File with no permissions set", 0},
|
||||
{"OR", "File can be read by others", FIBF_OTR_READ},
|
||||
{"OW", "File can be written by others", FIBF_OTR_WRITE},
|
||||
{"OE", "File can be executed by others", FIBF_OTR_EXECUTE},
|
||||
{"OD", "File can be deleted by others", FIBF_OTR_DELETE},
|
||||
{"GR", "File can be read by group", FIBF_GRP_READ},
|
||||
{"GW", "File can be written by group", FIBF_GRP_WRITE},
|
||||
{"GE", "File can be executed by group", FIBF_GRP_EXECUTE},
|
||||
{"GD", "File can be deleted by group", FIBF_GRP_DELETE},
|
||||
{"SCRIPT", "File is a script", FIBF_SCRIPT},
|
||||
{"PURE", "File is reentrant and re-executable", FIBF_PURE},
|
||||
{"ARCHIVE", "File has been archived", FIBF_ARCHIVE},
|
||||
{"READ", "File cannot be read", FIBF_READ},
|
||||
{"WRITE", "File cannot be written", FIBF_WRITE},
|
||||
{"EXECUTE", "File cannot be executed", FIBF_EXECUTE},
|
||||
{"DELETE", "File cannot be deleted", FIBF_DELETE},
|
||||
};
|
||||
|
||||
#endif // AARU_FSTESTER_SETTER_SRC_AMIGA_PERMS_H_
|
||||
Reference in New Issue
Block a user