1
0
mirror of https://github.com/fumiama/fumidb.git synced 2026-06-12 06:00:24 +08:00

add types

This commit is contained in:
源文雨
2022-05-01 21:16:17 +08:00
parent eda10fba91
commit 67b9176615
17 changed files with 310 additions and 26 deletions

View File

@@ -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) {