From: VMware, Inc <> Date: Fri, 12 Apr 2013 19:38:38 +0000 (-0700) Subject: HGFS: Server oplock code cleanup part I X-Git-Tag: 2013.04.16-1098359~92 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=219e11dc5bdf156870f277f110eab4eb8d4c26d4;p=thirdparty%2Fopen-vm-tools.git HGFS: Server oplock code cleanup part I 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 --- diff --git a/open-vm-tools/lib/hgfsServer/hgfsServer.c b/open-vm-tools/lib/hgfsServer/hgfsServer.c index 2b76447e2..d0e1cfeb7 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServer.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServer.c @@ -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" diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerInt.h b/open-vm-tools/lib/hgfsServer/hgfsServerInt.h index e7a66159a..8608c7e9d 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServerInt.h +++ b/open-vm-tools/lib/hgfsServer/hgfsServerInt.h @@ -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 diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c b/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c index 1188ed0a2..d17257c35 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c @@ -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" diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerOplock.c b/open-vm-tools/lib/hgfsServer/hgfsServerOplock.c index 9fcfea91f..708b99fe9 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServerOplock.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServerOplock.c @@ -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 index 000000000..23b506453 --- /dev/null +++ b/open-vm-tools/lib/hgfsServer/hgfsServerOplock.h @@ -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 index 000000000..1c2f146a7 --- /dev/null +++ b/open-vm-tools/lib/hgfsServer/hgfsServerOplockInt.h @@ -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_ diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerOplockLinux.c b/open-vm-tools/lib/hgfsServer/hgfsServerOplockLinux.c index 23da0a664..010b69f21 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServerOplockLinux.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServerOplockLinux.c @@ -30,6 +30,7 @@ #include "vmware.h" #include "hgfsServerInt.h" +#include "hgfsServerOplockInt.h" #ifdef HGFS_OPLOCKS # include