From 5fe2c34038bcd9772ddfe59bf30d69b37c73d653 Mon Sep 17 00:00:00 2001 From: nvt-se Date: Wed, 19 Nov 2008 13:42:07 +0000 Subject: [PATCH] - important bug fix regarding writing after a merge log operation: parameters must be restored. - fixed watchdog problem in reserve --- core/cfs/cfs-coffee.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/cfs/cfs-coffee.c b/core/cfs/cfs-coffee.c index 2f85c5b6b..ea9809cb0 100644 --- a/core/cfs/cfs-coffee.c +++ b/core/cfs/cfs-coffee.c @@ -492,13 +492,15 @@ reserve(const char *name, uint32_t size, int allow_duplicates) unsigned need_pages; int page; + watchdog_stop(); + if(!allow_duplicates && find_file(name) >= 0) { + watchdog_start(); return -1; } need_pages = (size + sizeof(hdr) + COFFEE_PAGE_SIZE - 1) / COFFEE_PAGE_SIZE; - watchdog_stop(); page = find_contiguous_pages(need_pages); if(page < 0) { cfs_garbage_collect(); @@ -1023,7 +1025,6 @@ cfs_write(int fd, const void *buf, unsigned size) } fdp = &coffee_fd_set[fd]; - /* Attempt to extend the file if we try to write past the end. */ while(size + fdp->offset + sizeof(struct file_header) > fdp->max_pages * COFFEE_PAGE_SIZE) { @@ -1042,6 +1043,9 @@ cfs_write(int fd, const void *buf, unsigned size) i = write_log_page(fdp, &lp); if(i == 0) { + lp.offset = fdp->offset; + lp.buf = (char *)buf + size - remains; + lp.size = remains; /* The file was merged with the log. Try again. */ i = write_log_page(fdp, &lp); }