diff options
author | Ian Moffett <ian@osmora.org> | 2025-10-17 16:22:03 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-10-17 16:22:03 -0400 |
commit | 4d6a6a58ddf41a903a602ef3f4be07c66e4cfed0 (patch) | |
tree | bbdf69723538e113774459feabe0beaad724fd68 /src/sys | |
parent | 07c188f279d0717bdb521c056bd6a755c54c2608 (diff) |
Use the actual amount of bytes inside the tmpfs entry for the length
tracking.
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/sys')
-rw-r--r-- | src/sys/fs/tmpfs.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/sys/fs/tmpfs.c b/src/sys/fs/tmpfs.c index c49dc93..63e6577 100644 --- a/src/sys/fs/tmpfs.c +++ b/src/sys/fs/tmpfs.c @@ -47,6 +47,7 @@ struct tmpfs_node { char name[TMPFS_NAMEMAX]; char *data; size_t len; + size_t real_len; int ref; TAILQ_ENTRY(tmpfs_node) link; }; @@ -93,6 +94,7 @@ tmpfs_new(const char *name, struct tmpfs_node **np_res) return -ENOMEM; } + np->real_len = 0; np->len = TMPFS_INIT_SIZE; np->ref = 1; memset(np->data, 0, TMPFS_INIT_SIZE); @@ -276,6 +278,7 @@ tmpfs_write(struct vop_rw_data *data) } } + np->real_len += len; node_len = np->len; dest = np->data + data->off; memcpy(dest, data->data, len); @@ -304,7 +307,7 @@ tmpfs_read(struct vop_rw_data *data) /* Return EOF if the offset is too far */ len = data->len; - if (data->off >= np->len) { + if (data->off >= np->real_len) { return 0; /* EOF */ } |