diff options
Diffstat (limited to 'lib9p/srv.c')
-rw-r--r-- | lib9p/srv.c | 7 |
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); |