From 08be8c66d3dd39ec539ed45c3a38a932617349d6 Mon Sep 17 00:00:00 2001 From: Douglas Thain Date: Mon, 18 Dec 2023 10:54:10 -0500 Subject: [PATCH] Update inode size when entering an item into an existing block. --- kernel/diskfs.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/diskfs.c b/kernel/diskfs.c index baf678d1..e3133772 100644 --- a/kernel/diskfs.c +++ b/kernel/diskfs.c @@ -366,7 +366,16 @@ static int diskfs_dirent_add( struct fs_dirent *d, const char *name, int type, i r->inumber = inumber; r->name_length = strlen(name); memcpy(r->name,name,r->name_length); + + /* Save the modified data block. */ diskfs_inode_write(d,b,i); + + /* If this increased the logical size, update that too. */ + uint32_t newsize = (i*DISKFS_BLOCK_SIZE) + (j+1)*sizeof(struct diskfs_item); + if(newsize>d->size) { + diskfs_dirent_resize(d,newsize); + diskfs_inode_save(d->volume,d->inumber,&d->disk); + } page_free(b); return 0; }