git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/vcfs@676
959494ce-11ee-0310-bf91-
de5d638817bd
#include "blocktree.h"
#define min(a, b) (((b) < (a))?(b):(a))
#include "blocktree.h"
#define min(a, b) (((b) < (a))?(b):(a))
+#define ISDELOP(op) (((op).buf == NULL) && ((op).fillfn == NULL))
ssize_t btget(struct store *st, struct btnode *tree, block_t bl, void *buf, size_t len)
{
ssize_t btget(struct store *st, struct btnode *tree, block_t bl, void *buf, size_t len)
{
+ if(ISDELOP(*op)) {
+ leaf->d = 0;
+ return(0);
+ }
buf = NULL;
if(op->buf == NULL) {
buf = op->buf = malloc(op->len);
buf = NULL;
if(op->buf == NULL) {
buf = op->buf = malloc(op->len);
hasid = 0;
for(i = 0; i < numops; ) {
hasid = 0;
for(i = 0; i < numops; ) {
+ if(ops[i].blk < bloff) {
+ errno = ERANGE;
+ return(-1);
+ }
bl = ops[i].blk - bloff;
if((d == 0) && (bl == 0)) {
bl = ops[i].blk - bloff;
if((d == 0) && (bl == 0)) {
i += subops;
if((sel == BT_INDSZ - 1) && (indir[sel].d == ((d - 1) | 0x80))) {
i += subops;
if((sel == BT_INDSZ - 1) && (indir[sel].d == ((d - 1) | 0x80))) {
+ } else if(indir[sel].d == 0) {
+ /* Erased */
+ if(--c == 1) {
+ tree->d = indir[0].d;
+ tree->a = indir[0].a;
+ }
static int opcmp(const struct btop **op1, const struct btop **op2)
{
static int opcmp(const struct btop **op1, const struct btop **op2)
{
- return((*op1)->blk - (*op2)->blk);
+ if(ISDELOP(**op1) && ISDELOP(**op2))
+ return((*op2)->blk - (*op1)->blk);
+ else if(!ISDELOP(**op1) && ISDELOP(**op2))
+ return(-1);
+ else if(ISDELOP(**op1) && !ISDELOP(**op2))
+ return(1);
+ else
+ return((*op1)->blk - (*op2)->blk);
}
void btsortops(struct btop *ops, int numops)
}
void btsortops(struct btop *ops, int numops)