summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-10-17 16:22:03 -0400
committerIan Moffett <ian@osmora.org>2025-10-17 16:22:03 -0400
commit4d6a6a58ddf41a903a602ef3f4be07c66e4cfed0 (patch)
treebbdf69723538e113774459feabe0beaad724fd68 /src
parent07c188f279d0717bdb521c056bd6a755c54c2608 (diff)
kern: tmpfs: Use real length for EOF trackingHEADmaster
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')
-rw-r--r--src/sys/fs/tmpfs.c5
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 */
}