From bffbb06d4a4cd11d62e3b7de1ac75051e1ab3062 Mon Sep 17 00:00:00 2001 From: nvt-se Date: Fri, 20 Mar 2009 15:15:43 +0000 Subject: [PATCH] corrected GC page isolation loop. adjusted cfs_coffee_reserve signature to use cfs_offset_t instead of uint32_t. made cfs_coffee_format also to clear *next_free. --- core/cfs/cfs-coffee.c | 8 +++++--- core/cfs/cfs-coffee.h | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/core/cfs/cfs-coffee.c b/core/cfs/cfs-coffee.c index d93bc2f80..e037509a6 100644 --- a/core/cfs/cfs-coffee.c +++ b/core/cfs/cfs-coffee.c @@ -215,8 +215,8 @@ get_sector_status(uint16_t sector, struct sector_stats *stats) { the following pages as isolated. */ memset(&hdr, 0, sizeof(hdr)); hdr.flags = HDR_FLAG_ALLOCATED | HDR_FLAG_ISOLATED; - for(page = sector_start; page < skip_pages; page++) { - write_header(&hdr, page); + for(page = 0; page < skip_pages; page++) { + write_header(&hdr, sector_start + page); } PRINTF("Coffee: Isolated %u pages starting in sector %d\n", (unsigned)skip_pages, (int)sector); @@ -1168,7 +1168,7 @@ cfs_closedir(struct cfs_dir *dir) } /*---------------------------------------------------------------------------*/ int -cfs_coffee_reserve(const char *name, uint32_t size) +cfs_coffee_reserve(const char *name, cfs_offset_t size) { return reserve(name, page_count(size), 0) == NULL ? -1 : 0; } @@ -1216,6 +1216,8 @@ cfs_coffee_format(void) PRINTF("Coffee: Formatting %d sectors", nsectors); + *next_free = 0; + watchdog_stop(); for(i = 0; i < nsectors; i++) { COFFEE_ERASE(i); diff --git a/core/cfs/cfs-coffee.h b/core/cfs/cfs-coffee.h index e8001756e..d511441bf 100644 --- a/core/cfs/cfs-coffee.h +++ b/core/cfs/cfs-coffee.h @@ -38,6 +38,8 @@ #ifndef CFS_COFFEE_H #define CFS_COFFEE_H +#include "cfs.h" + /** * \file * Header for the Coffee file system. @@ -59,7 +61,7 @@ * has been done, files will be set to a default size once opened for * the first time. */ -int cfs_coffee_reserve(const char *name, uint32_t size); +int cfs_coffee_reserve(const char *name, cfs_offset_t size); /** * \brief Configure the on-demand log file. @@ -73,7 +75,7 @@ int cfs_coffee_reserve(const char *name, uint32_t size); * is of log_entry_size. */ int cfs_coffee_configure_log(const char *file, unsigned log_size, - unsigned log_entry_size); + unsigned log_entry_size); /** * \brief Format the storage area assigned to Coffee.