diff --git a/sys/cnf.c b/sys/cnf.c index 634d5dc..eee2abd 100644 --- a/sys/cnf.c +++ b/sys/cnf.c @@ -622,7 +622,7 @@ parser(FILEPTR *f, long f_size, kfree(buf); } -void +long parse_include(const char *path, struct parsinf *inf, struct parser_item *parser_tab) { XATTR xattr; @@ -630,7 +630,7 @@ parse_include(const char *path, struct parsinf *inf, struct parser_item *parser_ long ret; ret = FP_ALLOC(rootproc, &fp); - if (ret) return; + if (ret) return -1; ret = do_open(&fp, path, O_RDONLY, 0, &xattr); if (!ret) @@ -647,6 +647,8 @@ parse_include(const char *path, struct parsinf *inf, struct parser_item *parser_ parser(fp, xattr.size, &include, parser_tab); do_close(rootproc, fp); + + return 0; } else { @@ -656,10 +658,12 @@ parse_include(const char *path, struct parsinf *inf, struct parser_item *parser_ parser_msg(inf, NULL); boot_printf(MSG_cnf_cannot_include, path); parser_msg(NULL, NULL); + + return -1; } } -void +long parse_cnf(const char *path, struct parser_item *parser_tab, void *data) { struct parsinf inf = { 0ul, NULL, 1, NULL, NULL, data }; @@ -668,13 +672,15 @@ parse_cnf(const char *path, struct parser_item *parser_tab, void *data) long ret; ret = FP_ALLOC (rootproc, &fp); - if (ret) return; + if (ret) return -1; ret = do_open(&fp, inf.file = path, O_RDONLY, 0, &xattr); if (!ret) { parser(fp, xattr.size, &inf, parser_tab); do_close(rootproc, fp); + + return 0; } else { @@ -682,5 +688,7 @@ parse_cnf(const char *path, struct parser_item *parser_tab, void *data) FP_FREE(fp); ALERT(MSG_cnf_cant_open, path); + + return -1; } } diff --git a/sys/cnf.h b/sys/cnf.h index bad9d2e..0affbf5 100644 --- a/sys/cnf.h +++ b/sys/cnf.h @@ -125,8 +125,8 @@ struct parser_item void parser_msg(struct parsinf *, const char *msg); -void parse_include(const char *path, struct parsinf *, struct parser_item *); -void parse_cnf(const char *path, struct parser_item *, void *); +long parse_include(const char *path, struct parsinf *, struct parser_item *); +long parse_cnf(const char *path, struct parser_item *, void *); # endif diff --git a/sys/cnf_mint.c b/sys/cnf_mint.c index 776035c..5e71e02 100644 --- a/sys/cnf_mint.c +++ b/sys/cnf_mint.c @@ -273,11 +273,17 @@ load_config(void) char cnf_path[128]; struct cnfdata mydata; + strcpy(cnf_path, mchdir); + strcat(cnf_path, "mint.cnf"); + if (parse_cnf(cnf_path, parser_tab, &mydata) != 0) + { + /* mchdir/mint.cnf not found, try sysdir/mint.cnf */ strcpy(cnf_path, sysdir); strcat(cnf_path, "mint.cnf"); parse_cnf(cnf_path, parser_tab, &mydata); } +} /*============================================================================*/ /* Now follows the callback definitions in alphabetical order diff --git a/sys/global.c b/sys/global.c index 331b6f2..28bf2f7 100644 --- a/sys/global.c +++ b/sys/global.c @@ -36,7 +36,7 @@ struct global global = { - 0, 0, 0, -1, 0, 0, "" + 0, 0, 0, -1, 0, 0, "", "" }; long mcpu = 0; diff --git a/sys/global.h b/sys/global.h index 01fcfaa..00fea67 100644 --- a/sys/global.h +++ b/sys/global.h @@ -49,6 +49,7 @@ extern struct global global; #define gl_kbd global.gl_kbd #define sysdrv global.sysdrv #define sysdir global.sysdir +#define mchdir global.mchdir extern BASEPAGE *_base; /* pointer to kernel's basepage */ diff --git a/sys/init.c b/sys/init.c index 7f34f6c..a2ea8cc 100644 --- a/sys/init.c +++ b/sys/init.c @@ -650,6 +650,33 @@ init (void) strcpy(sysdir, temp); } + /* create mchdir */ + { + char *mch_str = NULL; + + /* first check non-cpu defines */ +#if defined(MILAN) + mch_str = "mil"; +#elif defined(ARANYM) + mch_str = "ara"; +#elif defined(__mcoldfire__) + mch_str = "v4e"; +#elif defined(M68000) + mch_str = "000"; +#elif defined(M68030) + mch_str = "030"; +#elif defined(M68040) + mch_str = "040"; +#elif defined(M68060) + mch_str = "060"; +#endif + + if (mch_str != NULL) + { + ksprintf (mchdir, sizeof(mchdir), "%s%s/", sysdir, mch_str); + } + } + /* print the warning message if MP is turned off */ # ifdef WITH_MMU_SUPPORT if (no_mem_prot && mcpu > 20) diff --git a/sys/mint/kentry.h b/sys/mint/kentry.h index 42fe8b0..f7ef575 100644 --- a/sys/mint/kentry.h +++ b/sys/mint/kentry.h @@ -531,8 +531,8 @@ struct kentry_module */ struct kentry_cnf { - void _cdecl (*parse_cnf)(const char *path, struct parser_item *, void *); - void _cdecl (*parse_include)(const char *path, struct parsinf *, struct parser_item *); + long _cdecl (*parse_cnf)(const char *path, struct parser_item *, void *); + long _cdecl (*parse_include)(const char *path, struct parsinf *, struct parser_item *); void _cdecl (*parser_msg)(struct parsinf *, const char *msg); }; #define DEFAULTS_kentry_cnf \ diff --git a/sys/mint/ktypes.h b/sys/mint/ktypes.h index c3aac71..d41d3aa 100644 --- a/sys/mint/ktypes.h +++ b/sys/mint/ktypes.h @@ -112,7 +112,7 @@ typedef struct sizebuf SIZEBUF; /* sized buffer */ /* global data */ struct global { - long mch; /* machine we are are running */ + long mch; /* machine we are are running, derived from _MCH cookie */ long fputype; /* fpu type, value for cookie jar */ short tosvers; /* the underlying TOS version */ @@ -124,6 +124,7 @@ struct global */ short sysdrv; char sysdir[32]; + char mchdir[32]; /* sysdir/, derived from build type */ }; /* BIOS device map */ diff --git a/sys/module.c b/sys/module.c index f69df77..94d7a1d 100644 --- a/sys/module.c +++ b/sys/module.c @@ -155,37 +155,6 @@ kernel_close(struct file *f) do_close(rootproc, f); } -static const char *get_machdir(void) -{ - char *mach = NULL; - - /* first check non-cpu defines */ -#if defined(MILAN) - mach = "mil"; -#elif defined(ARANYM) - mach = "ara"; -#elif defined(__mcoldfire__) - mach = "v4e"; -#elif defined(M68000) - mach = "000"; -#elif defined(M68030) - mach = "030"; -#elif defined(M68040) - mach = "040"; -#elif defined(M68060) - mach = "060"; -#endif - - if (mach != NULL) - { - static char temp[32]; - ksprintf (temp, sizeof(temp), "%s%s\\", sysdir, mach); - return temp; - } - - return NULL; -} - static long load_xfs (struct basepage *b, const char *name, short *class, short *subclass); static long load_xdd (struct basepage *b, const char *name, short *class, short *subclass); @@ -205,9 +174,8 @@ void load_all_modules(unsigned long mask) { int i; - const char *machdir = get_machdir(); - if (machdir != NULL) + if (strlen(mchdir) > 0) { for (i = 0; i < (sizeof(_types) / sizeof(*_types)); i++) { @@ -215,7 +183,7 @@ load_all_modules(unsigned long mask) if (mask & (1L << i)) { DEBUG(("load_all_modules (machine): processing \"%s\"", _types [i])); - load_modules(machdir, _types [i], _loads [i]); + load_modules(mchdir, _types [i], _loads [i]); DEBUG(("load_all_modules (machine): done with \"%s\"", _types [i])); stop_and_ask(); @@ -386,12 +354,11 @@ void _cdecl load_modules_old(const char *ext, long (*loader)(struct basepage *, const char *)) { long (*l)(struct basepage *, const char *, short *, short *); - const char *machdir = get_machdir(); l = (void *)loader; - if (machdir != NULL) - load_modules(machdir, ext, l); + if (strlen(mchdir) > 0) + load_modules(mchdir, ext, l); load_modules(sysdir, ext, l); }