#include #include #include #include #include #include "static9p.h" #include "static.h" /* configuration **************************************************************/ #include "config.h" #ifndef CONFIG_NETIO_NUM_CONNS # error config.h must define CONFIG_NETIO_NUM_CONNS #endif /* implementation *************************************************************/ #define UNUSED(name) /* name __attribute__((unused)) */ 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 */ .pathnum = __COUNTER__, .name = "README.md", .perm = 0444, .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, }, }; static struct lib9p_srv_file *get_root(struct lib9p_srv_ctx *UNUSED(ctx), char *UNUSED(treename)) { return &root.metadata.header; } int main() { int sock = netio_listen(9000); if (sock < 0) error(1, -sock, "netio_listen"); struct lib9p_srv srv = { .sockfd = sock, .rootdir = get_root, }; for (int i = 0; i < CONFIG_NETIO_NUM_CONNS; i++) if (!coroutine_add(lib9p_srv_read_cr, &srv)) error(1, 0, "coroutine_add(lib9p_srv_read_cr, &srv)"); for (int i = 0; i < 2*CONFIG_NETIO_NUM_CONNS; i++) if (!coroutine_add(lib9p_srv_write_cr, &srv)) error(1, 0, "coroutine_add(lib9p_srv_write_cr, &srv)"); coroutine_main(); return 1; }