From: Oliver Kurth Date: Fri, 15 Sep 2017 18:23:32 +0000 (-0700) Subject: Tools Hgfs Transport: Make the server callback table constant X-Git-Tag: stable-10.2.0~281 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d77b6c7ba1dc5a38e38c35c321eabe7ccbc801c1;p=thirdparty%2Fopen-vm-tools.git Tools Hgfs Transport: Make the server callback table constant Simple change to make the Hgfs tools transport use the server table of callbacks as a constant. --- diff --git a/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuest.c b/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuest.c index baf2c0ae8..6b960eee0 100644 --- a/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuest.c +++ b/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuest.c @@ -68,7 +68,7 @@ * also removed and the HGFS server exit is called and this object is torn down. */ typedef struct HgfsChannelServerData { - HgfsServerCallbacks *serverCBTable; /* HGFS server entry points. */ + const HgfsServerCallbacks *serverCBTable; /* HGFS server entry points. */ Atomic_uint32 refCount; /* Server data reference count. */ } HgfsChannelServerData; @@ -80,12 +80,12 @@ typedef struct HgfsChannelServerData { * for each client that it is returned to (a usage count). */ typedef struct HgfsChannelData { - const char *name; /* Channel name. */ - HgfsGuestChannelCBTable *ops; /* Channel operations. */ - uint32 state; /* Channel state (see flags below). */ - struct HgfsGuestConn *connection; /* Opaque server connection */ - HgfsChannelServerData *serverInfo; /* HGFS server entry points. */ - Atomic_uint32 refCount; /* Channel reference count. */ + const char *name; /* Channel name. */ + const HgfsGuestChannelCBTable *ops; /* Channel operations. */ + uint32 state; /* Channel state (see flags below). */ + struct HgfsGuestConn *connection; /* Opaque server connection */ + HgfsChannelServerData *serverInfo; /* HGFS server entry points. */ + Atomic_uint32 refCount; /* Channel reference count. */ } HgfsChannelData; #define HGFS_CHANNEL_STATE_INIT (1 << 0) @@ -197,7 +197,9 @@ HgfsChannelInitServer(HgfsServerMgrCallbacks *mgrCb, // IN: server manager Debug("%s: Initialize Hgfs server.\n", __FUNCTION__); /* If we have a new connection initialize the server session with default settings. */ - result = HgfsServer_InitState(&serverInfo->serverCBTable, &gHgfsGuestCfgSettings, mgrCb); + result = HgfsServer_InitState((HgfsServerCallbacks **)&serverInfo->serverCBTable, + &gHgfsGuestCfgSettings, + mgrCb); if (!result) { Debug("%s: Could not init Hgfs server.\n", __FUNCTION__); } diff --git a/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuestBd.c b/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuestBd.c index a9399f51c..844635d24 100644 --- a/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuestBd.c +++ b/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuestBd.c @@ -43,7 +43,7 @@ typedef enum { typedef struct HgfsGuestConn { Atomic_uint32 refCount; /* Reference count. */ HgfsGuestConnState state; - HgfsServerSessionCallbacks *serverCbTable; /* Server session callbacks. */ + const HgfsServerSessionCallbacks *serverCbTable; /* Server session callbacks. */ HgfsServerChannelCallbacks channelCbTable; void *serverSession; size_t packetOutLen; @@ -53,7 +53,7 @@ typedef struct HgfsGuestConn { /* Callback functions. */ -static Bool HgfsChannelGuestBdInit(HgfsServerSessionCallbacks *serverCBTable, +static Bool HgfsChannelGuestBdInit(const HgfsServerSessionCallbacks *serverCBTable, void *rpc, void *rpcCallback, HgfsGuestConn **connection); @@ -68,7 +68,7 @@ static Bool HgfsChannelGuestBdReceive(HgfsGuestConn *data, size_t *packetOutSize); static uint32 HgfsChannelGuestBdInvalidateInactiveSessions(HgfsGuestConn *data); -HgfsGuestChannelCBTable gGuestBackdoorOps = { +const HgfsGuestChannelCBTable gGuestBackdoorOps = { HgfsChannelGuestBdInit, HgfsChannelGuestBdExit, HgfsChannelGuestBdReceive, @@ -163,8 +163,8 @@ HgfsChannelGuestConnPut(HgfsGuestConn *connData) // IN: connection */ static Bool -HgfsChannelGuestConnInit(HgfsGuestConn **connData, // IN/OUT: channel object - HgfsServerSessionCallbacks *serverCBTable) // IN: server callbacks +HgfsChannelGuestConnInit(HgfsGuestConn **connData, // IN/OUT: channel object + const HgfsServerSessionCallbacks *serverCBTable) // IN: server callbacks { HgfsGuestConn *conn = NULL; @@ -676,10 +676,10 @@ HgfsChannelGuestBdSend(void *conn, // IN: our connection data */ static Bool -HgfsChannelGuestBdInit(HgfsServerSessionCallbacks *serverCBTable, // IN: server callbacks - void *rpc, // IN: Rpc channel unused - void *rpcCallback, // IN: Rpc callback unused - HgfsGuestConn **connection) // OUT: connection object +HgfsChannelGuestBdInit(const HgfsServerSessionCallbacks *serverCBTable, // IN: server callbacks + void *rpc, // IN: Rpc channel unused + void *rpcCallback, // IN: Rpc callback unused + HgfsGuestConn **connection) // OUT: connection object { HgfsGuestConn *connData = NULL; Bool result; diff --git a/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuestInt.h b/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuestInt.h index 6bf9a8a43..ac1770c19 100644 --- a/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuestInt.h +++ b/open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuestInt.h @@ -48,14 +48,14 @@ * Guest channel table of callbacks. */ typedef struct HgfsGuestChannelCBTable { - Bool (*init)(HgfsServerSessionCallbacks *, void *, void *, struct HgfsGuestConn **); + Bool (*init)(const HgfsServerSessionCallbacks *, void *, void *, struct HgfsGuestConn **); void (*exit)(struct HgfsGuestConn *); Bool (*receive)(struct HgfsGuestConn *, char const *, size_t, char *, size_t *); uint32 (*invalidateInactiveSessions)(struct HgfsGuestConn *); } HgfsGuestChannelCBTable; /* The guest channels callback tables. */ -extern HgfsGuestChannelCBTable gGuestBackdoorOps; +extern const HgfsGuestChannelCBTable gGuestBackdoorOps; /* For use by HgfsServerManager. */ Bool HgfsChannelGuest_Init(HgfsServerMgrData *data, HgfsServerMgrCallbacks *cb);