static void test10(BattFsSuper *disk)
{
- BattFsKFile fd1;
- BattFsKFile fd2;
+ BattFS fd1;
+ BattFS fd2;
kprintf("Test10: open file test, inode 0 and inode 4\n");
fp = fopen(test_filename, "w+");
static void test11(BattFsSuper *disk)
{
- BattFsKFile fd1;
+ BattFS fd1;
uint8_t buf[16];
kprintf("Test11: read file test\n");
static void test12(BattFsSuper *disk)
{
- BattFsKFile fd1;
+ BattFS fd1;
kprintf("Test12: read file test across page boundary and seek test\n");
*/
static int battfs_fileclose(struct KFile *fd)
{
- BattFsKFile *fdb = BATTFSKFILE(fd);
+ BattFS *fdb = BATTFSKFILE(fd);
battfs_flush(fd);
REMOVE(&fdb->link);
*/
static size_t battfs_read(struct KFile *fd, void *_buf, size_t size)
{
- BattFsKFile *fdb = BATTFSKFILE(fd);
+ BattFS *fdb = BATTFSKFILE(fd);
uint8_t *buf = (uint8_t *)_buf;
size_t total_read = 0;
* File context is stored in \a fd.
* \return true if ok, false otherwise.
*/
-bool battfs_fileopen(BattFsSuper *disk, BattFsKFile *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)
{
- BattFsKFile *file = containerof(n, BattFsKFile, link);
+ BattFS *file = containerof(n, BattFS, link);
if (file->inode >= inode)
break;
}
/* Close all open files */
FOREACH_NODE(n, &disk->file_opened_list)
{
- BattFsKFile *file = containerof(n, BattFsKFile, link);
+ BattFS *file = containerof(n, BattFS, link);
res += battfs_fileclose(&file->fd);
}
/**
* Describe a BattFs file usign a KFile.
*/
-typedef struct BattFsKFile
+typedef struct BattFS
{
KFile fd; ///< KFile context
Node link; ///< Link for inserting in opened file list
BattFsSuper *disk; ///< Disk context
filemode_t mode; ///< File open mode
pgcnt_t *start; ///< Pointer to page_array file start position.
-} BattFsKFile;
+} BattFS;
/**
* Id for battfs file descriptors.
#define KFT_BATTFS MAKE_ID('B', 'T', 'F', 'S')
/**
- * Macro used to cast a KFile to a BattFsKFile.
+ * Macro used to cast a KFile to a BattFS.
* Also perform dynamic type check.
*/
-INLINE BattFsKFile * BATTFSKFILE(KFile *fd)
+INLINE BattFS * BATTFSKFILE(KFile *fd)
{
ASSERT(fd->_type == KFT_BATTFS);
- return (BattFsKFile *)fd;
+ return (BattFS *)fd;
}
bool battfs_init(struct BattFsSuper *d);
bool battfs_close(struct BattFsSuper *disk);
bool battfs_fileExists(BattFsSuper *disk, inode_t inode);
-bool battfs_fileopen(BattFsSuper *disk, BattFsKFile *fd, inode_t inode, filemode_t mode);
+bool battfs_fileopen(BattFsSuper *disk, BattFS *fd, inode_t inode, filemode_t mode);
bool battfs_writeTestBlock(struct BattFsSuper *disk, pgcnt_t page, inode_t inode, seq_t seq, fill_t fill, pgoff_t pgoff, mark_t mark);