]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Tools Hgfs Transport: Make the server callback table constant
authorOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:32 +0000 (11:23 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:32 +0000 (11:23 -0700)
Simple change to make the Hgfs tools transport use the server
table of callbacks as a constant.

open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuest.c
open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuestBd.c
open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuestInt.h

index baf2c0ae825466d7d0efc1ac1e692d3c1f19f957..6b960eee0799c4b971faff4ae70e44eb24776e7e 100644 (file)
@@ -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__);
    }
index a9399f51cc160bf68256c2e0e22a318ee18a9efb..844635d247044296195f557b7f4f2bccec3acf18 100644 (file)
@@ -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;
index 6bf9a8a4363c194378c229ee4c93747db3a8fb95..ac1770c19784ab552bcc155eb9b8f34dcc90998e 100644 (file)
  * 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);