summaryrefslogtreecommitdiff
path: root/cmd/srv9p/main.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-10-12 17:53:05 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-10-12 17:53:05 -0600
commiteb4e0bc7dd140b356a62071bf8e0427fc0cee816 (patch)
treec71d7daf1dfccf7e261c2fe22d7d5a0bd55bf34d /cmd/srv9p/main.c
parent7508de2e4ec10baf46c7cde6e7774051ac19e95a (diff)
get read working correctly
Diffstat (limited to 'cmd/srv9p/main.c')
-rw-r--r--cmd/srv9p/main.c49
1 files changed, 36 insertions, 13 deletions
diff --git a/cmd/srv9p/main.c b/cmd/srv9p/main.c
index 4aaae28..8609f36 100644
--- a/cmd/srv9p/main.c
+++ b/cmd/srv9p/main.c
@@ -5,6 +5,7 @@
#include <libnetio/netio.h>
#include <lib9p/srv.h>
+#include "static9p.h"
#include "static.h"
/* configuration **************************************************************/
@@ -19,26 +20,48 @@
#define UNUSED(name) /* name __attribute__((unused)) */
-static struct static_dir root = {
- .header = { .vtable = &static_dir_vtable },
+static struct static_file readme = {
+ .metadata = {
+ .header = { .vtable = &static_file_vtable },
+
+ .u_name = "root", .u_num = 0, /* owner user */
+ .g_name = "root", .g_num = 0, /* owner group */
+ .m_name = "root", .m_num = 0, /* last-modified-by user */
- .u_name = "root", .u_num = 0, /* owner user */
- .g_name = "root", .g_num = 0, /* owner group */
- .m_name = "root", .m_num = 0, /* last-modified-by user */
+ .pathnum = __COUNTER__,
+ .name = "README.md",
+ .perm = 0444,
+ .atime = 1728337905,
+ .mtime = 1728337904,
+ },
- .pathnum = __COUNTER__,
- .name = "",
- .perm = 0555,
- .atime = 1728337905,
- .mtime = 1728337904,
+ .data_start = _binary_static_README_md_start,
+ .data_end = _binary_static_README_md_end,
+};
+
+static struct static_dir root = {
+ .metadata = {
+ .header = { .vtable = &static_dir_vtable },
+
+ .u_name = "root", .u_num = 0, /* owner user */
+ .g_name = "root", .g_num = 0, /* owner group */
+ .m_name = "root", .m_num = 0, /* last-modified-by user */
+
+ .pathnum = __COUNTER__,
+ .name = "",
+ .perm = 0555,
+ .atime = 1728337905,
+ .mtime = 1728337904,
+ },
.members = {
+ &readme.metadata.header,
NULL,
},
};
-struct lib9p_srv_file *fs_root(struct lib9p_srv_ctx *UNUSED(ctx), char *UNUSED(treename)) {
- return &root.header;
+static struct lib9p_srv_file *get_root(struct lib9p_srv_ctx *UNUSED(ctx), char *UNUSED(treename)) {
+ return &root.metadata.header;
}
int main() {
@@ -48,7 +71,7 @@ int main() {
struct lib9p_srv srv = {
.sockfd = sock,
- .rootdir = fs_root,
+ .rootdir = get_root,
};
for (int i = 0; i < CONFIG_NETIO_NUM_CONNS; i++)