* nativefs.c\r
* - Host filesystem access\r
*/\r
-#define DEBUG 1\r
+#define DEBUG 0\r
#define off_t _acess_off_t\r
#include <acess.h> // Acess\r
#include <vfs.h> // Acess\r
\r
dp = opendir(Device);\r
if(!dp) {\r
- Log_Warning("NativeFS", "ERRO: Unable to open device root '%s'", Device);\r
+ Log_Warning("NativeFS", "ERROR: Unable to open device root '%s'", Device);\r
return NULL;\r
}\r
\r
ret->Flags = VFS_FFLAG_DIRECTORY;\r
\r
ret->Type = &gNativeFS_DirNodeType; \r
- \r
+\r
return ret;\r
}\r
\r
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)
#include <disktool_common.h>
#include <ctype.h>
+// === 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
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)
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");
+/*
+ * 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
+
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)
+{
+
+}
+
// === CODE ===
int main(int argc, char *argv[])
{
- // Setup
-
// Parse arguments
for( int i = 1; i < argc; i ++ )
{
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;
+}
+