ref: c0662c5330449e43f4a1f10c2d440d9bf60a6f4a
parent: 715570c24e89cea414feb181be3aee65df1ceec5
author: cinap_lenrek <cinap_lenrek@localhost>
date: Fri Apr 15 01:21:21 EDT 2011
hacked libdisk/proto to support skipping file names (.dummy) and setting uid/gid recursively (this solves issue #13). moved cdproto to /sys/lib/sysconfig/proto and added glendas mbox.
--- a/sys/lib/dist/mkfile
+++ b/sys/lib/dist/mkfile
@@ -1,7 +1,7 @@
cd:V: /tmp/9front.iso
-%.iso: pc/cdproto pc/plan9.ini.cd
+%.iso: pc/plan9.ini.cd
bind pc/plan9.ini.cd /n/src9/cfg/plan9.ini
- disk/mk9660 -9cj -B 386/9bootiso -p pc/cdproto -s /n/src9 -v 'Plan 9 Front' $target
+ disk/mk9660 -9cj -B 386/9bootiso -p /n/src9/sys/lib/sysconfig/proto/cdproto -s /n/src9 -v 'Plan 9 Front' $target
unmount /n/src9/cfg/plan9.ini
--- a/sys/lib/dist/pc/cdproto
+++ /dev/null
@@ -1,120 +1,0 @@
-adm
- timezone
- *
-cfg
- +
-fd
-lib
- +
-rc
- +
- box
- faxoutqueue
- faxqueue
- fs
- grey
- lib
- *
- queue
- tmp
-$cputype
- +
-acme
- acid
- *
- $cputype
- *
- bin
- *
- $cputype
- *
- *
- $cputype
- *
- news
- *
- wiki
- *
-mnt
- acme
- apeselect
- apm
- cd
- cons
- cons
- consctl
- consoles
- doc
- exportfs
- *
- keys
- lp
- netkeys
- news
- plumb
- rdb
- temp
- term
- ums
- vmware
- web
- webcookies
- wiki
- wrap
- wsys
-n
-sys
- games
- +
- include
- +
- lib
- +
- log
- cs 666 sys sys /dev/null
- dns 666 sys sys /dev/null
- mail 666 sys sys /dev/null
- smtp 666 sys sys /dev/null
- smtpd 666 sys sys /dev/null
- listen 666 sys sys /dev/null
- ipboot 666 sys sys /dev/null
- man
- fonts
- 1pub
- *
- 1
- *
- 2
- *
- 3
- *
- 4
- *
- 5
- *
- 6
- *
- 7
- *
- 8
- *
- src
- +
-tmp
-usr
- glenda
- bin
- 386
- +
- rc
- +
- lib
- *
- tmp
-
-LICENSE
-LICENSE.afpl
-LICENSE.gpl
-NOTICE
--- /dev/null
+++ b/sys/lib/sysconfig/proto/cdproto
@@ -1,0 +1,106 @@
+skip=.dummy
+uid=sys
+gid=sys
+adm d775 adm adm
+ uid=adm
+ gid=adm
+ timezone d775
+ *
+cfg d775
+ +
+fd d775
+lib d775
+ +
+rc d775
+ +
+mail d775 upas upas
+ uid=upas
+ gid=upas
+ box d775
+ glenda d775 glenda glenda
+ mbox a662 glenda glenda
+ faxoutqueue d777
+ faxqueue d777
+ fs d555
+ grey d775
+ lib d775
+ *
+ queue d777
+ tmp d777
+$cputype d775
+ +
+acme d775
+ +
+mnt d775
+ acme d555
+ apeselect d555
+ apm d555
+ cd d555
+ cons d555
+ cons d555
+ consctl d555
+ consoles d555
+ doc d555
+ exportfs d555
+ *
+ keys d555
+ lp d555
+ netkeys d555
+ news d555
+ plumb d555
+ rdb d555
+ temp d555
+ term d555
+ ums d555
+ vmware d555
+ web d555
+ webcookies d555
+ wiki d555
+ wrap d555
+ wsys d555
+n d775
+sys d775
+ games
+ +
+ include
+ +
+ lib
+ +
+ log
+ man
+ fonts
+ 1
+ *
+ 2
+ *
+ 3
+ *
+ 4
+ *
+ 5
+ *
+ 6
+ *
+ 7
+ *
+ 8
+ *
+ src
+ +
+tmp d555
+usr d775
+ glenda d775 glenda glenda
+ uid=glenda
+ gid=glenda
+ bin d775
+ 386 d775
+ +
+ rc d775
+ +
+ lib d775
+ *
+ tmp d775
+LICENSE 444
+LICENSE.afpl 444
+LICENSE.gpl 444
+NOTICE 444
--- a/sys/src/libdisk/proto.c
+++ b/sys/src/libdisk/proto.c
@@ -29,6 +29,15 @@
char *s;
};
+typedef struct Opt Opt;
+struct Opt {
+ int level;
+ char *skip;
+ char *uid;
+ char *gid;
+ Opt *prev;
+};
+
typedef struct Mkaux Mkaux;
struct Mkaux {
Mkfserr *warn;
@@ -43,6 +52,8 @@
int lineno;
int indent;
+ Opt *opt;
+
void *a;
};
@@ -60,6 +71,7 @@
static void setnames(Mkaux*, File*);
static void skipdir(Mkaux*);
static void warn(Mkaux*, char *, ...);
+static void popopt(Mkaux *mkaux);
//static void
//mprint(char *new, char *old, Dir *d, void*)
@@ -86,6 +98,7 @@
m->proto = proto;
m->lineno = 0;
m->indent = 0;
+ m->opt = nil;
if((m->b = Bopen(proto, OREAD)) == nil) {
werrstr("open '%s': %r", proto);
return -1;
@@ -102,6 +115,8 @@
rv = -1;
free(m->oldfile.s);
free(m->fullname.s);
+ m->indent = -1;
+ popopt(m);
return rv;
}
@@ -169,10 +184,12 @@
warn(mkaux, "can't open %s: %r", mkaux->oldfile.s);
return;
}
-
child = *me;
while((n = dirread(fd, &d)) > 0){
for(i = 0; i < n; i++){
+ if(mkaux->opt && mkaux->opt->skip)
+ if(strstr(d[i].name, mkaux->opt->skip))
+ continue;
child.new = mkpath(mkaux, me->new, d[i].name);
if(me->old)
child.old = mkpath(mkaux, me->old, d[i].name);
@@ -216,7 +233,7 @@
name->s = emalloc(mkaux, l+SLOP);
name->n = l+SLOP;
}
- snprint(name->s, name->n, "%s%s%s", s1, s1[0]==0 || s1[strlen(s1)-1]!='/' ? "/" : "", s2);
+ snprint(name->s, name->n, "%s%s%s", s1, *s1==0 || s1[strlen(s1)-1]!='/' ? "/" : "", s2);
}
static int
@@ -223,6 +240,7 @@
copyfile(Mkaux *mkaux, File *f, Dir *d, int permonly)
{
Dir *nd;
+ Opt *o;
ulong xmode;
char *p;
@@ -240,10 +258,15 @@
xmode = (d->mode >> 6) & 7;
d->mode |= xmode | (xmode << 3);
}
+ o = mkaux->opt;
if(strcmp(f->uid, "-") != 0)
d->uid = f->uid;
+ else if(o && o->uid)
+ d->uid = o->uid;
if(strcmp(f->gid, "-") != 0)
d->gid = f->gid;
+ else if(o && o->gid)
+ d->gid = o->gid;
if(f->mode != ~0){
if(permonly)
d->mode = (d->mode & ~0666) | (f->mode & 0666);
@@ -257,7 +280,6 @@
d->name = p+1;
else
d->name = f->new;
-
mkaux->mkenum(f->new, mkaux->fullname.s, d, mkaux->a);
xmode = d->mode;
free(nd);
@@ -292,6 +314,59 @@
}
static void
+setopt(Mkaux *mkaux, char *key, char *val)
+{
+ Opt *o;
+
+ o = mkaux->opt;
+ if(o == nil || mkaux->indent > o->level){
+ o = emalloc(mkaux, sizeof(*o));
+ if(o == nil)
+ longjmp(mkaux->jmp, 1);
+ if(mkaux->opt){
+ *o = *mkaux->opt;
+ if(o->skip)
+ o->skip = estrdup(mkaux, o->skip);
+ if(o->uid)
+ o->uid = estrdup(mkaux, o->uid);
+ if(o->gid)
+ o->gid = estrdup(mkaux, o->gid);
+ }else
+ memset(o, 0, sizeof(*o));
+ o->level = mkaux->indent;
+ o->prev = mkaux->opt;
+ mkaux->opt = o;
+ } else if(mkaux->indent < o->level)
+ return;
+ if(strcmp(key, "skip") == 0){
+ free(o->skip);
+ o->skip = *val ? estrdup(mkaux, val) : nil;
+ } else if(strcmp(key, "uid") == 0){
+ free(o->uid);
+ o->uid = *val ? estrdup(mkaux, val) : nil;
+ } else if(strcmp(key, "gid") == 0){
+ free(o->gid);
+ o->gid = *val ? estrdup(mkaux, val) : nil;
+ }
+}
+
+static void
+popopt(Mkaux *mkaux)
+{
+ Opt *o;
+
+ while(o = mkaux->opt){
+ if(o->level <= mkaux->indent)
+ break;
+ mkaux->opt = o->prev;
+ free(o->skip);
+ free(o->uid);
+ free(o->gid);
+ free(o);
+ }
+}
+
+static void
freefile(File *f)
{
if(f->old)
@@ -330,6 +405,7 @@
else
break;
if(mkaux->indent <= level){
+ popopt(mkaux);
Bseek(mkaux->b, -Blinelen(mkaux->b), 1);
mkaux->lineno--;
return;
@@ -342,7 +418,7 @@
{
File *f;
char *elem;
- char *p;
+ char *p, *s;
int c;
if(mkaux->indent < 0)
@@ -365,6 +441,14 @@
if(c == '\n' || c == '#')
goto loop;
p--;
+ popopt(mkaux);
+ *strchr(p, '\n') = 0;
+ if(s = strchr(p, '=')){
+ *s++ = 0;
+ setopt(mkaux, p, s);
+ goto loop;
+ }else
+ p[strlen(p)] = '\n';
f = emalloc(mkaux, sizeof *f);
p = getname(mkaux, p, &elem);
if(p == nil)