]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
HGFS: fix up the Hgfs header flags and information fields
authorVMware, Inc <>
Fri, 12 Apr 2013 19:44:18 +0000 (12:44 -0700)
committerDmitry Torokhov <dtor@vmware.com>
Wed, 17 Apr 2013 19:16:52 +0000 (12:16 -0700)
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 <dtor@vmware.com>
open-vm-tools/lib/hgfsServer/hgfsServer.c
open-vm-tools/lib/hgfsServer/hgfsServerInt.h
open-vm-tools/lib/hgfsServer/hgfsServerParameters.c
open-vm-tools/lib/hgfsServer/hgfsServerParameters.h
open-vm-tools/lib/include/hgfsProto.h

index 46fb4a8c17e4ed69c685a36b71e3c59868ac48bb..8e149d171aefc87f742aedc34a50f4ff4e5e0a63 100644 (file)
@@ -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;
    }
index cb57e4f5050e0847f5d70f457461cf001abdd1b8..03dc24c22381eb559b444b04baf1a1e1457dcd52 100644 (file)
@@ -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
index 9d679821a4374fad965e0c047a741cb19f0a87d0..293f25136653e6fe6cc9886a376f58380ffe6d79 100644 (file)
@@ -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;
index 066b8cc52fe7f37b941871cc8ba6f039f004631e..ee2757ee456074efac6be5f538e249372912ae44 100644 (file)
@@ -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
 
index 27e30d78ed1aff6662f2e319ac31c5df383de56c..01c79f816ec3a1ad999281d3b1abe59df21e8565 100644 (file)
@@ -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. */