]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
HGFS: Server oplock code cleanup part I
authorVMware, Inc <>
Fri, 12 Apr 2013 19:38:38 +0000 (12:38 -0700)
committerDmitry Torokhov <dtor@vmware.com>
Wed, 17 Apr 2013 19:16:41 +0000 (12:16 -0700)
Move the oplock code into its own header files and out from the general
dumping ground of usual headers.
Split the public and private oplock functions into public oplock API header
and a private API header file.
Move the private oplock defines and data structures into the private header
file.

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/hgfsServerLinux.c
open-vm-tools/lib/hgfsServer/hgfsServerOplock.c
open-vm-tools/lib/hgfsServer/hgfsServerOplock.h [new file with mode: 0644]
open-vm-tools/lib/hgfsServer/hgfsServerOplockInt.h [new file with mode: 0644]
open-vm-tools/lib/hgfsServer/hgfsServerOplockLinux.c

index 2b76447e24d86e08efede408db494a3521466391..d0e1cfeb7434b804aec669a6a32c42ffce0faedc 100644 (file)
@@ -44,6 +44,7 @@
 #include "util.h"
 #include "wiper.h"
 #include "hgfsServer.h"
+#include "hgfsServerOplock.h"
 #include "hgfsDirNotify.h"
 #include "hgfsTransport.h"
 #include "userlock.h"
index e7a66159aa6cabe7ba5d95a53149f34555614a69..8608c7e9d34129bdb3918cb017d0fc87fc0a1fcc 100644 (file)
@@ -42,15 +42,6 @@ struct DirectoryEntry;
 
 #define HGFS_DEBUG_ASYNC   (0)
 
-/*
- * Does this platform have oplock support? We define it here to avoid long
- * ifdefs all over the code. For now, Linux and Windows hosts only.
- *
- * XXX: Just kidding, no oplock support yet.
- */
-#if 0
-#define HGFS_OPLOCKS
-#endif
 
 /* Identifier for a local file */
 typedef struct HgfsLocalId {
@@ -485,13 +476,6 @@ typedef struct HgfsCreateSessionInfo {
 } HgfsCreateSessionInfo;
 
 
-/* Server lock related structure */
-typedef struct {
-   fileDesc fileDesc;
-   int32 event;
-   HgfsLockType serverLock;
-} ServerLockData;
-
 typedef struct HgfsInputParam {
    const char *metaPacket;
    size_t metaPacketSize;
@@ -977,10 +961,6 @@ HgfsHandle2LocalId(HgfsHandle handle,        // IN: Hgfs file handle
                    HgfsSessionInfo *session, // IN: session info
                    HgfsLocalId *localId);    // OUT: Local id info
 
-Bool
-HgfsHandle2ServerLock(HgfsHandle handle,        // IN: Hgfs file handle
-                      HgfsSessionInfo *session, // IN: session info
-                      HgfsLockType *lock);      // OUT: Server lock
 
 Bool
 HgfsUpdateNodeFileDesc(HgfsHandle handle,        // IN: Hgfs file handle
@@ -999,11 +979,6 @@ HgfsUpdateNodeAppendFlag(HgfsHandle handle,        // IN: Hgfs file handle
                          Bool appendFlag);         // OUT: Append flag
 
 Bool
-HgfsFileHasServerLock(const char *utf8Name,             // IN: Name in UTF8
-                      HgfsSessionInfo *session,         // IN: Session info
-                      HgfsLockType *serverLock,         // OUT: Existing oplock
-                      fileDesc   *fileDesc);            // OUT: Existing fd
-Bool
 HgfsGetNodeCopy(HgfsHandle handle,        // IN: Hgfs file handle
                 HgfsSessionInfo *session, // IN: session info
                 Bool copyName,            // IN: Should we copy the name?
@@ -1028,26 +1003,11 @@ Bool
 HgfsServerGetOpenMode(HgfsFileOpenInfo *openInfo, // IN:  Open info to examine
                       uint32 *modeOut);           // OUT: Local mode
 
-Bool
-HgfsAcquireServerLock(fileDesc fileDesc,            // IN: OS handle
-                      HgfsSessionInfo *session,     // IN: Session info
-                      HgfsLockType *serverLock);    // IN/OUT: Oplock asked for/granted
 
 char*
 HgfsServerGetTargetRelativePath(const char* source,    // IN: source file name
                                 const char* target);   // IN: target file name
 
-/* All oplock-specific functionality is defined here. */
-#ifdef HGFS_OPLOCKS
-void
-HgfsServerOplockBreak(ServerLockData *data); // IN: server lock info
-
-void
-HgfsAckOplockBreak(ServerLockData *lockData,  // IN: server lock info
-                   HgfsLockType replyLock);   // IN: client has this lock
-
-#endif
-
 /* Transport related functions. */
 Bool
 HgfsPackAndSendPacket(HgfsPacket *packet,           // IN/OUT: Hgfs Packet
index 1188ed0a2b02cf943e6f367518507d43827e01a7..d17257c35da3c23741c18ba01a50801cecc276e6 100644 (file)
@@ -54,6 +54,7 @@
 #include "vmware.h"
 #include "hgfsServerPolicy.h" // for security policy
 #include "hgfsServerInt.h"
+#include "hgfsServerOplock.h"
 #include "hgfsEscape.h"
 #include "str.h"
 #include "cpNameLite.h"
index 9fcfea91fb98a56418083392c156ffaa9c6da7b1..708b99fe9bb8617e46b8db3e74b5f6504be31cb7 100644 (file)
@@ -35,6 +35,7 @@
 #include "cpName.h"
 #include "cpNameLite.h"
 #include "hgfsServerInt.h"
+#include "hgfsServerOplockInt.h"
 
 
 
@@ -72,7 +73,7 @@
 Bool
 HgfsServerOplockInit(void)
 {
-   Bool result = TRUE;
+   Bool result = FALSE;
 #ifdef HGFS_OPLOCKS
    result = HgfsPlatformOplockInit();
 #endif
diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerOplock.h b/open-vm-tools/lib/hgfsServer/hgfsServerOplock.h
new file mode 100644 (file)
index 0000000..23b5064
--- /dev/null
@@ -0,0 +1,64 @@
+/*********************************************************
+ * Copyright (C) 2013 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
+ *
+ *********************************************************/
+
+/*
+ * hgfsServerOplock.h --
+ *
+ *     Header file for public common data types used in the HGFS
+ *     opportunistic lock routines.
+ */
+
+#ifndef _HGFS_SERVER_OPLOCK_H_
+#define _HGFS_SERVER_OPLOCK_H_
+
+#include "hgfsProto.h"     // for protocol types
+#include "hgfsServerInt.h" // for common server types e.g. HgfsSessionInfo
+
+
+/*
+ * Data structures
+ */
+
+
+
+/*
+ * Global variables
+ */
+
+
+
+/*
+ * Global functions
+ */
+
+Bool HgfsServerOplockInit(void);
+void HgfsServerOplockDestroy(void);
+Bool HgfsHandle2ServerLock(HgfsHandle handle,
+                           HgfsSessionInfo *session,
+                           HgfsLockType *lock);
+Bool HgfsFileHasServerLock(const char *utf8Name,
+                           HgfsSessionInfo *session,
+                           HgfsLockType *serverLock,
+                           fileDesc   *fileDesc);
+
+Bool HgfsAcquireServerLock(fileDesc fileDesc,
+                           HgfsSessionInfo *session,
+                           HgfsLockType *serverLock);
+
+
+#endif // ifndef _HGFS_SERVER_OPLOCK_H_
diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerOplockInt.h b/open-vm-tools/lib/hgfsServer/hgfsServerOplockInt.h
new file mode 100644 (file)
index 0000000..1c2f146
--- /dev/null
@@ -0,0 +1,74 @@
+/*********************************************************
+ * Copyright (C) 2013 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
+ *
+ *********************************************************/
+
+/*
+ * hgfsServerOplock.h --
+ *
+ *     Header file for private common data types used in the HGFS
+ *     opportunistic lock routines.
+ */
+
+#ifndef _HGFS_SERVER_OPLOCKINT_H_
+#define _HGFS_SERVER_OPLOCKINT_H_
+
+#include "hgfsProto.h"     // for protocol types
+#include "hgfsServerInt.h" // for common server types e.g. HgfsSessionInfo
+
+/*
+ * Does this platform have oplock support? We define it here to avoid long
+ * ifdefs all over the code. For now, Linux and Windows hosts only.
+ *
+ * XXX: Just kidding, no oplock support yet.
+ */
+#if 0
+#define HGFS_OPLOCKS
+#endif
+
+/*
+ * XXX describe the data structure
+ */
+
+/* Server lock related structure */
+typedef struct {
+   fileDesc fileDesc;
+   int32 event;
+   HgfsLockType serverLock;
+} ServerLockData;
+
+
+/*
+ * Global variables
+ */
+
+
+
+/*
+ * Global functions
+ */
+
+#ifdef HGFS_OPLOCKS
+void
+HgfsServerOplockBreak(ServerLockData *data);
+
+void
+HgfsAckOplockBreak(ServerLockData *lockData,
+                   HgfsLockType replyLock);
+
+#endif
+
+#endif // ifndef _HGFS_SERVER_OPLOCKINT_H_
index 23da0a6649fa38c0506f5bf9a1778f0e645a8038..010b69f217fd0439bfbdbce880e522e6fcb61f55 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "vmware.h"
 #include "hgfsServerInt.h"
+#include "hgfsServerOplockInt.h"
 
 #ifdef HGFS_OPLOCKS
 #   include <signal.h>