From: VMware, Inc <> Date: Fri, 12 Apr 2013 19:47:38 +0000 (-0700) Subject: HGFS: add new flags to Hgfs create session request X-Git-Tag: 2013.04.16-1098359~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48feaf7111bb2b9578b4e9726ed4004f957f8897;p=thirdparty%2Fopen-vm-tools.git HGFS: add new flags to Hgfs create session request 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 --- diff --git a/open-vm-tools/lib/hgfsServer/hgfsServer.c b/open-vm-tools/lib/hgfsServer/hgfsServer.c index 23e053685..532173b72 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServer.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServer.c @@ -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; diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerInt.h b/open-vm-tools/lib/hgfsServer/hgfsServerInt.h index 9cf6e9698..ca6ee9025 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServerInt.h +++ b/open-vm-tools/lib/hgfsServer/hgfsServerInt.h @@ -473,6 +473,7 @@ typedef struct HgfsCreateDirInfo { typedef struct HgfsCreateSessionInfo { uint32 maxPacketSize; + HgfsSessionFlags flags; /* Session capability flags. */ } HgfsCreateSessionInfo; diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerParameters.c b/open-vm-tools/lib/hgfsServer/hgfsServerParameters.c index 1231a3923..e8dc597a5 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServerParameters.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServerParameters.c @@ -5249,6 +5249,7 @@ HgfsUnpackCreateSessionPayloadV4(const HgfsRequestCreateSessionV4 *requestV4, // } info->maxPacketSize = requestV4->maxPacketSize; + info->flags = requestV4->flags; return TRUE; } diff --git a/open-vm-tools/lib/include/hgfsProto.h b/open-vm-tools/lib/include/hgfsProto.h index 01c79f816..b30b54890 100644 --- a/open-vm-tools/lib/include/hgfsProto.h +++ b/open-vm-tools/lib/include/hgfsProto.h @@ -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"