Trying to reduce the ability for a fork bomb to fault the kernel
[tpg/acess2.git] / Usermode / Applications / init_src / main.c
index 5005708..a88af9f 100644 (file)
@@ -2,12 +2,53 @@
  * Acess2 System Init Task
  */
 #include <acess/sys.h>
+#include <stdlib.h>
+#include <stdio.h>
+//#include <spiderscript.h>
+//#include "common.h"
 
 // === CONSTANTS ===
 #define NULL   ((void*)0)
 #define NUM_TERMS      4
 #define        DEFAULT_TERMINAL        "/Devices/VTerm/0"
 #define DEFAULT_SHELL  "/Acess/SBin/login"
+#define DEFAULT_SCRIPT "/Acess/Conf/BootConf.isc"
+
+#define ARRAY_SIZE(x)  ((sizeof(x))/(sizeof((x)[0])))
+
+// === PROTOTYPES ===
+/*
+tSpiderVariable        *Script_System_IO_Open(tSpiderScript *, int, tSpiderVariable *);
+*/
+
+// === GLOBALS ===
+/*
+tSpiderFunction        gaScriptNS_IO_Fcns[] = {
+       {"Open", Script_System_IO_Open}
+};
+tSpiderNamespace       gaScriptNS_System[] = {
+       {
+               "IO",
+               0, NULL,
+               ARRAY_SIZE(gaScriptNS_IO_Fcns), gaScriptNS_IO_Fcns,
+               0, NULL
+       }
+};
+
+tSpiderNamespace       gaScriptNamespaces[] = {
+       {
+               "System",
+               ARRAY_SIZE(gaScriptNS_System), gaScriptNS_System,
+               0, NULL,
+               0, NULL
+       }
+};
+
+tSpiderVariant gScriptVariant = {
+       "init", 0,
+       ARRAY_SIZE(gaScriptNamespaces), gaScriptNamespaces
+};
+*/
 
 // === CODE ===
 /**
@@ -21,6 +62,9 @@ int main(int argc, char *argv[])
        char    termpath[sizeof(DEFAULT_TERMINAL)] = DEFAULT_TERMINAL;
        char    *child_argv[2] = {DEFAULT_SHELL, 0};
        
+       // - Parse init script
+       
+       // - Start virtual terminals
        for( i = 0; i < NUM_TERMS; i++ )
        {               
                tid = clone(CLONE_VM, 0);
@@ -28,8 +72,6 @@ int main(int argc, char *argv[])
                {
                        termpath[sizeof(DEFAULT_TERMINAL)-2] = '0' + i;
                        
-                       //__asm__ __volatile__ ("int $0xAC" :: "a" (256), "b" ("%s"), "c" (termpath));
-                       
                        open(termpath, OPENFLAG_READ);  // Stdin
                        open(termpath, OPENFLAG_WRITE); // Stdout
                        open(termpath, OPENFLAG_WRITE); // Stderr
@@ -43,3 +85,27 @@ int main(int argc, char *argv[])
        
        return 42;
 }
+
+/**
+ * \brief Reads and parses the boot configuration script
+ * \param Filename     File to parse and execute
+ */
+void ExecuteScript(const char *Filename)
+{
+       /*
+       tSpiderScript   *script;
+       script = SpiderScript_ParseFile(&gScriptVariant, Filename);
+       SpiderScript_ExecuteMethod(script, "");
+       SpiderScript_Free(script);
+       */
+}
+
+/**
+ * \brief Open a file
+ */
+/*
+tSpiderVariable        *Script_System_IO_Open(tSpiderScript *Script, int NArgs, tSpiderVariable *Args)
+{
+       return NULL;
+}
+*/

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