1 | /* $Revision: 33439 $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxGuestR0LibSharedFolders - Ring 0 Shared Folders calls.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2010 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 | /* Entire file is ifdef'ed with !VBGL_VBOXGUEST */
|
---|
28 | #ifndef VBGL_VBOXGUEST
|
---|
29 |
|
---|
30 | #ifdef RT_OS_LINUX
|
---|
31 | # include "VBoxGuestR0LibSharedFolders.h"
|
---|
32 | # define DbgPrint RTAssertMsg2Weak
|
---|
33 | #else
|
---|
34 | # include "VBoxGuestR0LibSharedFolders.h"
|
---|
35 | #endif
|
---|
36 | #include <iprt/time.h>
|
---|
37 | #include <iprt/mem.h>
|
---|
38 | #include <iprt/path.h>
|
---|
39 | #include <iprt/string.h>
|
---|
40 |
|
---|
41 | #define SHFL_CPARMS_SET_UTF8 0
|
---|
42 | #define SHFL_CPARMS_SET_SYMLINKS 0
|
---|
43 |
|
---|
44 | #define VBOX_INIT_CALL(a, b, c) \
|
---|
45 | (a)->result = VINF_SUCCESS; \
|
---|
46 | (a)->u32ClientID = (c)->ulClientID; \
|
---|
47 | (a)->u32Function = SHFL_FN_##b; \
|
---|
48 | (a)->cParms = SHFL_CPARMS_##b
|
---|
49 |
|
---|
50 | #ifndef RT_OS_WINDOWS
|
---|
51 | # define RtlZeroMemory(a, b) memset (a, 0, b)
|
---|
52 | #endif
|
---|
53 |
|
---|
54 |
|
---|
55 | DECLVBGL(int) vboxInit (void)
|
---|
56 | {
|
---|
57 | int rc = VINF_SUCCESS;
|
---|
58 |
|
---|
59 | rc = VbglInit ();
|
---|
60 | return rc;
|
---|
61 | }
|
---|
62 |
|
---|
63 | DECLVBGL(void) vboxUninit (void)
|
---|
64 | {
|
---|
65 | VbglTerminate ();
|
---|
66 | }
|
---|
67 |
|
---|
68 | DECLVBGL(int) vboxConnect (PVBSFCLIENT pClient)
|
---|
69 | {
|
---|
70 | int rc = VINF_SUCCESS;
|
---|
71 |
|
---|
72 | VBoxGuestHGCMConnectInfo data;
|
---|
73 |
|
---|
74 | RtlZeroMemory (&data, sizeof (VBoxGuestHGCMConnectInfo));
|
---|
75 |
|
---|
76 | pClient->handle = NULL;
|
---|
77 |
|
---|
78 | data.result = VINF_SUCCESS;
|
---|
79 | data.Loc.type = VMMDevHGCMLoc_LocalHost_Existing;
|
---|
80 | strcpy (data.Loc.u.host.achName, "VBoxSharedFolders");
|
---|
81 |
|
---|
82 | rc = VbglHGCMConnect (&pClient->handle, &data);
|
---|
83 |
|
---|
84 | /* Log(("VBOXSF: VBoxSF::vboxConnect: VbglHGCMConnect rc = %#x, result = %#x\n",
|
---|
85 | rc, data.result));
|
---|
86 | */
|
---|
87 | if (RT_SUCCESS (rc))
|
---|
88 | {
|
---|
89 | rc = data.result;
|
---|
90 | }
|
---|
91 |
|
---|
92 | if (RT_SUCCESS (rc))
|
---|
93 | {
|
---|
94 | pClient->ulClientID = data.u32ClientID;
|
---|
95 | }
|
---|
96 | return rc;
|
---|
97 | }
|
---|
98 |
|
---|
99 | DECLVBGL(void) vboxDisconnect (PVBSFCLIENT pClient)
|
---|
100 | {
|
---|
101 | int rc;
|
---|
102 |
|
---|
103 | VBoxGuestHGCMDisconnectInfo data;
|
---|
104 |
|
---|
105 | if (pClient->handle == NULL)
|
---|
106 | return; /* not connected */
|
---|
107 |
|
---|
108 | RtlZeroMemory (&data, sizeof (VBoxGuestHGCMDisconnectInfo));
|
---|
109 |
|
---|
110 | data.result = VINF_SUCCESS;
|
---|
111 | data.u32ClientID = pClient->ulClientID;
|
---|
112 |
|
---|
113 | rc = VbglHGCMDisconnect (pClient->handle, &data);
|
---|
114 | /* Log(("VBOXSF: VBoxSF::vboxDisconnect: "
|
---|
115 | "VbglHGCMDisconnect rc = %#x, result = %#x\n", rc, data.result));
|
---|
116 | */
|
---|
117 | return;
|
---|
118 | }
|
---|
119 |
|
---|
120 | DECLVBGL(int) vboxCallQueryMappings (PVBSFCLIENT pClient, SHFLMAPPING paMappings[],
|
---|
121 | uint32_t *pcMappings)
|
---|
122 | {
|
---|
123 | int rc = VINF_SUCCESS;
|
---|
124 |
|
---|
125 | VBoxSFQueryMappings data;
|
---|
126 |
|
---|
127 | VBOX_INIT_CALL(&data.callInfo, QUERY_MAPPINGS, pClient);
|
---|
128 |
|
---|
129 | data.flags.type = VMMDevHGCMParmType_32bit;
|
---|
130 | data.flags.u.value32 = SHFL_MF_UCS2;
|
---|
131 |
|
---|
132 | data.numberOfMappings.type = VMMDevHGCMParmType_32bit;
|
---|
133 | data.numberOfMappings.u.value32 = *pcMappings;
|
---|
134 |
|
---|
135 | data.mappings.type = VMMDevHGCMParmType_LinAddr;
|
---|
136 | data.mappings.u.Pointer.size = sizeof (SHFLMAPPING) * *pcMappings;
|
---|
137 | data.mappings.u.Pointer.u.linearAddr = (uintptr_t)&paMappings[0];
|
---|
138 |
|
---|
139 | /* Log(("VBOXSF: in ifs difference %d\n",
|
---|
140 | (char *)&data.flags.type - (char *)&data.callInfo.cParms));
|
---|
141 | */
|
---|
142 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
143 |
|
---|
144 | /*
|
---|
145 | Log(("VBOXSF: VBoxSF::vboxCallQueryMappings: "
|
---|
146 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
147 | */
|
---|
148 | if (RT_SUCCESS (rc))
|
---|
149 | {
|
---|
150 | rc = data.callInfo.result;
|
---|
151 | }
|
---|
152 |
|
---|
153 | if (RT_SUCCESS (rc))
|
---|
154 | {
|
---|
155 | *pcMappings = data.numberOfMappings.u.value32;
|
---|
156 | }
|
---|
157 |
|
---|
158 | return rc;
|
---|
159 | }
|
---|
160 |
|
---|
161 | DECLVBGL(int) vboxCallQueryMapName (PVBSFCLIENT pClient, SHFLROOT root, SHFLSTRING *pString, uint32_t size)
|
---|
162 | {
|
---|
163 | int rc = VINF_SUCCESS;
|
---|
164 |
|
---|
165 | VBoxSFQueryMapName data;
|
---|
166 |
|
---|
167 | VBOX_INIT_CALL(&data.callInfo, QUERY_MAP_NAME, pClient);
|
---|
168 |
|
---|
169 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
170 | data.root.u.value32 = root;
|
---|
171 |
|
---|
172 | data.name.type = VMMDevHGCMParmType_LinAddr;
|
---|
173 | data.name.u.Pointer.size = size;
|
---|
174 | data.name.u.Pointer.u.linearAddr = (uintptr_t)pString;
|
---|
175 |
|
---|
176 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
177 |
|
---|
178 | /* Log(("VBOXSF: VBoxSF::vboxCallQueryMapName: "
|
---|
179 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
180 | */
|
---|
181 | if (RT_SUCCESS (rc))
|
---|
182 | {
|
---|
183 | rc = data.callInfo.result;
|
---|
184 | }
|
---|
185 |
|
---|
186 | return rc;
|
---|
187 | }
|
---|
188 |
|
---|
189 | DECLVBGL(int) vboxCallMapFolder(PVBSFCLIENT pClient, PSHFLSTRING szFolderName,
|
---|
190 | PVBSFMAP pMap)
|
---|
191 | {
|
---|
192 | int rc = VINF_SUCCESS;
|
---|
193 |
|
---|
194 | VBoxSFMapFolder data;
|
---|
195 |
|
---|
196 | VBOX_INIT_CALL(&data.callInfo, MAP_FOLDER, pClient);
|
---|
197 |
|
---|
198 | data.path.type = VMMDevHGCMParmType_LinAddr;
|
---|
199 | data.path.u.Pointer.size = ShflStringSizeOfBuffer (szFolderName);
|
---|
200 | data.path.u.Pointer.u.linearAddr = (uintptr_t)szFolderName;
|
---|
201 |
|
---|
202 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
203 | data.root.u.value32 = 0;
|
---|
204 |
|
---|
205 | data.delimiter.type = VMMDevHGCMParmType_32bit;
|
---|
206 | data.delimiter.u.value32 = RTPATH_DELIMITER;
|
---|
207 |
|
---|
208 | data.fCaseSensitive.type = VMMDevHGCMParmType_32bit;
|
---|
209 | #if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
|
---|
210 | data.fCaseSensitive.u.value32 = 0;
|
---|
211 | #else
|
---|
212 | data.fCaseSensitive.u.value32 = 1;
|
---|
213 | #endif
|
---|
214 |
|
---|
215 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
216 |
|
---|
217 | /* Log(("VBOXSF: VBoxSF::vboxCallMapFolder: "
|
---|
218 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
219 | */
|
---|
220 | if (RT_SUCCESS (rc))
|
---|
221 | {
|
---|
222 | pMap->root = data.root.u.value32;
|
---|
223 | rc = data.callInfo.result;
|
---|
224 | }
|
---|
225 | else if (rc == VERR_NOT_IMPLEMENTED)
|
---|
226 | {
|
---|
227 | /* try the legacy interface too; temporary to assure backwards compatibility */
|
---|
228 | VBoxSFMapFolder_Old OldData;
|
---|
229 |
|
---|
230 | VBOX_INIT_CALL(&OldData.callInfo, MAP_FOLDER_OLD, pClient);
|
---|
231 |
|
---|
232 | OldData.path.type = VMMDevHGCMParmType_LinAddr;
|
---|
233 | OldData.path.u.Pointer.size = ShflStringSizeOfBuffer (szFolderName);
|
---|
234 | OldData.path.u.Pointer.u.linearAddr = (uintptr_t)szFolderName;
|
---|
235 |
|
---|
236 | OldData.root.type = VMMDevHGCMParmType_32bit;
|
---|
237 | OldData.root.u.value32 = 0;
|
---|
238 |
|
---|
239 | OldData.delimiter.type = VMMDevHGCMParmType_32bit;
|
---|
240 | OldData.delimiter.u.value32 = RTPATH_DELIMITER;
|
---|
241 |
|
---|
242 | rc = VbglHGCMCall (pClient->handle, &OldData.callInfo, sizeof (OldData));
|
---|
243 |
|
---|
244 | if (RT_SUCCESS (rc))
|
---|
245 | {
|
---|
246 | pMap->root = OldData.root.u.value32;
|
---|
247 | rc = OldData.callInfo.result;
|
---|
248 | }
|
---|
249 | }
|
---|
250 | return rc;
|
---|
251 | }
|
---|
252 |
|
---|
253 | DECLVBGL(int) vboxCallUnmapFolder(PVBSFCLIENT pClient, PVBSFMAP pMap)
|
---|
254 | {
|
---|
255 | int rc = VINF_SUCCESS;
|
---|
256 |
|
---|
257 | VBoxSFUnmapFolder data;
|
---|
258 |
|
---|
259 | VBOX_INIT_CALL(&data.callInfo, UNMAP_FOLDER, pClient);
|
---|
260 |
|
---|
261 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
262 | data.root.u.value32 = pMap->root;
|
---|
263 |
|
---|
264 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
265 |
|
---|
266 | /* Log(("VBOXSF: VBoxSF::vboxCallUnmapFolder: "
|
---|
267 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
268 | */
|
---|
269 | if (RT_SUCCESS (rc))
|
---|
270 | {
|
---|
271 | rc = data.callInfo.result;
|
---|
272 | }
|
---|
273 | return rc;
|
---|
274 | }
|
---|
275 |
|
---|
276 | DECLVBGL(int) vboxCallCreate (PVBSFCLIENT pClient, PVBSFMAP pMap,
|
---|
277 | PSHFLSTRING pParsedPath, PSHFLCREATEPARMS pCreateParms)
|
---|
278 | {
|
---|
279 | /** @todo copy buffers to physical or mapped memory. */
|
---|
280 | int rc = VINF_SUCCESS;
|
---|
281 |
|
---|
282 | VBoxSFCreate data;
|
---|
283 |
|
---|
284 | VBOX_INIT_CALL(&data.callInfo, CREATE, pClient);
|
---|
285 |
|
---|
286 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
287 | data.root.u.value32 = pMap->root;
|
---|
288 |
|
---|
289 | data.path.type = VMMDevHGCMParmType_LinAddr;
|
---|
290 | data.path.u.Pointer.size = ShflStringSizeOfBuffer (pParsedPath);
|
---|
291 | data.path.u.Pointer.u.linearAddr = (uintptr_t)pParsedPath;
|
---|
292 |
|
---|
293 | data.parms.type = VMMDevHGCMParmType_LinAddr;
|
---|
294 | data.parms.u.Pointer.size = sizeof (SHFLCREATEPARMS);
|
---|
295 | data.parms.u.Pointer.u.linearAddr = (uintptr_t)pCreateParms;
|
---|
296 |
|
---|
297 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
298 |
|
---|
299 | /* Log(("VBOXSF: VBoxSF::vboxCallCreate: "
|
---|
300 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
301 | */
|
---|
302 | if (RT_SUCCESS (rc))
|
---|
303 | {
|
---|
304 | rc = data.callInfo.result;
|
---|
305 | }
|
---|
306 | return rc;
|
---|
307 | }
|
---|
308 |
|
---|
309 | DECLVBGL(int) vboxCallClose (PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE Handle)
|
---|
310 | {
|
---|
311 | int rc = VINF_SUCCESS;
|
---|
312 |
|
---|
313 | VBoxSFClose data;
|
---|
314 |
|
---|
315 | VBOX_INIT_CALL(&data.callInfo, CLOSE, pClient);
|
---|
316 |
|
---|
317 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
318 | data.root.u.value32 = pMap->root;
|
---|
319 |
|
---|
320 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
321 | data.handle.u.value64 = Handle;
|
---|
322 |
|
---|
323 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
324 |
|
---|
325 | /* Log(("VBOXSF: VBoxSF::vboxCallClose: "
|
---|
326 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
327 | */
|
---|
328 | if (RT_SUCCESS (rc))
|
---|
329 | {
|
---|
330 | rc = data.callInfo.result;
|
---|
331 | }
|
---|
332 |
|
---|
333 | return rc;
|
---|
334 | }
|
---|
335 |
|
---|
336 | DECLVBGL(int) vboxCallRemove (PVBSFCLIENT pClient, PVBSFMAP pMap,
|
---|
337 | PSHFLSTRING pParsedPath, uint32_t flags)
|
---|
338 | {
|
---|
339 | int rc = VINF_SUCCESS;
|
---|
340 |
|
---|
341 | VBoxSFRemove data;
|
---|
342 |
|
---|
343 | VBOX_INIT_CALL(&data.callInfo, REMOVE, pClient);
|
---|
344 |
|
---|
345 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
346 | data.root.u.value32 = pMap->root;
|
---|
347 |
|
---|
348 | data.path.type = VMMDevHGCMParmType_LinAddr_In;
|
---|
349 | data.path.u.Pointer.size = ShflStringSizeOfBuffer (pParsedPath);
|
---|
350 | data.path.u.Pointer.u.linearAddr = (uintptr_t)pParsedPath;
|
---|
351 |
|
---|
352 | data.flags.type = VMMDevHGCMParmType_32bit;
|
---|
353 | data.flags.u.value32 = flags;
|
---|
354 |
|
---|
355 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
356 |
|
---|
357 | /* Log(("VBOXSF: VBoxSF::vboxCallRemove: "
|
---|
358 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
359 | */
|
---|
360 | if (RT_SUCCESS (rc))
|
---|
361 | {
|
---|
362 | rc = data.callInfo.result;
|
---|
363 | }
|
---|
364 |
|
---|
365 | return rc;
|
---|
366 | }
|
---|
367 |
|
---|
368 | DECLVBGL(int) vboxCallRename (PVBSFCLIENT pClient, PVBSFMAP pMap,
|
---|
369 | PSHFLSTRING pSrcPath, PSHFLSTRING pDestPath, uint32_t flags)
|
---|
370 | {
|
---|
371 | int rc = VINF_SUCCESS;
|
---|
372 |
|
---|
373 | VBoxSFRename data;
|
---|
374 |
|
---|
375 | VBOX_INIT_CALL(&data.callInfo, RENAME, pClient);
|
---|
376 |
|
---|
377 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
378 | data.root.u.value32 = pMap->root;
|
---|
379 |
|
---|
380 | data.src.type = VMMDevHGCMParmType_LinAddr_In;
|
---|
381 | data.src.u.Pointer.size = ShflStringSizeOfBuffer (pSrcPath);
|
---|
382 | data.src.u.Pointer.u.linearAddr = (uintptr_t)pSrcPath;
|
---|
383 |
|
---|
384 | data.dest.type = VMMDevHGCMParmType_LinAddr_In;
|
---|
385 | data.dest.u.Pointer.size = ShflStringSizeOfBuffer (pDestPath);
|
---|
386 | data.dest.u.Pointer.u.linearAddr = (uintptr_t)pDestPath;
|
---|
387 |
|
---|
388 | data.flags.type = VMMDevHGCMParmType_32bit;
|
---|
389 | data.flags.u.value32 = flags;
|
---|
390 |
|
---|
391 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
392 |
|
---|
393 | /* Log(("VBOXSF: VBoxSF::vboxCallRename: "
|
---|
394 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
395 | */
|
---|
396 | if (RT_SUCCESS (rc))
|
---|
397 | {
|
---|
398 | rc = data.callInfo.result;
|
---|
399 | }
|
---|
400 | return rc;
|
---|
401 | }
|
---|
402 |
|
---|
403 | DECLVBGL(int) vboxCallRead(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
|
---|
404 | uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked)
|
---|
405 | {
|
---|
406 | int rc = VINF_SUCCESS;
|
---|
407 |
|
---|
408 | VBoxSFRead data;
|
---|
409 |
|
---|
410 | VBOX_INIT_CALL(&data.callInfo, READ, pClient);
|
---|
411 |
|
---|
412 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
413 | data.root.u.value32 = pMap->root;
|
---|
414 |
|
---|
415 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
416 | data.handle.u.value64 = hFile;
|
---|
417 | data.offset.type = VMMDevHGCMParmType_64bit;
|
---|
418 | data.offset.u.value64 = offset;
|
---|
419 | data.cb.type = VMMDevHGCMParmType_32bit;
|
---|
420 | data.cb.u.value32 = *pcbBuffer;
|
---|
421 | data.buffer.type = (fLocked) ? VMMDevHGCMParmType_LinAddr_Locked_Out : VMMDevHGCMParmType_LinAddr_Out;
|
---|
422 | data.buffer.u.Pointer.size = *pcbBuffer;
|
---|
423 | data.buffer.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
|
---|
424 |
|
---|
425 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
426 |
|
---|
427 | /* Log(("VBOXSF: VBoxSF::vboxCallRead: "
|
---|
428 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
429 | */
|
---|
430 | if (RT_SUCCESS (rc))
|
---|
431 | {
|
---|
432 | rc = data.callInfo.result;
|
---|
433 | *pcbBuffer = data.cb.u.value32;
|
---|
434 | }
|
---|
435 | return rc;
|
---|
436 | }
|
---|
437 |
|
---|
438 | DECLVBGL(int) vboxCallWrite(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
|
---|
439 | uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked)
|
---|
440 | {
|
---|
441 | int rc = VINF_SUCCESS;
|
---|
442 |
|
---|
443 | VBoxSFWrite data;
|
---|
444 |
|
---|
445 | VBOX_INIT_CALL(&data.callInfo, WRITE, pClient);
|
---|
446 |
|
---|
447 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
448 | data.root.u.value32 = pMap->root;
|
---|
449 |
|
---|
450 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
451 | data.handle.u.value64 = hFile;
|
---|
452 | data.offset.type = VMMDevHGCMParmType_64bit;
|
---|
453 | data.offset.u.value64 = offset;
|
---|
454 | data.cb.type = VMMDevHGCMParmType_32bit;
|
---|
455 | data.cb.u.value32 = *pcbBuffer;
|
---|
456 | data.buffer.type = (fLocked) ? VMMDevHGCMParmType_LinAddr_Locked_In : VMMDevHGCMParmType_LinAddr_In;
|
---|
457 | data.buffer.u.Pointer.size = *pcbBuffer;
|
---|
458 | data.buffer.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
|
---|
459 |
|
---|
460 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
461 |
|
---|
462 | /* Log(("VBOXSF: VBoxSF::vboxCallWrite: "
|
---|
463 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
464 | */
|
---|
465 | if (RT_SUCCESS (rc))
|
---|
466 | {
|
---|
467 | rc = data.callInfo.result;
|
---|
468 | *pcbBuffer = data.cb.u.value32;
|
---|
469 | }
|
---|
470 | return rc;
|
---|
471 | }
|
---|
472 |
|
---|
473 | DECLVBGL(int) VbglR0SfWritePhysCont(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer, RTCCPHYS PhysBuffer)
|
---|
474 | {
|
---|
475 | uint32_t cbToWrite = *pcbBuffer;
|
---|
476 | uint32_t cPages = RT_ALIGN_32((PhysBuffer & PAGE_OFFSET_MASK) + cbToWrite, PAGE_SIZE) >> PAGE_SHIFT;
|
---|
477 | uint32_t cbData = sizeof(VBoxSFWrite) + RT_UOFFSETOF(HGCMPageListInfo, aPages[cPages]);
|
---|
478 | VBoxSFWrite *pData = (VBoxSFWrite *)RTMemTmpAlloc(cbData);
|
---|
479 | HGCMPageListInfo *pPgLst = (HGCMPageListInfo *)(pData + 1);
|
---|
480 | uint32_t iPage;
|
---|
481 | int rc;
|
---|
482 |
|
---|
483 | if (RT_UNLIKELY(!pData))
|
---|
484 | return VERR_NO_TMP_MEMORY;
|
---|
485 |
|
---|
486 | VBOX_INIT_CALL(&pData->callInfo, WRITE, pClient);
|
---|
487 |
|
---|
488 | pData->root.type = VMMDevHGCMParmType_32bit;
|
---|
489 | pData->root.u.value32 = pMap->root;
|
---|
490 |
|
---|
491 | pData->handle.type = VMMDevHGCMParmType_64bit;
|
---|
492 | pData->handle.u.value64 = hFile;
|
---|
493 | pData->offset.type = VMMDevHGCMParmType_64bit;
|
---|
494 | pData->offset.u.value64 = offset;
|
---|
495 | pData->cb.type = VMMDevHGCMParmType_32bit;
|
---|
496 | pData->cb.u.value32 = cbToWrite;
|
---|
497 | pData->buffer.type = VMMDevHGCMParmType_PageList;
|
---|
498 | pData->buffer.u.PageList.size = cbToWrite;
|
---|
499 | pData->buffer.u.PageList.offset = sizeof(VBoxSFWrite);
|
---|
500 |
|
---|
501 | pPgLst->flags = VBOX_HGCM_F_PARM_DIRECTION_TO_HOST;
|
---|
502 | pPgLst->offFirstPage = PhysBuffer & PAGE_OFFSET_MASK;
|
---|
503 | pPgLst->cPages = cPages;
|
---|
504 | PhysBuffer &= ~(RTCCPHYS)PAGE_OFFSET_MASK;
|
---|
505 | for (iPage = 0; iPage < cPages; iPage++, PhysBuffer += PAGE_SIZE)
|
---|
506 | pPgLst->aPages[iPage] = PhysBuffer;
|
---|
507 |
|
---|
508 | rc = VbglHGCMCall (pClient->handle, &pData->callInfo, cbData);
|
---|
509 | if (RT_SUCCESS (rc))
|
---|
510 | {
|
---|
511 | rc = pData->callInfo.result;
|
---|
512 | *pcbBuffer = pData->cb.u.value32;
|
---|
513 | }
|
---|
514 |
|
---|
515 | RTMemTmpFree(pData);
|
---|
516 | return rc;
|
---|
517 |
|
---|
518 | }
|
---|
519 |
|
---|
520 | DECLVBGL(int) vboxCallFlush(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile)
|
---|
521 | {
|
---|
522 | int rc = VINF_SUCCESS;
|
---|
523 |
|
---|
524 | VBoxSFFlush data;
|
---|
525 |
|
---|
526 | VBOX_INIT_CALL(&data.callInfo, FLUSH, pClient);
|
---|
527 |
|
---|
528 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
529 | data.root.u.value32 = pMap->root;
|
---|
530 |
|
---|
531 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
532 | data.handle.u.value64 = hFile;
|
---|
533 |
|
---|
534 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
535 |
|
---|
536 | /* Log(("VBOXSF: VBoxSF::vboxCallFlush: "
|
---|
537 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
538 | */
|
---|
539 | if (RT_SUCCESS (rc))
|
---|
540 | {
|
---|
541 | rc = data.callInfo.result;
|
---|
542 | }
|
---|
543 | return rc;
|
---|
544 | }
|
---|
545 |
|
---|
546 | DECLVBGL(int) vboxCallDirInfo (
|
---|
547 | PVBSFCLIENT pClient,
|
---|
548 | PVBSFMAP pMap,
|
---|
549 | SHFLHANDLE hFile,
|
---|
550 | PSHFLSTRING ParsedPath,
|
---|
551 | uint32_t flags,
|
---|
552 | uint32_t index,
|
---|
553 | uint32_t *pcbBuffer,
|
---|
554 | PSHFLDIRINFO pBuffer,
|
---|
555 | uint32_t *pcFiles)
|
---|
556 | {
|
---|
557 | int rc = VINF_SUCCESS;
|
---|
558 |
|
---|
559 | VBoxSFList data;
|
---|
560 |
|
---|
561 | VBOX_INIT_CALL(&data.callInfo, LIST, pClient);
|
---|
562 |
|
---|
563 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
564 | data.root.u.value32 = pMap->root;
|
---|
565 |
|
---|
566 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
567 | data.handle.u.value64 = hFile;
|
---|
568 | data.flags.type = VMMDevHGCMParmType_32bit;
|
---|
569 | data.flags.u.value32 = flags;
|
---|
570 | data.cb.type = VMMDevHGCMParmType_32bit;
|
---|
571 | data.cb.u.value32 = *pcbBuffer;
|
---|
572 | data.path.type = VMMDevHGCMParmType_LinAddr_In;
|
---|
573 | data.path.u.Pointer.size =
|
---|
574 | (ParsedPath) ? ShflStringSizeOfBuffer(ParsedPath) : 0;
|
---|
575 | data.path.u.Pointer.u.linearAddr = (uintptr_t) ParsedPath;
|
---|
576 |
|
---|
577 | data.buffer.type = VMMDevHGCMParmType_LinAddr_Out;
|
---|
578 | data.buffer.u.Pointer.size = *pcbBuffer;
|
---|
579 | data.buffer.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
|
---|
580 |
|
---|
581 | data.resumePoint.type = VMMDevHGCMParmType_32bit;
|
---|
582 | data.resumePoint.u.value32 = index;
|
---|
583 | data.cFiles.type = VMMDevHGCMParmType_32bit;
|
---|
584 | data.cFiles.u.value32 = 0; /* out parameters only */
|
---|
585 |
|
---|
586 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
587 |
|
---|
588 | /* Log(("VBOXSF: VBoxSF::vboxCallDirInfo: "
|
---|
589 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
590 | */
|
---|
591 | if (RT_SUCCESS (rc))
|
---|
592 | {
|
---|
593 | rc = data.callInfo.result;
|
---|
594 | }
|
---|
595 | *pcbBuffer = data.cb.u.value32;
|
---|
596 | *pcFiles = data.cFiles.u.value32;
|
---|
597 | return rc;
|
---|
598 | }
|
---|
599 |
|
---|
600 | DECLVBGL(int) vboxCallFSInfo(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
|
---|
601 | uint32_t flags, uint32_t *pcbBuffer, PSHFLDIRINFO pBuffer)
|
---|
602 | {
|
---|
603 | int rc = VINF_SUCCESS;
|
---|
604 |
|
---|
605 | VBoxSFInformation data;
|
---|
606 |
|
---|
607 | VBOX_INIT_CALL(&data.callInfo, INFORMATION, pClient);
|
---|
608 |
|
---|
609 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
610 | data.root.u.value32 = pMap->root;
|
---|
611 |
|
---|
612 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
613 | data.handle.u.value64 = hFile;
|
---|
614 | data.flags.type = VMMDevHGCMParmType_32bit;
|
---|
615 | data.flags.u.value32 = flags;
|
---|
616 | data.cb.type = VMMDevHGCMParmType_32bit;
|
---|
617 | data.cb.u.value32 = *pcbBuffer;
|
---|
618 | data.info.type = VMMDevHGCMParmType_LinAddr;
|
---|
619 | data.info.u.Pointer.size = *pcbBuffer;
|
---|
620 | data.info.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
|
---|
621 |
|
---|
622 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
623 |
|
---|
624 | /* Log(("VBOXSF: VBoxSF::vboxCallFileInfo: "
|
---|
625 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
626 | */
|
---|
627 | if (RT_SUCCESS (rc))
|
---|
628 | {
|
---|
629 | rc = data.callInfo.result;
|
---|
630 | *pcbBuffer = data.cb.u.value32;
|
---|
631 | }
|
---|
632 | return rc;
|
---|
633 | }
|
---|
634 |
|
---|
635 | DECLVBGL(int) vboxCallLock(PVBSFCLIENT pClient, PVBSFMAP pMap, SHFLHANDLE hFile,
|
---|
636 | uint64_t offset, uint64_t cbSize, uint32_t fLock)
|
---|
637 | {
|
---|
638 | int rc = VINF_SUCCESS;
|
---|
639 |
|
---|
640 | VBoxSFLock data;
|
---|
641 |
|
---|
642 | VBOX_INIT_CALL(&data.callInfo, LOCK, pClient);
|
---|
643 |
|
---|
644 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
645 | data.root.u.value32 = pMap->root;
|
---|
646 |
|
---|
647 | data.handle.type = VMMDevHGCMParmType_64bit;
|
---|
648 | data.handle.u.value64 = hFile;
|
---|
649 | data.offset.type = VMMDevHGCMParmType_64bit;
|
---|
650 | data.offset.u.value64 = offset;
|
---|
651 | data.length.type = VMMDevHGCMParmType_64bit;
|
---|
652 | data.length.u.value64 = cbSize;
|
---|
653 |
|
---|
654 | data.flags.type = VMMDevHGCMParmType_32bit;
|
---|
655 | data.flags.u.value32 = fLock;
|
---|
656 |
|
---|
657 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
658 |
|
---|
659 | /* Log(("VBOXSF: VBoxSF::vboxCallLock: "
|
---|
660 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
661 | */
|
---|
662 | if (RT_SUCCESS (rc))
|
---|
663 | {
|
---|
664 | rc = data.callInfo.result;
|
---|
665 | }
|
---|
666 | return rc;
|
---|
667 | }
|
---|
668 |
|
---|
669 | DECLVBGL(int) vboxCallSetUtf8 (PVBSFCLIENT pClient)
|
---|
670 | {
|
---|
671 | int rc = VINF_SUCCESS;
|
---|
672 |
|
---|
673 | VBoxGuestHGCMCallInfo callInfo;
|
---|
674 |
|
---|
675 | VBOX_INIT_CALL (&callInfo, SET_UTF8, pClient);
|
---|
676 | rc = VbglHGCMCall (pClient->handle, &callInfo, sizeof (callInfo));
|
---|
677 | if (RT_SUCCESS (rc))
|
---|
678 | {
|
---|
679 | rc = callInfo.result;
|
---|
680 | }
|
---|
681 | return rc;
|
---|
682 | }
|
---|
683 |
|
---|
684 | DECLVBGL(int) vboxReadLink (PVBSFCLIENT pClient, PVBSFMAP pMap, PSHFLSTRING pParsedPath,
|
---|
685 | uint32_t cbBuffer, uint8_t *pBuffer)
|
---|
686 | {
|
---|
687 | int rc = VINF_SUCCESS;
|
---|
688 |
|
---|
689 | VBoxSFReadLink data;
|
---|
690 |
|
---|
691 | VBOX_INIT_CALL(&data.callInfo, READLINK, pClient);
|
---|
692 |
|
---|
693 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
694 | data.root.u.value32 = pMap->root;
|
---|
695 |
|
---|
696 | data.path.type = VMMDevHGCMParmType_LinAddr_In;
|
---|
697 | data.path.u.Pointer.size = ShflStringSizeOfBuffer (pParsedPath);
|
---|
698 | data.path.u.Pointer.u.linearAddr = (uintptr_t)pParsedPath;
|
---|
699 |
|
---|
700 | data.buffer.type = VMMDevHGCMParmType_LinAddr_Out;
|
---|
701 | data.buffer.u.Pointer.size = cbBuffer;
|
---|
702 | data.buffer.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
|
---|
703 |
|
---|
704 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
705 |
|
---|
706 | /* Log(("VBOXSF: VBoxSF::vboxCallReadline: "
|
---|
707 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
708 | */
|
---|
709 | if (RT_SUCCESS (rc))
|
---|
710 | {
|
---|
711 | rc = data.callInfo.result;
|
---|
712 | }
|
---|
713 | return rc;
|
---|
714 | }
|
---|
715 |
|
---|
716 | DECLVBGL(int) vboxCallSymlink (PVBSFCLIENT pClient, PVBSFMAP pMap, PSHFLSTRING pNewPath, PSHFLSTRING pOldPath, PRTFSOBJINFO pBuffer)
|
---|
717 | {
|
---|
718 | int rc = VINF_SUCCESS;
|
---|
719 |
|
---|
720 | VBoxSFSymlink data;
|
---|
721 |
|
---|
722 | VBOX_INIT_CALL(&data.callInfo, SYMLINK, pClient);
|
---|
723 |
|
---|
724 | data.root.type = VMMDevHGCMParmType_32bit;
|
---|
725 | data.root.u.value32 = pMap->root;
|
---|
726 |
|
---|
727 | data.newPath.type = VMMDevHGCMParmType_LinAddr_In;
|
---|
728 | data.newPath.u.Pointer.size = ShflStringSizeOfBuffer (pNewPath);
|
---|
729 | data.newPath.u.Pointer.u.linearAddr = (uintptr_t)pNewPath;
|
---|
730 |
|
---|
731 | data.oldPath.type = VMMDevHGCMParmType_LinAddr_In;
|
---|
732 | data.oldPath.u.Pointer.size = ShflStringSizeOfBuffer (pOldPath);
|
---|
733 | data.oldPath.u.Pointer.u.linearAddr = (uintptr_t)pOldPath;
|
---|
734 |
|
---|
735 | data.info.type = VMMDevHGCMParmType_LinAddr_Out;
|
---|
736 | data.info.u.Pointer.size = sizeof(RTFSOBJINFO);
|
---|
737 | data.info.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
|
---|
738 |
|
---|
739 | rc = VbglHGCMCall (pClient->handle, &data.callInfo, sizeof (data));
|
---|
740 |
|
---|
741 | /* Log(("VBOXSF: VBoxSF::vboxCallSymlink: "
|
---|
742 | "VbglHGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result));
|
---|
743 | */
|
---|
744 | if (RT_SUCCESS (rc))
|
---|
745 | {
|
---|
746 | rc = data.callInfo.result;
|
---|
747 | }
|
---|
748 | return rc;
|
---|
749 | }
|
---|
750 |
|
---|
751 | DECLVBGL(int) vboxCallSetSymlinks (PVBSFCLIENT pClient)
|
---|
752 | {
|
---|
753 | int rc = VINF_SUCCESS;
|
---|
754 |
|
---|
755 | VBoxGuestHGCMCallInfo callInfo;
|
---|
756 |
|
---|
757 | VBOX_INIT_CALL (&callInfo, SET_SYMLINKS, pClient);
|
---|
758 | rc = VbglHGCMCall (pClient->handle, &callInfo, sizeof (callInfo));
|
---|
759 | if (RT_SUCCESS (rc))
|
---|
760 | {
|
---|
761 | rc = callInfo.result;
|
---|
762 | }
|
---|
763 | return rc;
|
---|
764 | }
|
---|
765 |
|
---|
766 |
|
---|
767 | #endif /* !VBGL_VBOXGUEST */
|
---|