diff options
Diffstat (limited to 'lib9p')
-rw-r--r-- | lib9p/CMakeLists.txt | 2 | ||||
-rw-r--r-- | lib9p/include/lib9p/srv.h | 8 | ||||
-rw-r--r-- | lib9p/srv.c | 17 | ||||
-rwxr-xr-x | lib9p/tests/runtest | 8 | ||||
-rw-r--r-- | lib9p/tests/test_server/main.c | 8 |
5 files changed, 30 insertions, 13 deletions
diff --git a/lib9p/CMakeLists.txt b/lib9p/CMakeLists.txt index 11a58ba..d433a12 100644 --- a/lib9p/CMakeLists.txt +++ b/lib9p/CMakeLists.txt @@ -4,7 +4,7 @@ # SPDX-License-Identifier: AGPL-3.0-or-later add_library(lib9p INTERFACE) -target_include_directories(lib9p SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) +target_include_directories(lib9p PUBLIC INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) target_sources(lib9p INTERFACE 9p.generated.c 9p.c diff --git a/lib9p/include/lib9p/srv.h b/lib9p/include/lib9p/srv.h index ff5ebdc..070cf5a 100644 --- a/lib9p/include/lib9p/srv.h +++ b/lib9p/include/lib9p/srv.h @@ -26,9 +26,9 @@ struct lib9p_srv_ctx { uint32_t uid; struct lib9p_s uname; - BEGIN_PRIVATE(LIB9P_SRV_H) + BEGIN_PRIVATE(LIB9P_SRV_H); _lib9p_srv_flushch_t _flushch; - END_PRIVATE(LIB9P_SRV_H) + END_PRIVATE(LIB9P_SRV_H); }; bool lib9p_srv_flush_requested(struct lib9p_srv_ctx *ctx); @@ -140,11 +140,11 @@ struct lib9p_srv { lo_interface lib9p_srv_file (*rootdir)(struct lib9p_srv_ctx *, struct lib9p_s treename); /* For internal use */ - BEGIN_PRIVATE(LIB9P_SRV_H) + BEGIN_PRIVATE(LIB9P_SRV_H); unsigned int readers; unsigned int writers; _lib9p_srv_reqch_t _reqch; - END_PRIVATE(LIB9P_SRV_H) + END_PRIVATE(LIB9P_SRV_H); }; /** diff --git a/lib9p/srv.c b/lib9p/srv.c index bfeb06f..a425dc9 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -199,7 +199,11 @@ static void respond_error(struct _lib9p_srv_req *req) { LIB9P_TYP_Rerror, &host, &net); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat" +#pragma GCC diagnostic ignored "-Wformat-extra-args" infof("< %v", lo_box_lib9p_msg_Rerror_as_fmt_formatter(&host)); +#pragma GCC diagnostic pop r = write_Rmsg(req, &net); if (r < 0) nonrespond_errorf("write: %s", net_strerror(-r)); @@ -425,7 +429,11 @@ static void handle_message(struct _lib9p_srv_req *ctx) { enum lib9p_msg_type typ; lib9p_Tmsg_unmarshal(&ctx->ctx.basectx, ctx->net_bytes, &typ, host_req); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat" +#pragma GCC diagnostic ignored "-Wformat-extra-args" infof("> %v", lo_box_lib9p_msg_as_fmt_formatter(&ctx->ctx.basectx, typ, host_req)); +#pragma GCC diagnostic pop /* Handle it. */ tmessage_handlers[typ](ctx, (void *)host_req, (void *)host_resp); @@ -439,7 +447,11 @@ static void handle_message(struct _lib9p_srv_req *ctx) { typ+1, host_resp, &net_resp)) goto write; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat" +#pragma GCC diagnostic ignored "-Wformat-extra-args" infof("< %v", lo_box_lib9p_msg_as_fmt_formatter(&ctx->ctx.basectx, typ+1, &host_resp)); +#pragma GCC diagnostic pop write_Rmsg(ctx, &net_resp); } if (host_req) @@ -903,6 +915,7 @@ static void handle_Topen(struct _lib9p_srv_req *ctx, if (!srv_util_check_perm(ctx, &stat, perm_bits)) { lib9p_error(&ctx->ctx.basectx, LINUX_EACCES, "permission denied"); + return; } /* Actually make the call. */ @@ -953,6 +966,8 @@ static void handle_Tread(struct _lib9p_srv_req *ctx, struct lib9p_msg_Rread *resp) { util_handler_common(ctx, req, resp); + /* TODO: serialize simultaneous reads to the same FID */ + /* Check that the FID is valid for this. */ struct _srv_fidinfo *fidinfo = fidmap_load(&ctx->parent_sess->fids, req->fid); if (!fidinfo) { @@ -1015,6 +1030,8 @@ static void handle_Twrite(struct _lib9p_srv_req *ctx, struct lib9p_msg_Rwrite *resp) { util_handler_common(ctx, req, resp); + /* TODO: serialize simultaneous writes to the same FID */ + /* Check that the FID is valid for this. */ struct _srv_fidinfo *fidinfo = fidmap_load(&ctx->parent_sess->fids, req->fid); if (!fidinfo) { diff --git a/lib9p/tests/runtest b/lib9p/tests/runtest index a745f12..379ea6d 100755 --- a/lib9p/tests/runtest +++ b/lib9p/tests/runtest @@ -26,13 +26,13 @@ while [[ -d /proc/$server_pid && "$(readlink /proc/$server_pid/fd/4 2>/dev/null) out=$("${client[@]}" ls -l '') expect_lines \ - 'd-r-xr-xr-x M 0 root root 0 Oct 7 15:51 Documentation' \ - '--r--r--r-- M 0 root root 166 Oct 7 15:51 README.md' \ - '---w--w--w- M 0 root root 0 Oct 7 15:51 shutdown' + 'd-r-xr-xr-x M 0 root root 0 Oct 7 2024 Documentation' \ + '--r--r--r-- M 0 root root 166 Oct 7 2024 README.md' \ + '---w--w--w- M 0 root root 0 Oct 7 2024 shutdown' out=$("${client[@]}" ls -l 'Documentation/') expect_lines \ - '--r--r--r-- M 0 root root 166 Oct 7 15:51 x' + '--r--r--r-- M 0 root root 166 Oct 7 2024 x' out=$("${client[@]}" read 'README.md') expect_lines \ diff --git a/lib9p/tests/test_server/main.c b/lib9p/tests/test_server/main.c index c759029..a31c083 100644 --- a/lib9p/tests/test_server/main.c +++ b/lib9p/tests/test_server/main.c @@ -47,11 +47,11 @@ struct { struct api_file { uint64_t pathnum; }; -LO_IMPLEMENTATION_H(lib9p_srv_file, struct api_file, api) -LO_IMPLEMENTATION_H(lib9p_srv_fio, struct api_file, api) +LO_IMPLEMENTATION_H(lib9p_srv_file, struct api_file, api); +LO_IMPLEMENTATION_H(lib9p_srv_fio, struct api_file, api); -LO_IMPLEMENTATION_C(lib9p_srv_file, struct api_file, api, static) -LO_IMPLEMENTATION_C(lib9p_srv_fio, struct api_file, api, static) +LO_IMPLEMENTATION_C(lib9p_srv_file, struct api_file, api, static); +LO_IMPLEMENTATION_C(lib9p_srv_fio, struct api_file, api, static); static void api_free(struct api_file *self) { assert(self); |