VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibSharedFolders.c@ 75547

Last change on this file since 75547 was 73097, checked in by vboxsync, 6 years ago

*: Made RT_UOFFSETOF, RT_OFFSETOF, RT_UOFFSETOF_ADD and RT_OFFSETOF_ADD work like builtin_offsetof() and require compile time resolvable requests, adding RT_UOFFSETOF_DYN for the dynamic questions that can only be answered at runtime.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 26.9 KB
Line 
1/* $Id: VBoxGuestR0LibSharedFolders.c 73097 2018-07-12 21:06:33Z vboxsync $ */
2/** @file
3 * VBoxGuestR0LibSharedFolders - Ring 0 Shared Folders calls.
4 */
5
6/*
7 * Copyright (C) 2006-2018 Oracle Corporation
8 *
9 * Permission is hereby granted, free of charge, to any person
10 * obtaining a copy of this software and associated documentation
11 * files (the "Software"), to deal in the Software without
12 * restriction, including without limitation the rights to use,
13 * copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following
16 * conditions:
17 *
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
29 */
30
31
32/*********************************************************************************************************************************
33* Header Files *
34*********************************************************************************************************************************/
35#define LOG_GROUP LOG_GROUP_SHARED_FOLDERS
36#include "VBoxGuestR0LibInternal.h"
37#include <VBox/VBoxGuestLibSharedFolders.h>
38#include <VBox/log.h>
39#include <iprt/time.h>
40#include <iprt/mem.h>
41#include <iprt/path.h>
42#include <iprt/string.h>
43
44#ifdef VBGL_VBOXGUEST
45# error "This file shouldn't be part of the VBoxGuestR0LibBase library that is linked into VBoxGuest. It's client code."
46#endif
47
48
49/*********************************************************************************************************************************
50* Defined Constants And Macros *
51*********************************************************************************************************************************/
52#define SHFL_CPARMS_SET_UTF8 0
53#define SHFL_CPARMS_SET_SYMLINKS 0
54
55#define VBOX_INIT_CALL(a, b, c) \
56 LogFunc(("%s, idClient=%d\n", "SHFL_FN_" # b, (c)->idClient)); \
57 VBGL_HGCM_HDR_INIT(a, (c)->idClient, SHFL_FN_##b, SHFL_CPARMS_##b); \
58 (a)->fInterruptible = false /* Currently we do like nfs with -o hard (default). */
59
60#define VBOX_INIT_CALL_EX(a, b, c, a_cbReq) \
61 LogFunc(("%s, idClient=%d\n", "SHFL_FN_" # b, (c)->idClient)); \
62 VBGL_HGCM_HDR_INIT_EX(a, (c)->idClient, SHFL_FN_##b, SHFL_CPARMS_##b, a_cbReq); \
63 (a)->fInterruptible = false /* Currently we do like nfs with -o hard (default). */
64
65
66
67/** @todo We only need HGCM, not physical memory, so other guests should also
68 * switch to calling vbglR0HGCMInit() and vbglR0HGCMTerminate() instead
69 * of VbglR0SfInit() and VbglR0SfTerm(). */
70#ifndef RT_OS_LINUX
71DECLVBGL(int) VbglR0SfInit(void)
72{
73 return VbglR0InitClient();
74}
75
76DECLVBGL(void) VbglR0SfTerm(void)
77{
78 VbglR0TerminateClient();
79}
80#endif
81
82DECLVBGL(int) VbglR0SfConnect(PVBGLSFCLIENT pClient)
83{
84 int rc = VbglR0HGCMConnect(&pClient->handle, "VBoxSharedFolders", &pClient->idClient);
85 if (RT_SUCCESS(rc))
86 LogFunc(("idClient=%d\n", pClient->idClient));
87 else
88 LogFunc(("VbglR0HGCMConnect failed -> rc=%Rrc\n", rc));
89 return rc;
90}
91
92DECLVBGL(void) VbglR0SfDisconnect(PVBGLSFCLIENT pClient)
93{
94 int rc;
95 LogFunc(("u32ClientID=%d\n", pClient->idClient));
96 if (pClient->handle == NULL)
97 return; /* not connected */
98
99 rc = VbglR0HGCMDisconnect(pClient->handle, pClient->idClient);
100 NOREF(rc);
101/* Log(("VBOXSF: VbglR0SfDisconnect: VbglR0HGCMDisconnect -> %#x\n", rc)); */
102 pClient->idClient = 0;
103 pClient->handle = NULL;
104 return;
105}
106
107DECLVBGL(int) VbglR0SfQueryMappings(PVBGLSFCLIENT pClient, SHFLMAPPING paMappings[], uint32_t *pcMappings)
108{
109 int rc;
110 VBoxSFQueryMappings data;
111
112 VBOX_INIT_CALL(&data.callInfo, QUERY_MAPPINGS, pClient);
113
114 data.flags.type = VMMDevHGCMParmType_32bit;
115 data.flags.u.value32 = SHFL_MF_UCS2;
116
117 data.numberOfMappings.type = VMMDevHGCMParmType_32bit;
118 data.numberOfMappings.u.value32 = *pcMappings;
119
120 data.mappings.type = VMMDevHGCMParmType_LinAddr;
121 data.mappings.u.Pointer.size = sizeof(SHFLMAPPING) * *pcMappings;
122 data.mappings.u.Pointer.u.linearAddr = (uintptr_t)&paMappings[0];
123
124/* Log(("VBOXSF: in ifs difference %d\n", (char *)&data.flags.type - (char *)&data.callInfo.cParms)); */
125 rc = VbglR0HGCMCall(pClient->handle, &data.callInfo, sizeof(data));
126/* Log(("VBOXSF: VbglR0SfQueryMappings: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.result)); */
127 if (RT_SUCCESS(rc))
128 *pcMappings = data.numberOfMappings.u.value32;
129
130 return rc;
131}
132
133DECLVBGL(int) VbglR0SfQueryMapName(PVBGLSFCLIENT pClient, SHFLROOT root, SHFLSTRING *pString, uint32_t size)
134{
135 int rc;
136 VBoxSFQueryMapName data;
137
138 VBOX_INIT_CALL(&data.callInfo, QUERY_MAP_NAME, pClient);
139
140 data.root.type = VMMDevHGCMParmType_32bit;
141 data.root.u.value32 = root;
142
143 data.name.type = VMMDevHGCMParmType_LinAddr;
144 data.name.u.Pointer.size = size;
145 data.name.u.Pointer.u.linearAddr = (uintptr_t)pString;
146
147 rc = VbglR0HGCMCall(pClient->handle, &data.callInfo, sizeof(data));
148/* Log(("VBOXSF: VbglR0SfQueryMapName: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
149 return rc;
150}
151
152DECLVBGL(int) VbglR0SfMapFolder(PVBGLSFCLIENT pClient, PSHFLSTRING szFolderName, PVBGLSFMAP pMap)
153{
154 int rc;
155 VBoxSFMapFolder data;
156
157 VBOX_INIT_CALL(&data.callInfo, MAP_FOLDER, pClient);
158
159 data.path.type = VMMDevHGCMParmType_LinAddr;
160 data.path.u.Pointer.size = ShflStringSizeOfBuffer(szFolderName);
161 data.path.u.Pointer.u.linearAddr = (uintptr_t)szFolderName;
162
163 data.root.type = VMMDevHGCMParmType_32bit;
164 data.root.u.value32 = 0;
165
166 data.delimiter.type = VMMDevHGCMParmType_32bit;
167 data.delimiter.u.value32 = RTPATH_DELIMITER;
168
169 data.fCaseSensitive.type = VMMDevHGCMParmType_32bit;
170#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
171 data.fCaseSensitive.u.value32 = 0;
172#else
173 data.fCaseSensitive.u.value32 = 1;
174#endif
175
176 rc = VbglR0HGCMCallRaw(pClient->handle, &data.callInfo, sizeof(data));
177/* Log(("VBOXSF: VbglR0SfMapFolder: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
178 if (RT_SUCCESS(rc))
179 {
180 pMap->root = data.root.u.value32;
181 rc = data.callInfo.Hdr.rc;
182 }
183 return rc;
184}
185
186DECLVBGL(int) VbglR0SfUnmapFolder(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap)
187{
188 int rc;
189 VBoxSFUnmapFolder data;
190
191 VBOX_INIT_CALL(&data.callInfo, UNMAP_FOLDER, pClient);
192
193 data.root.type = VMMDevHGCMParmType_32bit;
194 data.root.u.value32 = pMap->root;
195
196 rc = VbglR0HGCMCall(pClient->handle, &data.callInfo, sizeof(data));
197/* Log(("VBOXSF: VbglR0SfUnmapFolder: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
198 return rc;
199}
200
201DECLVBGL(int) VbglR0SfCreate(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, PSHFLSTRING pParsedPath, PSHFLCREATEPARMS pCreateParms)
202{
203 /** @todo copy buffers to physical or mapped memory. */
204 int rc;
205 VBoxSFCreate data;
206
207 VBOX_INIT_CALL(&data.callInfo, CREATE, pClient);
208
209 data.root.type = VMMDevHGCMParmType_32bit;
210 data.root.u.value32 = pMap->root;
211
212 data.path.type = VMMDevHGCMParmType_LinAddr;
213 data.path.u.Pointer.size = ShflStringSizeOfBuffer (pParsedPath);
214 data.path.u.Pointer.u.linearAddr = (uintptr_t)pParsedPath;
215
216 data.parms.type = VMMDevHGCMParmType_LinAddr;
217 data.parms.u.Pointer.size = sizeof(SHFLCREATEPARMS);
218 data.parms.u.Pointer.u.linearAddr = (uintptr_t)pCreateParms;
219
220 rc = VbglR0HGCMCall(pClient->handle, &data.callInfo, sizeof(data));
221/* Log(("VBOXSF: VbglR0SfCreate: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
222 return rc;
223}
224
225DECLVBGL(int) VbglR0SfClose(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE Handle)
226{
227 int rc;
228 VBoxSFClose data;
229
230 VBOX_INIT_CALL(&data.callInfo, CLOSE, pClient);
231
232 data.root.type = VMMDevHGCMParmType_32bit;
233 data.root.u.value32 = pMap->root;
234
235 data.handle.type = VMMDevHGCMParmType_64bit;
236 data.handle.u.value64 = Handle;
237
238 rc = VbglR0HGCMCall(pClient->handle, &data.callInfo, sizeof(data));
239/* Log(("VBOXSF: VbglR0SfClose: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
240 return rc;
241}
242
243DECLVBGL(int) VbglR0SfRemove(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, PSHFLSTRING pParsedPath, uint32_t flags)
244{
245 int rc = VINF_SUCCESS;
246
247 VBoxSFRemove data;
248
249 VBOX_INIT_CALL(&data.callInfo, REMOVE, pClient);
250
251 data.root.type = VMMDevHGCMParmType_32bit;
252 data.root.u.value32 = pMap->root;
253
254 data.path.type = VMMDevHGCMParmType_LinAddr_In;
255 data.path.u.Pointer.size = ShflStringSizeOfBuffer(pParsedPath);
256 data.path.u.Pointer.u.linearAddr = (uintptr_t)pParsedPath;
257
258 data.flags.type = VMMDevHGCMParmType_32bit;
259 data.flags.u.value32 = flags;
260
261 rc = VbglR0HGCMCall(pClient->handle, &data.callInfo, sizeof(data));
262/* Log(("VBOXSF: VbglR0SfRemove: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
263 return rc;
264}
265
266DECLVBGL(int) VbglR0SfRename(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, PSHFLSTRING pSrcPath, PSHFLSTRING pDestPath, uint32_t flags)
267{
268 int rc;
269 VBoxSFRename data;
270
271 VBOX_INIT_CALL(&data.callInfo, RENAME, pClient);
272
273 data.root.type = VMMDevHGCMParmType_32bit;
274 data.root.u.value32 = pMap->root;
275
276 data.src.type = VMMDevHGCMParmType_LinAddr_In;
277 data.src.u.Pointer.size = ShflStringSizeOfBuffer(pSrcPath);
278 data.src.u.Pointer.u.linearAddr = (uintptr_t)pSrcPath;
279
280 data.dest.type = VMMDevHGCMParmType_LinAddr_In;
281 data.dest.u.Pointer.size = ShflStringSizeOfBuffer(pDestPath);
282 data.dest.u.Pointer.u.linearAddr = (uintptr_t)pDestPath;
283
284 data.flags.type = VMMDevHGCMParmType_32bit;
285 data.flags.u.value32 = flags;
286
287 rc = VbglR0HGCMCall(pClient->handle, &data.callInfo, sizeof(data));
288/* Log(("VBOXSF: VbglR0SfRename: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
289 return rc;
290}
291
292DECLVBGL(int) VbglR0SfRead(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile,
293 uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked)
294{
295 int rc;
296 VBoxSFRead data;
297
298 VBOX_INIT_CALL(&data.callInfo, READ, pClient);
299
300 data.root.type = VMMDevHGCMParmType_32bit;
301 data.root.u.value32 = pMap->root;
302
303 data.handle.type = VMMDevHGCMParmType_64bit;
304 data.handle.u.value64 = hFile;
305 data.offset.type = VMMDevHGCMParmType_64bit;
306 data.offset.u.value64 = offset;
307 data.cb.type = VMMDevHGCMParmType_32bit;
308 data.cb.u.value32 = *pcbBuffer;
309 data.buffer.type = (fLocked) ? VMMDevHGCMParmType_LinAddr_Locked_Out : VMMDevHGCMParmType_LinAddr_Out;
310 data.buffer.u.Pointer.size = *pcbBuffer;
311 data.buffer.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
312
313 rc = VbglR0HGCMCallRaw(pClient->handle, &data.callInfo, sizeof(data));
314/* Log(("VBOXSF: VbglR0SfRead: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
315 if (RT_SUCCESS(rc))
316 {
317 rc = data.callInfo.Hdr.rc;
318 *pcbBuffer = data.cb.u.value32;
319 }
320 return rc;
321}
322
323DECLVBGL(int) VbglR0SfReadPageList(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer,
324 uint16_t offFirstPage, uint16_t cPages, RTGCPHYS64 *paPages)
325{
326 uint32_t cbToRead = *pcbBuffer;
327 uint32_t cbData = (uint32_t)(sizeof(VBoxSFRead) + RT_UOFFSETOF_DYN(HGCMPageListInfo, aPages[cPages]));
328 VBoxSFRead *pData = (VBoxSFRead *)RTMemTmpAlloc(cbData);
329 HGCMPageListInfo *pPgLst = (HGCMPageListInfo *)(pData + 1);
330 uint16_t iPage;
331 int rc;
332
333 if (RT_UNLIKELY(!pData))
334 return VERR_NO_TMP_MEMORY;
335
336 VBOX_INIT_CALL_EX(&pData->callInfo, READ, pClient, cbData);
337
338 pData->root.type = VMMDevHGCMParmType_32bit;
339 pData->root.u.value32 = pMap->root;
340
341 pData->handle.type = VMMDevHGCMParmType_64bit;
342 pData->handle.u.value64 = hFile;
343 pData->offset.type = VMMDevHGCMParmType_64bit;
344 pData->offset.u.value64 = offset;
345 pData->cb.type = VMMDevHGCMParmType_32bit;
346 pData->cb.u.value32 = cbToRead;
347 pData->buffer.type = VMMDevHGCMParmType_PageList;
348 pData->buffer.u.PageList.size = cbToRead;
349 pData->buffer.u.PageList.offset = sizeof(VBoxSFRead);
350
351 pPgLst->flags = VBOX_HGCM_F_PARM_DIRECTION_FROM_HOST;
352 pPgLst->offFirstPage = offFirstPage;
353 pPgLst->cPages = cPages;
354 for (iPage = 0; iPage < cPages; iPage++)
355 pPgLst->aPages[iPage] = paPages[iPage];
356
357 rc = VbglR0HGCMCallRaw(pClient->handle, &pData->callInfo, cbData);
358/* Log(("VBOXSF: VbglR0SfReadPageList: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
359 if (RT_SUCCESS(rc))
360 {
361 rc = pData->callInfo.Hdr.rc;
362 *pcbBuffer = pData->cb.u.value32;
363 }
364
365 RTMemTmpFree(pData);
366 return rc;
367}
368
369DECLVBGL(int) VbglR0SfWrite(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile,
370 uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer, bool fLocked)
371{
372 int rc;
373 VBoxSFWrite data;
374
375 VBOX_INIT_CALL(&data.callInfo, WRITE, pClient);
376
377 data.root.type = VMMDevHGCMParmType_32bit;
378 data.root.u.value32 = pMap->root;
379
380 data.handle.type = VMMDevHGCMParmType_64bit;
381 data.handle.u.value64 = hFile;
382 data.offset.type = VMMDevHGCMParmType_64bit;
383 data.offset.u.value64 = offset;
384 data.cb.type = VMMDevHGCMParmType_32bit;
385 data.cb.u.value32 = *pcbBuffer;
386 data.buffer.type = fLocked ? VMMDevHGCMParmType_LinAddr_Locked_In : VMMDevHGCMParmType_LinAddr_In;
387 data.buffer.u.Pointer.size = *pcbBuffer;
388 data.buffer.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
389
390 rc = VbglR0HGCMCallRaw(pClient->handle, &data.callInfo, sizeof(data));
391/* Log(("VBOXSF: VbglR0SfWrite: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
392 if (RT_SUCCESS(rc))
393 {
394 rc = data.callInfo.Hdr.rc;
395 *pcbBuffer = data.cb.u.value32;
396 }
397 return rc;
398}
399
400DECLVBGL(int) VbglR0SfWritePhysCont(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile, uint64_t offset,
401 uint32_t *pcbBuffer, RTCCPHYS PhysBuffer)
402{
403 uint32_t cbToWrite = *pcbBuffer;
404 uint32_t cPages = RT_ALIGN_32((PhysBuffer & PAGE_OFFSET_MASK) + cbToWrite, PAGE_SIZE) >> PAGE_SHIFT;
405 uint32_t cbData = (uint32_t)(sizeof(VBoxSFWrite) + RT_UOFFSETOF_DYN(HGCMPageListInfo, aPages[cPages]));
406 VBoxSFWrite *pData = (VBoxSFWrite *)RTMemTmpAlloc(cbData);
407 HGCMPageListInfo *pPgLst = (HGCMPageListInfo *)(pData + 1);
408 uint32_t iPage;
409 int rc;
410
411 if (RT_UNLIKELY(!pData))
412 return VERR_NO_TMP_MEMORY;
413
414 VBOX_INIT_CALL_EX(&pData->callInfo, WRITE, pClient, cbData);
415
416 pData->root.type = VMMDevHGCMParmType_32bit;
417 pData->root.u.value32 = pMap->root;
418
419 pData->handle.type = VMMDevHGCMParmType_64bit;
420 pData->handle.u.value64 = hFile;
421 pData->offset.type = VMMDevHGCMParmType_64bit;
422 pData->offset.u.value64 = offset;
423 pData->cb.type = VMMDevHGCMParmType_32bit;
424 pData->cb.u.value32 = cbToWrite;
425 pData->buffer.type = VMMDevHGCMParmType_PageList;
426 pData->buffer.u.PageList.size = cbToWrite;
427 pData->buffer.u.PageList.offset = sizeof(VBoxSFWrite);
428
429 pPgLst->flags = VBOX_HGCM_F_PARM_DIRECTION_TO_HOST;
430 pPgLst->offFirstPage = (uint16_t)(PhysBuffer & PAGE_OFFSET_MASK);
431 pPgLst->cPages = cPages;
432 PhysBuffer &= ~(RTCCPHYS)PAGE_OFFSET_MASK;
433 for (iPage = 0; iPage < cPages; iPage++, PhysBuffer += PAGE_SIZE)
434 pPgLst->aPages[iPage] = PhysBuffer;
435
436 rc = VbglR0HGCMCallRaw(pClient->handle, &pData->callInfo, cbData);
437/* Log(("VBOXSF: VbglR0SfWritePhysCont: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
438 if (RT_SUCCESS(rc))
439 {
440 rc = pData->callInfo.Hdr.rc;
441 *pcbBuffer = pData->cb.u.value32;
442 }
443
444 RTMemTmpFree(pData);
445 return rc;
446
447}
448
449DECLVBGL(int) VbglR0SfWritePageList(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile, uint64_t offset, uint32_t *pcbBuffer,
450 uint16_t offFirstPage, uint16_t cPages, RTGCPHYS64 *paPages)
451{
452 uint32_t cbToWrite = *pcbBuffer;
453 uint32_t cbData = (uint32_t)(sizeof(VBoxSFWrite) + RT_UOFFSETOF_DYN(HGCMPageListInfo, aPages[cPages]));
454 VBoxSFWrite *pData = (VBoxSFWrite *)RTMemTmpAlloc(cbData);
455 HGCMPageListInfo *pPgLst = (HGCMPageListInfo *)(pData + 1);
456 uint16_t iPage;
457 int rc;
458
459 if (RT_UNLIKELY(!pData))
460 return VERR_NO_TMP_MEMORY;
461
462 VBOX_INIT_CALL_EX(&pData->callInfo, WRITE, pClient, cbData);
463
464 pData->root.type = VMMDevHGCMParmType_32bit;
465 pData->root.u.value32 = pMap->root;
466
467 pData->handle.type = VMMDevHGCMParmType_64bit;
468 pData->handle.u.value64 = hFile;
469 pData->offset.type = VMMDevHGCMParmType_64bit;
470 pData->offset.u.value64 = offset;
471 pData->cb.type = VMMDevHGCMParmType_32bit;
472 pData->cb.u.value32 = cbToWrite;
473 pData->buffer.type = VMMDevHGCMParmType_PageList;
474 pData->buffer.u.PageList.size = cbToWrite;
475 pData->buffer.u.PageList.offset = sizeof(VBoxSFWrite);
476
477 pPgLst->flags = VBOX_HGCM_F_PARM_DIRECTION_TO_HOST;
478 pPgLst->offFirstPage = offFirstPage;
479 pPgLst->cPages = cPages;
480 for (iPage = 0; iPage < cPages; iPage++)
481 pPgLst->aPages[iPage] = paPages[iPage];
482
483 rc = VbglR0HGCMCallRaw(pClient->handle, &pData->callInfo, cbData);
484/* Log(("VBOXSF: VbglR0SfWritePageList: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
485 if (RT_SUCCESS(rc))
486 {
487 rc = pData->callInfo.Hdr.rc;
488 *pcbBuffer = pData->cb.u.value32;
489 }
490
491 RTMemTmpFree(pData);
492 return rc;
493}
494
495DECLVBGL(int) VbglR0SfFlush(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile)
496{
497 int rc;
498 VBoxSFFlush data;
499
500 VBOX_INIT_CALL(&data.callInfo, FLUSH, pClient);
501
502 data.root.type = VMMDevHGCMParmType_32bit;
503 data.root.u.value32 = pMap->root;
504
505 data.handle.type = VMMDevHGCMParmType_64bit;
506 data.handle.u.value64 = hFile;
507
508 rc = VbglR0HGCMCall(pClient->handle, &data.callInfo, sizeof(data));
509/* Log(("VBOXSF: VbglR0SfFlush: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
510 return rc;
511}
512
513DECLVBGL(int) VbglR0SfDirInfo(
514 PVBGLSFCLIENT pClient,
515 PVBGLSFMAP pMap,
516 SHFLHANDLE hFile,
517 PSHFLSTRING ParsedPath,
518 uint32_t flags,
519 uint32_t index,
520 uint32_t *pcbBuffer,
521 PSHFLDIRINFO pBuffer,
522 uint32_t *pcFiles)
523{
524 int rc;
525 VBoxSFList data;
526
527 VBOX_INIT_CALL(&data.callInfo, LIST, pClient);
528
529 data.root.type = VMMDevHGCMParmType_32bit;
530 data.root.u.value32 = pMap->root;
531
532 data.handle.type = VMMDevHGCMParmType_64bit;
533 data.handle.u.value64 = hFile;
534 data.flags.type = VMMDevHGCMParmType_32bit;
535 data.flags.u.value32 = flags;
536 data.cb.type = VMMDevHGCMParmType_32bit;
537 data.cb.u.value32 = *pcbBuffer;
538 data.path.type = VMMDevHGCMParmType_LinAddr_In;
539 data.path.u.Pointer.size = ParsedPath ? ShflStringSizeOfBuffer(ParsedPath) : 0;
540 data.path.u.Pointer.u.linearAddr = (uintptr_t) ParsedPath;
541
542 data.buffer.type = VMMDevHGCMParmType_LinAddr_Out;
543 data.buffer.u.Pointer.size = *pcbBuffer;
544 data.buffer.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
545
546 data.resumePoint.type = VMMDevHGCMParmType_32bit;
547 data.resumePoint.u.value32 = index;
548 data.cFiles.type = VMMDevHGCMParmType_32bit;
549 data.cFiles.u.value32 = 0; /* out parameters only */
550
551 rc = VbglR0HGCMCall(pClient->handle, &data.callInfo, sizeof(data));
552/* Log(("VBOXSF: VbglR0SfDirInfo: rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
553 *pcbBuffer = data.cb.u.value32;
554 *pcFiles = data.cFiles.u.value32;
555 return rc;
556}
557
558DECLVBGL(int) VbglR0SfFsInfo(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile,
559 uint32_t flags, uint32_t *pcbBuffer, PSHFLDIRINFO pBuffer)
560{
561 int rc;
562 VBoxSFInformation data;
563
564 VBOX_INIT_CALL(&data.callInfo, INFORMATION, pClient);
565
566 data.root.type = VMMDevHGCMParmType_32bit;
567 data.root.u.value32 = pMap->root;
568
569 data.handle.type = VMMDevHGCMParmType_64bit;
570 data.handle.u.value64 = hFile;
571 data.flags.type = VMMDevHGCMParmType_32bit;
572 data.flags.u.value32 = flags;
573 data.cb.type = VMMDevHGCMParmType_32bit;
574 data.cb.u.value32 = *pcbBuffer;
575 data.info.type = VMMDevHGCMParmType_LinAddr;
576 data.info.u.Pointer.size = *pcbBuffer;
577 data.info.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
578
579 rc = VbglR0HGCMCallRaw(pClient->handle, &data.callInfo, sizeof(data));
580/* Log(("VBOXSF: VbglR0SfFsInfo: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
581 if (RT_SUCCESS(rc))
582 {
583 rc = data.callInfo.Hdr.rc;
584 *pcbBuffer = data.cb.u.value32;
585 }
586 return rc;
587}
588
589DECLVBGL(int) VbglR0SfLock(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, SHFLHANDLE hFile,
590 uint64_t offset, uint64_t cbSize, uint32_t fLock)
591{
592 int rc;
593 VBoxSFLock data;
594
595 VBOX_INIT_CALL(&data.callInfo, LOCK, pClient);
596
597 data.root.type = VMMDevHGCMParmType_32bit;
598 data.root.u.value32 = pMap->root;
599
600 data.handle.type = VMMDevHGCMParmType_64bit;
601 data.handle.u.value64 = hFile;
602 data.offset.type = VMMDevHGCMParmType_64bit;
603 data.offset.u.value64 = offset;
604 data.length.type = VMMDevHGCMParmType_64bit;
605 data.length.u.value64 = cbSize;
606
607 data.flags.type = VMMDevHGCMParmType_32bit;
608 data.flags.u.value32 = fLock;
609
610 rc = VbglR0HGCMCall(pClient->handle, &data.callInfo, sizeof(data));
611/* Log(("VBOXSF: VbglR0SfLock: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
612 return rc;
613}
614
615DECLVBGL(int) VbglR0SfSetUtf8(PVBGLSFCLIENT pClient)
616{
617 int rc;
618 VBGLIOCHGCMCALL callInfo;
619
620 VBOX_INIT_CALL(&callInfo, SET_UTF8, pClient);
621 rc = VbglR0HGCMCall(pClient->handle, &callInfo, sizeof(callInfo));
622/* Log(("VBOXSF: VbglR0SfSetUtf8: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
623 return rc;
624}
625
626DECLVBGL(int) VbglR0SfReadLink(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, PSHFLSTRING pParsedPath, uint32_t cbBuffer, uint8_t *pBuffer)
627{
628 int rc;
629 VBoxSFReadLink data;
630
631 VBOX_INIT_CALL(&data.callInfo, READLINK, pClient);
632
633 data.root.type = VMMDevHGCMParmType_32bit;
634 data.root.u.value32 = pMap->root;
635
636 data.path.type = VMMDevHGCMParmType_LinAddr_In;
637 data.path.u.Pointer.size = ShflStringSizeOfBuffer (pParsedPath);
638 data.path.u.Pointer.u.linearAddr = (uintptr_t)pParsedPath;
639
640 data.buffer.type = VMMDevHGCMParmType_LinAddr_Out;
641 data.buffer.u.Pointer.size = cbBuffer;
642 data.buffer.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
643
644 rc = VbglR0HGCMCall(pClient->handle, &data.callInfo, sizeof(data));
645/* Log(("VBOXSF: VbglR0SfReadLink: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
646 return rc;
647}
648
649DECLVBGL(int) VbglR0SfSymlink(PVBGLSFCLIENT pClient, PVBGLSFMAP pMap, PSHFLSTRING pNewPath, PSHFLSTRING pOldPath,
650 PSHFLFSOBJINFO pBuffer)
651{
652 int rc;
653 VBoxSFSymlink data;
654
655 VBOX_INIT_CALL(&data.callInfo, SYMLINK, pClient);
656
657 data.root.type = VMMDevHGCMParmType_32bit;
658 data.root.u.value32 = pMap->root;
659
660 data.newPath.type = VMMDevHGCMParmType_LinAddr_In;
661 data.newPath.u.Pointer.size = ShflStringSizeOfBuffer (pNewPath);
662 data.newPath.u.Pointer.u.linearAddr = (uintptr_t)pNewPath;
663
664 data.oldPath.type = VMMDevHGCMParmType_LinAddr_In;
665 data.oldPath.u.Pointer.size = ShflStringSizeOfBuffer (pOldPath);
666 data.oldPath.u.Pointer.u.linearAddr = (uintptr_t)pOldPath;
667
668 data.info.type = VMMDevHGCMParmType_LinAddr_Out;
669 data.info.u.Pointer.size = sizeof(SHFLFSOBJINFO);
670 data.info.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
671
672 rc = VbglR0HGCMCall(pClient->handle, &data.callInfo, sizeof(data));
673/* Log(("VBOXSF: VbglR0SfSymlink: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
674 return rc;
675}
676
677DECLVBGL(int) VbglR0SfSetSymlinks(PVBGLSFCLIENT pClient)
678{
679 int rc;
680 VBGLIOCHGCMCALL callInfo;
681
682 VBOX_INIT_CALL(&callInfo, SET_SYMLINKS, pClient);
683 rc = VbglR0HGCMCall(pClient->handle, &callInfo, sizeof(callInfo));
684/* Log(("VBOXSF: VbglR0SfSetSymlinks: VbglR0HGCMCall rc = %#x, result = %#x\n", rc, data.callInfo.Hdr.rc)); */
685 return rc;
686}
687
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette