*
* -->
*
+ * \brief BattFS: a filesystem for embedded platforms (implementation).
+ *
* \version $Id:$
*
* \author Francesco Sacchi <batt@develer.com>
*
- * \brief BattFS: a filesystem for embedded platforms (implementation).
*/
#include "battfs.h"
+#warning TODO:Fix and complete this module.
+
+#if 0
#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 */
{
pgcnt_t dst = src + offset;
memmove(&disk->page_array[dst], &disk->page_array[src], (disk->page_count - MAX(dst, src)) * sizeof(pgcnt_t));
-
+
if (offset < 0)
{
/* Fill empty space in array with sentinel */
* Upper interval is invalid.
* Use lower values.
*/
-
+
disk->free_start = minl;
disk->free_next = maxl;
}
{
/* Increase free space */
disk->free_bytes += disk->page_size - BATTFS_HEADER_LEN;
-
+
/* Check if page is marked free */
if (hdr.fcs_free == computeFcsFree(&hdr))
{
else
{
BattFsPageHeader hdr_old;
-
+
if (!battfs_readHeader(disk, disk->page_array[array_pos], &hdr_old))
return false;
array_pos -= hdr.pgoff;
array_pos += filelen_table[hdr.inode];
movePages(disk, array_pos, -1);
-
+
/* Decrease file page count */
filelen_table[hdr.inode]--;
/* Init list for opened files. */
LIST_INIT(&disk->file_opened_list);
- return true;
+ return true;
}
/**
*/
static int battfs_fileclose(struct KFile *fd)
{
- KFileBattFs *fdb = KFILEBATTFS(fd);
+ BattFS *fdb = BATTFSKFILE(fd);
battfs_flush(fd);
REMOVE(&fdb->link);
*/
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;
pgaddr_t addr_offset;
pgaddr_t read_len;
- size = MIN(size, fd->size - fd->seek_pos);
+ size = MIN((kfile_off_t)size, fd->size - fd->seek_pos);
while (size)
{
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)
- 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;
* 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;
/* 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;
}
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;
/* 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);
}
return true;
}
+
+#endif