summaryrefslogtreecommitdiff
path: root/lib9p/srv.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-17 12:42:25 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-18 11:26:44 -0600
commit740bffed4da51c4d46a1295baabe3bd249cf9138 (patch)
treeb38e30e3eef47ecc58f7162e2bfa84bbb885cde3 /lib9p/srv.c
parentb44e1813b9a39827ebe5b8ade6dd68713925c58b (diff)
lib9p_srv: Set Twrite->byte_offset to zero if append-only
Diffstat (limited to 'lib9p/srv.c')
-rw-r--r--lib9p/srv.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib9p/srv.c b/lib9p/srv.c
index 9dcf605..9adaefa 100644
--- a/lib9p/srv.c
+++ b/lib9p/srv.c
@@ -92,6 +92,7 @@ struct srv_pathinfo {
#define FIDFLAG_OPEN_R (1<<0)
#define FIDFLAG_OPEN_W (1<<1)
#define FIDFLAG_RCLOSE (1<<2)
+#define FIDFLAG_APPEND (1<<3)
#define FIDFLAG_OPEN (FIDFLAG_OPEN_R|FIDFLAG_OPEN_W)
struct srv_fidinfo {
@@ -1046,8 +1047,10 @@ static void handle_Topen(struct srv_req *ctx,
LIB9P_ERRNO_L_EEXIST, "exclusive file is already opened");
goto topen_return;
}
- if (stat.file_mode & LIB9P_DM_APPEND)
+ if (stat.file_mode & LIB9P_DM_APPEND) {
+ fidflags |= FIDFLAG_APPEND;
reqmode = reqmode & ~LIB9P_O_TRUNC;
+ }
uint8_t perm_bits = 0;
bool rd = false, wr = false;
switch (reqmode & LIB9P_O_MODE_MASK) {
@@ -1216,6 +1219,8 @@ static void handle_Twrite(struct srv_req *ctx,
LIB9P_ERRNO_L_EINVAL, "FID not open for writing");
return;
}
+ if (fidinfo->flags & FIDFLAG_APPEND)
+ req->offset = 0;
/* Do it. */
ctx->user = srv_userid_incref(fidinfo->user);