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