Browse Source

rc: use some uppercase variables (PATH, USER...)

master
Giacomo Tesio 5 years ago
parent
commit
9202b04504
  1. 2
      arch/rc/aux/rio/window
  2. 2
      arch/rc/aux/rio/wloc
  3. 6
      arch/rc/cmd/diskparts
  4. 2
      arch/rc/cmd/psu
  5. 28
      arch/rc/lib/rcmain
  6. 20
      arch/rc/lib/startup/cpu
  7. 14
      arch/rc/lib/startup/terminal
  8. 20
      cfg/startup
  9. 10
      lib/namespace
  10. 4
      qa/check
  11. 12
      qa/kern/args.rc
  12. 2
      qa/kern/wdir.rc
  13. 24
      sys/include/envvars.h
  14. 12
      sys/src/cmd/acme/exec.c
  15. 4
      sys/src/cmd/acme/rows.c
  16. 4
      sys/src/cmd/auth/newns.c
  17. 1
      sys/src/cmd/auth/secstore/secstore.c
  18. 34
      sys/src/cmd/init.c
  19. 2
      sys/src/cmd/ip/listen.c
  20. 2
      sys/src/cmd/rc/simple.c
  21. 2
      sys/src/cmd/stats.c
  22. 2
      sys/src/kern/amd64/main.c
  23. 2
      sys/src/kern/boot/boot.c
  24. 2
      sys/src/kern/boot/createInitRD
  25. 12
      sys/src/lib/mp/port/reduce
  26. 12
      sys/src/lib/sec/port/reduce

2
arch/rc/aux/rio/window

@ -53,7 +53,7 @@ fn getwctl{
if(~ $wctl ''){
if(test -f /dev/wctl) echo /dev/wctl
if not if(test -f /mnt/term/dev/wctl) echo /mnt/term/dev/wctl
if not if(~ $service cpu) echo /mnt/term/srv/riowctl.*.*
if not if(~ $SERVICE cpu) echo /mnt/term/srv/riowctl.*.*
if not {
echo window: '$wctl' not defined >[1=2]
exit usage

2
arch/rc/aux/rio/wloc

@ -1,7 +1,7 @@
#!/cmd/rc
rfork e
ifs='
IFS='
'
for(i in `{ls /dev/wsys}) {

6
arch/rc/cmd/diskparts

@ -31,9 +31,9 @@ if(~ $#* 0){
# set up any fs(3) partitions
if (! test -e /dev/fs/ctl && test -e '#k/fs')
bind -b '#k' /dev
if (~ $#sysname 1 && ! ~ $sysname '' &&
test -r /cfg/$sysname/fsconfig && test -w /dev/fs/ctl)
awk '{print $0; fflush}' /cfg/$sysname/fsconfig >/dev/fs/ctl
if (~ $#SYSNAME 1 && ! ~ $SYSNAME '' &&
test -r /cfg/$SYSNAME/fsconfig && test -w /dev/fs/ctl)
awk '{print $0; fflush}' /cfg/$SYSNAME/fsconfig >/dev/fs/ctl
}
if not {
for(disk) {

2
arch/rc/cmd/psu

@ -11,7 +11,7 @@ while (! ~ $#* 0 && ~ $1 -*) {
# this is a huge difference in drawterm.
switch($#*){
case 0
ps $flags | sed -n '/^'$user' /p'
ps $flags | sed -n '/^'$USER' /p'
case 1
ps $flags | sed -n '/^'$1' /p'
case *

28
arch/rc/lib/rcmain

@ -1,34 +1,34 @@
# rcmain: Plan 9 version
if(~ $#home 0) home=/
if(~ $#ifs 0) ifs='
if(~ $#HOME 0) HOME=/
if(~ $#IFS 0) IFS='
'
switch($#prompt){
switch($#PROMPT){
case 0
prompt=('% ' ' ')
PROMPT=('% ' ' ')
case 1
prompt=($prompt ' ')
PROMPT=($PROMPT ' ')
}
if(~ $rcname ?.out) prompt=('broken! ' ' ')
if(flag p) path=/cmd
if(~ $rcname ?.out) PROMPT=('broken! ' ' ')
if(flag p) PATH=/cmd
if not{
finit
if(~ $#path 0) path=(/cmd .)
if(~ $#PATH 0) PATH=(/cmd .)
}
fn sigexit
if(! ~ $#rccmd 0){
if(flag l && /cmd/test -r $home/lib/profile) . $home/lib/profile
status=''
if(flag l && /cmd/test -r $HOME/lib/profile) . $HOME/lib/profile
STATUS=''
eval $rccmd
}
if not if(flag i){
if(flag l && /cmd/test -r $home/lib/profile) . $home/lib/profile
status=''
if(flag l && /cmd/test -r $HOME/lib/profile) . $HOME/lib/profile
STATUS=''
if(! ~ $#* 0) . $*
. -i '#d/0'
}
if not if(~ $#* 0) . '#d/0'
if not{
status=''
STATUS=''
. $*
}
exit $status
exit $STATUS

20
arch/rc/lib/startup/cpu

@ -7,7 +7,7 @@ mntgen -s slashn && chmod 666 /srv/slashn
# name translation, cs sets /dev/sysname
ndb/cs
sysname=`{cat /dev/sysname}
SYSNAME=`{cat /dev/sysname}
# parallelism for mk
NPROC = `{wc -l </dev/sysstat}
@ -16,15 +16,15 @@ NPROC = `{wc -l </dev/sysstat}
if(test -e /arch/rc/cmd/cpurc.local)
. /arch/rc/cmd/cpurc.local
if (~ $#sysname 0 || ~ $sysname '') {
sysname = jehanne # default
echo -n $sysname >/dev/sysname
if (~ $#SYSNAME 0 || ~ $SYSNAME '') {
SYSNAME = jehanne # default
echo -n $SYSNAME >/dev/sysname
}
prompt=($sysname^'# ' ' ')
PROMPT=($SYSNAME^'# ' ' ')
# cpu-specific startup
if(test -e /cfg/$sysname/cpurc)
. /cfg/$sysname/cpurc
if(test -e /cfg/$SYSNAME/cpurc)
. /cfg/$SYSNAME/cpurc
# start up internet if we don't already have an address
if(! grep u /net/ipselftab | grep -sv 127.0.0.1)
@ -69,8 +69,8 @@ if(! netstat -n | grep -s 'tcp.*Listen.* (7|9|21|22|23|25|110|113|565|993|17007|
#}
# cpu-specific late startup
if(test -e /cfg/$sysname/cpustart)
. /cfg/$sysname/cpustart
if(test -e /cfg/$SYSNAME/cpustart)
. /cfg/$SYSNAME/cpustart
# mode of /proc/*/ctl is inherited across rfork, and sets modes on
# other /proc files, such as note, so let listen be killed.
@ -83,5 +83,5 @@ if(test ! -e '#s/comconsole')
echo 'key proto=p9sk1 dom=jehanne user=glenda !password=demodemo' >/mnt/factotum/ctl
ip/listen1 -t tcp!*!17010 /cmd/cpu -R &
# echo `{date} $sysname >>/sys/log/boot
# echo `{date} $SYSNAME >>/sys/log/boot
exit ''

14
arch/rc/lib/startup/terminal

@ -27,15 +27,15 @@ if(test -e /arch/rc/cmd/termrc.local)
# cs sets sysname (termrc.local may already have started it so check)
if(! test -e /srv/cs && ! test -e /net/cs)
ndb/cs -f $NDBFILE
sysname=`{cat /dev/sysname}
if (~ $#sysname 0 || ~ $sysname '') {
sysname = jehanne # default
echo -n $sysname >/dev/sysname
SYSNAME=`{cat /dev/sysname}
if (~ $#SYSNAME 0 || ~ $SYSNAME '') {
SYSNAME = jehanne # default
echo -n $SYSNAME >/dev/sysname
}
# machine specific startup (e.g., for devices not probed)
if(test -e /cfg/$sysname/termrc)
. /cfg/$sysname/termrc
if(test -e /cfg/$SYSNAME/termrc)
. /cfg/$SYSNAME/termrc
# start IP on the LAN, if not already configured. diskless terminals
# are already configured by now. It's commented out to avoid a long timeout
@ -46,7 +46,7 @@ if(test -e /cfg/$sysname/termrc)
#if(! test -e /net/ipifc/0/ctl)
# ip/ipconfig
#
# Otherwise, see /cfg/$sysname/termrc (/cfg/example/termrc is an example).
# Otherwise, see /cfg/$SYSNAME/termrc (/cfg/example/termrc is an example).
# start dns if we have an internet
if(test -e /net/ipifc/0/ctl && ! test -e /srv/dns)

20
cfg/startup

@ -7,7 +7,7 @@ mntgen -s slashn && chmod 666 /srv/slashn
# name translation, cs sets /dev/sysname
ndb/cs
sysname=`{cat /dev/sysname}
SYSNAME=`{cat /dev/sysname}
# parallelism for mk
NPROC = `{wc -l </dev/sysstat}
@ -16,15 +16,15 @@ NPROC = `{wc -l </dev/sysstat}
if(test -e /arch/rc/cmd/cpurc.local)
. /arch/rc/cmd/cpurc.local
if (~ $#sysname 0 || ~ $sysname '') {
sysname = jehanne # default
echo -n $sysname >/dev/sysname
if (~ $#SYSNAME 0 || ~ $SYSNAME '') {
SYSNAME = jehanne # default
echo -n $SYSNAME >/dev/sysname
}
prompt=($sysname^'# ' ' ')
PROMPT=($SYSNAME^'# ' ' ')
# cpu-specific startup
if(test -e /cfg/$sysname/cpurc)
. /cfg/$sysname/cpurc
if(test -e /cfg/$SYSNAME/cpurc)
. /cfg/$SYSNAME/cpurc
# start up internet if we don't already have an address
if(! grep u /net/ipselftab | grep -sv 127.0.0.1)
@ -69,8 +69,8 @@ if(! netstat -n | grep -s 'tcp.*Listen.* (7|9|21|22|23|25|110|113|565|993|17007|
#}
# cpu-specific late startup
if(test -e /cfg/$sysname/cpustart)
. /cfg/$sysname/cpustart
if(test -e /cfg/$SYSNAME/cpustart)
. /cfg/$SYSNAME/cpustart
# mode of /proc/*/ctl is inherited across rfork, and sets modes on
# other /proc files, such as note, so let listen be killed.
@ -83,5 +83,5 @@ if(test ! -e '#s/comconsole')
echo 'key proto=p9sk1 dom=jehanne user=glenda !password=demodemo' >/mnt/factotum/ctl
ip/listen1 -t tcp!*!17010 /cmd/cpu -R &
# echo `{date} $sysname >>/sys/log/boot
# echo `{date} $SYSNAME >>/sys/log/boot
exit ''

10
lib/namespace

@ -29,7 +29,7 @@ mount -a /boot /cmd
mount -a /srv/factotum /mnt
# standard bin
bind /arch/$cputype/cmd /cmd
bind /arch/$CPUTYPE/cmd /cmd
bind -a /arch/rc/cmd /cmd
# internal networks
@ -42,9 +42,9 @@ mount -a /srv/net /net
mount -b /srv/ssh /net
bind -c /usr/$user/tmp /tmp
cd /usr/$user
bind -c /usr/$USER/tmp /tmp
cd /usr/$USER
. /lib/namespace.local
. /lib/namespace.$sysname
. /cfg/$sysname/namespace
. /lib/namespace.$SYSNAME
. /cfg/$SYSNAME/namespace

4
qa/check

@ -6,7 +6,7 @@ dir=$1
if(~ $dir '') dir=/qa
l = `{du -a /arch/$objtype/$dir|awk '{print $2}'|sort}
l = `{du -a /arch/$OBJTYPE/$dir|awk '{print $2}'|sort}
failed = ()
runner=.runner
@ -17,7 +17,7 @@ for(t in $l){
if not {
echo -n $t:
$t > /tmp/qa.log >[2=1]
st = $status
st = $STATUS
switch( `{echo $st|field 3} ){
case PASS
rm /tmp/qa.log && echo PASS

12
qa/kern/args.rc

@ -3,27 +3,27 @@
# verify that rc scripts get the correct arguments
/qa/kern/args.rc.0 a b c
a0=`{echo $status|awk '{print $3}'}
a0=`{echo $STATUS|awk '{print $3}'}
a0=$"a0 #"
/qa/kern/args.rc.1 a b c
a1=`{echo $status|awk '{print $3}'}
a1=`{echo $STATUS|awk '{print $3}'}
a1=$"a1 #"
/qa/kern/args.rc.2 a b c
a2=`{echo $status|awk '{print $3}'}
a2=`{echo $STATUS|awk '{print $3}'}
a2=$"a2 #"
/qa/kern/args.rc.0
b0=`{echo $status|awk '{print $3}'}
b0=`{echo $STATUS|awk '{print $3}'}
b0=$"b0 #"
/qa/kern/args.rc.1
b1=`{echo $status|awk '{print $3}'}
b1=`{echo $STATUS|awk '{print $3}'}
b1=$"b1 #"
/qa/kern/args.rc.2
b2=`{echo $status|awk '{print $3}'}
b2=`{echo $STATUS|awk '{print $3}'}
b2=$"b2 #"
if (test -z $a0 || ! ~ $a0 /qa/kern/args.rc.0) {

2
qa/kern/wdir.rc

@ -20,7 +20,7 @@ if ( ! ~ $dir $cwd ) {
exit FAIL
}
ppath=/proc/$pid/wdir
ppath=/proc/$PID/wdir
cwd=`{cat $ppath}
if ( ! ~ $dir $cwd ) {

24
sys/include/envvars.h

@ -25,18 +25,18 @@
*/
#define ENV_APID "APID"
#define ENV_USER "user"
#define ENV_HOME "home"
#define ENV_IFS "ifs"
#define ENV_PATH "path"
#define ENV_PID "pid"
#define ENV_PROMPT "prompt"
#define ENV_STATUS "status"
#define ENV_CDPATH "cdpath"
#define ENV_CPUTYPE "cputype"
#define ENV_SERVICE "service"
#define ENV_SYSNAME "sysname"
#define ENV_OBJTYPE "objtype"
#define ENV_USER "USER"
#define ENV_HOME "HOME"
#define ENV_IFS "IFS"
#define ENV_PATH "PATH"
#define ENV_PID "PID"
#define ENV_PROMPT "PROMPT"
#define ENV_STATUS "STATUS"
#define ENV_CDPATH "CDPATH"
#define ENV_CPUTYPE "CPUTYPE"
#define ENV_SERVICE "SERVICE"
#define ENV_SYSNAME "SYSNAME"
#define ENV_OBJTYPE "OBJTYPE"
#define ENV_WSYS "wsys"

12
sys/src/cmd/acme/exec.c

@ -1368,19 +1368,19 @@ runproc(void *argvp)
Hard:
/*
* ugly: set path = (. $cputype /cmd)
* should honor $path if unusual.
* ugly: set PATH = (/cmd . $CPUTYPE)
* should honor $PATH if unusual.
*/
if(cputype){
n = 0;
memmove(buf+n, ".", 2);
memmove(buf+n, "/cmd:", 5);
n += 5;
memmove(buf+n, ".:", 2);
n += 2;
i = strlen(cputype)+1;
memmove(buf+n, cputype, i);
n += i;
memmove(buf+n, "/cmd", 5);
n += 5;
fd = ocreate("/env/path", OWRITE, 0666);
fd = ocreate("/env/PATH", OWRITE, 0666);
write(fd, buf, n);
close(fd);
}

4
sys/src/cmd/acme/rows.c

@ -316,7 +316,7 @@ rowdump(Row *row, char *file)
buf = fbufalloc();
if(file == nil){
if(home == nil){
warning(nil, "can't find file for dump: $home not defined\n");
warning(nil, "can't find file for dump: $HOME not defined\n");
goto Rescue;
}
sprint(buf, "%s/acme.dump", home);
@ -498,7 +498,7 @@ rowload(Row *row, char *file, int initing)
buf = fbufalloc();
if(file == nil){
if(home == nil){
warning(nil, "can't find file for load: $home not defined\n");
warning(nil, "can't find file for load: $HOME not defined\n");
goto Rescue1;
}
sprint(buf, "%s/acme.dump", home);

4
sys/src/cmd/auth/newns.c

@ -25,7 +25,7 @@ void
main(int argc, char **argv)
{
extern int newnsdebug;
char *defargv[] = { "/bin/rc", "-i", nil };
char *defargv[] = { "/cmd/rc", "-i", nil };
char *nsfile, err[ERRMAX];
int add;
@ -55,7 +55,7 @@ main(int argc, char **argv)
exec(argv[0], argv);
if(!rooted(argv[0])){
rerrstr(err, sizeof err);
exec(smprint("/bin/%s", argv[0]), argv);
exec(smprint("/cmd/%s", argv[0]), argv);
errstr(err, sizeof err);
}
sysfatal("exec: %s: %r", argv[0]);

1
sys/src/cmd/auth/secstore/secstore.c

@ -2,6 +2,7 @@
#define PORTABLE_SYSCALLS
#include <u.h>
#include <lib9.h>
#include <envvars.h>
#include <mp.h>
#include <libsec.h>
#include <authsrv.h>

34
sys/src/cmd/init.c

@ -1,8 +1,10 @@
#include <u.h>
#include <lib9.h>
#include <envvars.h>
#include <auth.h>
#include <authsrv.h>
char* readfile(char *name);
char* readenv(char*);
void setenv(char*, char*);
void cpenv(char*, char*);
@ -51,12 +53,16 @@ main(int argc, char *argv[])
close(fd);
}
cpu = readenv("#e/cputype");
setenv("#e/objtype", cpu);
setenv("#e/service", service);
cpenv("/cfg/timezone", "#e/timezone");
user = readenv("#c/user");
systemname = readenv("#c/sysname");
cpu = readenv(ENV_CPUTYPE);
setenv(ENV_OBJTYPE, cpu);
setenv(ENV_SERVICE, service);
cpenv("/cfg/timezone", "timezone");
user = readfile("#c/user");
if(user == nil)
user = "*unknown*";
systemname = readfile("#c/sysname");
if(systemname == nil)
systemname = "*unknown*";
newns(user, 0);
iscpu = strcmp(service, "cpu")==0;
@ -155,7 +161,7 @@ rcexec(void)
else if(manual || iscpu){
execl("/cmd/rc", "rc", "-m/arch/rc/lib/rcmain", "-i", nil);
}else if(strcmp(service, "terminal") == 0)
execl("/cmd/rc", "rc", "-c", ". /sys/lib/rc/startup/terminal; home=/usr/$user; cd && . lib/profile", nil);
execl("/cmd/rc", "rc", "-c", ". /sys/lib/rc/startup/terminal; HOME=/usr/$USER; cd && . lib/profile", nil);
else
execl("/cmd/rc", "rc", nil);
}
@ -208,8 +214,10 @@ char*
readenv(char *name)
{
char *val;
char buf[128+4];
val = readfile(name);
snprint(buf, sizeof(buf), "#e/%s", name);
val = readfile(buf);
if(val == nil)
val = "*unknown*";
return val;
@ -219,10 +227,12 @@ void
setenv(char *name, char *val)
{
int fd;
char buf[128+4];
fd = ocreate(name, OWRITE, 0644);
snprint(buf, sizeof(buf), "#e/%s", name);
fd = ocreate(buf, OWRITE, 0644);
if(fd < 0)
fprint(2, "init: can't create %s: %r\n", name);
fprint(2, "init: can't create %s: %r\n", buf);
else{
write(fd, val, strlen(val));
close(fd);
@ -230,13 +240,13 @@ setenv(char *name, char *val)
}
void
cpenv(char *from, char *to)
cpenv(char *from, char *envname)
{
char *val;
val = readfile(from);
if(val != nil){
setenv(to, val);
setenv(envname, val);
free(val);
}
}

2
sys/src/cmd/ip/listen.c

@ -100,7 +100,7 @@ main(int argc, char *argv[])
argv0 = argv[0];
cpu = getenv(ENV_CPUTYPE);
if(cpu == 0)
error("can't get cputype");
error("can't get $CPUTYPE");
ARGBEGIN{
case 'd':

2
sys/src/cmd/rc/simple.c

@ -199,7 +199,7 @@ execcd(void)
pfmt(err, "Can't cd %s: %r\n", a->word);
}
else
pfmt(err, "Can't cd -- $home empty\n");
pfmt(err, "Can't cd -- $HOME empty\n");
break;
}
poplist();

2
sys/src/cmd/stats.c

@ -1239,7 +1239,7 @@ main(int argc, char *argv[])
nmach = 1;
mysysname = getenv(ENV_SYSNAME);
if(mysysname == nil){
fprint(2, "stats: can't find $sysname: %r\n");
fprint(2, "stats: can't find $" ENV_SYSNAME ": %r\n");
exits("sysname");
}

2
sys/src/kern/amd64/main.c

@ -212,7 +212,7 @@ configure_kernel(void)
int i, userpcnt;
unsigned int kpages;
if(p = getconf("service")){
if(p = getconf(ENV_SERVICE)){
if(strcmp(p, "cpu") == 0)
cpuserver = 1;
else if(strcmp(p,"terminal") == 0)

2
sys/src/kern/boot/boot.c

@ -93,7 +93,7 @@ boot(int argc, char *argv[])
fflag = 1;
break;
}ARGEND
readfile("#e/cputype", cputype, sizeof(cputype));
readfile("#e/" ENV_CPUTYPE, cputype, sizeof(cputype));
/*
* set up usb keyboard, mouse and disk, if any.

2
sys/src/kern/boot/createInitRD

@ -3,5 +3,5 @@
cd /sys/src/kern/boot
mkdir -p bootfs
disk/mkfs -s / -d bootfs bootfs.proto
disk/mkrofs -o /arch/$objtype/kern/initrd bootfs
disk/mkrofs -o /arch/$OBJTYPE/kern/initrd bootfs
rm -rf bootfs

12
sys/src/lib/mp/port/reduce

@ -1,16 +1,16 @@
O=$1
shift
objtype=$1
OBJTYPE=$1
shift
ls -p ../$objtype/*.[cs] >[2]/dev/null | sed 's/..$//' > /tmp/reduce.$pid
ls -p ../$OBJTYPE/*.[cs] >[2]/dev/null | sed 's/..$//' > /tmp/reduce.$PID
#
# if empty directory, just return the input files
#
if (! ~ $status '|') {
if (! ~ $STATUS '|') {
echo $*
rm /tmp/reduce.$pid
rm /tmp/reduce.$PID
exit 0
}
echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
rm /tmp/reduce.$pid
echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$PID | tr \012 ' '
rm /tmp/reduce.$PID

12
sys/src/lib/sec/port/reduce

@ -1,16 +1,16 @@
O=$1
shift
objtype=$1
OBJTYPE=$1
shift
ls -p ../$objtype/*.[cs] >[2]/dev/null | sed 's/..$//' > /tmp/reduce.$pid
ls -p ../$OBJTYPE/*.[cs] >[2]/dev/null | sed 's/..$//' > /tmp/reduce.$PID
#
# if empty directory, just return the input files
#
if (! ~ $status '|') {
if (! ~ $STATUS '|') {
echo $*
rm /tmp/reduce.$pid
rm /tmp/reduce.$PID
exit 0
}
echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' '
rm /tmp/reduce.$pid
echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$PID | tr \012 ' '
rm /tmp/reduce.$PID
Loading…
Cancel
Save