From be89f6a96033a2a9b6b286dd724521b0c78becb0 Mon Sep 17 00:00:00 2001 From: IonutParau Date: Tue, 29 Jul 2025 19:01:34 +0200 Subject: [PATCH] minor changes --- src/components/filesystem.c | 2 +- src/components/volatileFilesystem.c | 8 ++++---- src/emulator.c | 1 + src/neonucleus.h | 6 ++++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/components/filesystem.c b/src/components/filesystem.c index 3719598..1d35724 100644 --- a/src/components/filesystem.c +++ b/src/components/filesystem.c @@ -267,7 +267,7 @@ void nn_fs_lastModified(nn_filesystem *fs, nn_componentMethod *_, nn_component * nn_errorbuf_t err = ""; nn_lock(&fs->ctx, fs->lock); - nn_size_t t = fs->table.lastModified(fs->table.userdata, canonical, err); + nn_timestamp_t t = fs->table.lastModified(fs->table.userdata, canonical, err); nn_unlock(&fs->ctx, fs->lock); if(!nn_error_isEmpty(err)) { nn_setError(computer, err); diff --git a/src/components/volatileFilesystem.c b/src/components/volatileFilesystem.c index 27e9ed1..5059d0d 100644 --- a/src/components/volatileFilesystem.c +++ b/src/components/volatileFilesystem.c @@ -15,7 +15,7 @@ typedef struct nn_vfnode { }; nn_size_t len; nn_size_t cap; - nn_size_t lastModified; + nn_timestamp_t lastModified; // this is used to block deleting nn_refc handleCount; } nn_vfnode; @@ -41,11 +41,11 @@ typedef struct nn_vfilesystem { // virtual node helpers -nn_size_t nn_vf_now(nn_vfilesystem *fs) { +nn_timestamp_t nn_vf_now(nn_vfilesystem *fs) { nn_Clock c = fs->ctx.clock; double time = c.proc(c.userdata); double elapsed = time - fs->birthday; - nn_size_t elapsedMS = elapsed * 1000; + nn_timestamp_t elapsedMS = elapsed * 1000; return fs->opts.creationTime + elapsedMS; } @@ -285,7 +285,7 @@ nn_size_t nn_vfs_remove(nn_vfilesystem *fs, const char *path, nn_errorbuf_t err) return removed; } -nn_size_t nn_vfs_lastModified(nn_vfilesystem *fs, const char *path, nn_errorbuf_t err) { +nn_timestamp_t nn_vfs_lastModified(nn_vfilesystem *fs, const char *path, nn_errorbuf_t err) { nn_vfnode *node = nn_vf_resolvePath(fs, path); if(node == NULL) { nn_error_write(err, "No such file"); diff --git a/src/emulator.c b/src/emulator.c index c2a3321..6fa8c56 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -232,6 +232,7 @@ void *ne_fs_open(nn_address address, const char *path, const char *mode, nn_erro FILE *f = fopen(p, trueMode); if(f == NULL) { nn_error_write(err, strerror(errno)); + return NULL; } setvbuf(f, NULL, _IONBF, BUFSIZ); return f; diff --git a/src/neonucleus.h b/src/neonucleus.h index 1058fbd..d0585d1 100644 --- a/src/neonucleus.h +++ b/src/neonucleus.h @@ -141,6 +141,8 @@ typedef struct nn_computer nn_computer; typedef struct nn_component nn_component; typedef struct nn_componentTable nn_componentTable; +typedef unsigned long long nn_timestamp_t; + // A non-zero malloc is a null ptr, with a 0 oldSize, but a non-0 newSize. // A zero malloc is never called, the proc address itself is returned, which is ignored when freeing. // A free is a non-null ptr, with a non-zero oldSize, but a newSize of 0. @@ -778,7 +780,7 @@ typedef struct nn_filesystemTable { // general operations nn_size_t (*size)(void *userdata, const char *path, nn_errorbuf_t err); nn_size_t (*remove)(void *userdata, const char *path, nn_errorbuf_t err); - nn_size_t (*lastModified)(void *userdata, const char *path, nn_errorbuf_t err); + nn_timestamp_t (*lastModified)(void *userdata, const char *path, nn_errorbuf_t err); nn_size_t (*rename)(void *userdata, const char *from, const char *to, nn_errorbuf_t err); nn_bool_t (*exists)(void *userdata, const char *path, nn_errorbuf_t err); @@ -813,7 +815,7 @@ typedef struct nn_vfilesystemImageNode { typedef struct nn_vfilesystemOptions { // used to compute lastModified - nn_size_t creationTime; + nn_timestamp_t creationTime; nn_size_t maxDirEntries; nn_size_t capacity; nn_bool_t isReadOnly;