summaryrefslogtreecommitdiff
path: root/sysutils/open-vm-tools/patches/patch-vmhgfs-fuse_main.c
blob: 72cf64cb827ad83cc955669dae45d2a795ffc6a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
$NetBSD: patch-vmhgfs-fuse_main.c,v 1.1 2022/01/30 16:22:20 pho Exp $

Workaround for an issue regarding write operations on vmhgfs. See:
https://github.com/vmware/open-vm-tools/issues/437

Ideally this should be worked around by setting fuse_conn_info.max_write to
65457, but it doesn't work on NetBSD because neither PUFFS nor ReFUSE
support it at the moment.

--- vmhgfs-fuse/main.c.orig	2022-01-30 16:00:53.301468031 +0000
+++ vmhgfs-fuse/main.c
@@ -1138,7 +1138,20 @@ hgfs_write(const char *path,          //
       }
    }
 
-   res = HgfsWrite(fi, buf, size, offset);
+   for (res = 0; res < size; ) {
+       int remaining = size - res;
+       int chunkLen  = remaining > 65457 ? 65457 : remaining;
+       int nWrote    = HgfsWrite(fi, buf + res, chunkLen, offset + res);
+
+       if (nWrote < 0) {
+           res = nWrote; /* An error occured. */
+           break;
+       }
+       else {
+           res += nWrote;
+       }
+   }
+
    if (res >= 0) {
       /*
        * Positive result indicates the number of bytes written.