summaryrefslogtreecommitdiff
path: root/lib9p/include
diff options
context:
space:
mode:
Diffstat (limited to 'lib9p/include')
-rw-r--r--lib9p/include/lib9p/9p.generated.h1
-rw-r--r--lib9p/include/lib9p/9p.h22
-rw-r--r--lib9p/include/lib9p/srv.h12
3 files changed, 25 insertions, 10 deletions
diff --git a/lib9p/include/lib9p/9p.generated.h b/lib9p/include/lib9p/9p.generated.h
index 135cf8a..a682908 100644
--- a/lib9p/include/lib9p/9p.generated.h
+++ b/lib9p/include/lib9p/9p.generated.h
@@ -179,6 +179,7 @@ struct lib9p_msg_Tattach {
uint32_t afid;
struct lib9p_s uname;
struct lib9p_s aname;
+ uint32_t n_uname; /* 9P2000.u */
};
struct lib9p_msg_Rattach {
diff --git a/lib9p/include/lib9p/9p.h b/lib9p/include/lib9p/9p.h
index b96c938..66f7542 100644
--- a/lib9p/include/lib9p/9p.h
+++ b/lib9p/include/lib9p/9p.h
@@ -7,19 +7,33 @@
#ifndef _LIB9P_9P_H_
#define _LIB9P_9P_H_
+#include <assert.h>
#include <stdbool.h>
#include <sys/types.h> /* for ssize_t */
#include <lib9p/9p.generated.h>
#include <lib9p/linux-errno.h>
+#define _USE_CONFIG_9P_ERR
+#include "config.h"
+
#define LIB9P_NOTAG ((uint16_t)~0U)
#define LIB9P_NOFID ((uint32_t)~0U)
-struct lib9p_ctx;
-enum lib9p_version lib9p_ctx_version(struct lib9p_ctx *);
-uint32_t lib9p_ctx_max_msg_size(struct lib9p_ctx *);
-bool lib9p_ctx_has_error(struct lib9p_ctx *);
+struct lib9p_ctx {
+ /* negotiated */
+ enum lib9p_version version;
+ uint32_t max_msg_size;
+
+ /* state */
+ uint32_t err_num;
+ char err_msg[CONFIG_9P_MAX_ERR_SIZE];
+};
+
+static bool lib9p_ctx_has_error(struct lib9p_ctx *ctx) {
+ assert(ctx);
+ return ctx->err_num || ctx->err_msg[0];
+}
/** Write an static error into ctx, return -1. */
int lib9p_error(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *msg);
diff --git a/lib9p/include/lib9p/srv.h b/lib9p/include/lib9p/srv.h
index 11894ea..769b562 100644
--- a/lib9p/include/lib9p/srv.h
+++ b/lib9p/include/lib9p/srv.h
@@ -6,6 +6,12 @@
#include <lib9p/9p.h>
+struct lib9p_srv_reqctx {
+ struct lib9p_ctx *base;
+ uint32_t uid;
+ char *uname;
+};
+
/* vtables you must implement *************************************************/
struct lib9p_srv_file_vtable {
@@ -39,12 +45,6 @@ struct lib9p_srv_io_file_vtable {
/* objects you'll deal with ***************************************************/
-struct lib9p_srv_reqctx {
- struct lib9p_ctx ctx;
- uint32_t uid;
- char *uname;
-};
-
struct lib9p_srv_file {
struct lib9p_srv_file_vtable vtable;