Complete some tidy up of the input params created from the HgfsPacket.
This can be contained to only the HgfsServer code and not required to be
exposed beyond that. So this removes the one usage from the parameter
pack and unpack code which was in the unpack write request.
As I was modifying up the HGFS server write request I correct a couple of
const char * to const void * for the write data.
I removed a HSPU_PutPacket declaration as the function did not exist.
Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
/* Default maximun number of open nodes that have server locks. */
#define MAX_LOCKED_FILENODES 10
+
+/* The input request paramaters object. */
+typedef struct HgfsInputParam {
+ const void *request; /* Hgfs header followed by operation request */
+ size_t requestSize; /* Size of Hgfs header and operation request */
+ HgfsSessionInfo *session; /* Hgfs session data */
+ HgfsTransportSessionInfo *transportSession;
+ HgfsPacket *packet; /* Public (server/transport) Hgfs packet */
+ void const *payload; /* Hgfs operation request */
+ uint32 payloadOffset; /* Offset to start of Hgfs operation request */
+ size_t payloadSize; /* Hgfs operation request size */
+ HgfsOp op; /* Hgfs operation command code */
+ uint32 id; /* Request ID to be matched with the reply */
+ Bool sessionEnabled; /* Requests have session enabled headers */
+} HgfsInputParam;
+
/*
* The HGFS server configurable settings.
* (Note: the guest sets these to all defaults only modifiable from the VMX.)
HgfsInternalStatus status;
HgfsWriteFlags flags;
uint64 offset;
- const char *dataToWrite;
+ const void *dataToWrite;
uint32 replyActualSize;
size_t replyPayloadSize = 0;
HgfsHandle file;
HGFS_ASSERT_INPUT(input);
- if (HgfsUnpackWriteRequest(input, &file, &offset, &numberBytesToWrite,
- &flags, &dataToWrite)) {
+ if (!HgfsUnpackWriteRequest(input->payload, input->payloadSize, input->op,
+ &file, &offset, &numberBytesToWrite, &flags,
+ &dataToWrite)) {
+ LOG(4, ("%s: Error: Op %d unpack write request arguments\n", __FUNCTION__, input->op));
+ status = HGFS_ERROR_PROTOCOL;
+ goto exit;
+ }
- status = HgfsPlatformWriteFile(file, input->session, offset, numberBytesToWrite,
- flags, (void *)dataToWrite, &replyActualSize);
- if (HGFS_ERROR_SUCCESS == status) {
- if (!HgfsPackWriteReply(input->packet, input->request, input->op,
- replyActualSize, &replyPayloadSize, input->session)) {
- status = HGFS_ERROR_INTERNAL;
- }
+ if (NULL == dataToWrite) {
+ /* No inline data to write, get it from the transport shared memory. */
+ dataToWrite = HSPU_GetDataPacketBuf(input->packet, BUF_READABLE,
+ input->transportSession);
+ if (NULL == dataToWrite) {
+ LOG(4, ("%s: Error: Op %d mapping write data buffer\n", __FUNCTION__, input->op));
+ status = HGFS_ERROR_PROTOCOL;
+ goto exit;
}
- } else {
- status = HGFS_ERROR_PROTOCOL;
}
+ status = HgfsPlatformWriteFile(file, input->session, offset, numberBytesToWrite,
+ flags, dataToWrite, &replyActualSize);
+ if (HGFS_ERROR_SUCCESS != status) {
+ goto exit;
+ }
+
+ if (!HgfsPackWriteReply(input->packet, input->request, input->op,
+ replyActualSize, &replyPayloadSize, input->session)) {
+ status = HGFS_ERROR_INTERNAL;
+ }
+
+exit:
HgfsServerCompleteRequest(status, replyPayloadSize, input);
}
HgfsSessionFlags flags; /* Session capability flags. */
} HgfsCreateSessionInfo;
-
-typedef struct HgfsInputParam {
- const void *request; /* Hgfs header followed by operation request */
- size_t requestSize; /* Size of Hgfs header and operation request */
- HgfsSessionInfo *session; /* Hgfs session data */
- HgfsTransportSessionInfo *transportSession;
- HgfsPacket *packet; /* Public (server/transport) Hgfs packet */
- void const *payload; /* Hgfs operation request */
- uint32 payloadOffset; /* Offset to start of Hgfs operation request */
- size_t payloadSize; /* Hgfs operation request size */
- HgfsOp op; /* Hgfs operation command code */
- uint32 id; /* Request ID to be matched with the reply */
- Bool sessionEnabled; /* Requests have session enabled headers */
-} HgfsInputParam;
-
Bool
HgfsCreateAndCacheFileNode(HgfsFileOpenInfo *openInfo, // IN: Open info struct
HgfsLocalId const *localId, // IN: Local unique file ID
uint64 offset, // IN: file offset to write to
uint32 requiredSize, // IN: length of data to write
HgfsWriteFlags flags, // IN: write flags
- void* payload, // IN: data to be written
+ const void *payload, // IN: data to be written
uint32 *actualSize); // OUT: actual length written
HgfsInternalStatus
HgfsPlatformWriteWin32Stream(HgfsHandle file, // IN: packet header
MappingType mappingType, // IN: Readable/ Writeable ?
HgfsTransportSessionInfo *transportSession); // IN: Session Info
-void
-HSPU_PutPacket(HgfsPacket *packet, // IN/OUT: Hgfs Packet
- HgfsTransportSessionInfo *transportSession); // IN: Session Info
-
void
HSPU_PutDataPacketBuf(HgfsPacket *packet, // IN/OUT: Hgfs Packet
HgfsTransportSessionInfo *transportSession); // IN: Session Info
uint64 offset, // IN: file offset to write to
uint32 requiredSize, // IN: length of data to write
HgfsWriteFlags flags, // IN: write flags
- void* payload, // IN: data to be written
+ const void *payload, // IN: data to be written
uint32 *actualSize) // OUT: actual length written
{
HgfsInternalStatus status;
uint64 *offset, // OUT: offset to read from
uint32 *length, // OUT: length of data to write
HgfsWriteFlags *flags, // OUT: write flags
- const char **data) // OUT: data to be written
+ const void **data) // OUT: data to be written
{
LOG(4, ("%s: HGFS_OP_WRITE\n", __FUNCTION__));
if (payloadSize >= sizeof *request) {
uint64 *offset, // OUT: offset to read from
uint32 *length, // OUT: length of data to write
HgfsWriteFlags *flags, // OUT: write flags
- const char **data) // OUT: data to be written
+ const void **data) // OUT: data to be written
{
LOG(4, ("%s: HGFS_OP_WRITE_V3\n", __FUNCTION__));
if (payloadSize >= sizeof *requestV3) {
*/
Bool
-HgfsUnpackWriteRequest(HgfsInputParam *input, // IN: Input params
+HgfsUnpackWriteRequest(void const *writeRequest,// IN: write request params
+ size_t writeRequestSize, // IN: write request params size
+ HgfsOp writeOp, // IN: request version
HgfsHandle *file, // OUT: Handle to write to
uint64 *offset, // OUT: offset to write to
uint32 *length, // OUT: length of data to write
HgfsWriteFlags *flags, // OUT: write flags
- const char **data) // OUT: data to be written
+ const void **data) // OUT: data to be written
{
Bool result;
- ASSERT(input);
-
- switch (input->op) {
+ switch (writeOp) {
case HGFS_OP_WRITE_FAST_V4: {
- const HgfsRequestWriteV3 *requestV3 = input->payload;
+ const HgfsRequestWriteV3 *requestV3 = writeRequest;
- result = HgfsUnpackWriteFastPayloadV4(requestV3, input->payloadSize, file,
+ *data = NULL; /* Write data is retrieved from shared memory. */
+ result = HgfsUnpackWriteFastPayloadV4(requestV3, writeRequestSize, file,
offset, length, flags);
- if (result) {
- *data = HSPU_GetDataPacketBuf(input->packet,
- BUF_READABLE,
- input->transportSession);
- if (NULL == *data) {
- LOG(4, ("%s: Failed to get data in guest memory\n", __FUNCTION__));
- result = FALSE;
- }
- }
break;
}
case HGFS_OP_WRITE_V3: {
- const HgfsRequestWriteV3 *requestV3 = input->payload;
+ const HgfsRequestWriteV3 *requestV3 = writeRequest;
- result = HgfsUnpackWritePayloadV3(requestV3, input->payloadSize, file, offset,
+ result = HgfsUnpackWritePayloadV3(requestV3, writeRequestSize, file, offset,
length, flags, data);
break;
}
case HGFS_OP_WRITE: {
- const HgfsRequestWrite *requestV1 = input->payload;
+ const HgfsRequestWrite *requestV1 = writeRequest;
- result = HgfsUnpackWritePayload(requestV1, input->payloadSize, file, offset,
+ result = HgfsUnpackWritePayload(requestV1, writeRequestSize, file, offset,
length, flags, data);
break;
}
default:
- LOG(4, ("%s: Incorrect opcode %d\n", __FUNCTION__, input->op));
+ LOG(4, ("%s: Incorrect opcode %d\n", __FUNCTION__, writeOp));
NOT_REACHED();
result = FALSE;
}
uint64 *offset, // OUT: offset to read from
uint32 *length); // OUT: length of data to read
Bool
-HgfsUnpackWriteRequest(HgfsInputParam *input, // IN: Input params
+HgfsUnpackWriteRequest(void const *writeRequest,// IN: HGFS write request params
+ size_t writeRequestSize, // IN: write request params size
+ HgfsOp writeOp, // IN: request version
HgfsHandle *file, // OUT: Handle to write to
uint64 *offset, // OUT: offset to write to
uint32 *length, // OUT: length of data to write
HgfsWriteFlags *flags, // OUT: write flags
- const char **data); // OUT: data to be written
+ const void **data); // OUT: data to be written
Bool
HgfsPackCreateSessionReply(HgfsPacket *packet, // IN/OUT: Hgfs Packet
void const *packetHeader, // IN: packet header