diff options
Diffstat (limited to 'lib9p/tests/test_server/fs_flush.c')
-rw-r--r-- | lib9p/tests/test_server/fs_flush.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/lib9p/tests/test_server/fs_flush.c b/lib9p/tests/test_server/fs_flush.c index 63a52af..0ae905f 100644 --- a/lib9p/tests/test_server/fs_flush.c +++ b/lib9p/tests/test_server/fs_flush.c @@ -9,20 +9,19 @@ #define IMPLEMENTATION_FOR_LIB9P_SRV_H YES /* for ctx->flush_ch */ #include "fs_flush.h" -LO_IMPLEMENTATION_C(lib9p_srv_file, struct flush_file, flush_file, static); +LO_IMPLEMENTATION_C(lib9p_srv_file, struct flush_file, flush_file); struct flush_fio { struct flush_file *parent; }; -LO_IMPLEMENTATION_H(lib9p_srv_fio, struct flush_fio, flush_fio); -LO_IMPLEMENTATION_C(lib9p_srv_fio, struct flush_fio, flush_fio, static); +LO_IMPLEMENTATION_STATIC(lib9p_srv_fio, struct flush_fio, flush_fio); /* srv_file *******************************************************************/ -static void flush_file_free(struct flush_file *self) { +void flush_file_free(struct flush_file *self) { assert(self); } -static struct lib9p_qid flush_file_qid(struct flush_file *self) { +struct lib9p_qid flush_file_qid(struct flush_file *self) { assert(self); return (struct lib9p_qid){ .type = LIB9P_QT_FILE, @@ -31,7 +30,7 @@ static struct lib9p_qid flush_file_qid(struct flush_file *self) { }; } -static lib9p_srv_stat_or_error flush_file_stat(struct flush_file *self, struct lib9p_srv_ctx *ctx) { +lib9p_srv_stat_or_error flush_file_stat(struct flush_file *self, struct lib9p_srv_ctx *ctx) { assert(self); assert(ctx); return ERROR_NEW_VAL(lib9p_srv_stat, ((struct lib9p_srv_stat){ @@ -47,20 +46,20 @@ static lib9p_srv_stat_or_error flush_file_stat(struct flush_file *self, struct l .extension = lib9p_str(NULL), })); } -static error flush_file_wstat(struct flush_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_srv_stat) { +error flush_file_wstat(struct flush_file *self, struct lib9p_srv_ctx *ctx, struct lib9p_srv_stat) { assert(self); assert(ctx); return error_new(E_POSIX_EROFS, "cannot wstat API file"); } -static error flush_file_remove(struct flush_file *self, struct lib9p_srv_ctx *ctx) { +error flush_file_remove(struct flush_file *self, struct lib9p_srv_ctx *ctx) { assert(self); assert(ctx); return error_new(E_POSIX_EROFS, "cannot remove API file"); } -LIB9P_SRV_NOTDIR(struct flush_file, flush_file); +LIB9P_SRV_NOTDIR(, struct flush_file, flush_file); -static lib9p_srv_fio_or_error flush_file_fopen(struct flush_file *self, struct lib9p_srv_ctx *ctx, bool, bool, bool) { +lib9p_srv_fio_or_error flush_file_fopen(struct flush_file *self, struct lib9p_srv_ctx *ctx, bool, bool, bool) { assert(self); assert(ctx); @@ -77,7 +76,7 @@ static void flush_fio_iofree(struct flush_fio *self) { free(self); } -static struct lib9p_qid flush_fio_qid(struct flush_fio *self) { +static struct lib9p_qid flush_fio_ioqid(struct flush_fio *self) { assert(self); return flush_file_qid(self->parent); } @@ -94,8 +93,8 @@ static uint32_t_or_error flush_fio_pwrite(struct flush_fio *LM_UNUSED(self), assert_notreached("not writable"); } -static iovec_or_error flush_fio_pread(struct flush_fio *self, struct lib9p_srv_ctx *ctx, - uint32_t byte_count, uint64_t LM_UNUSED(byte_offset)) { +static error flush_fio_pread(struct flush_fio *self, struct lib9p_srv_ctx *ctx, + lo_interface io_writer dst, uint64_t LM_UNUSED(src_offset), uint32_t byte_count) { assert(self); assert(ctx); @@ -115,14 +114,11 @@ static iovec_or_error flush_fio_pread(struct flush_fio *self, struct lib9p_srv_c /* Return */ switch (self->parent->flush_behavior) { case FLUSH_READ: - return ERROR_NEW_VAL(iovec, ((struct iovec){ - .iov_base = "Sloth\n", - .iov_len = 6 < byte_count ? 6 : byte_count, - })); + return io_write(dst, "Sloth\n", 6 < byte_count ? 6 : byte_count).err; case FLUSH_ERROR: - return ERROR_NEW_ERR(iovec, error_new(E_POSIX_EAGAIN, "request canceled by flush")); + return error_new(E_POSIX_EAGAIN, "request canceled by flush"); case FLUSH_SILENT: - return ERROR_NEW_ERR(iovec, error_new(E_POSIX_ECANCELED, "request canceled by flush")); + return error_new(E_POSIX_ECANCELED, "request canceled by flush"); default: assert_notreached("invalid flush_behavior"); } |