From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Sun, 11 Apr 2010 11:06:35 -0600 To: "Fans of the OS Plan 9 from Bell Labs" <9fans@9fans.net> From: "EBo" Message-ID: In-Reply-To: <94f361d12533ee74d9af4827460b357b@ladd.quanstro.net> References: <46914d2c-437d-406e-a928-123f4d09f9f7@u15g2000prd.googlegroups.com> , Subject: [9fans] 9vx patch to read environment var PLAN9 Topicbox-Message-UUID: feceb0c6-ead5-11e9-9d60-3106f5b1d025 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 +#include #include #include #include @@ -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= 0)