summaryrefslogtreecommitdiff
path: root/lib9p/srv.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-19 12:31:51 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-19 12:53:42 -0600
commit7f34046f5b27617b70c1d55f479c2a1abb8b8d8a (patch)
tree8037e1493bfebe72cb6023f5eccb62cff0c63349 /lib9p/srv.c
parent22899c1c7b30d7f46a2c91841d8b7144f8476de3 (diff)
lib9p: Don't require that CONFIG_9P_ENABLE_9P2000
Diffstat (limited to 'lib9p/srv.c')
-rw-r--r--lib9p/srv.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib9p/srv.c b/lib9p/srv.c
index fd8e662..08ccfc3 100644
--- a/lib9p/srv.c
+++ b/lib9p/srv.c
@@ -176,6 +176,7 @@ static inline bool srv_check_perm(struct srv_req *ctx, struct lib9p_srv_stat *st
return mode & action;
}
+[[gnu::unused]]
static struct lib9p_srv_userid *srv_userid_new(struct lib9p_s name
#if CONFIG_9P_ENABLE_9P2000_u || CONFIG_9P_ENABLE_9P2000_L
, lib9p_nuid_t num
@@ -591,6 +592,7 @@ void lib9p_srv_worker_loop(struct lib9p_srv *srv) {
static void handle_T##typ(struct srv_req *, \
struct lib9p_msg_T##typ *)
_HANDLER_PROTO(version);
+#if _LIB9P_ENABLE_stat
_HANDLER_PROTO(auth);
_HANDLER_PROTO(attach);
_HANDLER_PROTO(flush);
@@ -603,6 +605,7 @@ _HANDLER_PROTO(clunk);
_HANDLER_PROTO(remove);
_HANDLER_PROTO(stat);
_HANDLER_PROTO(wstat);
+#endif
#if CONFIG_9P_ENABLE_9P2000_p9p
_HANDLER_PROTO(openfd);
#endif
@@ -636,6 +639,7 @@ void lib9p_srv_worker(struct srv_req *ctx) {
#pragma GCC diagnostic ignored "-Wswitch-enum"
switch (typ) {
case LIB9P_TYP_Tversion: handler = (tmessage_handler)handle_Tversion; break;
+#if _LIB9P_ENABLE_stat
case LIB9P_TYP_Tauth: handler = (tmessage_handler)handle_Tauth; break;
case LIB9P_TYP_Tattach: handler = (tmessage_handler)handle_Tattach; break;
case LIB9P_TYP_Tflush: handler = (tmessage_handler)handle_Tflush; break;
@@ -648,6 +652,7 @@ void lib9p_srv_worker(struct srv_req *ctx) {
case LIB9P_TYP_Tremove: handler = (tmessage_handler)handle_Tremove; break;
case LIB9P_TYP_Tstat: handler = (tmessage_handler)handle_Tstat; break;
case LIB9P_TYP_Twstat: handler = (tmessage_handler)handle_Twstat; break;
+#endif
#if CONFIG_9P_ENABLE_9P2000_p9p
case LIB9P_TYP_Topenfd: handler = (tmessage_handler)handle_Topenfd; break;
#endif
@@ -725,7 +730,9 @@ static void handle_Tversion(struct srv_req *ctx,
'0' <= req->version.utf8[4] && req->version.utf8[4] <= '9' &&
'0' <= req->version.utf8[5] && req->version.utf8[5] <= '9' &&
(req->version.len == 6 || req->version.utf8[6] == '.')) {
+#if CONFIG_9P_ENABLE_9P2000
version = LIB9P_VER_9P2000;
+#endif
#if CONFIG_9P_ENABLE_9P2000_p9p
struct lib9p_srv *srv = ctx->parent_sess->parent_conn->parent_srv;
if (srv->type_assert_unix && !LO_IS_NULL(srv->type_assert_unix(ctx->parent_sess->parent_conn->fd)))
@@ -790,6 +797,7 @@ static void handle_Tversion(struct srv_req *ctx,
srv_respond(ctx, version, &resp);
}
+#if _LIB9P_ENABLE_stat
static void handle_Tauth(struct srv_req *ctx,
struct lib9p_msg_Tauth *req) {
srv_handler_common(ctx, auth, req);
@@ -1184,6 +1192,7 @@ static void handle_Tread(struct srv_req *ctx,
ctx->user = srv_userid_incref(fidinfo->user);
switch (fidinfo->type) {
case SRV_FILETYPE_DIR:
+#if _LIB9P_ENABLE_stat
/* Seek. */
if (req->offset == 0) {
fidinfo->dir.idx = 0;
@@ -1256,6 +1265,9 @@ static void handle_Tread(struct srv_req *ctx,
fidinfo->dir.off += nbytes;
fidinfo->dir.buffered_dirent = (struct lib9p_srv_dirent){};
}
+#else
+ assert_notreached("Tread for directory on protocol version without that");
+#endif
break;
case SRV_FILETYPE_FILE:
struct iovec iov;
@@ -1396,6 +1408,7 @@ static void handle_Twstat(struct srv_req *ctx,
srv_respond(ctx, wstat, &resp);
}
+#endif
#if CONFIG_9P_ENABLE_9P2000_p9p
static void handle_Topenfd(struct srv_req *ctx,