projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
monitor_checkStack(): simplify and fix the degenerate case sp_size == 0
[bertos.git]
/
bertos
/
fs
/
battfs.c
diff --git
a/bertos/fs/battfs.c
b/bertos/fs/battfs.c
index 6df3d956076fcf6307ba4b830fbc493eac36bf11..481674e1e0f73c931578546357f2ce37603826a6 100644
(file)
--- a/
bertos/fs/battfs.c
+++ b/
bertos/fs/battfs.c
@@
-30,18
+30,22
@@
*
* -->
*
*
* -->
*
+ * \brief BattFS: a filesystem for embedded platforms (implementation).
+ *
* \version $Id:$
*
* \author Francesco Sacchi <batt@develer.com>
*
* \version $Id:$
*
* \author Francesco Sacchi <batt@develer.com>
*
- * \brief BattFS: a filesystem for embedded platforms (implementation).
*/
#include "battfs.h"
*/
#include "battfs.h"
+#warning TODO:Fix and complete this module.
+
+#if 0
#include <cfg/debug.h>
#include <cfg/macros.h> /* MIN, MAX */
#include <cfg/debug.h>
#include <cfg/macros.h> /* MIN, MAX */
-#include <
mware
/byteorder.h> /* cpu_to_xx */
+#include <
cpu
/byteorder.h> /* cpu_to_xx */
#include <string.h> /* memset, memmove */
#include <string.h> /* memset, memmove */
@@
-320,7
+324,7
@@
static void findFreeStartNext(struct BattFsSuper *disk, mark_t minl, mark_t maxl
* Upper interval is invalid.
* Use lower values.
*/
* Upper interval is invalid.
* Use lower values.
*/
-
+
disk->free_start = minl;
disk->free_next = maxl;
}
disk->free_start = minl;
disk->free_next = maxl;
}
@@
-396,7
+400,7
@@
static bool countDiskFilePages(struct BattFsSuper *disk, pgoff_t *filelen_table)
{
/* Increase free space */
disk->free_bytes += disk->page_size - BATTFS_HEADER_LEN;
{
/* Increase free space */
disk->free_bytes += disk->page_size - BATTFS_HEADER_LEN;
-
+
/* Check if page is marked free */
if (hdr.fcs_free == computeFcsFree(&hdr))
{
/* Check if page is marked free */
if (hdr.fcs_free == computeFcsFree(&hdr))
{
@@
-464,7
+468,7
@@
static bool fillPageArray(struct BattFsSuper *disk, pgoff_t *filelen_table)
else
{
BattFsPageHeader hdr_old;
else
{
BattFsPageHeader hdr_old;
-
+
if (!battfs_readHeader(disk, disk->page_array[array_pos], &hdr_old))
return false;
if (!battfs_readHeader(disk, disk->page_array[array_pos], &hdr_old))
return false;
@@
-507,7
+511,7
@@
static bool fillPageArray(struct BattFsSuper *disk, pgoff_t *filelen_table)
array_pos -= hdr.pgoff;
array_pos += filelen_table[hdr.inode];
movePages(disk, array_pos, -1);
array_pos -= hdr.pgoff;
array_pos += filelen_table[hdr.inode];
movePages(disk, array_pos, -1);
-
+
/* Decrease file page count */
filelen_table[hdr.inode]--;
/* Decrease file page count */
filelen_table[hdr.inode]--;
@@
-587,7
+591,7
@@
bool battfs_init(struct BattFsSuper *disk)
/* Init list for opened files. */
LIST_INIT(&disk->file_opened_list);
/* Init list for opened files. */
LIST_INIT(&disk->file_opened_list);
- return true;
+ return true;
}
/**
}
/**
@@
-607,7
+611,7
@@
static int battfs_flush(struct KFile *fd)
*/
static int battfs_fileclose(struct KFile *fd)
{
*/
static int battfs_fileclose(struct KFile *fd)
{
-
KFileBattFs *fdb = KFILEBATTFS
(fd);
+
BattFS *fdb = BATTFSKFILE
(fd);
battfs_flush(fd);
REMOVE(&fdb->link);
battfs_flush(fd);
REMOVE(&fdb->link);
@@
-620,7
+624,7
@@
static int battfs_fileclose(struct KFile *fd)
*/
static size_t battfs_read(struct KFile *fd, void *_buf, size_t size)
{
*/
static size_t battfs_read(struct KFile *fd, void *_buf, size_t size)
{
-
KFileBattFs *fdb = KFILEBATTFS
(fd);
+
BattFS *fdb = BATTFSKFILE
(fd);
uint8_t *buf = (uint8_t *)_buf;
size_t total_read = 0;
uint8_t *buf = (uint8_t *)_buf;
size_t total_read = 0;
@@
-664,18
+668,18
@@
static pgcnt_t *findFile(BattFsSuper *disk, inode_t inode)
while (first <= last)
{
while (first <= last)
{
-
page = (first + last) / 2;
+ page = (first + last) / 2;
if (!battfs_readHeader(disk, disk->page_array[page], &hdr))
return NULL;
fcs = computeFcs(&hdr);
if (hdr.fcs == fcs && hdr.inode == inode)
if (!battfs_readHeader(disk, disk->page_array[page], &hdr))
return NULL;
fcs = computeFcs(&hdr);
if (hdr.fcs == fcs && hdr.inode == inode)
- return (&disk->page_array[page]) - hdr.pgoff;
-
else if (hdr.fcs == fcs && hdr.inode < inode)
- first = page + 1;
-
else
- last = page - 1;
+ return (&disk->page_array[page]) - hdr.pgoff;
+ else if (hdr.fcs == fcs && hdr.inode < inode)
+ first = page + 1;
+ else
+ last = page - 1;
}
return NULL;
}
return NULL;
@@
-715,7
+719,7
@@
static bool countFileSize(BattFsSuper *disk, pgcnt_t *start, inode_t inode, file
* File context is stored in \a fd.
* \return true if ok, false otherwise.
*/
* File context is stored in \a fd.
* \return true if ok, false otherwise.
*/
-bool battfs_fileopen(BattFsSuper *disk,
KFileBattFs
*fd, inode_t inode, filemode_t mode)
+bool battfs_fileopen(BattFsSuper *disk,
BattFS
*fd, inode_t inode, filemode_t mode)
{
Node *n;
{
Node *n;
@@
-750,7
+754,7
@@
bool battfs_fileopen(BattFsSuper *disk, KFileBattFs *fd, inode_t inode, filemode
/* Insert file handle in list, ordered by inode, ascending. */
FOREACH_NODE(n, &disk->file_opened_list)
{
/* Insert file handle in list, ordered by inode, ascending. */
FOREACH_NODE(n, &disk->file_opened_list)
{
-
KFileBattFs *file = containerof(n, KFileBattFs
, link);
+
BattFS *file = containerof(n, BattFS
, link);
if (file->inode >= inode)
break;
}
if (file->inode >= inode)
break;
}
@@
-766,7
+770,7
@@
bool battfs_fileopen(BattFsSuper *disk, KFileBattFs *fd, inode_t inode, filemode
fd->fd.read = battfs_read;
fd->fd.reopen = kfile_genericReopen;
fd->fd.seek = kfile_genericSeek;
fd->fd.read = battfs_read;
fd->fd.reopen = kfile_genericReopen;
fd->fd.seek = kfile_genericSeek;
-
+
#warning TODO battfs_write, battfs_error, battfs_clearerr
#if 0
fd->fd.write = battfs_write;
#warning TODO battfs_write, battfs_error, battfs_clearerr
#if 0
fd->fd.write = battfs_write;
@@
-790,7
+794,7
@@
bool battfs_close(struct BattFsSuper *disk)
/* Close all open files */
FOREACH_NODE(n, &disk->file_opened_list)
{
/* Close all open files */
FOREACH_NODE(n, &disk->file_opened_list)
{
-
KFileBattFs *file = containerof(n, KFileBattFs
, link);
+
BattFS *file = containerof(n, BattFS
, link);
res += battfs_fileclose(&file->fd);
}
res += battfs_fileclose(&file->fd);
}
@@
-824,3
+828,5
@@
bool battfs_writeTestBlock(struct BattFsSuper *disk, pgcnt_t page, inode_t inode
return true;
}
return true;
}
+
+#endif