ext2: update the vfs_file_t length after writing

The vfs_file_t->length field is initialized but never used afterwards.
It seams correct to updated it after the inode size possibly changed.
This commit is contained in:
Florian Fischer
2024-02-13 21:47:58 +01:00
parent 4d4504486d
commit 44b1acf33c
+4 -1
View File
@@ -2589,7 +2589,10 @@ static ssize_t ext2_write(vfs_file_t *file, const void *buffer, off_t offset, si
pr_err("Failed to read the inode `%s`.\n", file->name);
return -1;
}
return ext2_write_inode_data(fs, &inode, file->ino, offset, nbyte, (char *)buffer);
ssize_t written = ext2_write_inode_data(fs, &inode, file->ino, offset, nbyte, (char *)buffer);
// Update the file length
file->length = inode.size;
return written;
}
/// @brief Repositions the file offset inside a file.