History

20080809-2014

forsyth committed 17 years ago

Commit ea36ff61 parent ce0a0c37 files · +157 −183Browse files

Unified · Split

7 files
  1. CHANGES +3 −0
  2. appl/cmd/disk/mkext.b +10 −35
  3. appl/cmd/disk/mkfs.b +47 −93
  4. dis/disk/mkext.dis +0 −0
  5. dis/disk/mkfs.dis +0 −0
  6. include/version.h +1 −1
  7. man/8/mkfs +98 −56
CHANGES+3−0
@@ -1,3 +1,6 @@
120090809
2 bring mkfs(8) up to date (issue 176)
3 remove -q options from mkfs and mkext (-q was a transitional option to suppress quoting of file names)
120090806420090806
2 increase `backlog' value in all listen calls in hosted Inferno (emu/*/ipif*.c) [powerman]5 increase `backlog' value in all listen calls in hosted Inferno (emu/*/ipif*.c) [powerman]
320090805620090805
appl/cmd/disk/mkext.b+10−35
@@ -30,17 +30,10 @@ tflag := 0; · 29 unmodified lines
30hflag := 0;30hflag := 0;
31vflag := 0;31vflag := 0;
32fflag := 0;32fflag := 0;
33qflag := 1;
34stderr: ref Sys->FD;33stderr: ref Sys->FD;
35bout: ref Iobuf;34bout: ref Iobuf;
36argv0 := "mkext";35argv0 := "mkext";
37 36
38usage()
39{
40 fprint(stderr, "Usage: mkext [-h] [-u] [-v] [-f] [-t] [-q] [-d dest-fs] [file ...]\n");
41 raise "fail:usage";
42}
43
44init(nil: ref Draw->Context, args: list of string)37init(nil: ref Draw->Context, args: list of string)
45{38{
46 sys = load Sys Sys->PATH;39 sys = load Sys Sys->PATH;
@@ -59,12 +52,11 @@ init(nil: ref Draw->Context, args: list of string) · 12 unmodified lines
59 52
60 destdir := "";53 destdir := "";
61 arg->init(args);54 arg->init(args);
55 arg->setusage("mkext [-h] [-d destdir] [-T] [-u] [-v] [file ...]");
62 while((c := arg->opt()) != 0)56 while((c := arg->opt()) != 0)
63 case c {57 case c {
64 'd' =>58 'd' =>
65 destdir = arg->arg();59 destdir = arg->earg();
66 if(destdir == nil)
67 error("destination directory name missing");
68 'f' =>60 'f' =>
69 fflag = 1;61 fflag = 1;
70 62
@@ -75,14 +67,13 @@ init(nil: ref Draw->Context, args: list of string) · 4 unmodified lines
75 error(sys->sprint("can't access standard output: %r"));67 error(sys->sprint("can't access standard output: %r"));
76 'u' =>68 'u' =>
77 uflag = 1;69 uflag = 1;
78 't' =>70 tflag = 1;
71 't' or 'T' =>
79 tflag = 1;72 tflag = 1;
80 'v' =>73 'v' =>
81 vflag = 1;74 vflag = 1;
82 'q' =>
83 qflag = 0;
84 * =>75 * =>
85 usage();76 arg->usage();
86 }77 }
87 args = arg->argv();78 args = arg->argv();
88 79
@@ -94,14 +85,8 @@ init(nil: ref Draw->Context, args: list of string) · 5 unmodified lines
94 fprint(stderr, "done\n");85 fprint(stderr, "done\n");
95 quit(nil);86 quit(nil);
96 }87 }
97 fields: list of string;88 fields := str->unquoted(p);
98 nf: int;89 if(len fields != NFLDS){
99 if(qflag){
100 fields = str->unquoted(p);
101 nf = len fields;
102 }else
103 (nf, fields) = sys->tokenize(p, " \t\n");
104 if(nf != NFLDS){
105 warn("too few fields in file header");90 warn("too few fields in file header");
106 continue;91 continue;
107 }92 }
@@ -126,8 +111,8 @@ init(nil: ref Draw->Context, args: list of string) · 18 unmodified lines
126 }111 }
127 name = destdir+name;112 name = destdir+name;
128 if(hflag){113 if(hflag){
129 bout.puts(sys->sprint("%s %s %s %s %ud %bd\n",114 bout.puts(sys->sprint("%q %s %s %s %ud %bd\n",
130 quoted(name), octal(mode), uid, gid, mtime, bytes));115 name, octal(mode), uid, gid, mtime, bytes));
131 if(bytes != big 0)116 if(bytes != big 0)
132 seekpast(bytes);117 seekpast(bytes);
133 continue;118 continue;
@@ -212,7 +197,6 @@ mkdir(name: string, mode: int, mtime: int, uid: string, gid: string) · 78 unmodified lines
212 if(uflag){197 if(uflag){
213 d.uid = uid;198 d.uid = uid;
214 d.gid = gid;199 d.gid = gid;
215 d.mtime = mtime;
216 }200 }
217 d.mode = mode;201 d.mode = mode;
218 if(sys->wstat(name, d) < 0)202 if(sys->wstat(name, d) < 0)
@@ -272,7 +256,7 @@ extract(name: string, mode: int, mtime: int, uid: string, gid: string, bytes: bi · 53 unmodified lines
272 if(p == nil)256 if(p == nil)
273 p = name;257 p = name;
274 d.name = p;258 d.name = p;
275 if(tflag || uflag)259 if(tflag)
276 d.mtime = mtime;260 d.mtime = mtime;
277 if(uflag){261 if(uflag){
278 d.uid = uid;262 d.uid = uid;
@@ -366,12 +350,3 @@ create(name : string, rw : int, mode : int) : ref Sys->FD · 87 unmodified lines
366 }350 }
367 return fd;351 return fd;
368}352}
369
370quoted(s: string): string
371{
372 if(qflag)
373 for(i:=0; i<len s; i++)
374 if((c := s[i]) == ' ' || c == '\t' || c == '\n' || c == '\'')
375 return str->quoted(s :: nil);
376 return s;
377}
appl/cmd/disk/mkfs.b+47−93
@@ -55,7 +55,6 @@ modes: int; · 54 unmodified lines
55ream: int;55ream: int;
56debug: int;56debug: int;
57xflag: int;57xflag: int;
58qflag := 1;
59sfd: ref Sys->FD;58sfd: ref Sys->FD;
60fskind: int; # Kfs, Fs, Archive59fskind: int; # Kfs, Fs, Archive
61user: string;60user: string;
@@ -63,12 +62,6 @@ stderr: ref Sys->FD; · 1 unmodified line
63usrid, grpid : string;62usrid, grpid : string;
64setuid: int;63setuid: int;
65 64
66usage()
67{
68 fprint(stderr, "usage: %s [-apqrvx] [-d root] [-n kfsname] [-s src-fs] [-u userfile] [-z n] proto ...\n", prog);
69 quit("usage");
70}
71
72init(nil: ref Draw->Context, args: list of string)65init(nil: ref Draw->Context, args: list of string)
73{66{
74 sys = load Sys Sys->PATH;67 sys = load Sys Sys->PATH;
@@ -80,7 +73,7 @@ init(nil: ref Draw->Context, args: list of string) · 5 unmodified lines
80 73
81 stderr = sys->fildes(2);74 stderr = sys->fildes(2);
82 if(arg == nil)75 if(arg == nil)
83 error(sys->sprint("can't load %s: %r", Arg->PATH));76 error(sys->sprint("can't load %q: %r", Arg->PATH));
84 77
85 user = getuser();78 user = getuser();
86 if(user == nil)79 if(user == nil)
@@ -95,6 +88,7 @@ init(nil: ref Draw->Context, args: list of string) · 8 unmodified lines
95 users = nil;88 users = nil;
96 fskind = Kfs; # i suspect Inferno default should be different89 fskind = Kfs; # i suspect Inferno default should be different
97 arg->init(args);90 arg->init(args);
91 arg->setusage("mkfs [-aprvxS] [-d root] [-n kfscmdname] [-s src-fs] [-u userfile] [-z n] [-G group] [-U user] proto ...");
98 while((c := arg->opt()) != 0)92 while((c := arg->opt()) != 0)
99 case c {93 case c {
100 'a' =>94 'a' =>
@@ -105,49 +99,52 @@ init(nil: ref Draw->Context, args: list of string) · 4 unmodified lines
105 error(sys->sprint("can't open standard output for archive: %r"));99 error(sys->sprint("can't open standard output for archive: %r"));
106 'd' =>100 'd' =>
107 fskind = Fs;101 fskind = Fs;
108 newroot = reqarg("destination directory (-d)");102 newroot = arg->earg();
109 'D' =>103 'D' =>
110 debug = 1;104 debug = 1;
111 'n' =>105 'n' =>
112 name = reqarg("kfs instance name (-n)");106 name = arg->earg();
113 'p' =>107 'p' =>
114 modes = 1;108 modes = 1;
115 'q' =>109 'q' =>
116 qflag = 0;110 ;
117 'r' =>111 'r' =>
118 ream = 1;112 ream = 1;
119 's' =>113 's' =>
120 oldroot = reqarg("source directory (-d)");114 oldroot = arg->earg();
121 'u' =>115 'u' =>
122 users = reqarg("/adm/users file (-u)");116 users = arg->earg();
123 'v' =>117 'v' =>
124 verb = 1;118 verb = 1;
125 'x' =>119 'x' =>
126 xflag = 1;120 xflag = 1;
127 'z' =>121 'z' =>
128 (buflen, nil) = str->toint(reqarg("buffer length (-z)"), 10);122 (buflen, nil) = str->toint(arg->earg(), 10);
129 buflen -= 8; # qid.path and tag at end of each kfs block123 buflen -= 8; # qid.path and tag at end of each kfs block
130 'U' => 124 'U' =>
131 usrid = reqarg("user name (-U)");125 usrid = arg->earg();
132 'G' =>126 'G' =>
133 grpid = reqarg("group name (-G)");127 grpid = arg->earg();
134 'S' =>128 'S' =>
135 setuid = 1;129 setuid = 1;
136 * =>130 * =>
137 usage();131 arg->usage();
138 }132 }
139 133
140 args = arg->argv();134 args = arg->argv();
141 if(args == nil)135 if(args == nil)
142 usage();136 arg->usage();
143 137
144 buf = array [buflen] of byte;138 buf = array [buflen] of byte;
145 zbuf = array [buflen] of { * => byte 0 };139 zbuf = array [buflen] of { * => byte 0 };
146 140
147 mountkfs(name);141 if(name != nil)
142 openkfscmd(name);
148 kfscmd("allow");143 kfscmd("allow");
149 proto = "users";144 if(users != nil){
150 setusers();145 proto = "users"; # for diagnostics
146 setusers();
147 }
151 cputype = getenv("cputype");148 cputype = getenv("cputype");
152 if(cputype == nil)149 if(cputype == nil)
153 cputype = "dis";150 cputype = "dis";
@@ -159,7 +156,7 @@ init(nil: ref Draw->Context, args: list of string) · 5 unmodified lines
159 156
160 b = bufio->open(proto, Sys->OREAD);157 b = bufio->open(proto, Sys->OREAD);
161 if(b == nil){158 if(b == nil){
162 fprint(stderr, "%s: can't open %s: %r: skipping\n", prog, proto);159 fprint(stderr, "%s: can't open %q: %r: skipping\n", prog, proto);
163 errs++;160 errs++;
164 continue;161 continue;
165 }162 }
@@ -190,15 +187,6 @@ quit(why: string) · 24 unmodified lines
190 exit;187 exit;
191}188}
192 189
193reqarg(what: string): string
194{
195 if((o := arg->arg()) == nil){
196 sys->fprint(stderr, "%s: missing %s\n", prog, what);
197 quit("usage");
198 }
199 return o;
200}
201
202mkfs(me: ref File, level: int)190mkfs(me: ref File, level: int)
203{191{
204 (child, fp) := getfile(me);192 (child, fp) := getfile(me);
@@ -227,7 +215,7 @@ mktree(me: ref File, rec: int, filesonly: int) · 22 unmodified lines
227{215{
228 fd := sys->open(oldfile, Sys->OREAD);216 fd := sys->open(oldfile, Sys->OREAD);
229 if(fd == nil){217 if(fd == nil){
230 warn(sys->sprint("can't open %s: %r", oldfile));218 warn(sys->sprint("can't open %q: %r", oldfile));
231 return;219 return;
232 }220 }
233 221
@@ -282,7 +270,7 @@ mkfile(f: ref File): int · 48 unmodified lines
282{270{
283 (i, dir) := sys->stat(oldfile);271 (i, dir) := sys->stat(oldfile);
284 if(i < 0){272 if(i < 0){
285 warn(sys->sprint("can't stat file %s: %r", oldfile));273 warn(sys->sprint("can't stat file %q: %r", oldfile));
286 skipdir();274 skipdir();
287 return 0;275 return 0;
288 }276 }
@@ -294,7 +282,7 @@ copyfile(f: ref File, d: ref Dir, permonly: int): int · 5 unmodified lines
294 mode: int;282 mode: int;
295 283
296 if(xflag && bout != nil){284 if(xflag && bout != nil){
297 bout.puts(sys->sprint("%s\t%d\t%bd\n", quoted(f.new), d.mtime, d.length));285 bout.puts(sys->sprint("%q\t%d\t%bd\n", f.new, d.mtime, d.length));
298 return (d.mode & Sys->DMDIR) != 0;286 return (d.mode & Sys->DMDIR) != 0;
299 }287 }
300 d.name = f.elem;288 d.name = f.elem;
@@ -329,7 +317,7 @@ copyfile(f: ref File, d: ref Dir, permonly: int): int · 28 unmodified lines
329 mkdir(d);317 mkdir(d);
330 else {318 else {
331 if(verb)319 if(verb)
332 fprint(stderr, "%s\n", f.new);320 fprint(stderr, "%q\n", f.new);
333 copy(d);321 copy(d);
334 }322 }
335 }else if(modes){323 }else if(modes){
@@ -338,7 +326,7 @@ copyfile(f: ref File, d: ref Dir, permonly: int): int · 2 unmodified lines
338 nd.mtime = d.mtime;326 nd.mtime = d.mtime;
339 nd.gid = d.gid;327 nd.gid = d.gid;
340 if(sys->wstat(newfile, nd) < 0)328 if(sys->wstat(newfile, nd) < 0)
341 warn(sys->sprint("can't set modes for %s: %r", f.new));329 warn(sys->sprint("can't set modes for %q: %r", f.new));
342 # do the uid separately since different file systems object330 # do the uid separately since different file systems object
343 nd = sys->nulldir;331 nd = sys->nulldir;
344 nd.uid = d.uid;332 nd.uid = d.uid;
@@ -368,7 +356,7 @@ copy(d: ref Dir) · 23 unmodified lines
368 356
369 f := sys->open(oldfile, Sys->OREAD);357 f := sys->open(oldfile, Sys->OREAD);
370 if(f == nil){358 if(f == nil){
371 warn(sys->sprint("can't open %s: %r", oldfile));359 warn(sys->sprint("can't open %q: %r", oldfile));
372 return;360 return;
373 }361 }
374 t = nil;362 t = nil;
@@ -381,7 +369,7 @@ copy(d: ref Dir) · 6 unmodified lines
381 cptmp := dname+"__mkfstmp";369 cptmp := dname+"__mkfstmp";
382 t = sys->create(cptmp, Sys->OWRITE, 8r666);370 t = sys->create(cptmp, Sys->OWRITE, 8r666);
383 if(t == nil){371 if(t == nil){
384 warn(sys->sprint("can't create %s: %r", newfile));372 warn(sys->sprint("can't create %q: %r", newfile));
385 return;373 return;
386 }374 }
387 }375 }
@@ -389,7 +377,7 @@ copy(d: ref Dir) · 1 unmodified line
389 for(tot := big 0;; tot += big n){377 for(tot := big 0;; tot += big n){
390 n = sys->read(f, buf, buflen);378 n = sys->read(f, buf, buflen);
391 if(n < 0){379 if(n < 0){
392 warn(sys->sprint("can't read %s: %r", oldfile));380 warn(sys->sprint("can't read %q: %r", oldfile));
393 break;381 break;
394 }382 }
395 if(n == 0)383 if(n == 0)
@@ -399,9 +387,9 @@ copy(d: ref Dir) · 3 unmodified lines
399 error(sys->sprint("write error: %r"));387 error(sys->sprint("write error: %r"));
400 }else if(buf[0:buflen] == zbuf[0:buflen]){388 }else if(buf[0:buflen] == zbuf[0:buflen]){
401 if(sys->seek(t, big buflen, 1) < big 0)389 if(sys->seek(t, big buflen, 1) < big 0)
402 error(sys->sprint("can't write zeros to %s: %r", newfile));390 error(sys->sprint("can't write zeros to %q: %r", newfile));
403 }else if(sys->write(t, buf, n) < n)391 }else if(sys->write(t, buf, n) < n)
404 error(sys->sprint("can't write %s: %r", newfile));392 error(sys->sprint("can't write %q: %r", newfile));
405 }393 }
406 f = nil;394 f = nil;
407 if(tot != d.length){395 if(tot != d.length){
@@ -420,11 +408,11 @@ copy(d: ref Dir) · 12 unmodified lines
420 nd.mode = d.mode;408 nd.mode = d.mode;
421 nd.mtime = d.mtime;409 nd.mtime = d.mtime;
422 if(sys->fwstat(t, nd) < 0)410 if(sys->fwstat(t, nd) < 0)
423 error(sys->sprint("can't move tmp file to %s: %r", newfile));411 error(sys->sprint("can't move tmp file to %q: %r", newfile));
424 nd = sys->nulldir;412 nd = sys->nulldir;
425 nd.gid = d.gid;413 nd.gid = d.gid;
426 if(sys->fwstat(t, nd) < 0)414 if(sys->fwstat(t, nd) < 0)
427 warn(sys->sprint("can't set group id of %s to %s: %r", newfile, d.gid));415 warn(sys->sprint("can't set group id of %q to %q: %r", newfile, d.gid));
428 nd.gid = nil;416 nd.gid = nil;
429 nd.uid = d.uid;417 nd.uid = d.uid;
430 sys->fwstat(t, nd);418 sys->fwstat(t, nd);
@@ -444,16 +432,16 @@ mkdir(d: ref Dir) · 13 unmodified lines
444 if(fd == nil){432 if(fd == nil){
445 (i, d1) := sys->stat(newfile);433 (i, d1) := sys->stat(newfile);
446 if(i < 0 || !(d1.mode & Sys->DMDIR))434 if(i < 0 || !(d1.mode & Sys->DMDIR))
447 error(sys->sprint("can't create %s", newfile));435 error(sys->sprint("can't create %q", newfile));
448 if(sys->wstat(newfile, nd) < 0)436 if(sys->wstat(newfile, nd) < 0)
449 warn(sys->sprint("can't set modes for %s: %r", newfile));437 warn(sys->sprint("can't set modes for %q: %r", newfile));
450 nd = sys->nulldir;438 nd = sys->nulldir;
451 nd.uid = d.uid;439 nd.uid = d.uid;
452 sys->wstat(newfile, nd);440 sys->wstat(newfile, nd);
453 return;441 return;
454 }442 }
455 if(sys->fwstat(fd, nd) < 0)443 if(sys->fwstat(fd, nd) < 0)
456 warn(sys->sprint("can't set modes for %s: %r", newfile));444 warn(sys->sprint("can't set modes for %q: %r", newfile));
457 nd = sys->nulldir;445 nd = sys->nulldir;
458 nd.uid = d.uid;446 nd.uid = d.uid;
459 sys->fwstat(fd, nd);447 sys->fwstat(fd, nd);
@@ -461,8 +449,8 @@ mkdir(d: ref Dir) · 1 unmodified line
461 449
462arch(d: ref Dir)450arch(d: ref Dir)
463{451{
464 bout.puts(sys->sprint("%s %s %s %s %ud %bd\n",452 bout.puts(sys->sprint("%q %uo %q %q %ud %bd\n",
465 quoted(newfile), octal(d.mode), d.uid, d.gid, d.mtime, d.length));453 newfile, d.mode, d.uid, d.gid, d.mtime, d.length));
466}454}
467 455
468mkpath(prefix, elem: string): string456mkpath(prefix, elem: string): string
@@ -543,11 +531,11 @@ getfile(old: ref File): (ref File, big) · 74 unmodified lines
543 f = ref File;531 f = ref File;
544 (elem, p) = getname(p);532 (elem, p) = getname(p);
545 if(debug)533 if(debug)
546 fprint(stderr, "getfile: %s root %s\n", elem, old.new);534 fprint(stderr, "getfile: %q root %q\n", elem, old.new);
547 f.new = mkpath(old.new, elem);535 f.new = mkpath(old.new, elem);
548 (nil, f.elem) = str->splitr(f.new, "/");536 (nil, f.elem) = str->splitr(f.new, "/");
549 if(f.elem == nil)537 if(f.elem == nil)
550 error(sys->sprint("can't find file name component of %s", f.new));538 error(sys->sprint("can't find file name component of %q", f.new));
551 (f.mode, p) = getmode(p);539 (f.mode, p) = getmode(p);
552 (f.uid, p) = getname(p);540 (f.uid, p) = getname(p);
553 if(f.uid == nil)541 if(f.uid == nil)
@@ -585,7 +573,7 @@ getname(p: string): (string, string) · 31 unmodified lines
585 for(; (c = p[0]) != '\n' && (c != ' ' && c != '\t' || quoted); p = p[1:]){573 for(; (c = p[0]) != '\n' && (c != ' ' && c != '\t' || quoted); p = p[1:]){
586 if(quoted && c == '\'' && p[1] == '\'')574 if(quoted && c == '\'' && p[1] == '\'')
587 p = p[1:];575 p = p[1:];
588 else if(c == '\'' && qflag){576 else if(c == '\''){
589 quoted = !quoted;577 quoted = !quoted;
590 continue;578 continue;
591 }579 }
@@ -594,7 +582,7 @@ getname(p: string): (string, string) · 2 unmodified lines
594 if(len s > 0 && s[0] == '$'){582 if(len s > 0 && s[0] == '$'){
595 s = getenv(s[1:]);583 s = getenv(s[1:]);
596 if(s == nil)584 if(s == nil)
597 error(sys->sprint("can't read environment variable %s", s));585 error(sys->sprint("can't read environment variable %q", s));
598 }586 }
599 return (s, p);587 return (s, p);
600}588}
@@ -654,13 +642,6 @@ getmode(p: string): (int, string) · 53 unmodified lines
654 return (m|v, p);642 return (m|v, p);
655}643}
656 644
657quoted(s: string): string
658{
659 if(qflag)
660 return sys->sprint("%q", s);
661 return s;
662}
663
664setusers()645setusers()
665{646{
666 if(fskind != Kfs)647 if(fskind != Kfs)
@@ -693,30 +674,14 @@ setusers() · 26 unmodified lines
693 modes = m;674 modes = m;
694}675}
695 676
696# this isn't right for the current #K677openkfscmd(name: string)
697mountkfs(name: string)
698{678{
699 kname: string;
700
701 if(fskind != Kfs)679 if(fskind != Kfs)
702 return;680 return;
703 if(name != nil)681 kname := sys->sprint("/chan/kfs.%s.cmd", name);
704 kname = sys->sprint("/srv/kfs.%s", name);
705 else
706 kname = "/srv/kfs";
707 fd := sys->open(kname, Sys->ORDWR);
708 if(fd == nil){
709 fprint(stderr, "%s: can't open %s: %r\n", prog, kname);
710 quit("open kfs");
711 }
712 if(sys->mount(fd, nil, "/n/kfs", Sys->MREPL|Sys->MCREATE, "") < 0){
713 fprint(stderr, "%s: can't mount kfs on /n/kfs: %r\n", prog);
714 quit("mount kfs");
715 }
716 kname += ".cmd";
717 sfd = sys->open(kname, Sys->ORDWR);682 sfd = sys->open(kname, Sys->ORDWR);
718 if(sfd == nil){683 if(sfd == nil){
719 fprint(stderr, "%s: can't open %s: %r\n", prog, kname);684 fprint(stderr, "%s: can't open %q: %r\n", prog, kname);
720 quit("open kfscmd");685 quit("open kfscmd");
721 }686 }
722}687}
@@ -747,7 +712,7 @@ kfscmd(cmd: string) · 24 unmodified lines
747 712
748error(s: string)713error(s: string)
749{714{
750 fprint(stderr, "%s: %s: %d: %s\n", prog, proto, lineno, s);715 fprint(stderr, "%s: %s:%d: %s\n", prog, proto, lineno, s);
751 kfscmd("disallow");716 kfscmd("disallow");
752 kfscmd("sync");717 kfscmd("sync");
753 quit("error");718 quit("error");
@@ -755,24 +720,13 @@ error(s: string) · 1 unmodified line
755 720
756warn(s: string)721warn(s: string)
757{722{
758 fprint(stderr, "%s: %s: %d: %s\n", prog, proto, lineno, s);723 fprint(stderr, "%s: %s:%d: %s\n", prog, proto, lineno, s);
759}724}
760 725
761printfile(f: ref File)726printfile(f: ref File)
762{727{
763 if(f.old != nil)728 if(f.old != nil)
764 fprint(stderr, "%s from %s %s %s %s\n", f.new, f.old, f.uid, f.gid, octal(f.mode));729 fprint(stderr, "%q from %q %q %q %uo\n", f.new, f.old, f.uid, f.gid, f.mode);
765 else730 else
766 fprint(stderr, "%s %s %s %s\n", f.new, f.uid, f.gid, octal(f.mode));731 fprint(stderr, "%q %q %q %uo\n", f.new, f.uid, f.gid, f.mode);
767}
768
769octal(i: int): string
770{
771 s := "";
772 do {
773 t: string;
774 t[0] = '0' + (i&7);
775 s = t+s;
776 } while((i = (i>>3)&~(7<<29)) != 0);
777 return s;
778}732}
dis/disk/mkext.dis+0−0

Binary file not shown.

dis/disk/mkfs.dis+0−0

Binary file not shown.

include/version.h+1−1
@@ -1 +1 @@
1#define VERSION "Fourth Edition (20090806)"1#define VERSION "Fourth Edition (20090809)"
man/8/mkfs+98−56
@@ -3,7 +3,9 @@ · 2 unmodified lines
3mkfs, mkext \- archive or update a file system3mkfs, mkext \- archive or update a file system
4.SH SYNOPSIS4.SH SYNOPSIS
5.B disk/mkfs5.B disk/mkfs
6.RB [ -aprvx ]6.RB [ -aprvxS ]
7.RB [ -d
8.IR dest ]
7.RB [ -n9.RB [ -n
8.IR name ]10.IR name ]
9.RB [ -s11.RB [ -s
@@ -12,15 +14,23 @@ mkfs, mkext \- archive or update a file system · 2 unmodified lines
12.IR users ]14.IR users ]
13.RB [ -z15.RB [ -z
14.IR n ]16.IR n ]
17.RB [ -G
18.IR group ]
19.RB [ -U
20.IR user ]
15.I proto ...21.I proto ...
16.PP22.PP
17.B disk/mkext23.B disk/mkext
18.RB [ -d24.RB [ -d
19.IR name ]25.IR name ]
20.RB [ -u ]26.RB [ -f ]
21.RB [ -h ]27.RB [ -h ]
28.RB [ -T ]
29.RB [ -u ]
22.RB [ -v ]30.RB [ -v ]
31[
23.I file ...32.I file ...
33]
24.SH DESCRIPTION34.SH DESCRIPTION
25.I Mkfs35.I Mkfs
26copies files from the file tree36copies files from the file tree
@@ -30,24 +40,22 @@ copies files from the file tree · 3 unmodified lines
30to a40to a
31.B kfs41.B kfs
32file system (see42file system (see
33.IR kfs (4)).43.IR kfs (4))
34The kfs service is mounted on44assumed to be mounted on
35.BR /n/kfs ,45.I dest
36and46(default:
37.BR /adm/users ,47.BR /n/kfs ).
38if it exists, is copied to
39.BR /n/kfs/adm/users .
40The48The
41.I proto49.I proto
42files are read,50files are read,
43and any files specified in them that are out of date are copied to51and any files specified in them that are out of date are copied to
44.BR /n/kfs .52.IR dest .
45See53See
46.IR proto (6)54.IR proto (6)
47for the description of file system prototype files.55for the description of file system prototype files.
48.PP56.PP
49.I Mkfs57.I Mkfs
50copies only those files that are out of date.58by default copies only those files that are out of date.
51Such a file is first copied into a temporary59Such a file is first copied into a temporary
52file in the appropriate destination directory60file in the appropriate destination directory
53and then moved to the destination file.61and then moved to the destination file.
@@ -61,88 +69,122 @@ are not updated and not removed. · 7 unmodified lines
61The options to69The options to
62.I mkfs70.I mkfs
63are:71are:
64.TF "s source"72.TF "-s source"
65.TP73.TP
66.B a74.B -a
67Instead of writing to a75Instead of writing to a
68.B kfs76.B kfs
69file system, write an archive file to standard output, suitable for77file system, write an archive file to standard output, suitable for
70.IR mkext .78.IR mkext .
71All files in79All files in
72.IR proto ,80.I proto
73not just those out of date, are archived.81are archived,
82not just those out of date.
74.TP83.TP
75.B x84.B -x
76For use with85For use with
77.BR -a ,86.BR -a ,
78this option writes a list of file names, dates, and sizes to standard output87this option writes a list of file names, dates, and sizes to standard output
79rather than producing an archive file.88rather than producing an archive file.
80.TP89.TP
81.BI "n " name90.BI -n " name"
82Use91Use
83.RI kfs. name92.BI kfs. name .cmd
84as the name of the kfs service (default93as the name of the command file for the
85.BR kfs ).94.IR kfs (4)
95assumed to be mounted on
96.IR dest .
86.TP97.TP
87.B p98.B -p
88Update the permissions of a file even if it is up to date.99Update the permissions of a file even if it is up to date.
89.TP100.TP
90.B r101.B -r
91Copy all files.102Copy all files.
92.TP103.TP
93.BI "s " source104.BI -s " source"
94Copy from files rooted at the tree105Copy from files rooted at the tree
95.IR source .106.IR source .
96.TP107.TP
97.BI "u " users108.BI -u " users"
98Copy file109Before copying any other file, copy file
99.I users110.I users
100into111into
101.B /adm/users112.IB dest /adm/users ,
102in the new system.113and if the
114.B -n
115option was given, also issue the
116.IR kfs (4)
117command
118.B users
119to update
120.IR kfs 's
121own user list.
103.TP122.TP
104.B v123.B -v
105Print the names of all of the files as they are copied.124Print the names of all of the files as they are copied.
106.TP125.TP
107.BI "z " n126.BI -z " n"
108Copy files assuming kfs block127Copy files assuming
128.I kfs
129is using a block size of
109.I n130.I n
110(default 1024)131bytes
111bytes long.132(default 1024).
112If a block contains only 0-valued bytes, it is not copied.133If a block contains only 0-valued bytes, it is not copied.
134.TP
135.B -S
136For use with the
137.B -d
138option,
139make owner and group of each file copied match the original.
140.TP
141.BI -G " group"
142Force all files copied to have the given
143.IR group .
144.TP
145.BI -U " user"
146Force all files copied to be owned by the given
147.IR user .
113.PD148.PD
114.PP149.PP
115.I Mkext150.I Mkext
116unpacks archive files made by the151unpacks an archive created by the
117.B -a152.B -a
118option of153option of
119.IR mkfs .154.IR mkfs ,
120The155read from the standard input.
121.B -d156If one or more files are specified on the command line,
122option specifies a directory (default157only those files are unpacked.
123.BR /n/kfs )158If a
124to serve as the root of the unpacked file system.159.I file
125The160is a directory,
126.B -u
127option, to be used only when initializing a new
128.IR kfs (4)
129file system, sets the owners of the files created to correspond to
130those in the archive and restores the modification times of the files.
131(This is only permitted at the initial load of the files into a file
132system.)
133Each file on the command line is unpacked in one pass through the archive.
134If the file is a directory,
135all files and subdirectories of that directory are also unpacked.161all files and subdirectories of that directory are also unpacked.
136When a file is unpacked, the entire path is created if it162When a file is unpacked, the entire path is created if it
137does not exist.163does not exist.
138If no files are specified, the entire archive is unpacked;164If no files are specified, the entire archive is unpacked;
139in this case, missing intermediate directories are not created.165in this case, missing intermediate directories are not created.
140The166The options are:
141.B -v167.TP
142option prints the names and sizes of files as they are extracted;168.BI -d " dir"
169Treat
170.I dir
171(default
172.LR / )
173as the root directory when unpacking the archive.
174.TP
143.B -h175.B -h
144prints headers for the files on standard output176Print headers for the files on standard output
145instead of unpacking the files.177instead of unpacking the files.
178.TP
179.B -T
180Restore the modification times of the files.
181.TP
182.B -u
183Set the owners of the files created to correspond to
184those in the archive and restore the modification times of the files.
185.TP
186.B -v
187Print the names and sizes of files as they are extracted.
146.SH EXAMPLES188.SH EXAMPLES
147.PP189.PP
148Make an archive to establish a new file system190Make an archive to establish a new file system
@@ -153,7 +195,7 @@ is not referenced by · 4 unmodified lines
153.IP195.IP
154.EX196.EX
155bind '#U' /n/local197bind '#U' /n/local
156disk/mkfs -a -u files/adm.users -s /n/local proto > arch198disk/mkfs -a -s /n/local proto > arch
157.EE199.EE
158.PP200.PP
159Unpack that archive on another machine:201Unpack that archive on another machine:
@@ -168,8 +210,8 @@ disk/mkext -u -d /n/remote < arch · 8 unmodified lines
168.B /lib/proto210.B /lib/proto
169directory of prototype files.211directory of prototype files.
170.TP212.TP
171.B /lib/proto/portproto213.B /lib/proto/all
172generic prototype file.214contains a single + (archive any directory structure)
173.SH SOURCE215.SH SOURCE
174.B /appl/cmd/disk/mkfs.b216.B /appl/cmd/disk/mkfs.b
175.br217.br