tapefs: more 64-bit tar fixes, add block size parameter to 32vfs [rsc] --rw-rw-r-- M 1812954 glenda sys 1815 Feb 26 10:06 sys/src/cmd/tapefs/tapefs.h /n/sourcesdump/2006/0226/plan9/sys/src/cmd/tapefs/tapefs.h:1,7 - /n/sourcesdump/2006/0227/plan9/sys/src/cmd/tapefs/tapefs.h:1,10 #define g2byte(x) (((x)[1]<<8) + (x)[0]) /* little-endian */ #define g3byte(x) (((x)[2]<<16) + ((x)[1]<<8) + (x)[0]) #define g4byte(x) (((x)[3]<<24) + ((x)[2]<<16) + ((x)[1]<<8) + (x)[0]) - #define g8byte(x) (((vlong)g4byte(x)<<32) | (u32int)g4byte(x+4)) + + /* big endian */ + #define b4byte(x) (((x)[0]<<24) + ((x)[1]<<16) + ((x)[2]<<8) + (x)[3]) + #define b8byte(x) (((vlong)b4byte(x)<<32) | (u32int)b4byte((x)+4)) enum { OPERM = 0x3, /* mask of all permission types in open mode */ /n/sourcesdump/2006/0226/plan9/sys/src/cmd/tapefs/tapefs.h:75,80 - /n/sourcesdump/2006/0227/plan9/sys/src/cmd/tapefs/tapefs.h:78,84 extern Idmap *uidmap; extern Idmap *gidmap; extern int replete; + extern int blocksize; void error(char*); void *erealloc(void*, ulong); void *emalloc(ulong); [rsc] --rw-rw-r-- M 1812954 glenda sys 1861 Feb 26 09:58 sys/man/4/tapefs /n/sourcesdump/2006/0226/plan9/sys/man/4/tapefs:4,9 - /n/sourcesdump/2006/0227/plan9/sys/man/4/tapefs:4,13 .SH SYNOPSIS .B fs/32vfs [ + .B -b + .I blocksize + ] + [ .B -m .I mountpoint ] /n/sourcesdump/2006/0226/plan9/sys/man/4/tapefs:52,58 - /n/sourcesdump/2006/0227/plan9/sys/man/4/tapefs:56,62 .PP .I 32vfs interprets raw disk images of 32V systems, which are ca. 1978 research Unix systems for - the VAX, and also pre-FFS Berkeley VAX systems (1KB block size). + the VAX (512 byte block size, the default), and also pre-FFS Berkeley VAX systems (1KB block size). .PP .I Cpiofs interprets /n/sourcesdump/2006/0226/plan9/sys/man/4/tapefs:101,106 - /n/sourcesdump/2006/0227/plan9/sys/man/4/tapefs:105,109 turn derive substantially from .IR ramfs (4). .SH "SEE ALSO - Section 5 - .IR passim , + .IR intro (5), .IR ramfs (4). [rsc] --rw-rw-r-- M 1812954 glenda sys 3922 Feb 26 09:56 sys/src/cmd/tapefs/32vfs.c /n/sourcesdump/2006/0226/plan9/sys/src/cmd/tapefs/32vfs.c:20,28 - /n/sourcesdump/2006/0227/plan9/sys/src/cmd/tapefs/32vfs.c:20,30 #define VSUPERB 1 #define VROOT 2 /* root inode */ #define VNAMELEN 14 - #define BLSIZE 512 + #define MAXBLSIZE 1024 + int BLSIZE; #define LINOPB (BLSIZE/sizeof(struct v32dinode)) - #define LNINDIR (BLSIZE/sizeof(unsigned long)) + #define LNINDIR (BLSIZE/4) + #define MAXLNINDIR (MAXBLSIZE/4) struct v32dinode { unsigned char flags[2]; /n/sourcesdump/2006/0226/plan9/sys/src/cmd/tapefs/32vfs.c:50,56 - /n/sourcesdump/2006/0227/plan9/sys/src/cmd/tapefs/32vfs.c:52,66 populate(char *name) { Fileinf f; + uchar buf[MAXBLSIZE]; + BLSIZE = 512; /* 32v */ + if(blocksize){ + /* 1024 for 4.1BSD */ + if(blocksize != 512 && blocksize != 1024) + error("bad block size"); + BLSIZE = blocksize; + } replete = 0; tapefile = open(name, OREAD); if (tapefile<0) /n/sourcesdump/2006/0226/plan9/sys/src/cmd/tapefs/32vfs.c:106,112 - /n/sourcesdump/2006/0227/plan9/sys/src/cmd/tapefs/32vfs.c:116,122 char * doread(Ram *r, vlong off, long cnt) { - static char buf[Maxbuf+BLSIZE]; + static char buf[Maxbuf+MAXBLSIZE]; int bno, i; bno = off/BLSIZE; /n/sourcesdump/2006/0226/plan9/sys/src/cmd/tapefs/32vfs.c:147,153 - /n/sourcesdump/2006/0227/plan9/sys/src/cmd/tapefs/32vfs.c:157,163 Fileinf iget(int ino) { - char buf[BLSIZE]; + char buf[MAXBLSIZE]; struct v32dinode *dp; long flags, i; Fileinf f; /n/sourcesdump/2006/0226/plan9/sys/src/cmd/tapefs/32vfs.c:194,200 - /n/sourcesdump/2006/0227/plan9/sys/src/cmd/tapefs/32vfs.c:204,210 long bmap(Ram *r, long bno) { - unsigned char indbuf[LNINDIR][sizeof(long)]; + unsigned char indbuf[MAXLNINDIR][4]; if (bno < VNADDR-3) return ((long*)r->data)[bno]; [rsc] --rw-rw-r-- M 1812954 glenda sys 2964 Feb 26 10:01 sys/src/cmd/tapefs/util.c /n/sourcesdump/2006/0226/plan9/sys/src/cmd/tapefs/util.c:58,76 - /n/sourcesdump/2006/0227/plan9/sys/src/cmd/tapefs/util.c:58,82 Ram * poppath(Fileinf fi, int new) { - char *suffix; + char *suffix, *origname; Ram *dir, *ent; Fileinf f; if (*fi.name=='\0') return 0; + origname = estrdup(fi.name); if (suffix=strrchr(fi.name, '/')){ *suffix = 0; suffix++; if (*suffix=='\0'){ fi.mode |= DMDIR; + free(origname); return poppath(fi, 1); } + /* + * create parent directory of suffix; + * may recurse, thus shortening fi.name even further. + */ f = fi; f.size = 0; f.addr = 0; /n/sourcesdump/2006/0226/plan9/sys/src/cmd/tapefs/util.c:81,95 - /n/sourcesdump/2006/0227/plan9/sys/src/cmd/tapefs/util.c:87,106 } else { suffix = fi.name; dir = ram; - if (strcmp(suffix, ".")==0) + if (strcmp(suffix, ".")==0) { + free(origname); return dir; + } } ent = lookup(dir, suffix); fi.mode |= 0400; /* at least user read */ if (ent){ if (((fi.mode&DMDIR)!=0) != ((ent->qid.type&QTDIR)!=0)){ - fprint(2, "%s/%s directory botch\n", fi.name, suffix); - exits(""); + fprint(2, + "%s file type changed; probably due to union dir.; ignoring\n", + origname); + free(origname); + return ent; } if (new) { ent->ndata = fi.size; /n/sourcesdump/2006/0226/plan9/sys/src/cmd/tapefs/util.c:104,109 - /n/sourcesdump/2006/0227/plan9/sys/src/cmd/tapefs/util.c:115,121 fi.name = suffix; ent = popfile(dir, fi); } + free(origname); return ent; } [rsc] --rw-rw-r-- M 1812954 glenda sys 1815 Feb 26 10:06 sys/src/cmd/tapefs/tapefs.h [rsc] --rw-rw-r-- M 1812954 glenda sys 9887 Feb 26 20:22 sys/src/cmd/tapefs/fs.c /n/sourcesdump/2006/0226/plan9/sys/src/cmd/tapefs/fs.c:16,23 - /n/sourcesdump/2006/0227/plan9/sys/src/cmd/tapefs/fs.c:16,25 Idmap *uidmap; Idmap *gidmap; int replete; + int blocksize; /* for 32v */ int verbose; int newtap; /* tap with time in sec */ + int blocksize; Fid * newfid(int); int ramstat(Ram*, uchar*, int); /n/sourcesdump/2006/0226/plan9/sys/src/cmd/tapefs/fs.c:80,98 - /n/sourcesdump/2006/0227/plan9/sys/src/cmd/tapefs/fs.c:82,103 defmnt = "/n/tapefs"; ARGBEGIN{ case 'm': - defmnt = ARGF(); + defmnt = EARGF(usage()); break; case 'p': /* password file */ - uidmap = getpass(ARGF()); + uidmap = getpass(EARGF(usage())); break; case 'g': /* group file */ - gidmap = getpass(ARGF()); + gidmap = getpass(EARGF(usage())); break; case 'v': verbose++; - + break; case 'n': newtap++; + break; + case 'b': + blocksize = atoi(EARGF(usage())); break; default: usage(); [rsc] --rw-rw-r-- M 1812954 glenda sys 2759 Feb 26 20:22 sys/src/cmd/tapefs/tarfs.c /n/sourcesdump/2006/0226/plan9/sys/src/cmd/tapefs/tarfs.c:53,59 - /n/sourcesdump/2006/0227/plan9/sys/src/cmd/tapefs/tarfs.c:53,59 f.uid = strtoul(dblock.dbuf.uid, 0, 8); f.gid = strtoul(dblock.dbuf.gid, 0, 8); if((uchar)dblock.dbuf.size[0] == 0x80) - f.size = g8byte(dblock.dbuf.size+3); + f.size = b8byte(dblock.dbuf.size+3); else f.size = strtoull(dblock.dbuf.size, 0, 8); f.mdate = strtoul(dblock.dbuf.mtime, 0, 8); aux/disksim: use even less memory [rsc] --rw-rw-r-- M 1812954 rsc sys 11178 Feb 26 09:40 sys/src/cmd/aux/disksim.c /n/sourcesdump/2006/0226/plan9/sys/src/cmd/aux/disksim.c:23,28 - /n/sourcesdump/2006/0227/plan9/sys/src/cmd/aux/disksim.c:23,29 LOGNPTR = LOGBLKSZ-2, /* assume sizeof(void*) == 4 */ NPTR = 1<ifcall.type == Tread) dat = (uchar*)r->ofcall.data; - else + else{ dat = (uchar*)r->ifcall.data; + nonzero = isnonzero(dat, r->ifcall.count); + } o = offset & (BLKSZ-1); /* left fringe block */ - if(o && count){ - blk = getblock(offset, r->ifcall.type==Twrite); - if(blk == nil) - abort(); + if(o && count){ + blk = getblock(offset, r->ifcall.type==Twrite && nonzero); n = BLKSZ - o; if(n > count) n = count; - (*move)(dat, blk+o, n); + if(r->ifcall.type != Twrite || blk != zero) + (*move)(dat, blk+o, n); if(r->ifcall.type == Twrite) dirty(offset, blk); tot += n; } + next: /* full and right fringe blocks */ while(tot < count){ - blk = getblock(offset+tot, r->ifcall.type==Twrite); - if(blk == nil) - abort(); + blk = getblock(offset+tot, r->ifcall.type==Twrite && nonzero); n = BLKSZ; if(n > count-tot) n = count-tot; - (*move)(dat+tot, blk, n); + if(r->ifcall.type != Twrite || blk != zero) + (*move)(dat+tot, blk, n); if(r->ifcall.type == Twrite) dirty(offset+tot, blk); tot += n; [rsc] --rw-rw-r-- M 1812954 rsc sys 1452 Feb 26 22:08 sys/man/8/disksim tar: 64-bit fixes [rsc] --rw-rw-r-- M 1812954 glenda sys 24018 Feb 26 21:37 sys/src/cmd/tar.c [diffs elided - too long] [diff -c /n/sourcesdump/2006/0226/plan9/sys/src/cmd/tar.c /n/sourcesdump/2006/0227/plan9/sys/src/cmd/tar.c]