From 9abfcb2cfa3eab09ec5fdb915f6aeaa75578d5f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Fri, 1 Dec 2023 02:22:37 +0900 Subject: [PATCH] fix: mmap panic on first create --- file.h | 3 ++- uploader/push.sh | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/file.h b/file.h index b9cf138..7bf2858 100644 --- a/file.h +++ b/file.h @@ -31,7 +31,7 @@ int file_cache_init(file_cache_t* fc, char* path) { perror("pthread_rwlock_init"); return -1; } - fd = open(path, O_RDWR|O_CREAT); + fd = open(path, O_RDWR|O_CREAT, 0644); if(fd < 0) { perror("open"); return -2; @@ -45,6 +45,7 @@ int file_cache_init(file_cache_t* fc, char* path) { perror("ftruncate"); return -4; } + sb.st_size = page_size; } mapped = mmap(NULL, (size_t)sb.st_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); close(fd); diff --git a/uploader/push.sh b/uploader/push.sh index 292562c..0473c53 100755 --- a/uploader/push.sh +++ b/uploader/push.sh @@ -11,10 +11,13 @@ $kanban EOF echo md5:${md5val##* } | tr -d '\n' >> $3 cat > cmd_seq.txt << EOF -$5$6dat +$5 +$6 +dat file $4 -$6ver +$6 +ver file $3 quit