The following is a little patch to 9vx which uses getenv to read the
environmental variable PLAN9 to set "plan 9 root" on startup if it has not
been overloaded on the command line or in the CWD. I would enjoy any feedback.
Best regards,
EBo --
=====================================================================
diff -r 8184025094f4 src/9vx/main.c
--- a/src/9vx/main.c Mon Oct 05 02:53:41 2009 -0400
+++ b/src/9vx/main.c Sun Apr 11 11:59:03 2010 -0500
@@ -10,6 +10,8 @@
#include "u.h"
#include "libvx32/vx32.h"
+#include <stdlib.h>
+#include <string.h>
#include <sys/mman.h>
#include <signal.h>
#include <pwd.h>
@@ -224,12 +226,13 @@
findroot(void)
{
static char cwd[1024];
+ static char plan9[1024];
int i;
char buf[1024];
char *dir[] = {
cwd,
- "/Users/rsc/9vx",
- "/home/rsc/plan9/4e"
+ plan9,
+ "/usr/local/plan9"
};
if(getcwd(cwd, sizeof cwd) == nil){
@@ -237,6 +240,9 @@
panic("getcwd: %r");
}
+ if(getenv("PLAN9") != nil)
+ strncpy(plan9, getenv("PLAN9"), sizeof plan9);
+
for(i=0; i<nelem(dir); i++){
snprint(buf, sizeof buf, "%s/386/bin/rc", dir[i]);
if(access(buf, 0) >= 0)