diff options
Diffstat (limited to 'lib9p/srv.c')
-rw-r--r-- | lib9p/srv.c | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/lib9p/srv.c b/lib9p/srv.c index 0bfe5da..0e58068 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -12,7 +12,6 @@ #include <libcr_ipc/mutex.h> #include <libcr_ipc/select.h> #include <libmisc/assert.h> -#include <libmisc/vcall.h> #include <libhw/generic/net.h> #define LOG_NAME 9P_SRV @@ -54,7 +53,7 @@ int lib9p_srv_acknowledge_flush(struct lib9p_srv_ctx *ctx) { typedef typeof( ((struct lib9p_qid){}).path ) srv_path_t; struct srv_pathinfo { - implements_lib9p_srv_file *file; + lo_interface lib9p_srv_file file; srv_path_t parent_dir; /* References from other srv_pathinfos (via .parent_dir) or @@ -470,15 +469,15 @@ static inline bool srv_util_check_perm(struct _lib9p_srv_req *ctx, struct lib9p_ * Returns a pointer to the stored pathinfo. */ static inline struct srv_pathinfo *srv_util_pathsave(struct _lib9p_srv_req *ctx, - implements_lib9p_srv_file *file, + lo_interface lib9p_srv_file file, srv_path_t parent_path) { assert(ctx); - assert(file); + assert(!LO_IS_NULL(file)); - struct lib9p_qid qid = VCALL(file, qid); + struct lib9p_qid qid = LO_CALL(file, qid); struct srv_pathinfo *pathinfo = pathmap_load(&ctx->parent_sess->paths, qid.path); if (pathinfo) - assert(pathinfo->file == file); + assert(LO_EQ(pathinfo->file, file)); else { pathinfo = pathmap_store(&ctx->parent_sess->paths, qid.path, (struct srv_pathinfo){ @@ -512,14 +511,14 @@ static inline void srv_util_pathfree(struct _lib9p_srv_req *ctx, srv_path_t path if (pathinfo->gc_refcount == 0) { if (pathinfo->parent_dir != path) srv_util_pathfree(ctx, pathinfo->parent_dir); - VCALL(pathinfo->file, free); + LO_CALL(pathinfo->file, free); pathmap_del(&ctx->parent_sess->paths, path); } } static inline bool srv_util_pathisdir(struct srv_pathinfo *pathinfo) { assert(pathinfo); - return VCALL(pathinfo->file, qid).type & LIB9P_QT_DIR; + return LO_CALL(pathinfo->file, qid).type & LIB9P_QT_DIR; } /** @@ -532,7 +531,7 @@ static inline struct _srv_fidinfo *srv_util_fidsave(struct _lib9p_srv_req *ctx, assert(fid != LIB9P_FID_NOFID); assert(pathinfo); - struct lib9p_qid qid = VCALL(pathinfo->file, qid); + struct lib9p_qid qid = LO_CALL(pathinfo->file, qid); struct _srv_fidinfo *fidinfo = fidmap_load(&ctx->parent_sess->fids, fid); if (fidinfo) { @@ -703,12 +702,12 @@ static void handle_Tattach(struct _lib9p_srv_req *ctx, } /* 1. File object */ - implements_lib9p_srv_file *root_file = srv->rootdir(&ctx->ctx, req->aname); - assert((root_file == NULL) == lib9p_ctx_has_error(&ctx->ctx.basectx)); + lo_interface lib9p_srv_file root_file = srv->rootdir(&ctx->ctx, req->aname); + assert(LO_IS_NULL(root_file) == lib9p_ctx_has_error(&ctx->ctx.basectx)); if (lib9p_ctx_has_error(&ctx->ctx.basectx)) return; - struct lib9p_qid root_qid = VCALL(root_file, qid); + struct lib9p_qid root_qid = LO_CALL(root_file, qid); assert(root_qid.type & LIB9P_QT_DIR); /* 2. pathinfo */ @@ -770,37 +769,37 @@ static void handle_Twalk(struct _lib9p_srv_req *ctx, break; } - implements_lib9p_srv_file *member_file = VCALL(pathinfo->file, dopen, &ctx->ctx, req->wname[resp->nwqid]); - assert((member_file == NULL) == lib9p_ctx_has_error(&ctx->ctx.basectx)); + lo_interface lib9p_srv_file member_file = LO_CALL(pathinfo->file, dopen, &ctx->ctx, req->wname[resp->nwqid]); + assert(LO_IS_NULL(member_file) == lib9p_ctx_has_error(&ctx->ctx.basectx)); if (lib9p_ctx_has_error(&ctx->ctx.basectx)) break; - new_pathinfo = srv_util_pathsave(ctx, member_file, VCALL(pathinfo->file, qid).path); + new_pathinfo = srv_util_pathsave(ctx, member_file, LO_CALL(pathinfo->file, qid).path); } if (srv_util_pathisdir(new_pathinfo)) { - struct lib9p_stat stat = VCALL(new_pathinfo->file, stat, &ctx->ctx); + struct lib9p_stat stat = LO_CALL(new_pathinfo->file, stat, &ctx->ctx); if (lib9p_ctx_has_error(&ctx->ctx.basectx)) break; lib9p_stat_assert(stat); if (!srv_util_check_perm(ctx, &stat, 0b001)) { lib9p_error(&ctx->ctx.basectx, LINUX_EACCES, "you do not have execute permission on that directory"); - srv_util_pathfree(ctx, VCALL(new_pathinfo->file, qid).path); + srv_util_pathfree(ctx, LO_CALL(new_pathinfo->file, qid).path); break; } } - resp->wqid[resp->nwqid] = VCALL(new_pathinfo->file, qid); + resp->wqid[resp->nwqid] = LO_CALL(new_pathinfo->file, qid); - srv_util_pathfree(ctx, VCALL(pathinfo->file, qid).path); + srv_util_pathfree(ctx, LO_CALL(pathinfo->file, qid).path); pathinfo = new_pathinfo; } if (resp->nwqid == req->nwname) { if (!srv_util_fidsave(ctx, req->newfid, pathinfo, req->newfid == req->fid)) - srv_util_pathfree(ctx, VCALL(pathinfo->file, qid).path); + srv_util_pathfree(ctx, LO_CALL(pathinfo->file, qid).path); } else { assert(lib9p_ctx_has_error(&ctx->ctx.basectx)); - srv_util_pathfree(ctx, VCALL(pathinfo->file, qid).path); + srv_util_pathfree(ctx, LO_CALL(pathinfo->file, qid).path); if (resp->nwqid > 0) lib9p_ctx_clear_error(&ctx->ctx.basectx); } @@ -844,7 +843,7 @@ static void handle_Topen(struct _lib9p_srv_req *ctx, if (reqmode & LIB9P_O_RCLOSE) { struct srv_pathinfo *parent = pathmap_load(&ctx->parent_sess->paths, pathinfo->parent_dir); assert(parent); - struct lib9p_stat parent_stat = VCALL(parent->file, stat, &ctx->ctx); + struct lib9p_stat parent_stat = LO_CALL(parent->file, stat, &ctx->ctx); if (lib9p_ctx_has_error(&ctx->ctx.basectx)) return; lib9p_stat_assert(parent_stat); @@ -855,7 +854,7 @@ static void handle_Topen(struct _lib9p_srv_req *ctx, } fidflags = fidflags | FIDFLAG_RCLOSE; } - struct lib9p_stat stat = VCALL(pathinfo->file, stat, &ctx->ctx); + struct lib9p_stat stat = LO_CALL(pathinfo->file, stat, &ctx->ctx); if (lib9p_ctx_has_error(&ctx->ctx.basectx)) return; lib9p_stat_assert(stat); @@ -893,10 +892,10 @@ static void handle_Topen(struct _lib9p_srv_req *ctx, /* Actually make the call. */ if ((reqmode & LIB9P_O_TRUNC) || (rd && !pathinfo->rd_refcount) || (wr && !pathinfo->wr_refcount) ) { - iounit = VCALL(pathinfo->file, chio, &ctx->ctx, - fidflags & FIDFLAG_OPEN_R, - fidflags & FIDFLAG_OPEN_W, - reqmode & LIB9P_O_TRUNC); + iounit = LO_CALL(pathinfo->file, chio, &ctx->ctx, + fidflags & FIDFLAG_OPEN_R, + fidflags & FIDFLAG_OPEN_W, + reqmode & LIB9P_O_TRUNC); if (lib9p_ctx_has_error(&ctx->ctx.basectx)) return; } @@ -962,7 +961,7 @@ static void handle_Tread(struct _lib9p_srv_req *ctx, return; } /* Do it. */ - size_t num = VCALL(pathinfo->file, dread, &ctx->ctx, (uint8_t *)resp->data, req->count, idx); + size_t num = LO_CALL(pathinfo->file, dread, &ctx->ctx, (uint8_t *)resp->data, req->count, idx); /* Translate object-count back to byte-count. */ uint32_t len = 0; for (size_t i = 0; i < num; i++) { @@ -975,7 +974,7 @@ static void handle_Tread(struct _lib9p_srv_req *ctx, fidinfo->dir_idx = idx+num; fidinfo->dir_off = req->offset + len; } else - resp->count = VCALL(pathinfo->file, pread, &ctx->ctx, resp->data, req->count, req->offset); + resp->count = LO_CALL(pathinfo->file, pread, &ctx->ctx, resp->data, req->count, req->offset); } static void handle_Twrite(struct _lib9p_srv_req *ctx, @@ -1001,7 +1000,7 @@ static void handle_Twrite(struct _lib9p_srv_req *ctx, assert(pathinfo); /* Do it. */ - resp->count = VCALL(pathinfo->file, pwrite, &ctx->ctx, req->data, req->count, req->offset); + resp->count = LO_CALL(pathinfo->file, pwrite, &ctx->ctx, req->data, req->count, req->offset); } static void clunkremove(struct _lib9p_srv_req *ctx, lib9p_fid_t fid, bool remove) { @@ -1024,17 +1023,17 @@ static void clunkremove(struct _lib9p_srv_req *ctx, lib9p_fid_t fid, bool remove } struct srv_pathinfo *parent = pathmap_load(&ctx->parent_sess->paths, pathinfo->parent_dir); assert(parent); - struct lib9p_stat parent_stat = VCALL(parent->file, stat, &ctx->ctx); + struct lib9p_stat parent_stat = LO_CALL(parent->file, stat, &ctx->ctx); if (!srv_util_check_perm(ctx, &parent_stat, 0b010)) { lib9p_error(&ctx->ctx.basectx, LINUX_EACCES, "you do not have write permission on the parent directory"); goto clunk; } - VCALL(pathinfo->file, remove, &ctx->ctx); + LO_CALL(pathinfo->file, remove, &ctx->ctx); } clunk: - srv_util_pathfree(ctx, VCALL(pathinfo->file, qid).path); + srv_util_pathfree(ctx, LO_CALL(pathinfo->file, qid).path); fidmap_del(&ctx->parent_sess->fids, fid); } @@ -1069,7 +1068,7 @@ static void handle_Tstat(struct _lib9p_srv_req *ctx, struct srv_pathinfo *pathinfo = pathmap_load(&ctx->parent_sess->paths, fidinfo->path); assert(pathinfo); - resp->stat = VCALL(pathinfo->file, stat, &ctx->ctx); + resp->stat = LO_CALL(pathinfo->file, stat, &ctx->ctx); if (!lib9p_ctx_has_error(&ctx->ctx.basectx)) lib9p_stat_assert(resp->stat); } |