From e4f1c4fa49ed5a4147c834289d04cc3760c4373d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 4 Jul 1996 21:29:55 +0000 Subject: (netfs_S_io_write): Bother implementing O_APPEND. --- libnetfs/io-write.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/libnetfs/io-write.c b/libnetfs/io-write.c index 81e47189..6c463c89 100644 --- a/libnetfs/io-write.c +++ b/libnetfs/io-write.c @@ -30,6 +30,7 @@ netfs_S_io_write (struct protid *user, mach_msg_type_number_t *amount) { error_t err; + off_t off = offset; if (!user) return EOPNOTSUPP; @@ -42,9 +43,24 @@ netfs_S_io_write (struct protid *user, } *amount = datalen; + + if (off == -1) + { + if (user->po->openstat & O_APPEND) + { + err = netfs_validate_stat (np, user->po->np); + if (err) + { + mutex_unlock (&user->po->np->lock); + return err; + } + user->po->filepointer = np->nn_stat.st_size; + } + off = user->po->filepointer; + } + err = netfs_attempt_write (user->credential, user->po->np, - offset == -1 ? user->po->filepointer : offset, - amount, data); + off, amount, data); if (offset == -1 && !err) user->po->filepointer += *amount; mutex_unlock (&user->po->np->lock); -- cgit v1.2.3