From: VMware, Inc <> Date: Fri, 12 Apr 2013 19:44:18 +0000 (-0700) Subject: HGFS: fix up the Hgfs header flags and information fields X-Git-Tag: 2013.04.16-1098359~61 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ed4f677b599756dd0ef52214308085bca31df9ba;p=thirdparty%2Fopen-vm-tools.git HGFS: fix up the Hgfs header flags and information fields Currently, the Hgfs server just blindly sets the header information field to the host platform's internal error value. This isn't very handy as it will involve determining whether it is Posix or Win32. Then mapping accordingly to the Windows client or Linux client internal kernel error values. It would be more suited to being used in conjunction with a flag to state what the field contains, so that it can be used for multiple things if required - albeit not simultaneously. This would also allow the client to know that the field is really valid, and not some host specific error value which is currently set. Also, since the clients only require one or two host error extended information, it probably is simpler to define a crossplatform value for that new error value and have the clients map it as they already do for the existing crossplatform errors. Also there was a flag for the flags field defined but never used. So it is being thrown away and redefined. The flag was previously defined to be a notification bug was intended to be more generic meaning host server initiated request and not a reply to a client initiated request. Fixed this. Signed-off-by: Dmitry Torokhov --- diff --git a/open-vm-tools/lib/hgfsServer/hgfsServer.c b/open-vm-tools/lib/hgfsServer/hgfsServer.c index 46fb4a8c1..8e149d171 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServer.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServer.c @@ -2887,7 +2887,8 @@ HgfsServerCompleteRequest(HgfsInternalStatus status, // IN: Status of the requ replySessionId = input->session->sessionId; } HgfsPackReplyHeaderV4(status, replyPayloadSize, input->op, - replySessionId, input->id, header); + replySessionId, input->id, HGFS_PACKET_FLAG_REPLY, + header); } } else { HgfsReply *reply; @@ -8035,7 +8036,7 @@ HgfsServerDirWatchEvent(HgfsSharedFolderHandle sharedFolder, // IN: shared folde char *shareName = NULL; size_t shareNameLen; size_t sizeNeeded; - uint32 flags; + uint32 notifyFlags; LOG(4, ("%s:Entered shr hnd %u hnd %"FMT64"x file %s mask %u\n", __FUNCTION__, sharedFolder, subscriber, fileName, mask)); @@ -8054,13 +8055,13 @@ HgfsServerDirWatchEvent(HgfsSharedFolderHandle sharedFolder, // IN: shared folde packet->metaPacketSize = sizeNeeded; packet->metaPacket = packetHeader; packet->dataPacketIsAllocated = TRUE; - flags = 0; + notifyFlags = 0; if (mask & HGFS_NOTIFY_EVENTS_DROPPED) { - flags |= HGFS_NOTIFY_FLAG_OVERFLOW; + notifyFlags |= HGFS_NOTIFY_FLAG_OVERFLOW; } if (!HgfsPackChangeNotificationRequest(packetHeader, subscriber, shareName, fileName, mask, - flags, session, &sizeNeeded)) { + notifyFlags, session, &sizeNeeded)) { LOG(4, ("%s: failed to pack notification request\n", __FUNCTION__)); goto exit; } diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerInt.h b/open-vm-tools/lib/hgfsServer/hgfsServerInt.h index cb57e4f50..03dc24c22 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServerInt.h +++ b/open-vm-tools/lib/hgfsServer/hgfsServerInt.h @@ -844,6 +844,7 @@ HgfsPackReplyHeaderV4(HgfsInternalStatus status, // IN: platfrom independent HG HgfsOp op, // IN: request type uint64 sessionId, // IN: session id uint32 requestId, // IN: request id + uint32 hdrFlags, // IN: header flags HgfsHeader *header); // OUT: packet header HgfsInternalStatus diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerParameters.c b/open-vm-tools/lib/hgfsServer/hgfsServerParameters.c index 9d679821a..293f25136 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServerParameters.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServerParameters.c @@ -676,7 +676,7 @@ HgfsUnpackOpenRequest(void const *packet, // IN: HGFS packet * * HgfsPackReplyHeaderV4 -- * - * Pack hgfs header that corresponds an incoming packet. + * Pack hgfs header that corresponds to an HGFS protocol packet. * * Results: * None. @@ -693,17 +693,18 @@ HgfsPackReplyHeaderV4(HgfsInternalStatus status, // IN: reply status HgfsOp op, // IN: request type uint64 sessionId, // IN: session id uint32 requestId, // IN: request id + uint32 hdrFlags, // IN: header flags HgfsHeader *header) // OUT: outgoing packet header { memset(header, 0, sizeof *header); - header->version = 1; + header->version = HGFS_HEADER_VERSION; header->dummy = HGFS_V4_LEGACY_OPCODE; header->packetSize = payloadSize + sizeof *header; header->headerSize = sizeof *header; header->requestId = requestId; header->op = op; header->status = HgfsConvertFromInternalStatus(status); - header->flags = 0; + header->flags = hdrFlags; header->information = status; header->sessionId = sessionId; } @@ -5730,11 +5731,12 @@ HgfsPackOplockBreakRequest(void *packet, // IN/OUT: Hgfs Pack goto exit; } - HgfsPackReplyHeaderV4(0, + HgfsPackReplyHeaderV4(HGFS_ERROR_SUCCESS, opBreakRequestSize, HGFS_OP_OPLOCK_BREAK_V4, sessionId, 0, + HGFS_PACKET_FLAG_REQUEST, header); exit: @@ -6038,7 +6040,7 @@ HgfsPackChangeNotificationRequest(void *packet, // IN/OUT: Hg char const *shareName, // IN: share name char *fileName, // IN: relative name uint32 mask, // IN: event mask - uint32 flags, // IN: notify flags + uint32 notifyFlags, // IN: notify flags HgfsSessionInfo *session, // IN: session size_t *bufferSize) // INOUT: size of packet { @@ -6050,7 +6052,7 @@ HgfsPackChangeNotificationRequest(void *packet, // IN/OUT: Hg ASSERT(packet); ASSERT(shareName); ASSERT(NULL != fileName || - (flags & HGFS_NOTIFY_FLAG_OVERFLOW) == HGFS_NOTIFY_FLAG_OVERFLOW); + (notifyFlags & HGFS_NOTIFY_FLAG_OVERFLOW) == HGFS_NOTIFY_FLAG_OVERFLOW); ASSERT(session); ASSERT(bufferSize); @@ -6066,14 +6068,20 @@ HgfsPackChangeNotificationRequest(void *packet, // IN/OUT: Hg */ notifyRequest = (HgfsRequestNotifyV4 *)((char *)header + sizeof *header); notifyRequestSize = HgfsPackChangeNotifyRequestV4(subscriber, - flags, + notifyFlags, mask, shareName, fileName, *bufferSize - sizeof *header, notifyRequest); if (0 != notifyRequestSize) { - HgfsPackReplyHeaderV4(0, notifyRequestSize, HGFS_OP_NOTIFY_V4, session->sessionId, 0, header); + HgfsPackReplyHeaderV4(HGFS_ERROR_SUCCESS, + notifyRequestSize, + HGFS_OP_NOTIFY_V4, + session->sessionId, + 0, + HGFS_PACKET_FLAG_REQUEST, + header); result = TRUE; } else { result = FALSE; diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerParameters.h b/open-vm-tools/lib/hgfsServer/hgfsServerParameters.h index 066b8cc52..ee2757ee4 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServerParameters.h +++ b/open-vm-tools/lib/hgfsServer/hgfsServerParameters.h @@ -334,7 +334,7 @@ HgfsPackChangeNotificationRequest(void *packet, // IN/OUT: Hg char const *shareName, // IN: share name char *fileName, // IN: file name uint32 mask, // IN: event mask - uint32 flags, // IN: notify flags + uint32 notifyFlags, // IN: notify flags HgfsSessionInfo *session, // IN: session size_t *bufferSize); // IN/OUT: packet size diff --git a/open-vm-tools/lib/include/hgfsProto.h b/open-vm-tools/lib/include/hgfsProto.h index 27e30d78e..01c79f816 100644 --- a/open-vm-tools/lib/include/hgfsProto.h +++ b/open-vm-tools/lib/include/hgfsProto.h @@ -1654,13 +1654,17 @@ struct HgfsReplySymlinkCreateV3 { HgfsReplySymlinkCreateV3; /* HGFS protocol version 4 definitions. */ +#define HGFS_HEADER_VERSION_1 1 +#define HGFS_HEADER_VERSION HGFS_HEADER_VERSION_1 /* - * HGFS_PACKET_FLAG_NOTIFICATION set in flags field means that - * this is a notification or a callback request (not a reply to client request). + * Flags to indicate the type of packet following the header and + * the overall state of the operation. */ -#define HGFS_PACKET_FLAG_NOTIFICATION (1 << 0) +#define HGFS_PACKET_FLAG_REQUEST (1 << 0) // Request packet +#define HGFS_PACKET_FLAG_REPLY (1 << 1) // Reply packet +#define HGFS_PACKET_FLAG_INFO_EXTERROR (1 << 2) // Info has ext error typedef #include "vmware_pack_begin.h" @@ -1674,7 +1678,7 @@ struct HgfsHeader { uint32 requestId; /* Request ID. */ uint32 op; /* Operation. */ uint32 status; /* Return value. */ - uint32 flags; /* Flags. */ + uint32 flags; /* Flags. See above. */ uint32 information; /* Generic field, used e.g. for native error code. */ uint64 sessionId; /* Session ID. */ uint64 reserved; /* Reserved for future use. */