8 copydentry(Fs *fs, FLoc *a, Loc *b, char *nname)
15 if(!namevalid(nname)){
19 ba = getbuf(fs->d, a->blk, TDENTRY, 0);
22 bb = getbuf(fs->d, b->blk, TDENTRY, 0);
27 rc = newentry(fs, b, bb, nname, &c, 1);
34 bc = getbuf(fs->d, c.blk, TDENTRY, 0);
38 memcpy(d, &ba->de[a->deind], sizeof(*d));
39 strcpy(d->name, nname);
40 for(i = 0; i < NDIRECT; i++)
42 chref(fs, d->db[i], 1);
43 for(i = 0; i < NINDIRECT; i++)
45 chref(fs, d->ib[i], 1);
58 for(l = fs->rootloc->gnext; l != fs->rootloc; l = l->gnext)
72 tm = localtime(time(0));
73 snprint(buf, sizeof(buf), "%.4d", tm->year + 1900);
74 ch = chanattach(fs, CHFNOLOCK|CHFDUMP);
80 if(chanwalk(ch, buf) < 0){
82 rc = chancreat(chh, buf, DMDIR|0555, OREAD);
86 if(chanwalk(ch, buf) < 0)
89 b = getbuf(fs->d, ch->loc->blk, TDENTRY, 0);
93 e = buf + sizeof(buf);
94 p = seprint(buf, e, "%.2d%.2d", tm->mon + 1, tm->mday);
96 seprint(p, e, "%d", n);
97 rc = findentry(fs, ch->loc, b, buf, nil, 1);
104 rc = copydentry(fs, fs->rootloc, ch->loc, buf);
116 willmodify1(Fs *fs, Loc *l)
124 rc = chref(fs, l->blk, 0);
128 dprint("willmodify: block %lld has refcount 0\n", l->blk);
129 werrstr("phase error -- willmodify");
135 p = getbuf(fs->d, l->next->blk, TDENTRY, 0);
138 d = getdent(l->next, p);
139 if(d != nil) for(i = 0; i < d->size; i++){
140 rc = getblk(fs, l->next, p, i, &r, GBREAD);
147 werrstr("willmodify -- phase error");
151 rc = getblk(fs, l->next, p, i, &r, GBWRITE);
162 * block got dumped, update the loctree so locs
163 * point to the new block.
166 for(m = l->cnext; m != l; m = m->cnext)
170 qunlock(&fs->loctree);
178 willmodify(Fs *fs, Loc *l, int nolock)
183 if((l->flags & LDUMPED) != 0)
190 st = emalloc(sizeof(Loc *));
194 if((st[sti]->flags & LDUMPED) != 0 || st[sti]->next == nil)
196 st = erealloc(st, (sti + 2) * sizeof(Loc *));
197 st[sti + 1] = st[sti]->next;
201 for(; sti >= 0; sti--){
202 rc = willmodify1(fs, st[sti]);
215 if(chref(fs, l->blk, 0) != 1)