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.