Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "odfs/error.h"

static const char *error_strings[] = {
static const char *const error_strings[] = {
[ODFS_OK] = "OK",
[ODFS_ERR_NOMEM] = "out of memory",
[ODFS_ERR_IO] = "I/O error",
Expand Down
4 changes: 2 additions & 2 deletions core/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <stdio.h>
#include <string.h>

static const char *level_names[] = {
static const char *const level_names[] = {
[ODFS_LOG_FATAL] = "FATAL",
[ODFS_LOG_ERROR] = "ERROR",
[ODFS_LOG_WARN] = "WARN",
Expand All @@ -18,7 +18,7 @@ static const char *level_names[] = {
[ODFS_LOG_TRACE] = "TRACE",
};

static const char *subsys_names[] = {
static const char *const subsys_names[] = {
[ODFS_SUB_NONE] = "",
[ODFS_SUB_CORE] = "core",
[ODFS_SUB_DOS] = "dos",
Expand Down
2 changes: 1 addition & 1 deletion core/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern const odfs_backend_ops_t hfsplus_backend_ops;
* UDF and HFS probed independently for standalone media.
* For hybrid discs, ISO-family wins unless overridden.
*/
static const odfs_backend_ops_t *backend_table[] = {
static const odfs_backend_ops_t *const backend_table[] = {
#if ODFS_FEATURE_ISO9660
&iso9660_backend_ops,
#endif
Expand Down
4 changes: 2 additions & 2 deletions core/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "odfs/node.h"

static const char *backend_names[] = {
static const char *const backend_names[] = {
[ODFS_BACKEND_NONE] = "none",
[ODFS_BACKEND_ISO9660] = "iso9660",
[ODFS_BACKEND_ROCK_RIDGE] = "rock_ridge",
Expand All @@ -17,7 +17,7 @@ static const char *backend_names[] = {
[ODFS_BACKEND_CDDA] = "cdda",
};

static const char *kind_names[] = {
static const char *const kind_names[] = {
[ODFS_NODE_FILE] = "file",
[ODFS_NODE_DIR] = "dir",
[ODFS_NODE_SYMLINK] = "symlink",
Expand Down
29 changes: 20 additions & 9 deletions platform/amiga/common/sys_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ struct Hook;

typedef LONG (*odfs_amiga_interrupt_fn)(APTR data);

extern struct ExecBase *SysBase;
extern struct DosLibrary *DOSBase;

void odfs_amiga_init_sysbase(void);
struct ExecBase *odfs_amiga_sysbase(void);
struct DosLibrary *odfs_amiga_dosbase(void);
/*
* The library bases one handler instance owns.
*/
typedef struct odfs_amiga_libs {
struct DosLibrary *dos;
} odfs_amiga_libs_t;

int odfs_amiga_open_libraries(void);
void odfs_amiga_close_libraries(void);
int odfs_amiga_open_libraries(odfs_amiga_libs_t *libs);
void odfs_amiga_close_libraries(odfs_amiga_libs_t *libs);

void *odfs_amiga_alloc_mem(ULONG size, ULONG flags);
void odfs_amiga_free_mem(void *ptr, ULONG size);
Expand All @@ -55,7 +55,18 @@ void odfs_amiga_free_signal(LONG num);
void *odfs_amiga_create_dos_entry(const char *name, LONG type);
void odfs_amiga_delete_dos_entry(void *node);

void odfs_amiga_init_interrupt(struct Interrupt *intr,
/*
* An exec Interrupt plus the callback it dispatches to. The trampoline finds
* the function through is_Data, so nothing about the binding is held at file
* scope and every instance can install its own.
*/
typedef struct odfs_amiga_interrupt {
struct Interrupt intr;
odfs_amiga_interrupt_fn fn;
APTR data;
} odfs_amiga_interrupt_t;

void odfs_amiga_init_interrupt(odfs_amiga_interrupt_t *ai,
const char *name,
APTR data,
odfs_amiga_interrupt_fn code);
Expand Down
6 changes: 3 additions & 3 deletions platform/amiga/handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "amiga_target_compat.h"
#include "aros_compat.h"
#include "sys_compat.h"
#include "odfs/api.h"

typedef struct odfs_volume odfs_volume_t;
Expand Down Expand Up @@ -88,8 +89,7 @@ typedef struct handler_global {
odfs_volume_t *current_volume;/* current mounted volume state */

/* libraries */
struct ExecBase *sysbase;
struct DosLibrary *dosbase;
odfs_amiga_libs_t libs;

/* device I/O */
struct MsgPort *devport; /* device I/O port */
Expand Down Expand Up @@ -134,7 +134,7 @@ typedef struct handler_global {
/* media change */
struct MsgPort *chgport; /* media change signal port */
struct IOStdReq *chgreq; /* media change I/O request */
struct Interrupt changeint; /* TD_ADDCHANGEINT callback */
odfs_amiga_interrupt_t changeint; /* TD_ADDCHANGEINT callback + binding */
odfs_changeint_data_t changeint_data; /* callback payload */
LONG chgsigbit; /* signal bit for media change */
int chg_installed; /* TD_CHANGEINT installed? */
Expand Down
37 changes: 21 additions & 16 deletions platform/amiga/handler_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
#include <proto/exec.h>
#include <proto/dos.h>

#if !ODFS_AMIGA_OS4
#define DOSBase (g->libs.dos)
#endif

#include <string.h>

#include "odfs/error.h"
Expand Down Expand Up @@ -105,7 +109,7 @@ static void unmount_volume(handler_global_t *g);
static void free_volume(odfs_volume_t *volume);
static void destroy_device_node(struct DeviceNode *devnode);
static void destroy_volume_node(struct DeviceList *volnode);
static int detach_volume_node(odfs_volume_t *volume);
static int detach_volume_node(handler_global_t *g, odfs_volume_t *volume);
static int publish_volume_node(handler_global_t *g);
static void schedule_volume_publish_retry(handler_global_t *g);
static void cancel_volume_publish_retry(handler_global_t *g);
Expand Down Expand Up @@ -1632,7 +1636,7 @@ static int destroy_stale_volume(handler_global_t *g, odfs_volume_t *volume)
return 1;

if (volume->volnode) {
if (!detach_volume_node(volume))
if (!detach_volume_node(g, volume))
return 0;
destroy_volume_node(volume->volnode);
}
Expand Down Expand Up @@ -4099,6 +4103,8 @@ typedef struct exall_ctx {
static odfs_err_t exall_cb(const odfs_node_t *entry, void *ctx)
{
exall_ctx_t *ec = ctx;
/* named g so the proto/dos.h inlines below find this instance's base */
handler_global_t *g = ec->g;
ULONG key = amiga_node_key(entry);
struct ExAllData *slot;
struct ExAllData *cursor_before;
Expand All @@ -4118,8 +4124,7 @@ static odfs_err_t exall_cb(const odfs_node_t *entry, void *ctx)
cursor_before = ec->cursor;
remaining_before = ec->remaining;
slot = ec->cursor;
if (!exall_fill_entry(ec->g, &ec->cursor, &ec->remaining, ec->data,
entry)) {
if (!exall_fill_entry(g, &ec->cursor, &ec->remaining, ec->data, entry)) {
ec->full = 1;
return ODFS_ERR_EOF;
}
Expand Down Expand Up @@ -5007,11 +5012,13 @@ static void destroy_volume_publish_timer(handler_global_t *g)
g->publish_timer_open = 0;
}

static int detach_volume_node(odfs_volume_t *volume)
static int detach_volume_node(handler_global_t *g, odfs_volume_t *volume)
{
struct DeviceList *volnode;
int removed;

(void)g; /* OS4 reaches DOS via IDOS, not the instance's base */

if (!volume || !volume->volnode || !volume->listed)
return 1;

Expand Down Expand Up @@ -5170,8 +5177,9 @@ static int toc_has_data_track(const odfs_toc_t *toc)
return 0;
}

static int load_cdda_disk_icon_path(cdda_context_t *ctx, const char *path)
static int load_cdda_disk_icon_path(handler_global_t *g, const char *path)
{
cdda_context_t *ctx = (cdda_context_t *)g->cdda_ctx;
BPTR fh;
LONG size;
LONG actual;
Expand Down Expand Up @@ -5228,8 +5236,8 @@ static void load_cdda_disk_icon(handler_global_t *g)
if (!ctx || ctx->is_mixed_mode)
return;

if (load_cdda_disk_icon_path(ctx, "ENV:Sys/def_cdda.info") ||
load_cdda_disk_icon_path(ctx, "ENVARC:Sys/def_cdda.info")) {
if (load_cdda_disk_icon_path(g, "ENV:Sys/def_cdda.info") ||
load_cdda_disk_icon_path(g, "ENVARC:Sys/def_cdda.info")) {
ODFS_INFO(&g->log, ODFS_SUB_MOUNT,
"using def_cdda.info as audio CD Disk.info");
}
Expand Down Expand Up @@ -5495,8 +5503,9 @@ static void install_media_change(handler_global_t *g)
g->changeint_data.sigmask = 1UL << g->chgsigbit;
odfs_amiga_init_interrupt(&g->changeint, "odfs-mediachange",
&g->changeint_data, changeint_signal);
g->chgreq->io_Data = (APTR)&g->changeint;
g->chgreq->io_Length = sizeof(g->changeint);
/* the device is handed the embedded Interrupt, not our wrapper */
g->chgreq->io_Data = (APTR)&g->changeint.intr;
g->chgreq->io_Length = sizeof(g->changeint.intr);
g->chgreq->io_Flags = 0;

SendIO((struct IORequest *)g->chgreq);
Expand Down Expand Up @@ -5685,8 +5694,6 @@ void handler_main_startup(struct Message *startup_msg)

(void)version_string; /* ensure $VER is not optimized out */

odfs_amiga_init_sysbase();

g = odfs_amiga_alloc_mem(sizeof(*g), MEMF_PUBLIC | MEMF_CLEAR);
if (!g) {
/*
Expand All @@ -5707,7 +5714,6 @@ void handler_main_startup(struct Message *startup_msg)
return;
}

g->sysbase = odfs_amiga_sysbase();
g->locklist.mlh_Head = (struct MinNode *)&g->locklist.mlh_Tail;
g->locklist.mlh_Tail = NULL;
g->locklist.mlh_TailPred = (struct MinNode *)&g->locklist.mlh_Head;
Expand Down Expand Up @@ -5767,7 +5773,7 @@ void handler_main_startup(struct Message *startup_msg)
"ODFileSystem " ODFS_GIT_VERSION
" (" ODFS_AMIGA_DATE ") starting...");

if (!odfs_amiga_open_libraries()) {
if (!odfs_amiga_open_libraries(&g->libs)) {
ODFS_ERROR(&g->log, ODFS_SUB_CORE,
"open dos.library failed");
pkt->dp_Res1 = DOSFALSE;
Expand All @@ -5776,7 +5782,6 @@ void handler_main_startup(struct Message *startup_msg)
odfs_amiga_free_mem(g, sizeof(*g));
return;
}
g->dosbase = odfs_amiga_dosbase();

/*
* Validate the FileSysStartupMsg before trusting any of its fields.
Expand Down Expand Up @@ -6152,7 +6157,7 @@ void handler_main_startup(struct Message *startup_msg)
deactivate_vector_port(g);
#endif

odfs_amiga_close_libraries();
odfs_amiga_close_libraries(&g->libs);
odfs_amiga_free_mem(g, sizeof(*g));
}

Expand Down
5 changes: 1 addition & 4 deletions platform/amiga/libc_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
*/

#include <exec/types.h>
#include "amiga_target_compat.h"
#include <proto/exec.h>

extern struct ExecBase *SysBase;

int __errno = 0;

void _exit(int status);
void _exit(int status)
{
Expand Down
7 changes: 7 additions & 0 deletions platform/amiga/os3/amiga_target_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@

#define ODFS_AMIGA_OS4 0

#ifndef __NOLIBBASE__
#define __NOLIBBASE__
#endif

struct ExecBase;
#define SysBase (*(struct ExecBase **)4UL)

/*
* OS4 V51+ shutdown packet. OS3 DOS never sends it, but accepting it
* unconditionally keeps the shared packet loop free of OS conditionals.
Expand Down
Loading
Loading