mirror of
https://github.com/aaru-dps/fstester.git
synced 2025-12-16 19:24:39 +00:00
Implement permissions for Atari ST.
This commit is contained in:
@@ -26,4 +26,4 @@ if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "MiNT")
|
||||
return()
|
||||
endif()
|
||||
|
||||
add_sources(attr.c attr.h deleted.c dirdepth.c filename.c files.c frag.c links.c os.c os.h perms.c rsrcfork.c sparse.c time.c tostime.h volume.c xattr.c)
|
||||
add_sources(attr.c attr.h deleted.c dirdepth.c filename.c files.c frag.c links.c os.c os.h perms.c perms.h rsrcfork.c sparse.c time.c tostime.h volume.c xattr.c)
|
||||
|
||||
@@ -22,8 +22,75 @@ Aaru Data Preservation Suite
|
||||
Copyright (C) 2011-2021 Natalia Portillo
|
||||
*****************************************************************************/
|
||||
|
||||
#include <errno.h>
|
||||
#include <eti.h>
|
||||
#include <mint/cookie.h>
|
||||
#include <mint/mintbind.h>
|
||||
#include <mint/osbind.h>
|
||||
#include <mint/sysvars.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "perms.h"
|
||||
|
||||
#include "../include/defs.h"
|
||||
#include "../log.h"
|
||||
|
||||
void FilePermissions(const char* path)
|
||||
{ // TODO: MiNT. MagiC?
|
||||
{
|
||||
long** cookieJar = _p_cookies;
|
||||
long cookie;
|
||||
int rc, cRc;
|
||||
FILE* file;
|
||||
char driveNo = path[0] - '@';
|
||||
|
||||
// Check for a cookie jar
|
||||
if(*cookieJar == 0) return;
|
||||
|
||||
// Check if MiNT or MagiC
|
||||
rc = (Getcookie(C_MiNT, &cookie) == E_OK) || (Getcookie(C_MagX, &cookie) == E_OK) ||
|
||||
(Getcookie(C_MgMc, &cookie) == E_OK) || (Getcookie(C_MgMx, &cookie) == E_OK) ||
|
||||
(Getcookie(C_MgPC, &cookie) == E_OK);
|
||||
|
||||
if(rc == 0) return;
|
||||
|
||||
if(driveNo > 32) driveNo -= 32;
|
||||
|
||||
Dsetdrv(driveNo);
|
||||
Dsetpath("\\");
|
||||
|
||||
rc = Dcreate("PERMS");
|
||||
|
||||
if(rc != E_OK)
|
||||
{
|
||||
log_write("Error %d creating working directory.\n", rc);
|
||||
return;
|
||||
}
|
||||
|
||||
rc = Dsetpath("PERMS");
|
||||
|
||||
if(rc != E_OK)
|
||||
{
|
||||
log_write("Error %d changing to working directory.\n", rc);
|
||||
return;
|
||||
}
|
||||
|
||||
log_write("Creating permission files.\n");
|
||||
|
||||
for(i = 0; i < KNOWN_ATARI_PERMS; i++)
|
||||
{
|
||||
file = fopen(atari_perms[i].filename, "w+");
|
||||
rc = 0;
|
||||
cRc = 0;
|
||||
|
||||
if(!file) rc = errno;
|
||||
else
|
||||
{
|
||||
fprintf(file, "%s.\n", atari_perms[i].description);
|
||||
fclose(file);
|
||||
cRc = Fchmod(atari_perms[i].filename, atari_perms[i].mode);
|
||||
}
|
||||
|
||||
log_write(
|
||||
"\t%s: name = \"%s\", rc = %d, cRc = %d\n", atari_perms[i].description, atari_perms[i].filename, rc, cRc);
|
||||
}
|
||||
}
|
||||
|
||||
53
setter/src/atarist/perms.h
Normal file
53
setter/src/atarist/perms.h
Normal 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_ATARI_PERMS_H_
|
||||
#define AARU_FSTESTER_SETTER_SRC_ATARI_PERMS_H_
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char filename[256];
|
||||
char description[256];
|
||||
mode_t mode;
|
||||
} atari_perms_tests_t;
|
||||
|
||||
#define KNOWN_ATARI_PERMS 14
|
||||
|
||||
static const atari_perms_tests_t atari_perms[KNOWN_ATARI_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_ATARI_PERMS_H_
|
||||
Reference in New Issue
Block a user