summaryrefslogtreecommitdiff
path: root/lib9p/include
diff options
context:
space:
mode:
Diffstat (limited to 'lib9p/include')
-rw-r--r--lib9p/include/lib9p/9p.generated.h401
-rw-r--r--lib9p/include/lib9p/9p.h158
-rw-r--r--lib9p/include/lib9p/linux-errno.h139
-rwxr-xr-xlib9p/include/lib9p/linux-errno.h.gen40
-rw-r--r--lib9p/include/lib9p/srv.h120
5 files changed, 0 insertions, 858 deletions
diff --git a/lib9p/include/lib9p/9p.generated.h b/lib9p/include/lib9p/9p.generated.h
deleted file mode 100644
index 25aacfe..0000000
--- a/lib9p/include/lib9p/9p.generated.h
+++ /dev/null
@@ -1,401 +0,0 @@
-/* Generated by `lib9p/idl.gen lib9p/idl/2002-9P2000.9p lib9p/idl/2005-9P2000.u.9p lib9p/idl/2012-9P2000.e.9p`. DO NOT EDIT! */
-
-#ifndef _LIB9P_9P_H_
- #error Do not include <lib9p/9p.generated.h> directly; include <lib9p/9p.h> instead
-#endif
-
-#include <stdint.h> /* for uint{n}_t types */
-
-/* config *********************************************************************/
-
-#include "config.h"
-
-#ifndef CONFIG_9P_ENABLE_9P2000
- #error config.h must define CONFIG_9P_ENABLE_9P2000
-#endif
-
-#ifndef CONFIG_9P_ENABLE_9P2000_e
- #error config.h must define CONFIG_9P_ENABLE_9P2000_e
-#endif
-
-#ifndef CONFIG_9P_ENABLE_9P2000_u
- #error config.h must define CONFIG_9P_ENABLE_9P2000_u
-#endif
-
-/* versions *******************************************************************/
-
-enum lib9p_version {
- LIB9P_VER_unknown = 0, /* "unknown" */
-#if CONFIG_9P_ENABLE_9P2000
- LIB9P_VER_9P2000, /* "9P2000" */
-#endif /* CONFIG_9P_ENABLE_9P2000 */
-#if CONFIG_9P_ENABLE_9P2000_e
- LIB9P_VER_9P2000_e, /* "9P2000.e" */
-#endif /* CONFIG_9P_ENABLE_9P2000_e */
-#if CONFIG_9P_ENABLE_9P2000_u
- LIB9P_VER_9P2000_u, /* "9P2000.u" */
-#endif /* CONFIG_9P_ENABLE_9P2000_u */
- LIB9P_VER_NUM,
-};
-
-const char *lib9p_version_str(enum lib9p_version);
-
-/* non-message types **********************************************************/
-
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
-typedef uint16_t lib9p_tag_t;
-
-typedef uint32_t lib9p_fid_t;
-
-struct lib9p_d {
- uint32_t len;
- char *dat;
-};
-
-struct lib9p_s {
- uint16_t len;
- char *utf8;
-};
-
-typedef uint32_t lib9p_dm_t;
-
-#define LIB9P_DM_DIR ((lib9p_dm_t)(1<<31))
-#define LIB9P_DM_APPEND ((lib9p_dm_t)(1<<30))
-#define LIB9P_DM_EXCL ((lib9p_dm_t)(1<<29))
-#define _LIB9P_DM_PLAN9_MOUNT ((lib9p_dm_t)(1<<28))
-#define LIB9P_DM_AUTH ((lib9p_dm_t)(1<<27))
-#define LIB9P_DM_TMP ((lib9p_dm_t)(1<<26))
-/* unused ((lib9p_dm_t)(1<<25)) */
-/* unused ((lib9p_dm_t)(1<<24)) */
-#if CONFIG_9P_ENABLE_9P2000_u
-# define LIB9P_DM_DEVICE ((lib9p_dm_t)(1<<23))
-#endif /* CONFIG_9P_ENABLE_9P2000_u */
-/* unused ((lib9p_dm_t)(1<<22)) */
-#if CONFIG_9P_ENABLE_9P2000_u
-# define LIB9P_DM_NAMEDPIPE ((lib9p_dm_t)(1<<21))
-# define LIB9P_DM_SOCKET ((lib9p_dm_t)(1<<20))
-# define LIB9P_DM_SETUID ((lib9p_dm_t)(1<<19))
-# define LIB9P_DM_SETGID ((lib9p_dm_t)(1<<18))
-#endif /* CONFIG_9P_ENABLE_9P2000_u */
-/* unused ((lib9p_dm_t)(1<<17)) */
-/* unused ((lib9p_dm_t)(1<<16)) */
-/* unused ((lib9p_dm_t)(1<<15)) */
-/* unused ((lib9p_dm_t)(1<<14)) */
-/* unused ((lib9p_dm_t)(1<<13)) */
-/* unused ((lib9p_dm_t)(1<<12)) */
-/* unused ((lib9p_dm_t)(1<<11)) */
-/* unused ((lib9p_dm_t)(1<<10)) */
-/* unused ((lib9p_dm_t)(1<<9)) */
-#define LIB9P_DM_OWNER_R ((lib9p_dm_t)(1<<8))
-#define LIB9P_DM_OWNER_W ((lib9p_dm_t)(1<<7))
-#define LIB9P_DM_OWNER_X ((lib9p_dm_t)(1<<6))
-#define LIB9P_DM_GROUP_R ((lib9p_dm_t)(1<<5))
-#define LIB9P_DM_GROUP_W ((lib9p_dm_t)(1<<4))
-#define LIB9P_DM_GROUP_X ((lib9p_dm_t)(1<<3))
-#define LIB9P_DM_OTHER_R ((lib9p_dm_t)(1<<2))
-#define LIB9P_DM_OTHER_W ((lib9p_dm_t)(1<<1))
-#define LIB9P_DM_OTHER_X ((lib9p_dm_t)(1<<0))
-
-#define LIB9P_DM_PERM_MASK ((lib9p_dm_t)(0777))
-
-typedef uint8_t lib9p_qt_t;
-
-#define LIB9P_QT_DIR ((lib9p_qt_t)(1<<7))
-#define LIB9P_QT_APPEND ((lib9p_qt_t)(1<<6))
-#define LIB9P_QT_EXCL ((lib9p_qt_t)(1<<5))
-#define _LIB9P_QT_PLAN9_MOUNT ((lib9p_qt_t)(1<<4))
-#define LIB9P_QT_AUTH ((lib9p_qt_t)(1<<3))
-#define LIB9P_QT_TMP ((lib9p_qt_t)(1<<2))
-#if CONFIG_9P_ENABLE_9P2000_u
-# define LIB9P_QT_SYMLINK ((lib9p_qt_t)(1<<1))
-#endif /* CONFIG_9P_ENABLE_9P2000_u */
-/* unused ((lib9p_qt_t)(1<<0)) */
-
-#define LIB9P_QT_FILE ((lib9p_qt_t)(0))
-
-struct lib9p_qid {
- lib9p_qt_t type;
- uint32_t vers;
- uint64_t path;
-};
-
-struct lib9p_stat {
- uint16_t kern_type;
- uint32_t kern_dev;
- struct lib9p_qid file_qid;
- lib9p_dm_t file_mode;
- uint32_t file_atime;
- uint32_t file_mtime;
- uint64_t file_size;
- struct lib9p_s file_name;
- struct lib9p_s file_owner_uid;
- struct lib9p_s file_owner_gid;
- struct lib9p_s file_last_modified_uid;
-#if CONFIG_9P_ENABLE_9P2000_u
- struct lib9p_s file_extension;
- uint32_t file_owner_n_uid;
- uint32_t file_owner_n_gid;
- uint32_t file_last_modified_n_uid;
-#endif /* CONFIG_9P_ENABLE_9P2000_u */
-};
-
-typedef uint8_t lib9p_o_t;
-
-/* unused ((lib9p_o_t)(1<<7)) */
-#define LIB9P_O_RCLOSE ((lib9p_o_t)(1<<6))
-/* unused ((lib9p_o_t)(1<<5)) */
-#define LIB9P_O_TRUNC ((lib9p_o_t)(1<<4))
-/* unused ((lib9p_o_t)(1<<3)) */
-/* unused ((lib9p_o_t)(1<<2)) */
-#define LIB9P_O_mode_1 ((lib9p_o_t)(1<<1))
-#define LIB9P_O_mode_0 ((lib9p_o_t)(1<<0))
-
-#define LIB9P_O_READ ((lib9p_o_t)(0))
-#define LIB9P_O_WRITE ((lib9p_o_t)(1))
-#define LIB9P_O_RDWR ((lib9p_o_t)(2))
-#define LIB9P_O_EXEC ((lib9p_o_t)(3))
-#define LIB9P_O_MODE_MASK ((lib9p_o_t)(0b00000011))
-#define LIB9P_O_FLAG_MASK ((lib9p_o_t)(0b11111100))
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-
-/* messages *******************************************************************/
-
-enum lib9p_msg_type { /* uint8_t */
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
- LIB9P_TYP_Tversion = 100,
- LIB9P_TYP_Rversion = 101,
- LIB9P_TYP_Tauth = 102,
- LIB9P_TYP_Rauth = 103,
- LIB9P_TYP_Tattach = 104,
- LIB9P_TYP_Rattach = 105,
- LIB9P_TYP_Rerror = 107,
- LIB9P_TYP_Tflush = 108,
- LIB9P_TYP_Rflush = 109,
- LIB9P_TYP_Twalk = 110,
- LIB9P_TYP_Rwalk = 111,
- LIB9P_TYP_Topen = 112,
- LIB9P_TYP_Ropen = 113,
- LIB9P_TYP_Tcreate = 114,
- LIB9P_TYP_Rcreate = 115,
- LIB9P_TYP_Tread = 116,
- LIB9P_TYP_Rread = 117,
- LIB9P_TYP_Twrite = 118,
- LIB9P_TYP_Rwrite = 119,
- LIB9P_TYP_Tclunk = 120,
- LIB9P_TYP_Rclunk = 121,
- LIB9P_TYP_Tremove = 122,
- LIB9P_TYP_Rremove = 123,
- LIB9P_TYP_Tstat = 124,
- LIB9P_TYP_Rstat = 125,
- LIB9P_TYP_Twstat = 126,
- LIB9P_TYP_Rwstat = 127,
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000_e
- LIB9P_TYP_Tsession = 150,
- LIB9P_TYP_Rsession = 151,
- LIB9P_TYP_Tsread = 152,
- LIB9P_TYP_Rsread = 153,
- LIB9P_TYP_Tswrite = 154,
- LIB9P_TYP_Rswrite = 155,
-#endif /* CONFIG_9P_ENABLE_9P2000_e */
-};
-
-#if CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u
-struct lib9p_msg_Tversion {
- lib9p_tag_t tag;
- uint32_t max_msg_size;
- struct lib9p_s version;
-};
-
-struct lib9p_msg_Rversion {
- lib9p_tag_t tag;
- uint32_t max_msg_size;
- struct lib9p_s version;
-};
-
-struct lib9p_msg_Tauth {
- lib9p_tag_t tag;
- lib9p_fid_t afid;
- struct lib9p_s uname;
- struct lib9p_s aname;
-#if CONFIG_9P_ENABLE_9P2000_u
- uint32_t n_uname;
-#endif /* CONFIG_9P_ENABLE_9P2000_u */
-};
-
-struct lib9p_msg_Rauth {
- lib9p_tag_t tag;
- struct lib9p_qid aqid;
-};
-
-struct lib9p_msg_Tattach {
- lib9p_tag_t tag;
- lib9p_fid_t fid;
- lib9p_fid_t afid;
- struct lib9p_s uname;
- struct lib9p_s aname;
-#if CONFIG_9P_ENABLE_9P2000_u
- uint32_t n_uname;
-#endif /* CONFIG_9P_ENABLE_9P2000_u */
-};
-
-struct lib9p_msg_Rattach {
- lib9p_tag_t tag;
- struct lib9p_qid qid;
-};
-
-struct lib9p_msg_Rerror {
- lib9p_tag_t tag;
- struct lib9p_s ename;
-#if CONFIG_9P_ENABLE_9P2000_u
- uint32_t errno;
-#endif /* CONFIG_9P_ENABLE_9P2000_u */
-};
-
-struct lib9p_msg_Tflush {
- lib9p_tag_t tag;
- uint16_t oldtag;
-};
-
-struct lib9p_msg_Rflush {
- lib9p_tag_t tag;
-};
-
-struct lib9p_msg_Twalk {
- lib9p_tag_t tag;
- lib9p_fid_t fid;
- lib9p_fid_t newfid;
- uint16_t nwname;
- struct lib9p_s *wname;
-};
-
-struct lib9p_msg_Rwalk {
- lib9p_tag_t tag;
- uint16_t nwqid;
- struct lib9p_qid *wqid;
-};
-
-struct lib9p_msg_Topen {
- lib9p_tag_t tag;
- lib9p_fid_t fid;
- lib9p_o_t mode;
-};
-
-struct lib9p_msg_Ropen {
- lib9p_tag_t tag;
- struct lib9p_qid qid;
- uint32_t iounit;
-};
-
-struct lib9p_msg_Tcreate {
- lib9p_tag_t tag;
- lib9p_fid_t fid;
- struct lib9p_s name;
- lib9p_dm_t perm;
- lib9p_o_t mode;
-};
-
-struct lib9p_msg_Rcreate {
- lib9p_tag_t tag;
- struct lib9p_qid qid;
- uint32_t iounit;
-};
-
-struct lib9p_msg_Tread {
- lib9p_tag_t tag;
- lib9p_fid_t fid;
- uint64_t offset;
- uint32_t count;
-};
-
-struct lib9p_msg_Rread {
- lib9p_tag_t tag;
- struct lib9p_d data;
-};
-
-struct lib9p_msg_Twrite {
- lib9p_tag_t tag;
- lib9p_fid_t fid;
- uint64_t offset;
- struct lib9p_d data;
-};
-
-struct lib9p_msg_Rwrite {
- lib9p_tag_t tag;
- uint32_t count;
-};
-
-struct lib9p_msg_Tclunk {
- lib9p_tag_t tag;
- lib9p_fid_t fid;
-};
-
-struct lib9p_msg_Rclunk {
- lib9p_tag_t tag;
-};
-
-struct lib9p_msg_Tremove {
- lib9p_tag_t tag;
- lib9p_fid_t fid;
-};
-
-struct lib9p_msg_Rremove {
- lib9p_tag_t tag;
-};
-
-struct lib9p_msg_Tstat {
- lib9p_tag_t tag;
- lib9p_fid_t fid;
-};
-
-struct lib9p_msg_Rstat {
- lib9p_tag_t tag;
- struct lib9p_stat stat;
-};
-
-struct lib9p_msg_Twstat {
- lib9p_tag_t tag;
- lib9p_fid_t fid;
- struct lib9p_stat stat;
-};
-
-struct lib9p_msg_Rwstat {
- lib9p_tag_t tag;
-};
-
-#endif /* CONFIG_9P_ENABLE_9P2000 || CONFIG_9P_ENABLE_9P2000_e || CONFIG_9P_ENABLE_9P2000_u */
-#if CONFIG_9P_ENABLE_9P2000_e
-struct lib9p_msg_Tsession {
- lib9p_tag_t tag;
- uint64_t key;
-};
-
-struct lib9p_msg_Rsession {
- lib9p_tag_t tag;
-};
-
-struct lib9p_msg_Tsread {
- lib9p_tag_t tag;
- uint32_t fid;
- uint16_t nwname;
- struct lib9p_s *wname;
-};
-
-struct lib9p_msg_Rsread {
- lib9p_tag_t tag;
- struct lib9p_d data;
-};
-
-struct lib9p_msg_Tswrite {
- lib9p_tag_t tag;
- uint32_t fid;
- uint16_t nwname;
- struct lib9p_s *wname;
- struct lib9p_d data;
-};
-
-struct lib9p_msg_Rswrite {
- lib9p_tag_t tag;
- uint32_t count;
-};
-#endif /* CONFIG_9P_ENABLE_9P2000_e */
diff --git a/lib9p/include/lib9p/9p.h b/lib9p/include/lib9p/9p.h
deleted file mode 100644
index fb1f97d..0000000
--- a/lib9p/include/lib9p/9p.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/* lib9p/9p.h - Base 9P protocol definitions for both clients and servers
- *
- * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
-
-#ifndef _LIB9P_9P_H_
-#define _LIB9P_9P_H_
-
-#include <stdbool.h>
-#include <sys/types.h> /* for ssize_t */
-
-#include <libmisc/assert.h>
-
-#include <lib9p/linux-errno.h>
-#include <lib9p/9p.generated.h>
-
-#ifndef CONFIG_9P_MAX_ERR_SIZE
- #error config.h must define CONFIG_9P_MAX_ERR_SIZE
-#endif
-
-/******************************************************************************/
-
-#define LIB9P_NOTAG ((uint16_t)~0U)
-#define LIB9P_NOFID ((uint32_t)~0U)
-
-/* ctx ************************************************************************/
-
-struct lib9p_ctx {
- /* negotiated */
- enum lib9p_version version;
- uint32_t max_msg_size;
-
- /* state */
-#ifdef CONFIG_9P_ENABLE_9P2000_u
- uint32_t err_num;
-#endif
- char err_msg[CONFIG_9P_MAX_ERR_SIZE];
-};
-
-void lib9p_ctx_clear_error(struct lib9p_ctx *ctx);
-
-bool lib9p_ctx_has_error(struct lib9p_ctx *ctx);
-
-/** Write an static error into ctx, return -1. */
-int lib9p_error(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *msg);
-/** Write a printf-style error into ctx, return -1. */
-int lib9p_errorf(struct lib9p_ctx *ctx, uint32_t linux_errno, char const *fmt, ...);
-
-const char *lib9p_msg_type_str(struct lib9p_ctx *, enum lib9p_msg_type);
-
-/* main message functions *****************************************************/
-
-/**
- * Validate a message's structure; it's size, string encodings, enums,
- * and bitfields.
- *
- * Return how much space the message will take when unmarshaled. This
- * number may be larger than net_bytes due to (1) struct padding, (2)
- * nul-terminator bytes for strings.
- *
- * Emits an error (return -1, set ctx->err_num and ctx->err_msg) if
- * either the message type is unknown, or if net_bytes is too short
- * for that message type, or if an invalid string (invalid UTF-8,
- * contains a nul-byte) is encountered.
- *
- * @param net_bytes : the complete request, starting with the "size[4]"
- *
- * @return required size, or -1 on error
- *
- * @errno LINUX_EOPNOTSUPP: message has unknown type
- * @errno LINUX_EBADMSG: message is wrong size for content
- * @errno LINUX_EBADMSG: message contains invalid UTF-8
- * @errno LINUX_EBADMSG: message contains a bitfield with unknown bits
- * @errno LINUX_EMSGSIZE: would-be return value overflows SSIZE_MAX
- */
-ssize_t lib9p_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes);
-
-/**
- * Unmarshal the 9P message `net_bytes` into the C struct `ret_body`.
- *
- * Emits an error (return 0, set ctx->err_num and ctx->err_msg) if a
- * string contains invalid UTF-8 or a nul-byte.
- *
- * lib9p_unmarshal does no validation; you must run lib9p_validate()
- * first.
- *
- * @param ctx : negotiated protocol parameters, where to record errors
- * @param net_bytes : the complete message, starting with the "size[4]"
- *
- * @return ret_typ : the mesage type
- * @return ret_body : the message body, must be at least lib9p_validate() bytes
- */
-void lib9p_unmarshal(struct lib9p_ctx *ctx, uint8_t *net_bytes,
- enum lib9p_msg_type *ret_typ, void *ret_body);
-
-/**
- * Marshal a `struct lib9p_msg_{typ}` structure into a byte-array.
- *
- * lib9p_marshal does no validation; it trusts that the programmer
- * won't give it garbage input. However, just as it doesn't marshal
- * struct fields that aren't in ctx->version, it won't marshal
- * bitfield bits that aren't in ctx->version; it applies a
- * version-specific mask to bitfields.
- *
- * @param ctx : negotiated protocol parameters, where to record errors
- * @param typ : the message type
- * @param msg : the message to encode
- *
- * @return ret_bytes : the buffer to encode to, must be at be at least ctx->max_msg_size bytes
- * @return whether there was an error (false=success, true=error)
- *
- * @errno LINUX_ERANGE: reply does not fit in ctx->max_msg_size
- */
-bool lib9p_marshal(struct lib9p_ctx *ctx, enum lib9p_msg_type typ, void *body,
- uint8_t *ret_bytes);
-
-/* `struct lib9p_stat` helpers ************************************************/
-
-/** Assert that a `struct lib9p_stat` object looks valid. */
-static inline void lib9p_assert_stat(struct lib9p_stat stat) {
- assert( ((bool)(stat.file_mode & LIB9P_DM_DIR )) == ((bool)(stat.file_qid.type & LIB9P_QT_DIR )) );
- assert( ((bool)(stat.file_mode & LIB9P_DM_APPEND )) == ((bool)(stat.file_qid.type & LIB9P_QT_APPEND )) );
- assert( ((bool)(stat.file_mode & LIB9P_DM_EXCL )) == ((bool)(stat.file_qid.type & LIB9P_QT_EXCL )) );
- assert( ((bool)(stat.file_mode & _LIB9P_DM_PLAN9_MOUNT)) == ((bool)(stat.file_qid.type & _LIB9P_QT_PLAN9_MOUNT)) );
- assert( ((bool)(stat.file_mode & LIB9P_DM_AUTH )) == ((bool)(stat.file_qid.type & LIB9P_QT_AUTH )) );
- assert( ((bool)(stat.file_mode & LIB9P_DM_TMP )) == ((bool)(stat.file_qid.type & LIB9P_QT_TMP )) );
- assert( (stat.file_size == 0) || !(stat.file_mode & LIB9P_DM_DIR) );
-}
-
-/**
- * TODO
- *
- * @return ret_net_size: number of bytes consumed; <=net_size
- * @return ret_host_size: number of bytes that lib9p_unmarshal_stat would take
- * @return whether there was an error
- */
-bool lib9p_validate_stat(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_bytes,
- uint32_t *ret_net_size, ssize_t *ret_host_size);
-
-/**
- * TODO
- *
- * @return ret_obj : where to put the stat object itself
- * @return ret_extra : where to put strings for the stat object
- * @return consumed net_bytes
- */
-uint32_t lib9p_unmarshal_stat(struct lib9p_ctx *ctx, uint8_t *net_bytes,
- struct lib9p_stat *ret_obj, void *ret_extra);
-
-/**
- * @return ret_bytes: the buffer to encode into
- * @return the number of bytes written, or 0 if the stat object does not fit in max_net_size
- */
-uint32_t lib9p_marshal_stat(struct lib9p_ctx *ctx, uint32_t max_net_size, struct lib9p_stat *obj,
- uint8_t *ret_bytes);
-
-#endif /* _LIB9P_9P_H_ */
diff --git a/lib9p/include/lib9p/linux-errno.h b/lib9p/include/lib9p/linux-errno.h
deleted file mode 100644
index e7c74f5..0000000
--- a/lib9p/include/lib9p/linux-errno.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/* lib9p/linux-errno.h - Generated by `lib9p/include/lib9p/linux-errno.h.gen 3rd-party/linux-errno.txt`. DO NOT EDIT! */
-/* 3rd-party/linux-errno.txt - Generated from build-aux/linux-errno.txt.gen and linux.git v6.7. DO NOT EDIT! */
-
-#ifndef _LIB9P_LINUX_ERRNO_H_
-#define _LIB9P_LINUX_ERRNO_H_
-
-#define LINUX_EPERM 1 /* Operation not permitted */
-#define LINUX_ENOENT 2 /* No such file or directory */
-#define LINUX_ESRCH 3 /* No such process */
-#define LINUX_EINTR 4 /* Interrupted system call */
-#define LINUX_EIO 5 /* I/O error */
-#define LINUX_ENXIO 6 /* No such device or address */
-#define LINUX_E2BIG 7 /* Argument list too long */
-#define LINUX_ENOEXEC 8 /* Exec format error */
-#define LINUX_EBADF 9 /* Bad file number */
-#define LINUX_ECHILD 10 /* No child processes */
-#define LINUX_EAGAIN 11 /* Try again */
-#define LINUX_ENOMEM 12 /* Out of memory */
-#define LINUX_EACCES 13 /* Permission denied */
-#define LINUX_EFAULT 14 /* Bad address */
-#define LINUX_ENOTBLK 15 /* Block device required */
-#define LINUX_EBUSY 16 /* Device or resource busy */
-#define LINUX_EEXIST 17 /* File exists */
-#define LINUX_EXDEV 18 /* Cross-device link */
-#define LINUX_ENODEV 19 /* No such device */
-#define LINUX_ENOTDIR 20 /* Not a directory */
-#define LINUX_EISDIR 21 /* Is a directory */
-#define LINUX_EINVAL 22 /* Invalid argument */
-#define LINUX_ENFILE 23 /* File table overflow */
-#define LINUX_EMFILE 24 /* Too many open files */
-#define LINUX_ENOTTY 25 /* Not a typewriter */
-#define LINUX_ETXTBSY 26 /* Text file busy */
-#define LINUX_EFBIG 27 /* File too large */
-#define LINUX_ENOSPC 28 /* No space left on device */
-#define LINUX_ESPIPE 29 /* Illegal seek */
-#define LINUX_EROFS 30 /* Read-only file system */
-#define LINUX_EMLINK 31 /* Too many links */
-#define LINUX_EPIPE 32 /* Broken pipe */
-#define LINUX_EDOM 33 /* Math argument out of domain of func */
-#define LINUX_ERANGE 34 /* Math result not representable */
-#define LINUX_EDEADLK 35 /* Resource deadlock would occur */
-#define LINUX_ENAMETOOLONG 36 /* File name too long */
-#define LINUX_ENOLCK 37 /* No record locks available */
-#define LINUX_ENOSYS 38 /* Invalid system call number */
-#define LINUX_ENOTEMPTY 39 /* Directory not empty */
-#define LINUX_ELOOP 40 /* Too many symbolic links encountered */
-#define LINUX_ENOMSG 42 /* No message of desired type */
-#define LINUX_EIDRM 43 /* Identifier removed */
-#define LINUX_ECHRNG 44 /* Channel number out of range */
-#define LINUX_EL2NSYNC 45 /* Level 2 not synchronized */
-#define LINUX_EL3HLT 46 /* Level 3 halted */
-#define LINUX_EL3RST 47 /* Level 3 reset */
-#define LINUX_ELNRNG 48 /* Link number out of range */
-#define LINUX_EUNATCH 49 /* Protocol driver not attached */
-#define LINUX_ENOCSI 50 /* No CSI structure available */
-#define LINUX_EL2HLT 51 /* Level 2 halted */
-#define LINUX_EBADE 52 /* Invalid exchange */
-#define LINUX_EBADR 53 /* Invalid request descriptor */
-#define LINUX_EXFULL 54 /* Exchange full */
-#define LINUX_ENOANO 55 /* No anode */
-#define LINUX_EBADRQC 56 /* Invalid request code */
-#define LINUX_EBADSLT 57 /* Invalid slot */
-#define LINUX_EBFONT 59 /* Bad font file format */
-#define LINUX_ENOSTR 60 /* Device not a stream */
-#define LINUX_ENODATA 61 /* No data available */
-#define LINUX_ETIME 62 /* Timer expired */
-#define LINUX_ENOSR 63 /* Out of streams resources */
-#define LINUX_ENONET 64 /* Machine is not on the network */
-#define LINUX_ENOPKG 65 /* Package not installed */
-#define LINUX_EREMOTE 66 /* Object is remote */
-#define LINUX_ENOLINK 67 /* Link has been severed */
-#define LINUX_EADV 68 /* Advertise error */
-#define LINUX_ESRMNT 69 /* Srmount error */
-#define LINUX_ECOMM 70 /* Communication error on send */
-#define LINUX_EPROTO 71 /* Protocol error */
-#define LINUX_EMULTIHOP 72 /* Multihop attempted */
-#define LINUX_EDOTDOT 73 /* RFS specific error */
-#define LINUX_EBADMSG 74 /* Not a data message */
-#define LINUX_EOVERFLOW 75 /* Value too large for defined data type */
-#define LINUX_ENOTUNIQ 76 /* Name not unique on network */
-#define LINUX_EBADFD 77 /* File descriptor in bad state */
-#define LINUX_EREMCHG 78 /* Remote address changed */
-#define LINUX_ELIBACC 79 /* Can not access a needed shared library */
-#define LINUX_ELIBBAD 80 /* Accessing a corrupted shared library */
-#define LINUX_ELIBSCN 81 /* .lib section in a.out corrupted */
-#define LINUX_ELIBMAX 82 /* Attempting to link in too many shared libraries */
-#define LINUX_ELIBEXEC 83 /* Cannot exec a shared library directly */
-#define LINUX_EILSEQ 84 /* Illegal byte sequence */
-#define LINUX_ERESTART 85 /* Interrupted system call should be restarted */
-#define LINUX_ESTRPIPE 86 /* Streams pipe error */
-#define LINUX_EUSERS 87 /* Too many users */
-#define LINUX_ENOTSOCK 88 /* Socket operation on non-socket */
-#define LINUX_EDESTADDRREQ 89 /* Destination address required */
-#define LINUX_EMSGSIZE 90 /* Message too long */
-#define LINUX_EPROTOTYPE 91 /* Protocol wrong type for socket */
-#define LINUX_ENOPROTOOPT 92 /* Protocol not available */
-#define LINUX_EPROTONOSUPPORT 93 /* Protocol not supported */
-#define LINUX_ESOCKTNOSUPPORT 94 /* Socket type not supported */
-#define LINUX_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
-#define LINUX_EPFNOSUPPORT 96 /* Protocol family not supported */
-#define LINUX_EAFNOSUPPORT 97 /* Address family not supported by protocol */
-#define LINUX_EADDRINUSE 98 /* Address already in use */
-#define LINUX_EADDRNOTAVAIL 99 /* Cannot assign requested address */
-#define LINUX_ENETDOWN 100 /* Network is down */
-#define LINUX_ENETUNREACH 101 /* Network is unreachable */
-#define LINUX_ENETRESET 102 /* Network dropped connection because of reset */
-#define LINUX_ECONNABORTED 103 /* Software caused connection abort */
-#define LINUX_ECONNRESET 104 /* Connection reset by peer */
-#define LINUX_ENOBUFS 105 /* No buffer space available */
-#define LINUX_EISCONN 106 /* Transport endpoint is already connected */
-#define LINUX_ENOTCONN 107 /* Transport endpoint is not connected */
-#define LINUX_ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
-#define LINUX_ETOOMANYREFS 109 /* Too many references: cannot splice */
-#define LINUX_ETIMEDOUT 110 /* Connection timed out */
-#define LINUX_ECONNREFUSED 111 /* Connection refused */
-#define LINUX_EHOSTDOWN 112 /* Host is down */
-#define LINUX_EHOSTUNREACH 113 /* No route to host */
-#define LINUX_EALREADY 114 /* Operation already in progress */
-#define LINUX_EINPROGRESS 115 /* Operation now in progress */
-#define LINUX_ESTALE 116 /* Stale file handle */
-#define LINUX_EUCLEAN 117 /* Structure needs cleaning */
-#define LINUX_ENOTNAM 118 /* Not a XENIX named type file */
-#define LINUX_ENAVAIL 119 /* No XENIX semaphores available */
-#define LINUX_EISNAM 120 /* Is a named type file */
-#define LINUX_EREMOTEIO 121 /* Remote I/O error */
-#define LINUX_EDQUOT 122 /* Quota exceeded */
-#define LINUX_ENOMEDIUM 123 /* No medium found */
-#define LINUX_EMEDIUMTYPE 124 /* Wrong medium type */
-#define LINUX_ECANCELED 125 /* Operation Canceled */
-#define LINUX_ENOKEY 126 /* Required key not available */
-#define LINUX_EKEYEXPIRED 127 /* Key has expired */
-#define LINUX_EKEYREVOKED 128 /* Key has been revoked */
-#define LINUX_EKEYREJECTED 129 /* Key was rejected by service */
-#define LINUX_EOWNERDEAD 130 /* Owner died */
-#define LINUX_ENOTRECOVERABLE 131 /* State not recoverable */
-#define LINUX_ERFKILL 132 /* Operation not possible due to RF-kill */
-#define LINUX_EHWPOISON 133 /* Memory page has hardware error */
-
-#endif /* _LIB9P_LINUX_ERRNO_H_ */
diff --git a/lib9p/include/lib9p/linux-errno.h.gen b/lib9p/include/lib9p/linux-errno.h.gen
deleted file mode 100755
index 8f4e0c8..0000000
--- a/lib9p/include/lib9p/linux-errno.h.gen
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/env python
-# lib9p/linux-errno.h.gen - Generate a C header from a list of errno numbers
-#
-# Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
-# SPDX-License-Identifier: AGPL-3.0-or-later
-
-import sys
-
-
-def print_errnos() -> None:
- print(
- f"/* lib9p/linux-errno.h - Generated by `{' '.join(sys.argv)}`. DO NOT EDIT! */"
- )
- errnos: dict[str, tuple[int, str]] = {}
- for txtlist in sys.argv[1:]:
- with open(txtlist, "r") as fh:
- for line in fh:
- if line.startswith("#"):
- print(f"/* {line[1:].strip()} */")
- continue
- _num, name, desc = line.split(maxsplit=2)
- num = int(_num)
- desc = desc.strip()
- errnos[name] = (num, desc)
- print()
- print("#ifndef _LIB9P_LINUX_ERRNO_H_")
- print("#define _LIB9P_LINUX_ERRNO_H_")
- print()
- namelen = max(len(name) for name in errnos.keys())
- numlen = max(len(str(num)) for (num, desc) in errnos.values())
- for name in errnos:
- print(
- f"#define LINUX_{name.ljust(namelen)} {str(errnos[name][0]).rjust(numlen)} /* {errnos[name][1]} */"
- )
- print()
- print("#endif /* _LIB9P_LINUX_ERRNO_H_ */")
-
-
-if __name__ == "__main__":
- print_errnos()
diff --git a/lib9p/include/lib9p/srv.h b/lib9p/include/lib9p/srv.h
deleted file mode 100644
index eb0e4f4..0000000
--- a/lib9p/include/lib9p/srv.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/* lib9p/srv.h - 9P server
- *
- * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
-
-#ifndef _LIB9P_SRV_H_
-#define _LIB9P_SRV_H_
-
-#include <libcr/coroutine.h>
-#include <libcr_ipc/rpc.h>
-#include <libcr_ipc/chan.h>
-#include <libhw/generic/net.h>
-#include <libmisc/private.h>
-
-#include <lib9p/9p.h>
-
-/* context ********************************************************************/
-
-CR_CHAN_DECLARE(_lib9p_srv_flushch, bool)
-
-struct lib9p_srv_ctx {
- struct lib9p_ctx basectx;
- uint32_t uid;
- char *uname;
-
- BEGIN_PRIVATE(LIB9P_SRV_H)
- _lib9p_srv_flushch_t _flushch;
- END_PRIVATE(LIB9P_SRV_H)
-};
-
-bool lib9p_srv_flush_requested(struct lib9p_srv_ctx *ctx);
-
-int lib9p_srv_acknowledge_flush(struct lib9p_srv_ctx *ctx);
-
-/* interface definitions ******************************************************/
-
-struct lib9p_srv_file_vtable;
-
-struct __lib9p_srv_file;
-typedef struct __lib9p_srv_file {
- struct lib9p_srv_file_vtable *vtable;
-
- BEGIN_PRIVATE(LIB9P_SRV_H)
- /* Managed by srv.c, but should be cloned by ->vtable->clone(). */
- struct __lib9p_srv_file *_parent_dir; /* clone this
-
- /* Managed by srv.c, but should be initialized to 0 by ->vtable->clone(). */
- /* ref type 1: an entry in fidmap
- * ref type 2: ->_parent_dir of another file */
- unsigned int _refcount;
- END_PRIVATE(LIB9P_SRV_H)
-} implements_lib9p_srv_file;
-
-struct lib9p_srv_file_vtable {
- /* all - resource management */
- implements_lib9p_srv_file *(*clone )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *);
- void (*free )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *);
-
- /* all - syscalls */
- uint32_t (*io )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *,
- lib9p_o_t flags);
- struct lib9p_stat (*stat )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *);
- void (*wstat )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *,
- struct lib9p_stat new);
- void (*remove )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *);
-
- /* directories - base */
- implements_lib9p_srv_file *(*dopen )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *,
- char *childname);
- implements_lib9p_srv_file *(*dcreate)(implements_lib9p_srv_file *, struct lib9p_srv_ctx *,
- char *childname,
- lib9p_dm_t perm, lib9p_o_t flags);
-
- /* directories - once opened */
- size_t /* <- obj cnt */ (*dread )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *,
- uint8_t *buf,
- uint32_t byte_count, /* <- num bytes */
- size_t obj_offset); /* <- starting at this object */
-
- /* non-directories - once opened */
- uint32_t (*pread )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *,
- void *buf,
- uint32_t byte_count,
- uint64_t byte_offset);
- uint32_t (*pwrite )(implements_lib9p_srv_file *, struct lib9p_srv_ctx *,
- void *buf,
- uint32_t byte_count,
- uint64_t byte_offset);
-};
-
-/* main server entrypoints ****************************************************/
-
-CR_RPC_DECLARE(_lib9p_srv_reqch, struct _lib9p_srv_req *, bool)
-
-struct lib9p_srv {
- /* Things you provide */
- void /*TODO*/ (*auth )(struct lib9p_srv_ctx *, char *treename); /* optional */
- implements_lib9p_srv_file *(*rootdir)(struct lib9p_srv_ctx *, char *treename);
-
- /* For internal use */
- BEGIN_PRIVATE(LIB9P_SRV_H)
- _lib9p_srv_reqch_t _reqch;
- END_PRIVATE(LIB9P_SRV_H)
-};
-
-/**
- * Will just close the connection if a T-message has a size[4] <7.
- *
- * @errno LINUX_EMSGSIZE T-message has size[4] bigger than max_msg_size
- * @errno LINUX_EDOM Tversion specified an impossibly small max_msg_size
- * @errno LINUX_EOPNOTSUPP T-message has an R-message type, or an unrecognized T-message type
- * @errno LINUX_EBADMSG T-message has wrong size[4] for its content, or has invalid UTF-8
- * @errno LINUX_ERANGE R-message does not fit into max_msg_size
- */
-
-[[noreturn]] void lib9p_srv_read_cr(struct lib9p_srv *srv, implements_net_stream_listener *listener);
-COROUTINE lib9p_srv_write_cr(void *_srv);
-
-#endif /* _LIB9P_SRV_H_ */