Usermode/insmod - Added insmod program (and relevant syscall)
authorJohn Hodge <[email protected]>
Mon, 16 Sep 2013 05:18:47 +0000 (13:18 +0800)
committerJohn Hodge <[email protected]>
Mon, 16 Sep 2013 05:18:47 +0000 (13:18 +0800)
KernelLand/Kernel/syscalls.c
Usermode/Applications/insmod_src/Makefile [new file with mode: 0644]
Usermode/Applications/insmod_src/main.c [new file with mode: 0644]

index 85fbbf8..96f1f85 100644 (file)
@@ -203,7 +203,20 @@ void SyscallHandler(tSyscallRegs *Regs)
                // Path, *Entrypoint
                ret = Binary_Load((char*)Regs->Arg1, (Uint*)Regs->Arg2);
                break;
-       
+
+       // -- Load a kernel module
+       case SYS_LOADMOD:
+               CHECK_STR_NONULL( (const char *)Regs->Arg1 );
+               if( Threads_GetUID() != 0 ) {
+                       MERR("Not root");
+                       ret = EACCES;
+               }
+               else {
+                       LOG("Module_LoadFile(\"%s\", NULL)", (const char *)Regs->Arg1);
+                       ret = Module_LoadFile( (const char *)Regs->Arg1, NULL );
+               }
+               break;
+
        // ---
        // Virtual Filesystem
        // ---
diff --git a/Usermode/Applications/insmod_src/Makefile b/Usermode/Applications/insmod_src/Makefile
new file mode 100644 (file)
index 0000000..0f41c35
--- /dev/null
@@ -0,0 +1,10 @@
+# Project: insmod
+
+-include ../Makefile.cfg
+
+DIR = SBin
+OBJ = main.o
+BIN = insmod
+
+-include ../Makefile.tpl
+
diff --git a/Usermode/Applications/insmod_src/main.c b/Usermode/Applications/insmod_src/main.c
new file mode 100644 (file)
index 0000000..78ad0a9
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Acess2 OS Userland - insmod
+ * - By John Hodge (thePowersGang)
+ *
+ * main.c
+ * - Core
+ */
+#include <stdio.h>
+#include <errno.h>
+#include <acess/sys.h>
+
+#define MODDIR "/Acess/Modules/"
+
+// === CODE ===
+void Usage(const char *progname)
+{
+       fprintf(stderr, "Usage: %s <module>\n", progname);
+}
+
+
+int main(int argc, char *argv[])
+{
+       if( argc != 2 ) {
+               Usage(argv[0]);
+               return 1;
+       }
+
+       const char *modname = argv[1];
+       
+       char path[strlen(MODDIR)+strlen(modname)+1];
+       strcpy(path, MODDIR);
+       strcat(path, modname);
+       
+       int rv = _SysLoadModule(path);
+       if( rv )
+       {
+               fprintf(stderr, "_SysLoadModule(\"%s\"): %s\n", path, strerror(rv));
+       }
+       else {
+               printf("Loaded module '%s'\n", path);
+       }
+
+       return 0;
+}

UCC git Repository :: git.ucc.asn.au