From 8a9fc1704dcf3ec117a3bf37fd70a44a43873659 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Thu, 29 May 2025 23:39:12 -0400 Subject: lib9p: Use errnums internally --- lib9p/tests/test_server/fs_shutdown.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib9p/tests/test_server/fs_shutdown.c') diff --git a/lib9p/tests/test_server/fs_shutdown.c b/lib9p/tests/test_server/fs_shutdown.c index 0dd473d..11a941f 100644 --- a/lib9p/tests/test_server/fs_shutdown.c +++ b/lib9p/tests/test_server/fs_shutdown.c @@ -49,12 +49,12 @@ static struct lib9p_srv_stat shutdown_file_stat(struct shutdown_file *self, stru static void shutdown_file_wstat(struct shutdown_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_srv_stat) { assert(self); assert(ctx); - lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EROFS, "cannot wstat API file"); + lib9p_error(&ctx->basectx, E_POSIX_EROFS, "cannot wstat API file"); } static void shutdown_file_remove(struct shutdown_file *self, struct lib9p_srv_ctx *ctx) { assert(self); assert(ctx); - lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_EROFS, "cannot remove API file"); + lib9p_error(&ctx->basectx, E_POSIX_EROFS, "cannot remove API file"); } LIB9P_SRV_NOTDIR(struct shutdown_file, shutdown_file) -- cgit v1.2.3-2-g168b From 945756b1b050bdf09d1119854cc5b22ad15efacd Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Thu, 29 May 2025 22:25:02 -0400 Subject: lib9p_core: Switch to use error.h --- lib9p/tests/test_server/fs_shutdown.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib9p/tests/test_server/fs_shutdown.c') diff --git a/lib9p/tests/test_server/fs_shutdown.c b/lib9p/tests/test_server/fs_shutdown.c index 11a941f..5b3bc71 100644 --- a/lib9p/tests/test_server/fs_shutdown.c +++ b/lib9p/tests/test_server/fs_shutdown.c @@ -49,12 +49,12 @@ static struct lib9p_srv_stat shutdown_file_stat(struct shutdown_file *self, stru static void shutdown_file_wstat(struct shutdown_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_srv_stat) { assert(self); assert(ctx); - lib9p_error(&ctx->basectx, E_POSIX_EROFS, "cannot wstat API file"); + lib9p_error(ctx, E_POSIX_EROFS, "cannot wstat API file"); } static void shutdown_file_remove(struct shutdown_file *self, struct lib9p_srv_ctx *ctx) { assert(self); assert(ctx); - lib9p_error(&ctx->basectx, E_POSIX_EROFS, "cannot remove API file"); + lib9p_error(ctx, E_POSIX_EROFS, "cannot remove API file"); } LIB9P_SRV_NOTDIR(struct shutdown_file, shutdown_file) -- cgit v1.2.3-2-g168b From 7b0f4d3ac1a64f4015148e89eeeeedf0a617cbc5 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Thu, 29 May 2025 22:25:02 -0400 Subject: lib9p_srv: Change the public API to use error.h --- lib9p/tests/test_server/fs_shutdown.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'lib9p/tests/test_server/fs_shutdown.c') diff --git a/lib9p/tests/test_server/fs_shutdown.c b/lib9p/tests/test_server/fs_shutdown.c index 5b3bc71..079442e 100644 --- a/lib9p/tests/test_server/fs_shutdown.c +++ b/lib9p/tests/test_server/fs_shutdown.c @@ -30,10 +30,10 @@ static struct lib9p_qid shutdown_file_qid(struct shutdown_file *self) { }; } -static struct lib9p_srv_stat shutdown_file_stat(struct shutdown_file *self, struct lib9p_srv_ctx *ctx) { +static lib9p_srv_stat_or_error shutdown_file_stat(struct shutdown_file *self, struct lib9p_srv_ctx *ctx) { assert(self); assert(ctx); - return (struct lib9p_srv_stat){ + return ERROR_NEW_VAL(lib9p_srv_stat, ((struct lib9p_srv_stat){ .qid = shutdown_file_qid(self), .mode = 0222 | LIB9P_DM_APPEND, .atime_sec = UTIL9P_ATIME, @@ -44,29 +44,29 @@ static struct lib9p_srv_stat shutdown_file_stat(struct shutdown_file *self, stru .owner_gid = { .name=lib9p_str("root"), .num=0 }, .last_modifier_uid = { .name=lib9p_str("root"), .num=0 }, .extension = lib9p_str(NULL), - }; + })); } -static void shutdown_file_wstat(struct shutdown_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_srv_stat) { +static error shutdown_file_wstat(struct shutdown_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_srv_stat) { assert(self); assert(ctx); - lib9p_error(ctx, E_POSIX_EROFS, "cannot wstat API file"); + return error_new(E_POSIX_EROFS, "cannot wstat API file"); } -static void shutdown_file_remove(struct shutdown_file *self, struct lib9p_srv_ctx *ctx) { +static error shutdown_file_remove(struct shutdown_file *self, struct lib9p_srv_ctx *ctx) { assert(self); assert(ctx); - lib9p_error(ctx, E_POSIX_EROFS, "cannot remove API file"); + return error_new(E_POSIX_EROFS, "cannot remove API file"); } -LIB9P_SRV_NOTDIR(struct shutdown_file, shutdown_file) +LIB9P_SRV_NOTDIR(struct shutdown_file, shutdown_file); -static lo_interface lib9p_srv_fio shutdown_file_fopen(struct shutdown_file *self, struct lib9p_srv_ctx *ctx, bool, bool, bool) { +static lib9p_srv_fio_or_error shutdown_file_fopen(struct shutdown_file *self, struct lib9p_srv_ctx *ctx, bool, bool, bool) { assert(self); assert(ctx); struct shutdown_fio *ret = heap_alloc(1, struct shutdown_fio); ret->parent = self; - return LO_BOX(lib9p_srv_fio, ret); + return ERROR_NEW_VAL(lib9p_srv_fio, LO_BOX(lib9p_srv_fio, ret)); } /* srv_fio ********************************************************************/ @@ -86,19 +86,18 @@ static uint32_t shutdown_fio_iounit(struct shutdown_fio *self) { return 0; } -static uint32_t shutdown_fio_pwrite(struct shutdown_fio *self, struct lib9p_srv_ctx *ctx, void *buf, uint32_t byte_count, uint64_t offset) { +static uint32_t_or_error shutdown_fio_pwrite(struct shutdown_fio *self, struct lib9p_srv_ctx *ctx, void *buf, uint32_t byte_count, uint64_t offset) { assert(self); assert(ctx); assert(buf); assert(offset == 0); if (byte_count == 0) - return 0; + return ERROR_NEW_VAL(uint32_t, 0); for (size_t i = 0; i < self->parent->nlisteners; i++) LO_CALL(LO_BOX(net_stream_listener, &self->parent->listeners[i]), close); - return byte_count; + return ERROR_NEW_VAL(uint32_t, byte_count); } -static void shutdown_fio_pread(struct shutdown_fio *LM_UNUSED(self), struct lib9p_srv_ctx *LM_UNUSED(ctx), - uint32_t LM_UNUSED(byte_count), uint64_t LM_UNUSED(byte_offset), - struct iovec *LM_UNUSED(ret)) { +static iovec_or_error shutdown_fio_pread(struct shutdown_fio *LM_UNUSED(self), struct lib9p_srv_ctx *LM_UNUSED(ctx), + uint32_t LM_UNUSED(byte_count), uint64_t LM_UNUSED(byte_offset)) { assert_notreached("not readable"); } -- cgit v1.2.3-2-g168b