From 850a464bfa48e3f4279bc2362c7b565896a88b9a Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 21 Jul 2025 03:52:25 -0400 Subject: kernel: tmpfs: Fixup real_size computation Signed-off-by: Ian Moffett --- sys/fs/tmpfs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sys/fs') diff --git a/sys/fs/tmpfs.c b/sys/fs/tmpfs.c index c3f2fae..4fd9e85 100644 --- a/sys/fs/tmpfs.c +++ b/sys/fs/tmpfs.c @@ -238,6 +238,7 @@ static int tmpfs_write(struct vnode *vp, struct sio_txn *sio) { struct tmpfs_node *np; + off_t res_off; uint8_t *buf; if (sio->buf == NULL || sio->len == 0) { @@ -274,8 +275,9 @@ tmpfs_write(struct vnode *vp, struct sio_txn *sio) * Bring up the real size if we are writing * more bytes. */ - if (sio->offset >= np->real_size) { - np->real_size = sio->offset; + res_off = sio->offset + sio->len; + if (res_off > np->real_size) { + np->real_size = res_off; } /* @@ -285,7 +287,7 @@ tmpfs_write(struct vnode *vp, struct sio_txn *sio) * into a suitable size that does not overflow what we * have left. */ - if ((sio->offset + sio->len) > np->len) { + if (res_off > np->len) { np->data = dynrealloc(np->data, (sio->offset + sio->len)); if (np->data == NULL) { sio->len = np->len; -- cgit v1.2.3