open-vm-tools/file-aligned.patch

370 lines
12 KiB
Diff
Raw Normal View History

2019-02-03 08:20:24 +00:00
diff -ru open-vm-tools-10.3.0-8931395-orig/vmhgfs-fuse/file.c open-vm-tools-10.3.0-8931395/vmhgfs-fuse/file.c
--- open-vm-tools-10.3.0-8931395-orig/vmhgfs-fuse/file.c 2018-06-23 03:03:28.000000000 -0700
+++ open-vm-tools-10.3.0-8931395/vmhgfs-fuse/file.c 2019-02-02 23:41:49.274822242 -0800
@@ -66,8 +66,6 @@
HgfsOp opUsed, // IN: Op to use
HgfsReq *req) // IN/OUT: Packet to write into
{
- char *name;
- uint32 *nameLength;
size_t reqSize;
int result;
int openMode, openFlags;
@@ -92,10 +90,16 @@
reqSize = sizeof(*requestV3) + HgfsGetRequestHeaderSize();
- /* We'll use these later. */
- name = requestV3->fileName.name;
- nameLength = &requestV3->fileName.length;
+ /* Convert to CP name. */
+ result = CPName_ConvertTo(path,
+ HGFS_LARGE_PACKET_MAX - (reqSize - 1),
+ requestV3->fileName.name);
+ if (result < 0) {
+ LOG(4, ("CP conversion failed.\n"));
+ return -EINVAL;
+ }
+ requestV3->fileName.length = (uint32) result;
/* Linux clients need case-sensitive lookups. */
requestV3->fileName.flags = 0;
requestV3->fileName.caseType = HGFS_FILE_NAME_CASE_SENSITIVE;
@@ -126,11 +130,18 @@
requestV2 = (HgfsRequestOpenV2 *)(HGFS_REQ_PAYLOAD(req));
- /* We'll use these later. */
- name = requestV2->fileName.name;
- nameLength = &requestV2->fileName.length;
reqSize = sizeof *requestV2;
+ /* Convert to CP name. */
+ result = CPName_ConvertTo(path,
+ HGFS_LARGE_PACKET_MAX - (reqSize - 1),
+ requestV2->fileName.name);
+ if (result < 0) {
+ LOG(4, ("CP conversion failed.\n"));
+ return -EINVAL;
+ }
+
+ requestV2->fileName.length = (uint32) result;
requestV2->mask = mask;
requestV2->mode = openMode;
requestV2->flags = openFlags;
@@ -151,11 +162,18 @@
HgfsRequestOpen *request;
request = (HgfsRequestOpen *)(HGFS_REQ_PAYLOAD(req));
- /* We'll use these later. */
- name = request->fileName.name;
- nameLength = &request->fileName.length;
reqSize = sizeof *request;
+ /* Convert to CP name. */
+ result = CPName_ConvertTo(path,
+ HGFS_LARGE_PACKET_MAX - (reqSize - 1),
+ request->fileName.name);
+ if (result < 0) {
+ LOG(4, ("CP conversion failed.\n"));
+ return -EINVAL;
+ }
+
+ request->fileName.length = (uint32) result;
request->mode = openMode;
request->flags = openFlags;
@@ -168,17 +186,6 @@
return -EPROTO;
}
-
- /* Convert to CP name. */
- result = CPName_ConvertTo(path,
- HGFS_LARGE_PACKET_MAX - (reqSize - 1),
- name);
- if (result < 0) {
- LOG(4, ("CP conversion failed.\n"));
- return -EINVAL;
- }
-
- *nameLength = (uint32) result;
req->payloadSize = reqSize + result;
/* Fill in header here as payloadSize needs to be there. */
@@ -915,10 +922,6 @@
HgfsRename(const char* from, const char* to)
{
HgfsReq *req = NULL;
- char *oldName;
- char *newName;
- uint32 *oldNameLength;
- uint32 *newNameLength;
int result = 0;
uint32 reqSize;
HgfsOp opUsed;
@@ -942,33 +945,41 @@
if (opUsed == HGFS_OP_RENAME_V3) {
HgfsRequestRenameV3 *requestV3 = HgfsGetRequestPayload(req);
- oldName = requestV3->oldName.name;
- oldNameLength = &requestV3->oldName.length;
requestV3->hints = 0;
requestV3->oldName.flags = 0;
requestV3->oldName.fid = HGFS_INVALID_HANDLE;
requestV3->oldName.caseType = HGFS_FILE_NAME_CASE_SENSITIVE;
requestV3->reserved = 0;
reqSize = sizeof(*requestV3) + HgfsGetRequestHeaderSize();
+ /* Convert old name to CP format. */
+ result = CPName_ConvertTo(from,
+ HGFS_NAME_BUFFER_SIZET(HGFS_LARGE_PACKET_MAX, reqSize),
+ requestV3->oldName.name);
+ if (result < 0) {
+ LOG(4, ("oldName CP conversion failed\n"));
+ result = -EINVAL;
+ goto out;
+ }
+
+ requestV3->oldName.length = result;
+ reqSize += result;
} else {
HgfsRequestRename *request = (HgfsRequestRename *)HGFS_REQ_PAYLOAD(req);
- oldName = request->oldName.name;
- oldNameLength = &request->oldName.length;
reqSize = sizeof *request;
- }
- /* Convert old name to CP format. */
- result = CPName_ConvertTo(from,
- HGFS_NAME_BUFFER_SIZET(HGFS_LARGE_PACKET_MAX, reqSize),
- oldName);
- if (result < 0) {
- LOG(4, ("oldName CP conversion failed\n"));
- result = -EINVAL;
- goto out;
- }
+ /* Convert old name to CP format. */
+ result = CPName_ConvertTo(from,
+ HGFS_NAME_BUFFER_SIZET(HGFS_LARGE_PACKET_MAX, reqSize),
+ request->oldName.name);
+ if (result < 0) {
+ LOG(4, ("oldName CP conversion failed\n"));
+ result = -EINVAL;
+ goto out;
+ }
- *oldNameLength = result;
- reqSize += result;
+ request->oldName.length = result;
+ reqSize += result;
+ }
/*
* Build full new name to send to server.
@@ -983,8 +994,20 @@
newNameP = (HgfsFileNameV3 *)((char *)&requestV3->oldName +
sizeof requestV3->oldName + result);
- newName = newNameP->name;
- newNameLength = &newNameP->length;
+
+ LOG(6, ("New name: \"%s\"\n", newNameP->name));
+
+ /* Convert new name to CP format. */
+ result = CPName_ConvertTo(to,
+ HGFS_NAME_BUFFER_SIZET(HGFS_LARGE_PACKET_MAX, reqSize) - result,
+ newNameP->name);
+ if (result < 0) {
+ LOG(4, ("newName CP conversion failed\n"));
+ result = -EINVAL;
+ goto out;
+ }
+ newNameP->length = result;
+ reqSize += result;
newNameP->flags = 0;
newNameP->fid = HGFS_INVALID_HANDLE;
newNameP->caseType = HGFS_FILE_NAME_CASE_SENSITIVE;
@@ -993,24 +1016,22 @@
HgfsFileName *newNameP;
newNameP = (HgfsFileName *)((char *)&request->oldName +
sizeof request->oldName + result);
- newName = newNameP->name;
- newNameLength = &newNameP->length;
- }
- LOG(6, ("New name: \"%s\"\n", newName));
+ LOG(6, ("New name: \"%s\"\n", newNameP->name));
- /* Convert new name to CP format. */
- result = CPName_ConvertTo(to,
- HGFS_NAME_BUFFER_SIZET(HGFS_LARGE_PACKET_MAX, reqSize) - result,
- newName);
- if (result < 0) {
- LOG(4, ("newName CP conversion failed\n"));
- result = -EINVAL;
- goto out;
+ /* Convert new name to CP format. */
+ result = CPName_ConvertTo(to,
+ HGFS_NAME_BUFFER_SIZET(HGFS_LARGE_PACKET_MAX, reqSize) - result,
+ newNameP->name);
+ if (result < 0) {
+ LOG(4, ("newName CP conversion failed\n"));
+ result = -EINVAL;
+ goto out;
+ }
+ newNameP->length = result;
+ reqSize += result;
}
- *newNameLength = result;
- reqSize += result;
req->payloadSize = reqSize;
/* Fill in header here as payloadSize needs to be there. */
@@ -1109,10 +1130,7 @@
{
HgfsAttrV2 *attrV2;
HgfsAttr *attrV1;
- HgfsAttrHint *hints;
HgfsAttrChanges *update;
- char *fileName = NULL;
- uint32 *fileNameLength = NULL;
size_t reqBufferSize;
size_t reqSize;
int result = 0;
@@ -1123,7 +1141,6 @@
HgfsRequestSetattrV3 *requestV3 = HgfsGetRequestPayload(req);
attrV2 = &requestV3->attr;
- hints = &requestV3->hints;
/*
* Clear attributes, mask, and hints before touching them.
@@ -1131,7 +1148,7 @@
* make sure to zero them all here.
*/
memset(attrV2, 0, sizeof *attrV2);
- memset(hints, 0, sizeof *hints);
+ requestV3->hints = 0;
/*
* When possible, issue a setattr using an existing handle. This will
@@ -1143,14 +1160,20 @@
* the times also requires write permissions on Windows, so we require it
* here too. Otherwise, any handle will do.
*/
- fileName = requestV3->fileName.name;
- fileNameLength = &requestV3->fileName.length;
requestV3->fileName.caseType = HGFS_FILE_NAME_CASE_SENSITIVE;
requestV3->fileName.fid = HGFS_INVALID_HANDLE;
requestV3->fileName.flags = 0;
requestV3->reserved = 0;
reqSize = sizeof(*requestV3) + HgfsGetRequestHeaderSize();
reqBufferSize = HGFS_NAME_BUFFER_SIZET(HGFS_LARGE_PACKET_MAX, reqSize);
+ result = CPName_ConvertTo(path,
+ reqBufferSize,
+ requestV3->fileName.name);
+ if (result < 0) {
+ LOG(4, ("CP conversion failed.\n"));
+ return -EINVAL;
+ }
+ requestV3->fileName.length = result;
attrV2->mask = attr->mask;
if (attr->mask & (HGFS_ATTR_VALID_SPECIAL_PERMS |
@@ -1173,11 +1196,11 @@
}
if (attr->mask & HGFS_ATTR_VALID_ACCESS_TIME) {
attrV2->accessTime = attr->accessTime;
- *hints |= HGFS_ATTR_HINT_SET_ACCESS_TIME;
+ requestV3->hints |= HGFS_ATTR_HINT_SET_ACCESS_TIME;
}
if (attr->mask & HGFS_ATTR_VALID_WRITE_TIME) {
attrV2->writeTime = attr->writeTime;
- *hints |= HGFS_ATTR_HINT_SET_WRITE_TIME;
+ requestV3->hints |= HGFS_ATTR_HINT_SET_WRITE_TIME;
}
break;
@@ -1188,7 +1211,6 @@
requestV2 = (HgfsRequestSetattrV2 *)(HGFS_REQ_PAYLOAD(req));
attrV2 = &requestV2->attr;
- hints = &requestV2->hints;
/*
* Clear attributes, mask, and hints before touching them.
@@ -1196,13 +1218,18 @@
* make sure to zero them all here.
*/
memset(attrV2, 0, sizeof *attrV2);
- memset(hints, 0, sizeof *hints);
-
- fileName = requestV2->fileName.name;
- fileNameLength = &requestV2->fileName.length;
+ requestV2->hints = 0;
reqSize = sizeof *requestV2;
reqBufferSize = HGFS_NAME_BUFFER_SIZE(HGFS_LARGE_PACKET_MAX, requestV2);
+ result = CPName_ConvertTo(path,
+ reqBufferSize,
+ requestV2->fileName.name);
+ if (result < 0) {
+ LOG(4, ("CP conversion failed.\n"));
+ return -EINVAL;
+ }
+ requestV2->fileName.length = result;
if (attr->mask & (HGFS_ATTR_VALID_SPECIAL_PERMS |
HGFS_ATTR_VALID_OWNER_PERMS |
@@ -1224,11 +1251,11 @@
}
if (attr->mask & HGFS_ATTR_VALID_ACCESS_TIME) {
attrV2->accessTime = attr->accessTime;
- *hints |= HGFS_ATTR_HINT_SET_ACCESS_TIME;
+ requestV2->hints |= HGFS_ATTR_HINT_SET_ACCESS_TIME;
}
if (attr->mask & HGFS_ATTR_VALID_WRITE_TIME) {
attrV2->writeTime = attr->writeTime;
- *hints |= HGFS_ATTR_HINT_SET_WRITE_TIME;
+ requestV2->hints |= HGFS_ATTR_HINT_SET_WRITE_TIME;
}
break;
@@ -1241,11 +1268,16 @@
attrV1 = &request->attr;
update = &request->update;
- /* We'll use these later. */
- fileName = request->fileName.name;
- fileNameLength = &request->fileName.length;
reqSize = sizeof *request;
reqBufferSize = HGFS_NAME_BUFFER_SIZE(HGFS_LARGE_PACKET_MAX, request);
+ result = CPName_ConvertTo(path,
+ reqBufferSize,
+ request->fileName.name);
+ if (result < 0) {
+ LOG(4, ("CP conversion failed.\n"));
+ return -EINVAL;
+ }
+ request->fileName.length = result;
/*
* Clear attributes before touching them.
@@ -1284,15 +1316,6 @@
return -EPROTO;
}
- result = CPName_ConvertTo(path,
- reqBufferSize,
- fileName);
- if (result < 0) {
- LOG(4, ("CP conversion failed.\n"));
- return -EINVAL;
- }
-
- *fileNameLength = result;
req->payloadSize = reqSize + result;
/* Fill in header here as payloadSize needs to be there. */