From 9c41e36af7e136db4eb85c29c555192965b3c371 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Sun, 24 Nov 2024 08:23:36 +0100 Subject: [PATCH] vfs: implement POSIX append-IO in vfs_pwrite_data() This basically just avoids clobbering a possible offset=VFS_PWRITE_APPEND_OFFSET when calling SMB_VFS_PWRITE(). Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- source3/smbd/vfs.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 76732691c09..c5be257c0d3 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -520,9 +520,14 @@ ssize_t vfs_pwrite_data(struct smb_request *req, } while (total < N) { - ret = SMB_VFS_PWRITE(fsp, buffer + total, N - total, - offset + total); - + off_t pwrite_offset = offset; + if (offset != VFS_PWRITE_APPEND_OFFSET) { + pwrite_offset += total; + } + ret = SMB_VFS_PWRITE(fsp, + buffer + total, + N - total, + pwrite_offset); if (ret == -1) return -1; if (ret == 0) -- 2.47.3