]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
HGFS: add new flags to Hgfs create session request
authorVMware, Inc <>
Fri, 12 Apr 2013 19:47:38 +0000 (12:47 -0700)
committerDmitry Torokhov <dtor@vmware.com>
Wed, 17 Apr 2013 19:16:53 +0000 (12:16 -0700)
The Hgfs create session request assumes currently that the only flags
required are on a per request type basis. This is simply not true. There
are some features that trancend many operations and will require a
general per session flag to denote support.

Two examples that immediately come to mind: oplocks and short name
support.

For oplocks the server is going to need to know ahead of any requests
that the client is going to be using this feature if supported by the
server. Furthermore, oplocks affect the whole operation of requests as
far as the server is concerned.  The server should handle requests
asynchronously if oplocks are in play to prevent deadlock. Also, oplocks
are taken out a file open time but can be broken by many other requests
not just concurrent opens.

Also for short name support for the host, these can occur not just with
directory listings and enumeration but for the client opens too.
Currently, the client must know if the server does support short names
so that it does not try and look up the short name itself.

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/include/hgfsProto.h

index 23e053685022b55bd6f8529388482ff0d4f75ab2..532173b72e06a851295533ed6d0d4cbc90cf4a71 100644 (file)
@@ -3722,6 +3722,11 @@ HgfsServer_InitState(HgfsServerSessionCallbacks **callbackTable,  // IN/OUT: our
          Log("%s: initialized notification %s.\n", __FUNCTION__,
              (gHgfsDirNotifyActive ? "active" : "inactive"));
       }
+      if (0 != (gHgfsCfgSettings.flags & HGFS_CONFIG_OPLOCK_ENABLED)) {
+         if (!HgfsServerOplockInit()) {
+            gHgfsCfgSettings.flags &= ~HGFS_CONFIG_OPLOCK_ENABLED;
+         }
+      }
       gHgfsInitialized = TRUE;
    } else {
       HgfsServer_ExitState(); // Cleanup partially initialized state
@@ -3756,6 +3761,9 @@ HgfsServer_ExitState(void)
 {
    gHgfsInitialized = FALSE;
 
+   if (0 != (gHgfsCfgSettings.flags & HGFS_CONFIG_OPLOCK_ENABLED)) {
+      HgfsServerOplockDestroy();
+   }
    if (gHgfsDirNotifyActive) {
       HgfsNotify_Exit();
       gHgfsDirNotifyActive = FALSE;
@@ -8062,6 +8070,17 @@ HgfsServerCreateSession(HgfsInputParam *input)  // IN: Input params
       if (info.maxPacketSize < session->maxPacketSize) {
          session->maxPacketSize = info.maxPacketSize;
       }
+
+      /*
+       * If the server is enabled for processing oplocks and the client
+       * is requesting to use them, then report back to the client oplocks
+       * are enabled by propagating the session flag.
+       */
+      if ((0 != (info.flags & HGFS_SESSION_OPLOCK_ENABLED)) &&
+          (0 != (gHgfsCfgSettings.flags & HGFS_CONFIG_OPLOCK_ENABLED))) {
+         session->flags |= HGFS_SESSION_OPLOCK_ENABLED;
+      }
+
       if (HgfsPackCreateSessionReply(input->packet, input->metaPacket,
                                      &replyPayloadSize, session)) {
          status = HGFS_ERROR_SUCCESS;
index 9cf6e9698cb8aeeac85d25cd6bf7bbf7f0fd364f..ca6ee902557b804a87e8aff59887172c2c4a2fc3 100644 (file)
@@ -473,6 +473,7 @@ typedef struct HgfsCreateDirInfo {
 
 typedef struct HgfsCreateSessionInfo {
    uint32 maxPacketSize;
+   HgfsSessionFlags flags;       /* Session capability flags. */
 } HgfsCreateSessionInfo;
 
 
index 1231a3923f2b90166dc7ceee0644184e05f7c801..e8dc597a5f5ba18c6503976796b5c7faf2a771ce 100644 (file)
@@ -5249,6 +5249,7 @@ HgfsUnpackCreateSessionPayloadV4(const HgfsRequestCreateSessionV4 *requestV4, //
    }
 
    info->maxPacketSize = requestV4->maxPacketSize;
+   info->flags = requestV4->flags;
    return TRUE;
 }
 
index 01c79f816ec3a1ad999281d3b1abe59df21e8565..b30b54890068a42d027e776b8a00c5ad40b86de6 100644 (file)
@@ -1786,17 +1786,6 @@ struct HgfsIdentity {
 #include "vmware_pack_end.h"
 HgfsIdentity;
 
-typedef
-#include "vmware_pack_begin.h"
-struct HgfsRequestCreateSessionV4 {
-   uint32 numCapabilities;            /* Number of capabilities to follow. */
-   uint32 maxPacketSize;              /* Maximum packet size supported. */
-   uint64 reserved;                   /* Reserved for future use. */
-   HgfsCapability capabilities[1];    /* Array of HgfsCapabilities. */
-}
-#include "vmware_pack_end.h"
-HgfsRequestCreateSessionV4;
-
 #define HGFS_INVALID_SESSION_ID     (~((uint64)0))
 
 /*
@@ -1809,6 +1798,19 @@ typedef uint32 HgfsSessionFlags;
 
 #define HGFS_SESSION_MAXPACKETSIZE_VALID    (1 << 0)
 #define HGFS_SESSION_CHANGENOTIFY_ENABLED   (1 << 1)
+#define HGFS_SESSION_OPLOCK_ENABLED         (1 << 2)
+
+typedef
+#include "vmware_pack_begin.h"
+struct HgfsRequestCreateSessionV4 {
+   uint32 numCapabilities;            /* Number of capabilities to follow. */
+   uint32 maxPacketSize;              /* Maximum packet size supported. */
+   HgfsSessionFlags flags;            /* Session capability flags. */
+   uint32 reserved;                   /* Reserved for future use. */
+   HgfsCapability capabilities[1];    /* Array of HgfsCapabilities. */
+}
+#include "vmware_pack_end.h"
+HgfsRequestCreateSessionV4;
 
 typedef
 #include "vmware_pack_begin.h"