~n-muench/ubuntu/oneiric/open-vm-tools/open-vm-tools.fix-836277

« back to all changes in this revision

Viewing changes to modules/freebsd/vmhgfs/hgfsBd.c

  • Committer: Bazaar Package Importer
  • Author(s): Devid Antonio Filoni
  • Date: 2008-08-15 21:21:40 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080815212140-05fhxj8wroosysmj
Tags: 2008.08.08-109361-1ubuntu1
* Merge from Debian unstable (LP: #258393), remaining Ubuntu change:
  - add ubuntu_toolchain_FTBFS.dpatch patch, fix FTBFS
* Update ubuntu_toolchain_FTBFS.dpatch patch for the new version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
/*
43
43
 *-----------------------------------------------------------------------------
44
44
 *
45
 
 * HgfsBd_GetBuf --
 
45
 * HgfsBdGetBufInt --
46
46
 *
47
 
 *    Get a buffer to send hgfs requests in.
 
47
 *    Allocates a buffer to send a hgfs request in. This can be either a
 
48
 *    HGFS_PACKET_MAX or HGFS_LARGE_PACKET_MAX size buffer depending on the
 
49
 *    external funciton called.
48
50
 *
49
51
 * Results:
50
52
 *    Pointer to a buffer that has the correct backdoor command prefix for 
52
54
 *    NULL on failure (not enough memory).
53
55
 *
54
56
 * Side effects:
55
 
 *    None
 
57
 *    None.
56
58
 *
57
59
 *-----------------------------------------------------------------------------
58
60
 */
59
61
 
60
 
char *
61
 
HgfsBd_GetBuf(void)
 
62
static char *
 
63
HgfsBdGetBufInt(size_t bufSize)
62
64
{
63
65
   /* 
64
66
    * Allocate a buffer that is large enough for an HGFS packet and the 
65
67
    * synchronous HGFS command, write the command, and return a pointer that 
66
68
    * points into the buffer, after the command.
67
69
    */
68
 
   size_t len = HGFS_PACKET_MAX + HGFS_SYNC_REQREP_CLIENT_CMD_LEN;
 
70
   size_t len = bufSize + HGFS_SYNC_REQREP_CLIENT_CMD_LEN;
69
71
   char *buf = (char*) calloc(sizeof(char), len);
70
72
 
71
73
   if (!buf) {
82
84
/*
83
85
 *-----------------------------------------------------------------------------
84
86
 *
 
87
 * HgfsBd_GetBuf --
 
88
 *
 
89
 *    Get a buffer of size HGFS_PACKET_MAX to send hgfs requests in.
 
90
 *
 
91
 * Results:
 
92
 *    See HgfsBdGetBufInt.
 
93
 *
 
94
 * Side effects:
 
95
 *    Allocates memory that must be freed with a call to HgfsBd_PutBuf.
 
96
 *
 
97
 *-----------------------------------------------------------------------------
 
98
 */
 
99
 
 
100
char *
 
101
HgfsBd_GetBuf(void)
 
102
{
 
103
   return HgfsBdGetBufInt(HGFS_PACKET_MAX);
 
104
}
 
105
 
 
106
/*
 
107
 *-----------------------------------------------------------------------------
 
108
 *
 
109
 * HgfsBd_GetLargeBuf --
 
110
 *
 
111
 *    Get a buffer of size HGFS_LARGE_PACKET_MAX to send hgfs requests in.
 
112
 *
 
113
 * Results:
 
114
 *    See HgfsBdGetBufInt.
 
115
 *
 
116
 * Side effects:
 
117
 *    Allocates memory that must be freed with a call to HgfsBd_PutBuf.
 
118
 *
 
119
 *-----------------------------------------------------------------------------
 
120
 */
 
121
 
 
122
char *
 
123
HgfsBd_GetLargeBuf(void)
 
124
{
 
125
   return HgfsBdGetBufInt(HGFS_LARGE_PACKET_MAX);
 
126
}
 
127
 
 
128
 
 
129
/*
 
130
 *-----------------------------------------------------------------------------
 
131
 *
85
132
 * HgfsBd_PutBuf --
86
133
 *
87
134
 *    Release a buffer obtained with HgfsBd_GetBuf.
215
262
      return -1;
216
263
   }
217
264
 
218
 
   ASSERT(replyLen <= HGFS_PACKET_MAX);
 
265
   ASSERT(replyLen <= HGFS_LARGE_PACKET_MAX);
219
266
   *packetOut = reply;
220
267
   *packetSize = replyLen;
221
268