txtfs

A textual disk filesystem for Plan 9
git clone git://git.stellar-nexus.ru/txtfs
Log | Files | Refs

commit 2d6d7e9fe7df41cda9ffe91fea7a9c9faca981cc
parent 247bf998767f37d6ec43fa83f61e6c7e364a6fd7
Author: Plat <plat@stellar-nexus.ru>
Date:   Sun, 20 Sep 2026 05:03:10 +0000

"Fixed

Diffstat:
Mfrag.c | 31++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/frag.c b/frag.c @@ -11,8 +11,8 @@ fragstat(u64int inodepos, int nfrag) char buf[BLKSZ]; char field[STRSIZ+1]; - pos = dentrypos % BLKSZ + nfrag * FRAGSIZ; - blk = dentrypos / BLKSZ; + pos = inodepos % BLKSZ + nfrag * FRAGSIZ; + blk = inodepos / BLKSZ; if(blkread(blk, buf) < 0) { werrstr("blkread: %r"); @@ -44,12 +44,12 @@ initinode(u64int inodepos) char buf[BLKSZ]; char field[FRAGSIZ+1]; - pos = dentrypos % BLKSZ; - blk = dentrypos / BLKSZ; + pos = inodepos % BLKSZ; + blk = inodepos / BLKSZ; if(blkread(blk, buf) < 0) { werrstr("blkread: %r"); - return nil; + return -1; } buf[pos] = 'i'; @@ -80,23 +80,32 @@ addfrag(u64int inodepos, Frag *frag) char buf[BLKSZ]; char field[FRAGSIZ+1]; - pos = dentrypos % BLKSZ; - blk = dentrypos / BLKSZ; + pos = inodepos % BLKSZ; + blk = inodepos / BLKSZ; if(blkread(blk, buf) < 0) { werrstr("blkread: %r"); - return nil; + return -1; } char out; - for(out = 0; out < MAXFRAGS; ++out) { - if(buf[pos+FRAGS+FRAGSIZ*out] == 'd') + for(out = 0; out < MAXFRAGS; ++out, pos+=FRAGSIZ) { + if(buf[pos+FRAGS] == 'd') break; } - if(buf[pos+FRAGS+FRAGSIZ*out] != 'd') + if(buf[pos+FRAGS] != 'd') + return -1; + + buf[pos] = '+'; + writefield(buf + pos, BLOCK, BLOCKSIZ, frag->block); + writefield(buf + pos, SIZE, SIZESIZ, frag->size); + + if(blkwrite(blk, buf) < 0) { + werrstr("blkwrite: %r"); return -1; + } return out; }