From f9ca4a546d4ed1ecc1dc70f40adcd9e4acf72f79 Mon Sep 17 00:00:00 2001 From: nvt-se Date: Mon, 12 Apr 2010 13:20:55 +0000 Subject: [PATCH] Introduced append-only mode for systems with little available code space left, but which require basic FS support. Removes about 1.5kB ROM when the mode is enabled, i.e., COFFEE_CONF_APPEND_ONLY=1 --- core/cfs/cfs-coffee.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/cfs/cfs-coffee.c b/core/cfs/cfs-coffee.c index c58aba315..454211714 100644 --- a/core/cfs/cfs-coffee.c +++ b/core/cfs/cfs-coffee.c @@ -60,6 +60,16 @@ #define COFFEE_WATCHDOG_STOP() #endif +#ifndef COFFEE_CONF_APPEND_ONLY +#define COFFEE_APPEND_ONLY 0 +#else +#define COFFEE_APPEND_ONLY COFFEE_CONF_APPEND_ONLY +#if COFFEE_MICRO_LOGS +#error "Cannot have COFFEE_APPEND_ONLY when COFFEE_MICRO_LOGS is set." +#endif +#define COFFEE_MICRO_LOGS 0 +#endif + #if COFFEE_START & (COFFEE_SECTOR_SIZE - 1) #error COFFEE_START must point to the first byte in a sector. #endif @@ -1177,6 +1187,11 @@ cfs_write(int fd, const void *buf, unsigned size) } } else { #endif /* COFFEE_MICRO_LOGS */ +#if COFFEE_APPEND_ONLY + if(fdp->offset < file->end) { + return -1; + } +#endif /* COFFEE_APPEND_ONLY */ COFFEE_WRITE(buf, size, absolute_offset(file->page, fdp->offset)); fdp->offset += size; #if COFFEE_MICRO_LOGS