hlfw.ca

drawcpu

Download patch

ref: f254007bc5c57ebdf91986a3093fa496954bc28a
parent: 9b8e21a6669c6312809b174220fca59728cbb68b
author: halfwit <michaelmisch1985@gmail.com>
date: Tue Aug 6 15:38:17 PDT 2024

Take out rc

--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,6 @@
 
 LIBS1=\
 	kern/libkern.a\
-	rc/librc.a\
 	libip/libip.a\
 	libmemdraw/libmemdraw.a\
 	libmemlayer/libmemlayer.a\
@@ -49,9 +48,6 @@
 
 libc/libc.a:
 	(cd libc; $(MAKE))
-
-rc/librc.a:
-	(cd rc; $(MAKE))
 
 gui-$(GUI)/libgui.a:
 	(cd gui-$(GUI); $(MAKE))
--- a/TODO
+++ b/TODO
@@ -1,8 +1,8 @@
 TODO:
  - [ ] Look into args address space prior to hitting exec
  - [ ] /env/fn# to init functions?
- - [ ] set up initial connection before handing over to an rc session, to set up binds and mounts
- - [ ] Import our $objtype/bin and /rc from 9front instead of builtins, -f $9filesys
+ - [ ] set up initial connection before handing over to an rc session, to set up binds and mounts?
+ - [ ] Import our $objtype/bin and /rc from 9front instead of builtins, -f $9root
  - [x] remove rc builtins, possibly add os() as it uses devcmd locally, if needed
  - [ ] Adapt github.com/michaelforney/nine to load and execute our binaries (exec)
  - [x] start.s in libmachdep for each posix-target, just do like tas.c
@@ -17,6 +17,7 @@
  - [x] Makefile librc --> librc.a
  - [ ] RFREND + RFNOMEM could probably be handled in rfork
 
+Remove our rc, just add in all of our syscall intercepts properly.
 Kernel space needs:
  - devdraw  - #i: !needed, We use the client exported /dev/draw instead
  - devkbd   - #b: !needed, We use the client exported /dev/kbd instead
--- a/drawcpu.h
+++ b/drawcpu.h
@@ -1,5 +1,3 @@
-extern void runcommand(int, char**, int);
 extern char *getuser(void);
-extern int session(void);
 extern int aanclient(char*, int);
 extern int dbg;
\ No newline at end of file
--- a/kern/sysproc.c
+++ b/kern/sysproc.c
@@ -140,7 +140,6 @@
 		if(a < KZERO)
 			validaddr(a, 1, 0);
 	}
-print(" returning\n");
 	/* fits in one page */
 	return memchr((void*)a, c, i);
 }
--- a/main.c
+++ b/main.c
@@ -42,7 +42,6 @@
 main(int argc, char **argv)
 {
 	extern ulong kerndate;
-	int ifd, ofd,efd, dfd;
 	kerndate = seconds();
 	eve = getuser();
 	if(eve == nil)
@@ -67,29 +66,15 @@
 	if(bind("#U", "/root", MREPL|MCREATE) < 0)
 		panic("bind #U: %r");
 	bind("#C", "/", MAFTER);
-	//bind("#F", "/fd", MBEFORE)
+	//bind("#F", "/fd", MBEFORE);
+	//bind("#P", "/proc", MBEFORE);
 
-	/* We have to be a bit pedantic about the fds, leave 0, 1, 2 alone */
-	ifd = open("/dev/null", OREAD);
-	ofd = open("/dev/null", OWRITE);
-	efd = open("/dev/null", OWRITE);
-	if(argc == 2 && strcmp(argv[1], "-D") == 0)
-		dfd = create("/Users/halfwit/Work/drawcpu/error.log", OWRITE, 0644);
-	else
-		dfd = open("/dev/null", OWRITE);
-	close(ifd);
-	close(ofd);
-	close(efd);
-
-	char *cmd[] = {
-		"drawcpu",
-		"-c"
-		". <{n=`{read} && ! ~ $#n 0 && read -c $n} >[2=1]"	
-	};
-
 	if(bind("/root", "/", MAFTER) < 0)
 		panic("bind /root: %r");
-	
-	runcommand(3, cmd, dfd);
-	_exit(0);
+
+	// Flag in $nine for our binary paths
+	// bind in our $nine/$objtype/bin and $nine/rc/bin
+	// Maybe even rfork, wouldn't that be nice. Wouldn't that be quaint
+
+	execvp(argv[0], argv);
 }