HGFS_LARGE_IO_MAX and HGFS_LARGE_PACKET_MAX macros.
In preparation to bump up HGFS_LARGE_IO_MAX and HGFS_LARGE_PACKET_MAX,
replace most uses of the two macro constants with inline functions that
can return either the new limits or the older defaults based on the
configuration.
/*********************************************************
- * Copyright (C) 1998-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2016,2019 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
char *
HgfsBd_GetLargeBuf(void)
{
- return HgfsBdGetBufInt(HGFS_LARGE_PACKET_MAX);
+ return HgfsBdGetBufInt(HgfsLargePacketMax(FALSE));
}
return -1;
}
- ASSERT(replyLen <= HGFS_LARGE_PACKET_MAX);
+ ASSERT(replyLen <= HgfsLargePacketMax(TRUE));
*packetOut = reply;
*packetSize = replyLen;
HGFS_CLIENT_CMD_LEN,
&rpcStatus, &replyPacket, &replyLen);
if (success && rpcStatus) {
- ASSERT(replyLen <= HGFS_LARGE_PACKET_MAX);
+ ASSERT(replyLen <= HgfsLargePacketMax(TRUE));
}
return success && rpcStatus;
/*********************************************************
- * Copyright (C) 2010-2018 VMware, Inc. All rights reserved.
+ * Copyright (C) 2010-2019 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
if (HGFS_OP_NEW_HEADER != request->op) {
if (HGFS_OP_READ_V3 == op) {
- result = packetSize <= HGFS_LARGE_PACKET_MAX;
+ result = packetSize <= HgfsLargePacketMax(FALSE);
} else {
result = packetSize <= HGFS_PACKET_MAX;
}
/*********************************************************
- * Copyright (C) 1998-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2016,2019 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
#include "includeCheck.h"
#include "vm_assert.h"
+/* Page size for HGFS packet (4K). */
+#define HGFS_PAGE_SIZE 4096
+
+/*
+ * Maximum allowed header size in bytes.
+ */
+#define HGFS_HEADER_SIZE_MAX 2048
+
/*
* Maximum number of pages to transfer to/from the HGFS server for V3 protocol
* operations that support large requests/replies, e.g. reads and writes.
*/
#define HGFS_LARGE_IO_MAX_PAGES 15
+/* Maximum number of bytes to read or write to a hgfs server in a single packet. */
+#define HGFS_IO_MAX HGFS_PAGE_SIZE
+
/*
* Maximum allowed packet size in bytes. All hgfs code should be made
* safe with respect to this limit.
*/
#define HGFS_PACKET_MAX 6144
+/* Maximum number of bytes to read or write to a V3 server in a single hgfs packet. */
+#define HGFS_LARGE_IO_MAX (HGFS_PAGE_SIZE * HGFS_LARGE_IO_MAX_PAGES)
+
/*
* The HGFS_LARGE_PACKET_MAX size is used to allow guests to make
* read / write requests of sizes larger than HGFS_PACKET_MAX. The larger size
* can only be used with server operations that are specified to be large packet
* capable in hgfsProto.h.
*/
-#define HGFS_LARGE_PACKET_MAX ((4096 * HGFS_LARGE_IO_MAX_PAGES) + 2048)
+#define HGFS_LARGE_PACKET_MAX (HGFS_LARGE_IO_MAX + HGFS_HEADER_SIZE_MAX)
-/* Maximum number of bytes to read or write to a hgfs server in a single packet. */
-#define HGFS_IO_MAX 4096
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * HgfsLargeIoMax --
+ *
+ * Gets the maximum number of bytes to read or write to a V3 server in a
+ * single hgfs packet.
+ * By default, a caller should pass useLegacy=FALSE to get its value with the
+ * control of feature switch. Passing useLegacy=TRUE means you want to
+ * directly use the legacy value.
+ *
+ * Results:
+ * Returns the maximum number of bytes to read or write to a V3 server in a
+ * single hgfs packet.
+ *
+ * Side effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------------
+ */
-/* Maximum number of bytes to read or write to a V3 server in a single hgfs packet. */
-#define HGFS_LARGE_IO_MAX (HGFS_LARGE_IO_MAX_PAGES * 4096)
+static INLINE size_t HgfsLargeIoMax(Bool useLegacy) // IN
+{
+ if (useLegacy) {
+ // TODO: Return the legacy value
+ }
+ return HGFS_LARGE_IO_MAX;
+}
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * HgfsLargePacketMax --
+ *
+ * Gets the maximum number of bytes to allow guests to make read / write
+ * requests.
+ * By default, a caller should pass useLegacy=FALSE to get its value with the
+ * control of feature switch. Passing useLegacy=TRUE means you want to
+ * directly use the legacy value.
+ *
+ * Results:
+ * Returns the maximum number of bytes to allow guests to make read / write
+ * requests.
+ *
+ * Side effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static INLINE size_t HgfsLargePacketMax(Bool useLegacy) // IN
+{
+ if (useLegacy) {
+ // TODO: Return the legacy value
+ }
+ return HGFS_LARGE_PACKET_MAX;
+}
/*
* File type
/*********************************************************
- * Copyright (C) 2013 VMware, Inc. All rights reserved.
+ * Copyright (C) 2013,2019 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
ASSERT(req);
ASSERT(req->state == HGFS_REQ_STATE_UNSENT);
- ASSERT(req->payloadSize <= HGFS_LARGE_PACKET_MAX);
+ ASSERT(req->payloadSize <= HgfsLargePacketMax(FALSE));
pthread_mutex_lock(&channel->connLock);
reqSize = sizeof(*requestV3) + HgfsGetRequestHeaderSize();
/* Convert to CP name. */
result = CPName_ConvertTo(path,
- HGFS_LARGE_PACKET_MAX - (reqSize - 1),
+ HgfsLargePacketMax(FALSE) - (reqSize - 1),
requestV3->dirName.name);
if (result < 0) {
LOG(4, ("CP conversion failed\n"));
reqSize = sizeof *request;
/* Convert to CP name. */
result = CPName_ConvertTo(path,
- HGFS_LARGE_PACKET_MAX - (reqSize - 1),
+ HgfsLargePacketMax(FALSE) - (reqSize - 1),
request->dirName.name);
if (result < 0) {
LOG(4, ("CP conversion failed\n"));
requestV3->fileName.caseType = HGFS_FILE_NAME_CASE_SENSITIVE;
/* Convert to CP name. */
result = CPName_ConvertTo(path,
- HGFS_LARGE_PACKET_MAX - (reqSize - 1),
+ HgfsLargePacketMax(FALSE) - (reqSize - 1),
requestV3->fileName.name);
if (result < 0) {
LOG(4, ("CP conversion failed.\n"));
/* Convert to CP name. */
result = CPName_ConvertTo(path,
- HGFS_LARGE_PACKET_MAX - (reqSize - 1),
+ HgfsLargePacketMax(FALSE) - (reqSize - 1),
requestV2->fileName.name);
if (result < 0) {
LOG(4, ("CP conversion failed.\n"));
reqSize = sizeof *request;
/* Convert to CP name. */
result = CPName_ConvertTo(path,
- HGFS_LARGE_PACKET_MAX - (reqSize - 1),
+ HgfsLargePacketMax(FALSE) - (reqSize - 1),
request->fileName.name);
if (result < 0) {
LOG(4, ("CP conversion failed.\n"));
request->hints = 0;
/* Convert to CP name. */
result = CPName_ConvertTo(path,
- HGFS_NAME_BUFFER_SIZET(HGFS_LARGE_PACKET_MAX, reqSize),
+ HGFS_NAME_BUFFER_SIZET(HgfsLargePacketMax(FALSE), reqSize),
request->fileName.name);
if (result < 0) {
LOG(4, ("CP conversion failed.\n"));
reqSize = sizeof *request;
/* Convert to CP name. */
result = CPName_ConvertTo(path,
- HGFS_NAME_BUFFER_SIZET(HGFS_LARGE_PACKET_MAX, reqSize),
+ HGFS_NAME_BUFFER_SIZET(HgfsLargePacketMax(FALSE), reqSize),
request->fileName.name);
if (result < 0) {
LOG(4, ("CP conversion failed.\n"));
/* Convert to CP name. */
result = CPName_ConvertTo(path,
- HGFS_LARGE_PACKET_MAX - (reqSize - 1),
+ HgfsLargePacketMax(FALSE) - (reqSize - 1),
requestV3->fileName.name);
if (result < 0) {
LOG(4, ("CP conversion failed.\n"));
/* Convert to CP name. */
result = CPName_ConvertTo(path,
- HGFS_LARGE_PACKET_MAX - (reqSize - 1),
+ HgfsLargePacketMax(FALSE) - (reqSize - 1),
requestV2->fileName.name);
if (result < 0) {
LOG(4, ("CP conversion failed.\n"));
/* Convert to CP name. */
result = CPName_ConvertTo(path,
- HGFS_LARGE_PACKET_MAX - (reqSize - 1),
+ HgfsLargePacketMax(FALSE) - (reqSize - 1),
request->fileName.name);
if (result < 0) {
LOG(4, ("CP conversion failed.\n"));
fi->fh, count, offset));
do {
- nextCount = (remainingCount > HGFS_LARGE_IO_MAX) ?
- HGFS_LARGE_IO_MAX : remainingCount;
+ nextCount = (remainingCount > HgfsLargeIoMax(FALSE)) ?
+ HgfsLargeIoMax(FALSE) : remainingCount;
LOG(4, ("Issue DoRead(0x%"FMT64"x 0x%"FMTSZ"x bytes @ 0x%"FMT64"x)\n",
fi->fh, nextCount, curOffset));
result = HgfsDoRead(fi->fh, buffer, nextCount, curOffset);
fi->fh, count, offset));
do {
- nextCount = (remainingCount > HGFS_LARGE_IO_MAX) ?
- HGFS_LARGE_IO_MAX : remainingCount;
+ nextCount = (remainingCount > HgfsLargeIoMax(FALSE)) ?
+ HgfsLargeIoMax(FALSE) : remainingCount;
LOG(4, ("Issue DoWrite(0x%"FMT64"x 0x%"FMTSZ"x bytes @ 0x%"FMT64"x)\n",
fi->fh, nextCount, curOffset));
reqSize = sizeof(*requestV3) + HgfsGetRequestHeaderSize();
/* Convert old name to CP format. */
result = CPName_ConvertTo(from,
- HGFS_NAME_BUFFER_SIZET(HGFS_LARGE_PACKET_MAX, reqSize),
+ HGFS_NAME_BUFFER_SIZET(HgfsLargePacketMax(FALSE), reqSize),
requestV3->oldName.name);
if (result < 0) {
LOG(4, ("oldName CP conversion failed\n"));
reqSize = sizeof *request;
/* Convert old name to CP format. */
result = CPName_ConvertTo(from,
- HGFS_NAME_BUFFER_SIZET(HGFS_LARGE_PACKET_MAX, reqSize),
+ HGFS_NAME_BUFFER_SIZET(HgfsLargePacketMax(FALSE), reqSize),
request->oldName.name);
if (result < 0) {
LOG(4, ("oldName CP conversion failed\n"));
/* Convert new name to CP format. */
result = CPName_ConvertTo(to,
- HGFS_NAME_BUFFER_SIZET(HGFS_LARGE_PACKET_MAX, reqSize) - result,
+ HGFS_NAME_BUFFER_SIZET(HgfsLargePacketMax(FALSE), reqSize) - result,
newNameP->name);
if (result < 0) {
LOG(4, ("newName CP conversion failed\n"));
/* Convert new name to CP format. */
result = CPName_ConvertTo(to,
- HGFS_NAME_BUFFER_SIZET(HGFS_LARGE_PACKET_MAX, reqSize) - result,
+ HGFS_NAME_BUFFER_SIZET(HgfsLargePacketMax(FALSE), reqSize) - result,
newNameP->name);
if (result < 0) {
LOG(4, ("newName CP conversion failed\n"));
requestV3->fileName.flags = 0;
requestV3->reserved = 0;
reqSize = sizeof(*requestV3) + HgfsGetRequestHeaderSize();
- reqBufferSize = HGFS_NAME_BUFFER_SIZET(HGFS_LARGE_PACKET_MAX, reqSize);
+ reqBufferSize = HGFS_NAME_BUFFER_SIZET(HgfsLargePacketMax(FALSE), reqSize);
result = CPName_ConvertTo(path,
reqBufferSize,
requestV3->fileName.name);
requestV2->hints = 0;
reqSize = sizeof *requestV2;
- reqBufferSize = HGFS_NAME_BUFFER_SIZE(HGFS_LARGE_PACKET_MAX, requestV2);
+ reqBufferSize = HGFS_NAME_BUFFER_SIZE(HgfsLargePacketMax(FALSE), requestV2);
result = CPName_ConvertTo(path,
reqBufferSize,
requestV2->fileName.name);
update = &request->update;
reqSize = sizeof *request;
- reqBufferSize = HGFS_NAME_BUFFER_SIZE(HGFS_LARGE_PACKET_MAX, request);
+ reqBufferSize = HGFS_NAME_BUFFER_SIZE(HgfsLargePacketMax(FALSE), request);
result = CPName_ConvertTo(path,
reqBufferSize,
request->fileName.name);
requestSize = sizeof(*requestV3) + HgfsGetRequestHeaderSize();
/* Convert to CP name. */
result = CPName_ConvertTo(path,
- HGFS_LARGE_PACKET_MAX - (requestSize - 1),
+ HgfsLargePacketMax(FALSE) - (requestSize - 1),
requestV3->fileName.name);
if (result < 0) {
LOG(4, ("CP conversion failed.\n"));
requestSize = sizeof *request;
/* Convert to CP name. */
result = CPName_ConvertTo(path,
- HGFS_LARGE_PACKET_MAX - (requestSize - 1),
+ HgfsLargePacketMax(FALSE) - (requestSize - 1),
request->fileName.name);
if (result < 0) {
LOG(4, ("CP conversion failed.\n"));
length = replyV3->symlinkTarget.length;
/* Skip the symlinkTarget if it's too long. */
- if (length > HGFS_NAME_BUFFER_SIZET(HGFS_LARGE_PACKET_MAX,
+ if (length > HGFS_NAME_BUFFER_SIZET(HgfsLargePacketMax(FALSE),
sizeof *replyV3 + sizeof (HgfsReply))) {
LOG(4, ("symlink target name too long, ignoring\n"));
return -ENAMETOOLONG;
length = replyV2->symlinkTarget.length;
/* Skip the symlinkTarget if it's too long. */
- if (length > HGFS_NAME_BUFFER_SIZE(HGFS_LARGE_PACKET_MAX, replyV2)) {
+ if (length > HGFS_NAME_BUFFER_SIZE(HgfsLargePacketMax(FALSE), replyV2)) {
LOG(4, ("symlink target name too long, ignoring\n"));
return -ENAMETOOLONG;
}
requestV3->reserved = 0;
reqSize = sizeof(*requestV3) + HgfsGetRequestHeaderSize();
- reqBufferSize = HGFS_NAME_BUFFER_SIZET(HGFS_LARGE_PACKET_MAX, reqSize);
+ reqBufferSize = HGFS_NAME_BUFFER_SIZET(HgfsLargePacketMax(FALSE), reqSize);
/* Convert to CP name. */
result = CPName_ConvertTo(path,
requestV2 = (HgfsRequestGetattrV2 *)(HGFS_REQ_PAYLOAD(req));
requestV2->hints = 0;
reqSize = sizeof *requestV2;
- reqBufferSize = HGFS_NAME_BUFFER_SIZE(HGFS_LARGE_PACKET_MAX, requestV2);
+ reqBufferSize = HGFS_NAME_BUFFER_SIZE(HgfsLargePacketMax(FALSE), requestV2);
/* Convert to CP name. */
result = CPName_ConvertTo(path,
HgfsRequestGetattr *requestV1;
requestV1 = (HgfsRequestGetattr *)(HGFS_REQ_PAYLOAD(req));
reqSize = sizeof *requestV1;
- reqBufferSize = HGFS_NAME_BUFFER_SIZE(HGFS_LARGE_PACKET_MAX, requestV1);
+ reqBufferSize = HGFS_NAME_BUFFER_SIZE(HgfsLargePacketMax(FALSE), requestV1);
/* Convert to CP name. */
result = CPName_ConvertTo(path,
requestSize = sizeof(*requestV3) + HgfsGetRequestHeaderSize();
/* Convert symlink name to CP format. */
result = CPName_ConvertTo(symlink,
- HGFS_LARGE_PACKET_MAX - (requestSize - 1),
+ HgfsLargePacketMax(FALSE) - (requestSize - 1),
requestV3->symlinkName.name);
if (result < 0) {
LOG(4, ("SymlinkName CP conversion failed.\n"));
requestSize += result;
/* Copy target name into request packet. */
- if (targetNameBytes > HGFS_LARGE_PACKET_MAX - (requestSize - 1)) {
+ if (targetNameBytes > HgfsLargePacketMax(FALSE) - (requestSize - 1)) {
LOG(4, ("Target name is too long.\n"));
return -EINVAL;
}
requestSize = sizeof *request;
/* Convert symlink name to CP format. */
result = CPName_ConvertTo(symlink,
- HGFS_LARGE_PACKET_MAX - (requestSize - 1),
+ HgfsLargePacketMax(FALSE) - (requestSize - 1),
request->symlinkName.name);
if (result < 0) {
LOG(4, ("SymlinkName CP conversion failed.\n"));
requestSize += result;
/* Copy target name into request packet. */
- if (targetNameBytes > HGFS_LARGE_PACKET_MAX - (requestSize - 1)) {
+ if (targetNameBytes > HgfsLargePacketMax(FALSE) - (requestSize - 1)) {
LOG(4, ("Target name is too long.\n"));
return -EINVAL;
}
/*********************************************************
- * Copyright (C) 2013 VMware, Inc. All rights reserved.
+ * Copyright (C) 2013,2019 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
int ret;
ASSERT(req);
- ASSERT(req->payloadSize <= HGFS_LARGE_PACKET_MAX);
+ ASSERT(req->payloadSize <= HgfsLargePacketMax(FALSE));
req->state = HGFS_REQ_STATE_UNSENT;
{
ASSERT(req);
ASSERT(reply);
- ASSERT(replySize <= HGFS_LARGE_PACKET_MAX);
+ ASSERT(replySize <= HgfsLargePacketMax(FALSE));
memcpy(HGFS_REQ_PAYLOAD(req), reply, replySize);
req->payloadSize = replySize;
/*********************************************************
- * Copyright (C) 2015-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2015-2016,2019 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
HgfsRequestCreateSessionV4 *requestV4 = HgfsGetRequestPayload(req);
requestV4->numCapabilities = 0;
- requestV4->maxPacketSize = HGFS_LARGE_PACKET_MAX;
+ requestV4->maxPacketSize = HgfsLargePacketMax(FALSE);
requestV4->reserved = 0;
req->payloadSize = sizeof(*requestV4) + HgfsGetRequestHeaderSize();
/*********************************************************
- * Copyright (C) 2013 VMware, Inc. All rights reserved.
+ * Copyright (C) 2013,2019 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
int ret;
ASSERT(req);
ASSERT(req->state == HGFS_REQ_STATE_UNSENT);
- ASSERT(req->payloadSize <= HGFS_LARGE_PACKET_MAX);
+ ASSERT(req->payloadSize <= HgfsLargePacketMax(FALSE));
pthread_mutex_lock(&gHgfsActiveChannelLock);
#ifndef _VMHGFS_VERSION_H_
#define _VMHGFS_VERSION_H_
-#define VMHGFS_DRIVER_VERSION 1.6.9.0
-#define VMHGFS_DRIVER_VERSION_COMMAS 1,6,9,0
-#define VMHGFS_DRIVER_VERSION_STRING "1.6.9.0"
+#define VMHGFS_DRIVER_VERSION 1.6.10.0
+#define VMHGFS_DRIVER_VERSION_COMMAS 1,6,10,0
+#define VMHGFS_DRIVER_VERSION_STRING "1.6.10.0"
#endif /* _VMHGFS_VERSION_H_ */