From 7bbff69d53b90da29fd2758d4164d717208fe7ad Mon Sep 17 00:00:00 2001 From: JingWangTW Date: Wed, 17 Jun 2020 19:16:24 +0800 Subject: [PATCH] fix some bugs --- src/fs/fat32.c | 2 ++ src/main.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fs/fat32.c b/src/fs/fat32.c index b078c688..96e03555 100644 --- a/src/fs/fat32.c +++ b/src/fs/fat32.c @@ -236,6 +236,8 @@ int fat32_write ( file_t * file, const void * buf, size_t len ) } } + file_node->size = len; + writeblock ( ( dir_node->cluster - 2 ) * sd_root_bst->logic_sector_per_cluster + sd_root_partition->starting_sector + sd_root_partition->root_sector_abs, dir_entrty ); uart_printf ( "Write to file: %s, size: %d\n", file_node->name, len ); diff --git a/src/main.c b/src/main.c index f5572031..bad4dd6b 100644 --- a/src/main.c +++ b/src/main.c @@ -30,12 +30,14 @@ int main ( ) vfs_read ( b, buf, 100 ); uart_printf ( ">> %s\n", buf ); - vfs_write ( b, "Hello World\n", 12 ); + vfs_write ( b, "Hello World.\n", 12 ); + // vfs_write ( b, "Sample text in sample file.\n", 28 ); vfs_close ( b ); b = vfs_open ( "test.txt", 0 ); vfs_read ( b, buf, 100 ); uart_printf ( ">> %s\n", buf ); + vfs_close ( b ); // start shell shell_start ( );