diff --git a/core/cfs/cfs-coffee.c b/core/cfs/cfs-coffee.c index 64474cb8a..b5839dcd8 100644 --- a/core/cfs/cfs-coffee.c +++ b/core/cfs/cfs-coffee.c @@ -766,18 +766,19 @@ find_next_record(struct file_desc *fdp, coffee_page_t log_page, uint16_t batch_size; log_record = log_records; - for(processed = 0; processed < log_records;) { + for(processed = 0; processed < log_records; processed += batch_size) { batch_size = log_records - processed >= preferred_batch_size ? preferred_batch_size : log_records - processed; + COFFEE_READ(&indices, batch_size * sizeof(indices[0]), ABS_OFFSET(log_page, processed * sizeof(indices[0]))); for(i = 0; i < batch_size && indices[i] != 0; i++); log_record = i; + if(log_record < batch_size) { log_record += processed; break; } - processed += batch_size; } } else { log_record = fdp->next_log_record; @@ -944,10 +945,17 @@ cfs_seek(int fd, unsigned offset) } /*---------------------------------------------------------------------------*/ int -cfs_coffee_remove(const char *name) +cfs_remove(const char *name) { int page; + /* + * Coffee removes files by marking them as obsolete. The space + * is not guaranteed to be reclaimed immediately, but must be + * sweeped by the garbage collector. The garbage collector is + * called once a file reservation request cannot be granted. + */ + page = find_file(name); if(page < 0) { return -1; diff --git a/core/cfs/cfs-coffee.h b/core/cfs/cfs-coffee.h index 10560ded2..3b7557c7c 100644 --- a/core/cfs/cfs-coffee.h +++ b/core/cfs/cfs-coffee.h @@ -48,18 +48,6 @@ * @{ */ -/** - * \brief Remove a file. - * \param name The filename. - * \return 0 on success, -1 on failure. - * - * Coffee removes files by marking them as obsolete. Therefore, the - * space is not guaranteed to be reclaimed immediately, but must be - * sweeped by the garbage collector. The garbage collector is called - * once a file reservation request cannot be granted. - */ -int cfs_coffee_remove(const char *name); - /** * \brief Reserve space for a file. * \param name The filename. diff --git a/core/cfs/cfs-eeprom.c b/core/cfs/cfs-eeprom.c index cafe674f4..157aa5809 100644 --- a/core/cfs/cfs-eeprom.c +++ b/core/cfs/cfs-eeprom.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: cfs-eeprom.c,v 1.7 2008/01/24 13:08:35 adamdunkels Exp $ + * $Id: cfs-eeprom.c,v 1.8 2008/11/24 10:56:55 nvt-se Exp $ */ #include "cfs/cfs.h" @@ -117,6 +117,12 @@ cfs_seek(int f, unsigned int o) } /*---------------------------------------------------------------------------*/ int +cfs_remove(const char *name) +{ + return -1; +} +/*---------------------------------------------------------------------------*/ +int cfs_opendir(struct cfs_dir *p, const char *n) { return -1; diff --git a/core/cfs/cfs-posix.c b/core/cfs/cfs-posix.c index 5a9adc703..93bdb0bfe 100644 --- a/core/cfs/cfs-posix.c +++ b/core/cfs/cfs-posix.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: cfs-posix.c,v 1.11 2008/07/06 11:08:07 oliverschmidt Exp $ + * $Id: cfs-posix.c,v 1.12 2008/11/24 10:56:55 nvt-se Exp $ */ #include @@ -90,3 +90,9 @@ cfs_seek(int f, unsigned int o) return lseek(f, o, SEEK_SET); } /*---------------------------------------------------------------------------*/ +int +cfs_remove(const char *name) +{ + return remove(name); +} +/*---------------------------------------------------------------------------*/ diff --git a/core/cfs/cfs-ram.c b/core/cfs/cfs-ram.c index 8ab193ddc..081fea3ee 100644 --- a/core/cfs/cfs-ram.c +++ b/core/cfs/cfs-ram.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: cfs-ram.c,v 1.8 2008/01/24 23:07:05 adamdunkels Exp $ + * $Id: cfs-ram.c,v 1.9 2008/11/24 10:56:55 nvt-se Exp $ */ #include @@ -142,6 +142,12 @@ cfs_seek(int f, unsigned int o) } /*---------------------------------------------------------------------------*/ int +cfs_remove(const char *name) +{ + return -1; +} +/*---------------------------------------------------------------------------*/ +int cfs_opendir(struct cfs_dir *p, const char *n) { return -1; diff --git a/core/cfs/cfs-xmem.c b/core/cfs/cfs-xmem.c index 4dae6202e..7bce93300 100644 --- a/core/cfs/cfs-xmem.c +++ b/core/cfs/cfs-xmem.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: cfs-xmem.c,v 1.8 2008/01/24 13:08:35 adamdunkels Exp $ + * $Id: cfs-xmem.c,v 1.9 2008/11/24 10:56:55 nvt-se Exp $ */ #include "cfs/cfs.h" @@ -148,6 +148,12 @@ cfs_seek(int f, unsigned int o) } /*---------------------------------------------------------------------------*/ int +cfs_remove(const char *name) +{ + return -1; +} +/*---------------------------------------------------------------------------*/ +int cfs_opendir(struct cfs_dir *p, const char *n) { return -1; diff --git a/core/cfs/cfs.h b/core/cfs/cfs.h index 85b21e1ea..f909b9998 100644 --- a/core/cfs/cfs.h +++ b/core/cfs/cfs.h @@ -54,7 +54,7 @@ * * Author: Adam Dunkels * - * $Id: cfs.h,v 1.11 2008/01/24 13:08:35 adamdunkels Exp $ + * $Id: cfs.h,v 1.12 2008/11/24 10:56:55 nvt-se Exp $ */ #ifndef __CFS_H__ #define __CFS_H__ @@ -190,6 +190,16 @@ CCIF int cfs_write(int fd, const void *buf, unsigned int len); CCIF unsigned int cfs_seek(int fd, unsigned int offset); #endif +/** + * \brief Remove a file. + * \param name The name of the file. + * \retval 0 If the file was removed. + * \return -1 If the file could not be removed or if it doesn't exist. + */ +#ifndef cfs_remove +CCIF int cfs_remove(const char *name); +#endif + /** * \brief Open a directory for reading directory entries. * \param dirp A pointer to a struct cfs_dir that is filled in by the function.