Search code examples
b-tree

Can not find blkio.c while using WB B-tree


I installed WB B-Tree following the official guide. The process went well but while I am running a test, I got the following error:

blkio.c: 190: No such file or directory
unable to open database!
blkio.c: 283: Bad file descriptor
>>>>ERROR<<<<  couldn't read blk 0 (read -1 B)
blkio.c: 218: Bad file descriptor

Here is my code:

#include <stdio.h>
#include <wb/wbsys.h>


typedef unsigned char uchar;
typedef int bool;
#define true 1
#define false 0


int main(int argc, char *argv[])
{
    init_wb(75, 150, 4096);
    HAND* handle; //B-Tree handle

    //open existing database
    SEGD *db = open_seg("/tmp/btree.db", true);
    if (db == false)
    {
        printf("unable to open database!\n");
        exit(1);
    }
}

Why such error appears?


Solution

  • Well, if I had to guess, I'd say it's because the file you're trying to open does not exist - it says so right there in the error message :-)

    Perhaps you may want to use make_seg rather than open_seg. The former is for creating a file rather than opening an existing one.

    And, just so there's no confusion (indicated by the question title), it's not trying to find the C source file, that's almost certainly just the file and line containing the failing call trying to read the file.