From: qwert Date: Tue, 5 Aug 2008 12:57:51 +0000 (+0000) Subject: Re-Refactor code under new specs. BattFs. Nightlytest passed. X-Git-Tag: 2.0.0~389 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=ac4ffd37dc8234b555bf2f540bd09210febdd11b;p=bertos.git Re-Refactor code under new specs. BattFs. Nightlytest passed. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1545 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/app/battfs/battfs_test.c b/app/battfs/battfs_test.c index 1b5d9d56..e7b529eb 100644 --- a/app/battfs/battfs_test.c +++ b/app/battfs/battfs_test.c @@ -351,8 +351,8 @@ static void test9(BattFsSuper *disk) 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+"); @@ -416,7 +416,7 @@ static void test10(BattFsSuper *disk) static void test11(BattFsSuper *disk) { - BattFsKFile fd1; + BattFS fd1; uint8_t buf[16]; kprintf("Test11: read file test\n"); @@ -454,7 +454,7 @@ static void test11(BattFsSuper *disk) static void test12(BattFsSuper *disk) { - BattFsKFile fd1; + BattFS fd1; kprintf("Test12: read file test across page boundary and seek test\n"); diff --git a/bertos/fs/battfs.c b/bertos/fs/battfs.c index c940bad1..f975921a 100644 --- a/bertos/fs/battfs.c +++ b/bertos/fs/battfs.c @@ -611,7 +611,7 @@ static int battfs_flush(struct KFile *fd) */ static int battfs_fileclose(struct KFile *fd) { - BattFsKFile *fdb = BATTFSKFILE(fd); + BattFS *fdb = BATTFSKFILE(fd); battfs_flush(fd); REMOVE(&fdb->link); @@ -624,7 +624,7 @@ static int battfs_fileclose(struct KFile *fd) */ 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; @@ -719,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. */ -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; @@ -754,7 +754,7 @@ bool battfs_fileopen(BattFsSuper *disk, BattFsKFile *fd, inode_t inode, filemode /* 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; } @@ -794,7 +794,7 @@ bool battfs_close(struct BattFsSuper *disk) /* 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); } diff --git a/bertos/fs/battfs.h b/bertos/fs/battfs.h index afe69f5e..ec03da22 100644 --- a/bertos/fs/battfs.h +++ b/bertos/fs/battfs.h @@ -228,7 +228,7 @@ typedef uint32_t file_size_t; ///< Type for file sizes. /** * 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 @@ -236,7 +236,7 @@ typedef struct BattFsKFile 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. @@ -244,20 +244,20 @@ typedef struct BattFsKFile #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);