]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs: implement POSIX append-IO in vfs_pwrite_data()
authorRalph Boehme <slow@samba.org>
Sun, 24 Nov 2024 07:23:36 +0000 (08:23 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 7 Jan 2025 22:04:33 +0000 (22:04 +0000)
This basically just avoids clobbering a possible offset=VFS_PWRITE_APPEND_OFFSET
when calling SMB_VFS_PWRITE().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/vfs.c

index 76732691c0913a36960b9f5a1ae89e555627b9f6..c5be257c0d353e7c0eb4e4d80e933f46575accd5 100644 (file)
@@ -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)