From: John Hodge Date: Mon, 9 Jul 2012 07:32:34 +0000 (+0800) Subject: DiskTool - Compiling again, now with modules X-Git-Tag: rel0.15~611^2~41^2~24 X-Git-Url: https://git.ucc.asn.au/?p=tpg%2Facess2.git;a=commitdiff_plain;h=d212a6f1517af8a9c1d550f566a202418f04fffe DiskTool - Compiling again, now with modules --- diff --git a/AcessNative/acesskernel_src/nativefs.c b/AcessNative/acesskernel_src/nativefs.c index 835fce9f..022ab78a 100644 --- a/AcessNative/acesskernel_src/nativefs.c +++ b/AcessNative/acesskernel_src/nativefs.c @@ -5,7 +5,7 @@ * nativefs.c * - Host filesystem access */ -#define DEBUG 1 +#define DEBUG 0 #define off_t _acess_off_t #include // Acess #include // Acess @@ -63,7 +63,7 @@ tVFS_Node *NativeFS_Mount(const char *Device, const char **Arguments) dp = opendir(Device); if(!dp) { - Log_Warning("NativeFS", "ERRO: Unable to open device root '%s'", Device); + Log_Warning("NativeFS", "ERROR: Unable to open device root '%s'", Device); return NULL; } @@ -82,7 +82,7 @@ tVFS_Node *NativeFS_Mount(const char *Device, const char **Arguments) ret->Flags = VFS_FFLAG_DIRECTORY; ret->Type = &gNativeFS_DirNodeType; - + return ret; } diff --git a/Tools/DiskTool/src/Makefile b/Tools/DiskTool/src/Makefile index 05811f79..a85575c8 100644 --- a/Tools/DiskTool/src/Makefile +++ b/Tools/DiskTool/src/Makefile @@ -25,10 +25,10 @@ L_OBJ = vfs_handles.o threads.o nativefs.o time.o actions.o N_OBJ = main.o script.o logging.o # Compilation Options -CFLAGS := -Wall -std=gnu99 +CFLAGS := -Wall -std=gnu99 -g CPPFLAGS := -I include/ K_CPPFLAGS := -I $(KERNEL_SRC)include -LDFLAGS += -Wl,--defsym,__buildnum=$(BUILD_NUM) +LDFLAGS += -Wl,--defsym,__buildnum=$(BUILD_NUM) -g BUILDINFO_OBJ := obj/$(TARGET)/buildinfo.o BUILDINFO_SRC := $(BUILDINFO_OBJ:%.o=%.c) diff --git a/Tools/DiskTool/src/actions.c b/Tools/DiskTool/src/actions.c index d5c75ef3..f1f86864 100644 --- a/Tools/DiskTool/src/actions.c +++ b/Tools/DiskTool/src/actions.c @@ -10,11 +10,23 @@ #include #include +// === IMPORTS === +extern int NativeFS_Install(char **Arguments); + // === PROTOTYPES === +void DiskTool_Initialise(void) __attribute__((constructor(101))); size_t DiskTool_int_TranslatePath(char *Buffer, const char *Path); int DiskTool_int_TranslateOpen(const char *File, int Mode); // === CODE === +void DiskTool_Initialise(void) +{ + VFS_Init(); + NativeFS_Install(NULL); + VFS_MkDir("/Native"); + VFS_Mount("/", "/Native", "nativefs", ""); +} + int DiskTool_MountImage(const char *Identifier, const char *Path) { // Validate Identifier and make mountpoint string @@ -55,10 +67,18 @@ size_t DiskTool_int_TranslatePath(char *Buffer, const char *Path) return -1; } -native_path: - if( Buffer ) - strcpy(Buffer, Path); - return strlen(Path); +native_path: { + int len = strlen("/Native"); + len += strlen( getenv("PWD") ) + 1; + len += strlen(Path); + if( Buffer ) { + strcpy(Buffer, "/Native"); + strcat(Buffer, getenv("PWD")); + strcat(Buffer, "/"); + strcat(Buffer, Path); + } + return len; + } } int DiskTool_int_TranslateOpen(const char *File, int Mode) diff --git a/Tools/DiskTool/src/include/acess.h b/Tools/DiskTool/src/include/acess.h index 79eb27ed..deb18346 100644 --- a/Tools/DiskTool/src/include/acess.h +++ b/Tools/DiskTool/src/include/acess.h @@ -82,11 +82,20 @@ extern tGID Threads_GetGID(void); extern int strpos(const char *Str, char Ch); extern void itoa(char *buf, uint64_t num, int base, int minLength, char pad); - -#define ENTER(...) do{}while(0) -#define LOG(...) do{}while(0) -#define LEAVE(...) do{}while(0) -#define LEAVE_RET(t,v) return v; +// TODO: Move out? +extern int64_t DivUp(int64_t value, int64_t divisor); + +#if DEBUG +# define ENTER(str, v...) Log("%s:%i: ENTER "str, __func__, __LINE__) +# define LOG(fmt, v...) Log("%s:%i: "fmt, __func__, __LINE__, ##v) +# define LEAVE(...) do{}while(0) +# define LEAVE_RET(t,v) return v; +#else +# define ENTER(...) do{}while(0) +# define LOG(...) do{}while(0) +# define LEAVE(...) do{}while(0) +# define LEAVE_RET(t,v) return v; +#endif static inline int Mutex_Acquire(tMutex *m) { if(*m) Log_KernelPanic("---", "Double mutex lock"); diff --git a/Tools/DiskTool/src/include/modules.h b/Tools/DiskTool/src/include/modules.h index e69de29b..c940c10b 100644 --- a/Tools/DiskTool/src/include/modules.h +++ b/Tools/DiskTool/src/include/modules.h @@ -0,0 +1,20 @@ +/* + * Acess2 DiskTool + * - By John Hodge (thePowersGang) + * + * include/modules.h + * - Reimplimentation of kernel module interface for POSIX userland + */ +#ifndef _INCLUDE__MODULES_H_ +#define _INCLUDE__MODULES_H_ + +enum +{ + MODULE_ERR_OK, +}; + +#define MODULE_DEFINE(flags, version, name, init, deinit, deps...) \ +void __init_##init(void) __attribute__((constructor(200))); void __init_##init(void){init(NULL);} + +#endif + diff --git a/Tools/DiskTool/src/logging.c b/Tools/DiskTool/src/logging.c index 8f627f2d..6cdb1c0b 100644 --- a/Tools/DiskTool/src/logging.c +++ b/Tools/DiskTool/src/logging.c @@ -34,9 +34,15 @@ void Log_Debug(const char *Ident, const char *Message, ...) void Warning(const char *Message, ...) { const char *Ident = "WARNING"; - PUTERR("34", "W") + PUTERR("33", "W") } void Log(const char *Message, ...) { const char *Ident = "LOGLOG"; - PUTERR("31", "L") + PUTERR("37", "L") } + +void Debug_HexDump(const char *Prefix, size_t Length, const void *Data) +{ + +} + diff --git a/Tools/DiskTool/src/main.c b/Tools/DiskTool/src/main.c index 7dd85833..fbfe7a0b 100644 --- a/Tools/DiskTool/src/main.c +++ b/Tools/DiskTool/src/main.c @@ -10,8 +10,6 @@ // === CODE === int main(int argc, char *argv[]) { - // Setup - // Parse arguments for( int i = 1; i < argc; i ++ ) { @@ -64,3 +62,19 @@ int strpos(const char *Str, char Ch) if(!r) return -1; return r - Str; } + +int strucmp(const char *s1, const char *s2) +{ + return strcasecmp(s1, s2); +} + +int64_t DivUp(int64_t value, int64_t divisor) +{ + return (value + divisor - 1) / divisor; +} + +int64_t timestamp(int sec, int min, int hr, int day, int month, int year) +{ + return 0; +} +