summaryrefslogtreecommitdiff
path: root/lib9p/srv.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-14 07:46:18 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-14 14:45:11 -0600
commitb5ea4c02dc4940464d68b9061cc27b378bfbd368 (patch)
treed35f9aa10bae31170e6173841efa871d578bbd59 /lib9p/srv.c
parentc62c41bc8aba632439dc19848d395180c4ad8e19 (diff)
lib9p_core: linux-errno.h: Rename LINUX_* => LIB9P_ERRNO_L_*
Diffstat (limited to 'lib9p/srv.c')
-rw-r--r--lib9p/srv.c82
1 files changed, 41 insertions, 41 deletions
diff --git a/lib9p/srv.c b/lib9p/srv.c
index e664d0f..e1a1d84 100644
--- a/lib9p/srv.c
+++ b/lib9p/srv.c
@@ -51,7 +51,7 @@ bool lib9p_srv_flush_requested(struct lib9p_srv_ctx *ctx) {
void lib9p_srv_acknowledge_flush(struct lib9p_srv_ctx *ctx) {
assert(ctx);
assert(_lib9p_srv_flushch_can_send(&ctx->flushch));
- lib9p_error(&ctx->basectx, LINUX_ECANCELED, "request canceled by flush");
+ lib9p_error(&ctx->basectx, LIB9P_ERRNO_L_ECANCELED, "request canceled by flush");
_lib9p_srv_flushch_send(&ctx->flushch, true);
}
@@ -265,7 +265,7 @@ static inline void srv_fid_del(struct srv_req *ctx, lib9p_fid_t fid, bool remove
if (remove) {
if (pathinfo->parent_dir == fidinfo->path) {
lib9p_errorf(&ctx->basectx,
- LINUX_EBUSY, "cannot remove root");
+ LIB9P_ERRNO_L_EBUSY, "cannot remove root");
goto clunk;
}
struct srv_pathinfo *parent = map_load(&ctx->parent_sess->paths, pathinfo->parent_dir);
@@ -273,7 +273,7 @@ static inline void srv_fid_del(struct srv_req *ctx, lib9p_fid_t fid, bool remove
struct lib9p_stat parent_stat = LO_CALL(parent->file, stat, ctx);
if (!srv_check_perm(ctx, &parent_stat, 0b010)) {
lib9p_error(&ctx->basectx,
- LINUX_EACCES, "remove: you do not have write permission on the parent directory");
+ LIB9P_ERRNO_L_EACCES, "remove: you do not have write permission on the parent directory");
goto clunk;
}
LO_CALL(pathinfo->file, remove, ctx);
@@ -316,7 +316,7 @@ static struct srv_fidinfo *srv_fid_store(struct srv_req *ctx, lib9p_fid_t fid, s
srv_fid_del(ctx, fid, false);
} else {
lib9p_error(&ctx->basectx,
- LINUX_EBADF, "FID already in use");
+ LIB9P_ERRNO_L_EBADF, "FID already in use");
return NULL;
}
}
@@ -380,7 +380,7 @@ static void srv_respond_error(struct srv_req *req) {
uint32_t overhead = lib9p_version_min_msg_size(sess->version);
/* Truncate the error-string if necessary to avoid needing to
- * return LINUX_ERANGE. */
+ * return LIB9P_ERRNO_L_ERANGE. */
if (((uint32_t)host.errstr.len) + overhead > sess->max_msg_size)
host.errstr.len = sess->max_msg_size - overhead;
@@ -481,7 +481,7 @@ void lib9p_srv_read(struct lib9p_srv *srv, lo_interface net_stream_conn _conn) {
};
if (goal > sess.max_msg_size) {
lib9p_errorf(&req.basectx,
- LINUX_EMSGSIZE, "T-message larger than %s limit (%zu > %"PRIu32")",
+ LIB9P_ERRNO_L_EMSGSIZE, "T-message larger than %s limit (%zu > %"PRIu32")",
sess.initialized ? "negotiated" : "server",
goal,
sess.max_msg_size);
@@ -706,7 +706,7 @@ static void handle_Tversion(struct srv_req *ctx,
uint32_t min_msg_size = lib9p_version_min_msg_size(version);
if (req->max_msg_size < min_msg_size) {
lib9p_errorf(&ctx->basectx,
- LINUX_EDOM, "requested max_msg_size is less than minimum for %s (%"PRIu32" < %"PRIu32")",
+ LIB9P_ERRNO_L_EDOM, "requested max_msg_size is less than minimum for %s (%"PRIu32" < %"PRIu32")",
lib9p_version_str(version), req->max_msg_size, min_msg_size);
return;
}
@@ -757,7 +757,7 @@ static void handle_Tauth(struct srv_req *ctx,
struct lib9p_srv *srv = ctx->parent_sess->parent_conn->parent_srv;
if (!srv->auth) {
lib9p_error(&ctx->basectx,
- LINUX_EOPNOTSUPP, "authentication not required");
+ LIB9P_ERRNO_L_EOPNOTSUPP, "authentication not required");
return;
}
@@ -766,7 +766,7 @@ static void handle_Tauth(struct srv_req *ctx,
srv->auth(ctx, req->aname);
lib9p_error(&ctx->basectx,
- LINUX_EOPNOTSUPP, "TODO: auth not implemented");
+ LIB9P_ERRNO_L_EOPNOTSUPP, "TODO: auth not implemented");
if (lib9p_ctx_has_error(&ctx->basectx))
ctx->authinfo = srv_authinfo_decref(ctx->authinfo);
@@ -779,7 +779,7 @@ static void handle_Tattach(struct srv_req *ctx,
if (req->fid == LIB9P_FID_NOFID) {
lib9p_error(&ctx->basectx,
- LINUX_EBADF, "cannot assign to NOFID");
+ LIB9P_ERRNO_L_EBADF, "cannot assign to NOFID");
return;
}
@@ -788,36 +788,36 @@ static void handle_Tattach(struct srv_req *ctx,
struct srv_fidinfo *afid = map_load(&ctx->parent_sess->fids, req->afid);
if (!afid)
lib9p_error(&ctx->basectx,
- LINUX_EACCES, "FID provided as auth-file is not a valid FID");
+ LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is not a valid FID");
else if (afid->type != SRV_FILETYPE_AUTH)
lib9p_error(&ctx->basectx,
- LINUX_EACCES, "FID provided as auth-file is not an auth-file");
+ LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is not an auth-file");
else if (!lib9p_str_eq(afid->authinfo->uname, req->uname))
lib9p_errorf(&ctx->basectx,
- LINUX_EACCES, "FID provided as auth-file is for user=\"%.*s\" and cannot be used for user=\"%.*s\"",
+ LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is for user=\"%.*s\" and cannot be used for user=\"%.*s\"",
afid->authinfo->uname.len, afid->authinfo->uname.utf8,
req->uname.len, req->uname.utf8);
#if CONFIG_9P_ENABLE_9P2000_u
else if (afid->authinfo->uid != req->n_uid)
lib9p_errorf(&ctx->basectx,
- LINUX_EACCES, "FID provided as auth-file is for user=%"PRIu32" and cannot be used for user=%"PRIu32,
+ LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is for user=%"PRIu32" and cannot be used for user=%"PRIu32,
afid->authinfo->uid, req->n_uid);
#endif
else if (!lib9p_str_eq(afid->auth.aname, req->aname))
lib9p_errorf(&ctx->basectx,
- LINUX_EACCES, "FID provided as auth-file is for tree=\"%.*s\" and cannot be used for tree=\"%.*s\"",
+ LIB9P_ERRNO_L_EACCES, "FID provided as auth-file is for tree=\"%.*s\" and cannot be used for tree=\"%.*s\"",
afid->auth.aname.len, afid->auth.aname.utf8,
req->aname.len, req->aname.utf8);
else if (!afid->auth.completed)
lib9p_error(&ctx->basectx,
- LINUX_EACCES, "FID provided as auth-file has not completed authentication");
+ LIB9P_ERRNO_L_EACCES, "FID provided as auth-file has not completed authentication");
if (lib9p_ctx_has_error(&ctx->basectx))
return;
ctx->authinfo = srv_authinfo_incref(afid->authinfo);
} else {
if (req->afid != LIB9P_FID_NOFID) {
lib9p_error(&ctx->basectx,
- LINUX_EACCES, "FID provided as auth-file, but no auth-file is required");
+ LIB9P_ERRNO_L_EACCES, "FID provided as auth-file, but no auth-file is required");
return;
}
ctx->authinfo = srv_authinfo_new(req->uname, req->n_uid);
@@ -866,14 +866,14 @@ static void handle_Twalk(struct srv_req *ctx,
if (req->newfid == LIB9P_FID_NOFID) {
lib9p_error(&ctx->basectx,
- LINUX_EBADF, "cannot assign to NOFID");
+ LIB9P_ERRNO_L_EBADF, "cannot assign to NOFID");
return;
}
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
lib9p_errorf(&ctx->basectx,
- LINUX_EBADF, "bad file number %"PRIu32, req->fid);
+ LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
return;
}
ctx->authinfo = srv_authinfo_incref(fidinfo->authinfo);
@@ -892,7 +892,7 @@ static void handle_Twalk(struct srv_req *ctx,
} else {
if (pathinfo->type != SRV_FILETYPE_DIR) {
lib9p_error(&ctx->basectx,
- LINUX_ENOTDIR, "not a directory");
+ LIB9P_ERRNO_L_ENOTDIR, "not a directory");
break;
}
@@ -910,7 +910,7 @@ static void handle_Twalk(struct srv_req *ctx,
lib9p_stat_assert(stat);
if (!srv_check_perm(ctx, &stat, 0b001)) {
lib9p_error(&ctx->basectx,
- LINUX_EACCES, "you do not have execute permission on that directory");
+ LIB9P_ERRNO_L_EACCES, "you do not have execute permission on that directory");
srv_path_decref(ctx, LO_CALL(new_pathinfo->file, qid).path);
break;
}
@@ -942,12 +942,12 @@ static void handle_Topen(struct srv_req *ctx,
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
lib9p_errorf(&ctx->basectx,
- LINUX_EBADF, "bad file number %"PRIu32, req->fid);
+ LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
return;
}
if (fidinfo->flags & FIDFLAG_OPEN) {
lib9p_error(&ctx->basectx,
- LINUX_EALREADY, "FID is already open");
+ LIB9P_ERRNO_L_EALREADY, "FID is already open");
return;
}
if (fidinfo->type == SRV_FILETYPE_DIR) {
@@ -955,7 +955,7 @@ static void handle_Topen(struct srv_req *ctx,
(req->mode & LIB9P_O_TRUNC) ||
(req->mode & LIB9P_O_RCLOSE) ) {
lib9p_error(&ctx->basectx,
- LINUX_EISDIR, "directories cannot be written, executed, truncated, or removed-on-close");
+ LIB9P_ERRNO_L_EISDIR, "directories cannot be written, executed, truncated, or removed-on-close");
return;
}
}
@@ -977,7 +977,7 @@ static void handle_Topen(struct srv_req *ctx,
lib9p_stat_assert(parent_stat);
if (!srv_check_perm(ctx, &parent_stat, 0b010)) {
lib9p_error(&ctx->basectx,
- LINUX_EACCES, "permission denied to remove-on-close");
+ LIB9P_ERRNO_L_EACCES, "permission denied to remove-on-close");
goto topen_return;
}
fidflags |= FIDFLAG_RCLOSE;
@@ -988,7 +988,7 @@ static void handle_Topen(struct srv_req *ctx,
lib9p_stat_assert(stat);
if ((stat.file_mode & LIB9P_DM_EXCL) && pathinfo->io_refcount) {
lib9p_error(&ctx->basectx,
- LINUX_EEXIST, "exclusive file is already opened");
+ LIB9P_ERRNO_L_EEXIST, "exclusive file is already opened");
goto topen_return;
}
if (stat.file_mode & LIB9P_DM_APPEND)
@@ -1015,7 +1015,7 @@ static void handle_Topen(struct srv_req *ctx,
}
if (!srv_check_perm(ctx, &stat, perm_bits)) {
lib9p_error(&ctx->basectx,
- LINUX_EACCES, "permission denied");
+ LIB9P_ERRNO_L_EACCES, "permission denied");
goto topen_return;
}
@@ -1070,7 +1070,7 @@ static void handle_Tcreate(struct srv_req *ctx,
srv_handler_common(ctx, req, resp);
lib9p_error(&ctx->basectx,
- LINUX_EOPNOTSUPP, "create not (yet?) implemented");
+ LIB9P_ERRNO_L_EOPNOTSUPP, "create not (yet?) implemented");
}
static void handle_Tread(struct srv_req *ctx,
@@ -1084,12 +1084,12 @@ static void handle_Tread(struct srv_req *ctx,
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
lib9p_errorf(&ctx->basectx,
- LINUX_EBADF, "bad file number %"PRIu32, req->fid);
+ LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
return;
}
if (!(fidinfo->flags & FIDFLAG_OPEN_R)) {
lib9p_error(&ctx->basectx,
- LINUX_EINVAL, "FID not open for reading");
+ LIB9P_ERRNO_L_EINVAL, "FID not open for reading");
return;
}
@@ -1105,7 +1105,7 @@ static void handle_Tread(struct srv_req *ctx,
idx = fidinfo->dir.idx;
else {
lib9p_errorf(&ctx->basectx,
- LINUX_EINVAL, "invalid offset (must be 0 or %"PRIu64"): %"PRIu64,
+ LIB9P_ERRNO_L_EINVAL, "invalid offset (must be 0 or %"PRIu64"): %"PRIu64,
fidinfo->dir.off, req->offset);
ctx->authinfo = srv_authinfo_decref(ctx->authinfo);
return;
@@ -1153,12 +1153,12 @@ static void handle_Twrite(struct srv_req *ctx,
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
lib9p_errorf(&ctx->basectx,
- LINUX_EBADF, "bad file number %"PRIu32, req->fid);
+ LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
return;
}
if (!(fidinfo->flags & FIDFLAG_OPEN_W)) {
lib9p_error(&ctx->basectx,
- LINUX_EINVAL, "FID not open for writing");
+ LIB9P_ERRNO_L_EINVAL, "FID not open for writing");
return;
}
@@ -1176,7 +1176,7 @@ static void handle_Tclunk(struct srv_req *ctx,
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
lib9p_errorf(&ctx->basectx,
- LINUX_EBADF, "bad file number %"PRIu32, req->fid);
+ LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
return;
}
@@ -1193,7 +1193,7 @@ static void handle_Tremove(struct srv_req *ctx,
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
lib9p_errorf(&ctx->basectx,
- LINUX_EBADF, "bad file number %"PRIu32, req->fid);
+ LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
return;
}
@@ -1210,7 +1210,7 @@ static void handle_Tstat(struct srv_req *ctx,
struct srv_fidinfo *fidinfo = map_load(&ctx->parent_sess->fids, req->fid);
if (!fidinfo) {
lib9p_errorf(&ctx->basectx,
- LINUX_EBADF, "bad file number %"PRIu32, req->fid);
+ LIB9P_ERRNO_L_EBADF, "bad file number %"PRIu32, req->fid);
return;
}
struct srv_pathinfo *pathinfo = map_load(&ctx->parent_sess->paths, fidinfo->path);
@@ -1229,7 +1229,7 @@ static void handle_Twstat(struct srv_req *ctx,
srv_handler_common(ctx, req, resp);
lib9p_error(&ctx->basectx,
- LINUX_EOPNOTSUPP, "wstat not (yet?) implemented");
+ LIB9P_ERRNO_L_EOPNOTSUPP, "wstat not (yet?) implemented");
}
#if CONFIG_9P_ENABLE_9P2000_p9p
@@ -1239,7 +1239,7 @@ static void handle_Topenfd(struct srv_req *ctx,
srv_handler_common(ctx, req, resp);
lib9p_error(&ctx->basectx,
- LINUX_EOPNOTSUPP, "openfd not (yet?) implemented");
+ LIB9P_ERRNO_L_EOPNOTSUPP, "openfd not (yet?) implemented");
}
#endif
@@ -1250,7 +1250,7 @@ static void handle_Tsession(struct srv_req *ctx,
srv_handler_common(ctx, req, resp);
lib9p_error(&ctx->basectx,
- LINUX_EOPNOTSUPP, "session not (yet?) implemented");
+ LIB9P_ERRNO_L_EOPNOTSUPP, "session not (yet?) implemented");
}
static void handle_Tsread(struct srv_req *ctx,
@@ -1259,7 +1259,7 @@ static void handle_Tsread(struct srv_req *ctx,
srv_handler_common(ctx, req, resp);
lib9p_error(&ctx->basectx,
- LINUX_EOPNOTSUPP, "sread not (yet?) implemented");
+ LIB9P_ERRNO_L_EOPNOTSUPP, "sread not (yet?) implemented");
}
static void handle_Tswrite(struct srv_req *ctx,
@@ -1268,6 +1268,6 @@ static void handle_Tswrite(struct srv_req *ctx,
srv_handler_common(ctx, req, resp);
lib9p_error(&ctx->basectx,
- LINUX_EOPNOTSUPP, "swrite not (yet?) implemented");
+ LIB9P_ERRNO_L_EOPNOTSUPP, "swrite not (yet?) implemented");
}
#endif