From: qwert Date: Mon, 4 Aug 2008 15:55:19 +0000 (+0000) Subject: Refactor from KFileBattFs to BattFsKFile. X-Git-Tag: 2.0.0~392 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=330e739c66975353f97071ff31d67d62127dd2eb;p=bertos.git Refactor from KFileBattFs to BattFsKFile. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1542 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/app/battfs/battfs_test.c b/app/battfs/battfs_test.c index 05d40df8..1b5d9d56 100644 --- a/app/battfs/battfs_test.c +++ b/app/battfs/battfs_test.c @@ -99,7 +99,7 @@ static bool disk_close(struct BattFsSuper *d) static void testCheck(BattFsSuper *disk, pgcnt_t *reference) { ASSERT(battfs_init(disk)); - + for (int i = 0; i < disk->page_count; i++) { if (disk->page_array[i] != reference[i]) @@ -351,8 +351,8 @@ static void test9(BattFsSuper *disk) static void test10(BattFsSuper *disk) { - KFileBattFs fd1; - KFileBattFs fd2; + BattFsKFile fd1; + BattFsKFile 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) { - KFileBattFs fd1; + BattFsKFile 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) { - KFileBattFs fd1; + BattFsKFile 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 3a741344..3a5d90b0 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) { - KFileBattFs *fdb = KFILEBATTFS(fd); + BattFsKFile *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) { - KFileBattFs *fdb = KFILEBATTFS(fd); + BattFsKFile *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, KFileBattFs *fd, inode_t inode, filemode_t mode) +bool battfs_fileopen(BattFsSuper *disk, BattFsKFile *fd, inode_t inode, filemode_t mode) { Node *n; @@ -754,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) { - KFileBattFs *file = containerof(n, KFileBattFs, link); + BattFsKFile *file = containerof(n, BattFsKFile, 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) { - KFileBattFs *file = containerof(n, KFileBattFs, link); + BattFsKFile *file = containerof(n, BattFsKFile, link); res += battfs_fileclose(&file->fd); } diff --git a/bertos/fs/battfs.h b/bertos/fs/battfs.h index 59d8fece..5dace139 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 KFileBattFs +typedef struct BattFsKFile { KFile fd; ///< KFile context Node link; ///< Link for inserting in opened file list @@ -236,7 +236,7 @@ typedef struct KFileBattFs BattFsSuper *disk; ///< Disk context filemode_t mode; ///< File open mode pgcnt_t *start; ///< Pointer to page_array file start position. -} KFileBattFs; +} BattFsKFile; /** * Id for battfs file descriptors. @@ -244,20 +244,20 @@ typedef struct KFileBattFs #define KFT_BATTFS MAKE_ID('B', 'T', 'F', 'S') /** - * Macro used to cast a KFile to a KFileBattFs. + * Macro used to cast a KFile to a BattFsKFile. * Also perform dynamic type check. */ -INLINE KFileBattFs * KFILEBATTFS(KFile *fd) +INLINE BattFsKFile * BattFsKFile(KFile *fd) { ASSERT(fd->_type == KFT_BATTFS); - return (KFileBattFs *)fd; + return (BattFsKFile *)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, KFileBattFs *fd, inode_t inode, filemode_t mode); +bool battfs_fileopen(BattFsSuper *disk, BattFsKFile *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);