dbopen(3) Library Functions Manual dbopen(3) dbopen - (libc -lc) #include #include #include #include DB *dbopen(const char *path, int flags, int mode, DBTYPE type, const void *openinfo); : glibc 2.1. glibc 2.2 glibc . (APIs) libdb . dbopen() . btree hashed UNIX. btree . hashed . . btree(3) hash(3) recno(3). dbopen() path / . path NULL. flags mode open(2) O_CREAT O_EXCL O_EXLOCK O_NONBLOCK O_RDONLY O_RDWR O_SHLOCK O_TRUNC . ( O_WRONLY .) type DBTYPE ( ) DB_BTREE DB_HASH DB_RECNO. openinfo . openinfo NULL . dbopen() DB NULL . DB : typedef struct { DBTYPE type; int (*close)(const DB *db); int (*del)(const DB *db, const DBT *key, unsigned int flags); int (*fd)(const DB *db); int (*get)(const DB *db, DBT *key, DBT *data, unsigned int flags); int (*put)(const DB *db, DBT *key, const DBT *data, unsigned int flags); int (*sync)(const DB *db, unsigned int flags); int (*seq)(const DB *db, DBT *key, DBT *data, unsigned int flags); } DB; . dbopen() / . type ( ). close () . / close sync . close -1 ( errno) 0 . del / . flag : R_CURSOR . . delete -1 ( errno) 0 1 key . fd . dbopen() path. fcntl(2) flock(2). . . fd -1 ( errno) . get . key data. get -1 ( errno) 0 1 key . put / . flag : R_CURSOR / . . R_IAFTER key / . / key. ( DB_RECNO.) R_IBEFORE key / . / key. ( DB_RECNO.) R_NOOVERWRITE / . R_SETCURSOR / . ( DB_BTREE DB_RECNO.) R_SETCURSOR DB_BTREE DB_RECNO . R_IAFTER R_IBEFORE DB_RECNO . . put / . put -1 ( errno) 0 1 R_NOOVERWRITE flag . seq . key data. / "" del get put sync. . : R_CURSOR . get . (: DB_BTREE . .) R_FIRST / . R_LAST / . ( DB_BTREE DB_RECNO.) R_NEXT / . R_FIRST. R_PREV / . R_LAST. ( DB_BTREE DB_RECNO.) R_LAST R_PREV DB_BTREE DB_RECNO . seq -1 ( errno) 0 1 / . DB_RECNO / seq 2. sync . sync . : R_RECNOSYNC DB_RECNO btree recno recno . ( bfname recno(3) .) sync -1 ( errno) 0 . / /. : typedef struct { void *data; size_t size; } DBT; DBT : data . size . . . dbopen() errno open(2) malloc(3) : EFTYPE . EINVAL ( ) ( ) . close errno close(2) read(2) write(2) free(3) fsync(2). del get put seq errno read(2) write(2) free(3) malloc(3). fd errno ENOENT . sync errno fsync(2). DBT "data base thang" . . . btree(3), hash(3), mpool(3), recno(3) LIBTP: Portable, Modular Transactions for UNIX USENIX 1992. 3 . . : . 4.4 Berkeley Distribution 17 2025 dbopen(3)