1
0
mirror of https://github.com/fumiama/simple-kanban.git synced 2026-06-13 05:31:11 +08:00

fix: mmap panic on first create

This commit is contained in:
源文雨
2023-12-01 02:22:37 +09:00
parent 250ffa01e7
commit 9abfcb2cfa
2 changed files with 7 additions and 3 deletions

3
file.h
View File

@@ -31,7 +31,7 @@ int file_cache_init(file_cache_t* fc, char* path) {
perror("pthread_rwlock_init"); perror("pthread_rwlock_init");
return -1; return -1;
} }
fd = open(path, O_RDWR|O_CREAT); fd = open(path, O_RDWR|O_CREAT, 0644);
if(fd < 0) { if(fd < 0) {
perror("open"); perror("open");
return -2; return -2;
@@ -45,6 +45,7 @@ int file_cache_init(file_cache_t* fc, char* path) {
perror("ftruncate"); perror("ftruncate");
return -4; return -4;
} }
sb.st_size = page_size;
} }
mapped = mmap(NULL, (size_t)sb.st_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); mapped = mmap(NULL, (size_t)sb.st_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
close(fd); close(fd);

View File

@@ -11,10 +11,13 @@ $kanban
EOF EOF
echo md5:${md5val##* } | tr -d '\n' >> $3 echo md5:${md5val##* } | tr -d '\n' >> $3
cat > cmd_seq.txt << EOF cat > cmd_seq.txt << EOF
$5$6dat $5
$6
dat
file file
$4 $4
$6ver $6
ver
file file
$3 $3
quit quit