From e7941a0d66a18c19fb9239599db4e29a8bf51bbd Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Fri, 13 Feb 2026 13:54:12 +0000 Subject: [PATCH] Make it work in XENIX compilers. --- setter/projects/make/xenix/Makefile | 72 ++++++++++++++++++++++++++++ setter/projects/make/xenix/README.md | 1 + setter/src/main.c | 3 ++ setter/src/unix/frag.c | 4 ++ setter/src/unix/links.c | 2 + setter/src/unix/mkdir.c | 37 ++++++++++++++ setter/src/unix/perms.h | 4 ++ setter/src/unix/sparse.c | 6 +++ setter/src/unix/volume.c | 15 +++++- 9 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 setter/projects/make/xenix/Makefile create mode 100644 setter/projects/make/xenix/README.md create mode 100644 setter/src/unix/mkdir.c diff --git a/setter/projects/make/xenix/Makefile b/setter/projects/make/xenix/Makefile new file mode 100644 index 0000000..7186e2a --- /dev/null +++ b/setter/projects/make/xenix/Makefile @@ -0,0 +1,72 @@ +# /**************************************************************************** +# 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-2026 Natalia Portillo +# *****************************************************************************/ + +# Directory with main and log source files +MAINDIR = ../../../src + +# Directory with main platform source files +SRCDIR = $(MAINDIR)/unix + +# Directory with subplatform source files +PLATDIR = + +# Object files +OBJS = $(MAINDIR)/log.o $(MAINDIR)/main.o $(SRCDIR)/attr.o $(SRCDIR)/dirdepth.o \ + $(SRCDIR)/files.o $(SRCDIR)/links.o $(SRCDIR)/perms.o $(SRCDIR)/rsrcfork.o \ + $(SRCDIR)/time.o $(SRCDIR)/volume.o $(SRCDIR)/xattr.o $(SRCDIR)/deleted.o \ + $(SRCDIR)/filename.o $(SRCDIR)/frag.o $(SRCDIR)/os.o $(SRCDIR)/sparse.o \ + $(SRCDIR)/mkdir.o + +# Source files +SOURCE = $(MAINDIR)/log.c $(MAINDIR)/main.c $(SRCDIR)/attr.c $(SRCDIR)/dirdepth.c \ + $(SRCDIR)/files.c $(SRCDIR)/links.c $(SRCDIR)/perms.c $(SRCDIR)/rsrcfork.c \ + $(SRCDIR)/time.c $(SRCDIR)/volume.c $(SRCDIR)/xattr.c $(SRCDIR)/deleted.c \ + $(SRCDIR)/filename.c $(SRCDIR)/frag.c $(SRCDIR)/os.c $(SRCDIR)/sparse.c \ + $(SRCDIR)/mkdir.c + +# Header files +HEADER = $(MAINDIR)/log.h $(MAINDIR)/main.h $(SRCDIR)/perms.h $(SRCDIR)/time.h \ + $(SRCDIR)/volume.h + +# Outfile +OUT = fssetter + +# Linker flags +LFLAGS = + +# Compiler flags. This needs the definitions on how to find statfs.h as there is no autodetection +# BSD 2.11 defines statfs to be in sys/mount.h +CFLAGS = -DHAVE_SYS_MOUNT_H + +all: fssetter + +fssetter: $(OBJS) + $(CC) -o $@ $^ $(LFLAGS) + +%.o: %.c $(HEADER) + $(CC) $(CFLAGS) -c -o $@ $< + +# clean house +clean: + rm -f $(OBJS) $(OUT) diff --git a/setter/projects/make/xenix/README.md b/setter/projects/make/xenix/README.md new file mode 100644 index 0000000..e0df7c8 --- /dev/null +++ b/setter/projects/make/xenix/README.md @@ -0,0 +1 @@ +This directory contains the Makefile for XENIX. diff --git a/setter/src/main.c b/setter/src/main.c index 5bd39aa..e143622 100644 --- a/setter/src/main.c +++ b/setter/src/main.c @@ -25,6 +25,9 @@ Copyright (C) 2011-2026 Natalia Portillo #if defined(__STDC__) /* XENIX again */ #include #endif +#if defined(M_XENIX) && !defined(M_SYSV3) +typedef long size_t; +#endif #include #include diff --git a/setter/src/unix/frag.c b/setter/src/unix/frag.c index 9157dea..79542c7 100644 --- a/setter/src/unix/frag.c +++ b/setter/src/unix/frag.c @@ -39,6 +39,10 @@ Copyright (C) 2011-2026 Natalia Portillo #include "../include/defs.h" #include "../log.h" +#if M_XENIX +typedef long size_t; +#endif + #if defined(__STDC__) void Fragmentation(const char* path, size_t clusterSize) #else diff --git a/setter/src/unix/links.c b/setter/src/unix/links.c index 514d490..bd02cb1 100644 --- a/setter/src/unix/links.c +++ b/setter/src/unix/links.c @@ -87,9 +87,11 @@ char path; if(ret) { log_write("Error %d creating hard link.\n", errno); } +#if !defined(M_XENIX) && !defined(COHERENT) /* Predates symlinks */ ret = symlink("TARGET", "SYMBOLIC"); if(ret) { log_write("Error %d creating symbolic link.\n", errno); } +#endif #if defined(__APPLE__) && defined(__MACH__) ret = mkdir("TARGETDIR", 0755); diff --git a/setter/src/unix/mkdir.c b/setter/src/unix/mkdir.c new file mode 100644 index 0000000..c30da5e --- /dev/null +++ b/setter/src/unix/mkdir.c @@ -0,0 +1,37 @@ +/**************************************************************************** +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-2026 Natalia Portillo +*****************************************************************************/ + +#include +#include + +#if defined(__STDC__) +int mkdir(const char *path, int mode) +#else +int mkdir(path, mode) +char *path; +int mode; +#endif +{ + return mknod(path, S_IFDIR | mode, 0); +} diff --git a/setter/src/unix/perms.h b/setter/src/unix/perms.h index efbda36..41db84e 100644 --- a/setter/src/unix/perms.h +++ b/setter/src/unix/perms.h @@ -29,6 +29,10 @@ Copyright (C) 2011-2026 Natalia Portillo typedef int mode_t; #endif +#if defined(M_XENIX) +typedef int mode_t; +#endif + typedef struct { char filename[256]; diff --git a/setter/src/unix/sparse.c b/setter/src/unix/sparse.c index 8bcc736..a4341b6 100644 --- a/setter/src/unix/sparse.c +++ b/setter/src/unix/sparse.c @@ -38,6 +38,12 @@ Copyright (C) 2011-2026 Natalia Portillo #include #include +#ifdef M_XENIX +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + #include "../include/consts.h" #include "../include/defs.h" #include "../log.h" diff --git a/setter/src/unix/volume.c b/setter/src/unix/volume.c index 303abd3..9d071b5 100644 --- a/setter/src/unix/volume.c +++ b/setter/src/unix/volume.c @@ -46,9 +46,14 @@ Copyright (C) 2011-2026 Natalia Portillo #include #endif /* Rhapsody DR1 */ -#endif // __NeXT__ #endif /* __NeXT__ */ +#ifdef M_XENIX +#undef HAVE_SYS_STATFS_H +#undef HAVE_SYS_MOUNT_H +typedef long size_t; +#endif + #ifdef HAVE_SYS_STATFS_H #include #endif @@ -91,6 +96,14 @@ char *path; size_t *clusterSize; #endif { +#ifdef M_XENIX + log_write("Volume information:\n"); + log_write("\tPath: %s\n", path); + *clusterSize = 1024; + + return; +#else + #ifdef HAVE_SYS_STATVFS_H struct statvfs buf; #else