mirror of
https://github.com/fumiama/fumidb.git
synced 2026-06-12 06:00:24 +08:00
add types
This commit is contained in:
10
src/file.c
10
src/file.c
@@ -9,8 +9,16 @@
|
||||
uint8_t header[PAGESZ] = {'F', 'U', 'M', 'I', 'D', 'B', 1, 0};
|
||||
|
||||
int init_file_header_page(int fd) {
|
||||
uint8_t buf[8];
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
return write(fd, header, PAGESZ) != PAGESZ;
|
||||
if(write(fd, header, PAGESZ) != PAGESZ) return 1;
|
||||
// 将头的 HEADERSZ 字节之后的空间纳入空闲块
|
||||
if(lseek(fd, 8, SEEK_SET) < 0) return EOF;
|
||||
putle64(buf, HEADERSZ);
|
||||
if(write(fd, buf, 8) != 8) return 1;
|
||||
if(lseek(fd, HEADERSZ+8, SEEK_SET) < 0) return EOF;
|
||||
putle16(buf, PAGESZ - HEADERSZ);
|
||||
return write(fd, buf, 2) != 2;
|
||||
}
|
||||
|
||||
uint16_t get_db_version(int fd) {
|
||||
|
||||
Reference in New Issue
Block a user