VirtualBox

source: vbox/trunk/include/VBox/shflsvc.h@ 76463

Last change on this file since 76463 was 76421, checked in by vboxsync, 6 years ago

VBox/shflsvc.h: Use errcore.h rather than err.h. bugref:9344

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 53.2 KB
Line 
1/** @file
2 * Shared Folders - Common header for host service and guest clients.
3 */
4
5/*
6 * Copyright (C) 2006-2018 Oracle Corporation
7 *
8 * Permission is hereby granted, free of charge, to any person
9 * obtaining a copy of this software and associated documentation
10 * files (the "Software"), to deal in the Software without
11 * restriction, including without limitation the rights to use,
12 * copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following
15 * conditions:
16 *
17 * The above copyright notice and this permission notice shall be
18 * included in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
28 */
29
30#ifndef ___VBox_shflsvc_h
31#define ___VBox_shflsvc_h
32
33#ifndef IN_MODULE
34# include <VBox/VMMDevCoreTypes.h>
35# include <VBox/VBoxGuestCoreTypes.h>
36#endif
37#include <iprt/string.h>
38#include <VBox/cdefs.h>
39#include <VBox/types.h>
40#include <iprt/fs.h>
41#include <iprt/assert.h>
42#include <iprt/errcore.h>
43#if defined(IN_RING3) || (defined(IN_RING0) && defined(RT_OS_DARWIN))
44# include <iprt/mem.h>
45#endif
46#include <iprt/utf16.h>
47
48
49
50/** @defgroup grp_vbox_shfl Shared Folder Interface Definition.
51 *
52 * Structures shared between guest and the service can be relocated and use
53 * offsets to point to variable length parts.
54 *
55 * Shared folders protocol works with handles. Before doing any action on a
56 * file system object, one have to obtain the object handle via a SHFL_FN_CREATE
57 * request. A handle must be closed with SHFL_FN_CLOSE.
58 *
59 * @{
60 */
61
62/** @name Some bit flag manipulation macros.
63 * @{ */
64#ifndef BIT_FLAG
65#define BIT_FLAG(__Field,__Flag) ((__Field) & (__Flag))
66#endif
67
68#ifndef BIT_FLAG_SET
69#define BIT_FLAG_SET(__Field,__Flag) ((__Field) |= (__Flag))
70#endif
71
72#ifndef BIT_FLAG_CLEAR
73#define BIT_FLAG_CLEAR(__Field,__Flag) ((__Field) &= ~(__Flag))
74#endif
75/** @} */
76
77
78/** @name Shared Folders service functions. (guest)
79 * @{
80 */
81/** Query mappings changes.
82 * @note Description is currently misleading, it will always return all
83 * current mappings with SHFL_MS_NEW status. Only modification is the
84 * SHFL_MF_AUTOMOUNT flag that causes filtering out non-auto mounts. */
85#define SHFL_FN_QUERY_MAPPINGS (1)
86/** Query the name of a map. */
87#define SHFL_FN_QUERY_MAP_NAME (2)
88/** Open/create object. */
89#define SHFL_FN_CREATE (3)
90/** Close object handle. */
91#define SHFL_FN_CLOSE (4)
92/** Read object content. */
93#define SHFL_FN_READ (5)
94/** Write new object content. */
95#define SHFL_FN_WRITE (6)
96/** Lock/unlock a range in the object. */
97#define SHFL_FN_LOCK (7)
98/** List object content. */
99#define SHFL_FN_LIST (8)
100/** Query/set object information. */
101#define SHFL_FN_INFORMATION (9)
102/** Remove object */
103#define SHFL_FN_REMOVE (11)
104/** Map folder (legacy) */
105#define SHFL_FN_MAP_FOLDER_OLD (12)
106/** Unmap folder */
107#define SHFL_FN_UNMAP_FOLDER (13)
108/** Rename object (possibly moving it to another directory) */
109#define SHFL_FN_RENAME (14)
110/** Flush file */
111#define SHFL_FN_FLUSH (15)
112/** @todo macl, a description, please. */
113#define SHFL_FN_SET_UTF8 (16)
114/** Map folder */
115#define SHFL_FN_MAP_FOLDER (17)
116/** Read symlink destination.
117 * @since VBox 4.0 */
118#define SHFL_FN_READLINK (18)
119/** Create symlink.
120 * @since VBox 4.0 */
121#define SHFL_FN_SYMLINK (19)
122/** Ask host to show symlinks
123 * @since VBox 4.0 */
124#define SHFL_FN_SET_SYMLINKS (20)
125/** Query information about a map.
126 * @since VBox 6.0 */
127#define SHFL_FN_QUERY_MAP_INFO (21)
128/** Wait for changes to the mappings.
129 * @since VBox 6.0 */
130#define SHFL_FN_WAIT_FOR_MAPPINGS_CHANGES (22)
131/** Cancel all waits for changes to the mappings for the calling client.
132 * The wait calls will return VERR_CANCELLED.
133 * @since VBox 6.0 */
134#define SHFL_FN_CANCEL_MAPPINGS_CHANGES_WAITS (23)
135/** Sets the file size.
136 * @since VBox 6.0 */
137#define SHFL_FN_SET_FILE_SIZE (24)
138/** @} */
139
140
141/** @name Shared Folders service functions. (host)
142 * @{
143 */
144/** Add shared folder mapping. */
145#define SHFL_FN_ADD_MAPPING (1)
146/** Remove shared folder mapping. */
147#define SHFL_FN_REMOVE_MAPPING (2)
148/** Set the led status light address. */
149#define SHFL_FN_SET_STATUS_LED (3)
150/** Allow the guest to create symbolic links
151 * @since VBox 4.0 */
152#define SHFL_FN_ALLOW_SYMLINKS_CREATE (4)
153/** @} */
154
155
156/** Root handle for a mapping. Root handles are unique.
157 *
158 * @note Function parameters structures consider the root handle as 32 bit
159 * value. If the typedef will be changed, then function parameters must be
160 * changed accordingly. All those parameters are marked with SHFLROOT in
161 * comments.
162 */
163typedef uint32_t SHFLROOT;
164
165/** NIL shared folder root handle. */
166#define SHFL_ROOT_NIL ((SHFLROOT)~0)
167
168
169/** A shared folders handle for an opened object. */
170typedef uint64_t SHFLHANDLE;
171
172#define SHFL_HANDLE_NIL ((SHFLHANDLE)~0LL)
173#define SHFL_HANDLE_ROOT ((SHFLHANDLE)0LL)
174
175/** Hardcoded maximum length (in chars) of a shared folder name. */
176#define SHFL_MAX_LEN (256)
177/** Hardcoded maximum number of shared folder mapping available to the guest. */
178#define SHFL_MAX_MAPPINGS (64)
179
180
181/** @name Shared Folders strings. They can be either UTF-8 or UTF-16.
182 * @{
183 */
184
185/**
186 * Shared folder string buffer structure.
187 */
188typedef struct _SHFLSTRING
189{
190 /** Allocated size of the String member in bytes. */
191 uint16_t u16Size;
192
193 /** Length of string without trailing nul in bytes. */
194 uint16_t u16Length;
195
196 /** UTF-8 or UTF-16 string. Nul terminated. */
197 union
198 {
199#if 1
200 char ach[1]; /**< UTF-8 but with a type that makes some more sense. */
201 uint8_t utf8[1];
202 RTUTF16 utf16[1];
203 uint16_t ucs2[1]; /**< misnomer, use utf16. */
204#else
205 uint8_t utf8[RT_FLEXIBLE_ARRAY_IN_NESTED_UNION];
206 RTUTF16 utf16[RT_FLEXIBLE_ARRAY_IN_NESTED_UNION];
207 RTUTF16 ucs2[RT_FLEXIBLE_ARRAY_IN_NESTED_UNION]; /**< misnomer, use utf16. */
208#endif
209 } String;
210} SHFLSTRING;
211AssertCompileSize(RTUTF16, 2);
212AssertCompileSize(SHFLSTRING, 6);
213AssertCompileMemberOffset(SHFLSTRING, String, 4);
214/** The size of SHFLSTRING w/o the string part. */
215#define SHFLSTRING_HEADER_SIZE 4
216AssertCompileMemberOffset(SHFLSTRING, String, SHFLSTRING_HEADER_SIZE);
217
218/** Pointer to a shared folder string buffer. */
219typedef SHFLSTRING *PSHFLSTRING;
220/** Pointer to a const shared folder string buffer. */
221typedef const SHFLSTRING *PCSHFLSTRING;
222
223/** Calculate size of the string. */
224DECLINLINE(uint32_t) ShflStringSizeOfBuffer(PCSHFLSTRING pString)
225{
226 return pString ? (uint32_t)(SHFLSTRING_HEADER_SIZE + pString->u16Size) : 0;
227}
228
229DECLINLINE(uint32_t) ShflStringLength(PCSHFLSTRING pString)
230{
231 return pString ? pString->u16Length : 0;
232}
233
234DECLINLINE(PSHFLSTRING) ShflStringInitBuffer(void *pvBuffer, uint32_t u32Size)
235{
236 PSHFLSTRING pString = NULL;
237 const uint32_t u32HeaderSize = SHFLSTRING_HEADER_SIZE;
238
239 /*
240 * Check that the buffer size is big enough to hold a zero sized string
241 * and is not too big to fit into 16 bit variables.
242 */
243 if (u32Size >= u32HeaderSize && u32Size - u32HeaderSize <= 0xFFFF)
244 {
245 pString = (PSHFLSTRING)pvBuffer;
246 pString->u16Size = (uint16_t)(u32Size - u32HeaderSize);
247 pString->u16Length = 0;
248 if (pString->u16Size >= sizeof(pString->String.ucs2[0]))
249 pString->String.ucs2[0] = 0;
250 else if (pString->u16Size >= sizeof(pString->String.utf8[0]))
251 pString->String.utf8[0] = 0;
252 }
253
254 return pString;
255}
256
257/**
258 * Helper for copying one string into another.
259 *
260 * @returns IPRT status code.
261 * @retval VERR_BUFFER_OVERFLOW and pDst->u16Length set to source length.
262 * @param pDst The destination string.
263 * @param pSrc The source string.
264 * @param cbTerm The size of the string terminator.
265 */
266DECLINLINE(int) ShflStringCopy(PSHFLSTRING pDst, PCSHFLSTRING pSrc, size_t cbTerm)
267{
268 int rc = VINF_SUCCESS;
269 if (pDst->u16Size >= pSrc->u16Length + cbTerm)
270 {
271 memcpy(&pDst->String, &pSrc->String, pSrc->u16Length);
272 switch (cbTerm)
273 {
274 default:
275 case 2: pDst->String.ach[pSrc->u16Length + 1] = '\0'; RT_FALL_THROUGH();
276 case 1: pDst->String.ach[pSrc->u16Length + 0] = '\0'; break;
277 case 0: break;
278 }
279 }
280 else
281 rc = VERR_BUFFER_OVERFLOW;
282 pDst->u16Length = pSrc->u16Length;
283 return rc;
284}
285
286#if defined(IN_RING3) \
287 || (defined(IN_RING0) && defined(RT_OS_DARWIN))
288
289/**
290 * Duplicates a string using RTMemAlloc as allocator.
291 *
292 * @returns Copy, NULL if out of memory.
293 * @param pSrc The source string.
294 */
295DECLINLINE(PSHFLSTRING) ShflStringDup(PCSHFLSTRING pSrc)
296{
297 PSHFLSTRING pDst = (PSHFLSTRING)RTMemAlloc(SHFLSTRING_HEADER_SIZE + pSrc->u16Size);
298 if (pDst)
299 {
300 pDst->u16Length = pSrc->u16Length;
301 pDst->u16Size = pSrc->u16Size;
302 memcpy(&pDst->String, &pSrc->String, pSrc->u16Size);
303 }
304 return pDst;
305}
306
307/**
308 * Duplicates a UTF-16 string using RTMemAlloc as allocator.
309 *
310 * The returned string will be using UTF-16 encoding too.
311 *
312 * @returns Pointer to copy on success - pass to RTMemFree to free.
313 * NULL if out of memory.
314 * @param pwszSrc The source string. Encoding is not checked.
315 */
316DECLINLINE(PSHFLSTRING) ShflStringDupUtf16(PCRTUTF16 pwszSrc)
317{
318 size_t cwcSrc = RTUtf16Len(pwszSrc);
319 if (cwcSrc < UINT16_MAX / sizeof(RTUTF16))
320 {
321 PSHFLSTRING pDst = (PSHFLSTRING)RTMemAlloc(SHFLSTRING_HEADER_SIZE + (cwcSrc + 1) * sizeof(RTUTF16));
322 if (pDst)
323 {
324 pDst->u16Length = (uint16_t)(cwcSrc * sizeof(RTUTF16));
325 pDst->u16Size = (uint16_t)((cwcSrc + 1) * sizeof(RTUTF16));
326 memcpy(&pDst->String, pwszSrc, (cwcSrc + 1) * sizeof(RTUTF16));
327 return pDst;
328 }
329 }
330 AssertFailed();
331 return NULL;
332}
333
334/**
335 * Duplicates a UTF-8 string using RTMemAlloc as allocator.
336 *
337 * The returned string will be using UTF-8 encoding too.
338 *
339 * @returns Pointer to copy on success - pass to RTMemFree to free.
340 * NULL if out of memory.
341 * @param pszSrc The source string. Encoding is not checked.
342 */
343DECLINLINE(PSHFLSTRING) ShflStringDupUtf8(const char *pszSrc)
344{
345 size_t cchSrc = strlen(pszSrc);
346 if (cchSrc < UINT16_MAX)
347 {
348 PSHFLSTRING pDst = (PSHFLSTRING)RTMemAlloc(SHFLSTRING_HEADER_SIZE + cchSrc + 1);
349 if (pDst)
350 {
351 pDst->u16Length = (uint16_t)cchSrc;
352 pDst->u16Size = (uint16_t)(cchSrc + 1);
353 memcpy(&pDst->String, pszSrc, cchSrc + 1);
354 return pDst;
355 }
356 }
357 AssertFailed();
358 return NULL;
359}
360
361/**
362 * Creates a UTF-16 duplicate of the UTF-8 string @a pszSrc using RTMemAlloc as
363 * allocator.
364 *
365 * @returns Pointer to copy on success - pass to RTMemFree to free.
366 * NULL if out of memory or invalid UTF-8 encoding.
367 * @param pszSrc The source string.
368 */
369DECLINLINE(PSHFLSTRING) ShflStringDupUtf8AsUtf16(const char *pszSrc)
370{
371 size_t cwcConversion = 0;
372 int rc = RTStrCalcUtf16LenEx(pszSrc, RTSTR_MAX, &cwcConversion);
373 if ( RT_SUCCESS(rc)
374 && cwcConversion < UINT16_MAX / sizeof(RTUTF16))
375 {
376 PSHFLSTRING pDst = (PSHFLSTRING)RTMemAlloc(SHFLSTRING_HEADER_SIZE + (cwcConversion + 1) * sizeof(RTUTF16));
377 if (pDst)
378 {
379 PRTUTF16 pwszDst = pDst->String.ucs2;
380 pDst->u16Size = (uint16_t)((cwcConversion + 1) * sizeof(RTUTF16));
381 rc = RTStrToUtf16Ex(pszSrc, RTSTR_MAX, &pwszDst, cwcConversion + 1, &cwcConversion);
382 AssertRC(rc);
383 if (RT_SUCCESS(rc))
384 {
385 pDst->u16Length = (uint16_t)(cwcConversion * sizeof(RTUTF16));
386 return pDst;
387 }
388 RTMemFree(pDst);
389 }
390 }
391 AssertMsgFailed(("rc=%Rrc cwcConversion=%#x\n", rc, cwcConversion));
392 return NULL;
393}
394
395/**
396 * Copies a UTF-8 string to a buffer as UTF-16.
397 *
398 * @returns IPRT status code.
399 * @param pDst The destination buffer.
400 * @param pszSrc The source string.
401 * @param cchSrc The source string length, or RTSTR_MAX.
402 */
403DECLINLINE(int) ShflStringCopyUtf8AsUtf16(PSHFLSTRING pDst, const char *pszSrc, size_t cchSrc)
404{
405 int rc;
406 size_t cwcDst = 0;
407 if (pDst->u16Size >= sizeof(RTUTF16))
408 {
409 PRTUTF16 pwszDst = pDst->String.utf16;
410 rc = RTStrToUtf16Ex(pszSrc, cchSrc, &pwszDst, pDst->u16Size / sizeof(RTUTF16), &cwcDst);
411 }
412 else
413 {
414 RTStrCalcUtf16LenEx(pszSrc, cchSrc, &cwcDst);
415 rc = VERR_BUFFER_OVERFLOW;
416 }
417 pDst->u16Length = (uint16_t)(cwcDst * sizeof(RTUTF16));
418 return rc != VERR_BUFFER_OVERFLOW || cwcDst < UINT16_MAX / sizeof(RTUTF16) ? rc : VERR_TOO_MUCH_DATA;
419}
420
421/**
422 * Copies a UTF-8 string buffer to another buffer as UTF-16
423 *
424 * @returns IPRT status code.
425 * @param pDst The destination buffer (UTF-16).
426 * @param pSrc The source buffer (UTF-8).
427 */
428DECLINLINE(int) ShflStringCopyUtf8BufAsUtf16(PSHFLSTRING pDst, PCSHFLSTRING pSrc)
429{
430 return ShflStringCopyUtf8AsUtf16(pDst, pSrc->String.ach, pSrc->u16Length);
431}
432
433/**
434 * Copies a UTF-16 string to a buffer as UTF-8
435 *
436 * @returns IPRT status code.
437 * @param pDst The destination buffer.
438 * @param pwszSrc The source string.
439 * @param cwcSrc The source string length, or RTSTR_MAX.
440 */
441DECLINLINE(int) ShflStringCopyUtf16AsUtf8(PSHFLSTRING pDst, PCRTUTF16 pwszSrc, size_t cwcSrc)
442{
443 int rc;
444 size_t cchDst = 0;
445 if (pDst->u16Size > 0)
446 {
447 char *pszDst = pDst->String.ach;
448 rc = RTUtf16ToUtf8Ex(pwszSrc, cwcSrc, &pszDst, pDst->u16Size, &cchDst);
449 }
450 else
451 {
452 RTUtf16CalcUtf8LenEx(pwszSrc, cwcSrc, &cchDst);
453 rc = VERR_BUFFER_OVERFLOW;
454 }
455 pDst->u16Length = (uint16_t)cchDst;
456 return rc != VERR_BUFFER_OVERFLOW || cchDst < UINT16_MAX ? rc : VERR_TOO_MUCH_DATA;
457}
458
459/**
460 * Copies a UTF-16 string buffer to another buffer as UTF-8
461 *
462 * @returns IPRT status code.
463 * @param pDst The destination buffer (UTF-8).
464 * @param pSrc The source buffer (UTF-16).
465 */
466DECLINLINE(int) ShflStringCopyUtf16BufAsUtf8(PSHFLSTRING pDst, PCSHFLSTRING pSrc)
467{
468 return ShflStringCopyUtf16AsUtf8(pDst, pSrc->String.utf16, pSrc->u16Length / sizeof(RTUTF16));
469}
470
471#endif /* IN_RING3 */
472
473/**
474 * Validates a HGCM string output parameter.
475 *
476 * @returns true if valid, false if not.
477 *
478 * @param pString The string buffer pointer.
479 * @param cbBuf The buffer size from the parameter.
480 */
481DECLINLINE(bool) ShflStringIsValidOut(PCSHFLSTRING pString, uint32_t cbBuf)
482{
483 if (RT_LIKELY(cbBuf > RT_UOFFSETOF(SHFLSTRING, String)))
484 if (RT_LIKELY((uint32_t)pString->u16Size + RT_UOFFSETOF(SHFLSTRING, String) <= cbBuf))
485 if (RT_LIKELY(pString->u16Length < pString->u16Size))
486 return true;
487 return false;
488}
489
490/**
491 * Validates a HGCM string input parameter.
492 *
493 * @returns true if valid, false if not.
494 *
495 * @param pString The string buffer pointer.
496 * @param cbBuf The buffer size from the parameter.
497 * @param fUtf8Not16 Set if UTF-8 encoding, clear if UTF-16 encoding.
498 */
499DECLINLINE(bool) ShflStringIsValidIn(PCSHFLSTRING pString, uint32_t cbBuf, bool fUtf8Not16)
500{
501 int rc;
502 if (RT_LIKELY(cbBuf > RT_UOFFSETOF(SHFLSTRING, String)))
503 {
504 if (RT_LIKELY((uint32_t)pString->u16Size + RT_UOFFSETOF(SHFLSTRING, String) <= cbBuf))
505 {
506 if (fUtf8Not16)
507 {
508 /* UTF-8: */
509 if (RT_LIKELY(pString->u16Length < pString->u16Size))
510 {
511 rc = RTStrValidateEncodingEx((const char *)&pString->String.utf8[0], pString->u16Length + 1,
512 RTSTR_VALIDATE_ENCODING_EXACT_LENGTH | RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED);
513 if (RT_SUCCESS(rc))
514 return true;
515 }
516 }
517 else
518 {
519 /* UTF-16: */
520 if (RT_LIKELY(!(pString->u16Length & 1)))
521 {
522 if (RT_LIKELY((uint32_t)sizeof(RTUTF16) + pString->u16Length <= pString->u16Size))
523 {
524 rc = RTUtf16ValidateEncodingEx(&pString->String.ucs2[0], pString->u16Length / 2 + 1,
525 RTSTR_VALIDATE_ENCODING_EXACT_LENGTH
526 | RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED);
527 if (RT_SUCCESS(rc))
528 return true;
529 }
530 }
531 }
532 }
533 }
534 return false;
535}
536
537/**
538 * Validates an optional HGCM string input parameter.
539 *
540 * @returns true if valid, false if not.
541 *
542 * @param pString The string buffer pointer. Can be NULL.
543 * @param cbBuf The buffer size from the parameter.
544 * @param fUtf8Not16 Set if UTF-8 encoding, clear if UTF-16 encoding.
545 */
546DECLINLINE(bool) ShflStringIsValidOrNullIn(PCSHFLSTRING pString, uint32_t cbBuf, bool fUtf8Not16)
547{
548 if (pString)
549 return ShflStringIsValidIn(pString, cbBuf, fUtf8Not16);
550 if (RT_LIKELY(cbBuf == 0))
551 return true;
552 return false;
553}
554
555/** Macro for passing as string as a HGCM parmeter (pointer) */
556#define SHFLSTRING_TO_HGMC_PARAM(a_pParam, a_pString) \
557 do { \
558 (a_pParam)->type = VBOX_HGCM_SVC_PARM_PTR; \
559 (a_pParam)->u.pointer.addr = (a_pString); \
560 (a_pParam)->u.pointer.size = ShflStringSizeOfBuffer(a_pString); \
561 } while (0)
562
563/** @} */
564
565
566/**
567 * The available additional information in a SHFLFSOBJATTR object.
568 */
569typedef enum SHFLFSOBJATTRADD
570{
571 /** No additional information is available / requested. */
572 SHFLFSOBJATTRADD_NOTHING = 1,
573 /** The additional unix attributes (SHFLFSOBJATTR::u::Unix) are
574 * available / requested. */
575 SHFLFSOBJATTRADD_UNIX,
576 /** The additional extended attribute size (SHFLFSOBJATTR::u::EASize) is
577 * available / requested. */
578 SHFLFSOBJATTRADD_EASIZE,
579 /** The last valid item (inclusive).
580 * The valid range is SHFLFSOBJATTRADD_NOTHING thru
581 * SHFLFSOBJATTRADD_LAST. */
582 SHFLFSOBJATTRADD_LAST = SHFLFSOBJATTRADD_EASIZE,
583
584 /** The usual 32-bit hack. */
585 SHFLFSOBJATTRADD_32BIT_SIZE_HACK = 0x7fffffff
586} SHFLFSOBJATTRADD;
587
588
589/* Assert sizes of the IRPT types we're using below. */
590AssertCompileSize(RTFMODE, 4);
591AssertCompileSize(RTFOFF, 8);
592AssertCompileSize(RTINODE, 8);
593AssertCompileSize(RTTIMESPEC, 8);
594AssertCompileSize(RTDEV, 4);
595AssertCompileSize(RTUID, 4);
596
597/**
598 * Shared folder filesystem object attributes.
599 */
600#pragma pack(1)
601typedef struct SHFLFSOBJATTR
602{
603 /** Mode flags (st_mode). RTFS_UNIX_*, RTFS_TYPE_*, and RTFS_DOS_*.
604 * @remarks We depend on a number of RTFS_ defines to remain unchanged.
605 * Fortuntately, these are depending on windows, dos and unix
606 * standard values, so this shouldn't be much of a pain. */
607 RTFMODE fMode;
608
609 /** The additional attributes available. */
610 SHFLFSOBJATTRADD enmAdditional;
611
612 /**
613 * Additional attributes.
614 *
615 * Unless explicitly specified to an API, the API can provide additional
616 * data as it is provided by the underlying OS.
617 */
618 union SHFLFSOBJATTRUNION
619 {
620 /** Additional Unix Attributes
621 * These are available when SHFLFSOBJATTRADD is set in fUnix.
622 */
623 struct SHFLFSOBJATTRUNIX
624 {
625 /** The user owning the filesystem object (st_uid).
626 * This field is ~0U if not supported. */
627 RTUID uid;
628
629 /** The group the filesystem object is assigned (st_gid).
630 * This field is ~0U if not supported. */
631 RTGID gid;
632
633 /** Number of hard links to this filesystem object (st_nlink).
634 * This field is 1 if the filesystem doesn't support hardlinking or
635 * the information isn't available.
636 */
637 uint32_t cHardlinks;
638
639 /** The device number of the device which this filesystem object resides on (st_dev).
640 * This field is 0 if this information is not available. */
641 RTDEV INodeIdDevice;
642
643 /** The unique identifier (within the filesystem) of this filesystem object (st_ino).
644 * Together with INodeIdDevice, this field can be used as a OS wide unique id
645 * when both their values are not 0.
646 * This field is 0 if the information is not available. */
647 RTINODE INodeId;
648
649 /** User flags (st_flags).
650 * This field is 0 if this information is not available. */
651 uint32_t fFlags;
652
653 /** The current generation number (st_gen).
654 * This field is 0 if this information is not available. */
655 uint32_t GenerationId;
656
657 /** The device number of a character or block device type object (st_rdev).
658 * This field is 0 if the file isn't of a character or block device type and
659 * when the OS doesn't subscribe to the major+minor device idenfication scheme. */
660 RTDEV Device;
661 } Unix;
662
663 /**
664 * Extended attribute size.
665 */
666 struct SHFLFSOBJATTREASIZE
667 {
668 /** Size of EAs. */
669 RTFOFF cb;
670 } EASize;
671 } u;
672} SHFLFSOBJATTR;
673#pragma pack()
674AssertCompileSize(SHFLFSOBJATTR, 44);
675/** Pointer to a shared folder filesystem object attributes structure. */
676typedef SHFLFSOBJATTR *PSHFLFSOBJATTR;
677/** Pointer to a const shared folder filesystem object attributes structure. */
678typedef const SHFLFSOBJATTR *PCSHFLFSOBJATTR;
679
680
681/**
682 * Filesystem object information structure.
683 */
684#pragma pack(1)
685typedef struct SHFLFSOBJINFO
686{
687 /** Logical size (st_size).
688 * For normal files this is the size of the file.
689 * For symbolic links, this is the length of the path name contained
690 * in the symbolic link.
691 * For other objects this fields needs to be specified.
692 */
693 RTFOFF cbObject;
694
695 /** Disk allocation size (st_blocks * DEV_BSIZE). */
696 RTFOFF cbAllocated;
697
698 /** Time of last access (st_atime).
699 * @remarks Here (and other places) we depend on the IPRT timespec to
700 * remain unchanged. */
701 RTTIMESPEC AccessTime;
702
703 /** Time of last data modification (st_mtime). */
704 RTTIMESPEC ModificationTime;
705
706 /** Time of last status change (st_ctime).
707 * If not available this is set to ModificationTime.
708 */
709 RTTIMESPEC ChangeTime;
710
711 /** Time of file birth (st_birthtime).
712 * If not available this is set to ChangeTime.
713 */
714 RTTIMESPEC BirthTime;
715
716 /** Attributes. */
717 SHFLFSOBJATTR Attr;
718
719} SHFLFSOBJINFO;
720#pragma pack()
721AssertCompileSize(SHFLFSOBJINFO, 92);
722/** Pointer to a shared folder filesystem object information structure. */
723typedef SHFLFSOBJINFO *PSHFLFSOBJINFO;
724/** Pointer to a const shared folder filesystem object information
725 * structure. */
726typedef const SHFLFSOBJINFO *PCSHFLFSOBJINFO;
727
728
729/**
730 * Copy file system objinfo from IPRT to shared folder format.
731 *
732 * @param pDst The shared folder structure.
733 * @param pSrc The IPRT structure.
734 */
735DECLINLINE(void) vbfsCopyFsObjInfoFromIprt(PSHFLFSOBJINFO pDst, PCRTFSOBJINFO pSrc)
736{
737 pDst->cbObject = pSrc->cbObject;
738 pDst->cbAllocated = pSrc->cbAllocated;
739 pDst->AccessTime = pSrc->AccessTime;
740 pDst->ModificationTime = pSrc->ModificationTime;
741 pDst->ChangeTime = pSrc->ChangeTime;
742 pDst->BirthTime = pSrc->BirthTime;
743 pDst->Attr.fMode = pSrc->Attr.fMode;
744 /* Clear bits which we don't pass through for security reasons. */
745 pDst->Attr.fMode &= ~(RTFS_UNIX_ISUID | RTFS_UNIX_ISGID | RTFS_UNIX_ISTXT);
746 RT_ZERO(pDst->Attr.u);
747 switch (pSrc->Attr.enmAdditional)
748 {
749 default:
750 case RTFSOBJATTRADD_NOTHING:
751 pDst->Attr.enmAdditional = SHFLFSOBJATTRADD_NOTHING;
752 break;
753
754 case RTFSOBJATTRADD_UNIX:
755 pDst->Attr.enmAdditional = SHFLFSOBJATTRADD_UNIX;
756 pDst->Attr.u.Unix.uid = pSrc->Attr.u.Unix.uid;
757 pDst->Attr.u.Unix.gid = pSrc->Attr.u.Unix.gid;
758 pDst->Attr.u.Unix.cHardlinks = pSrc->Attr.u.Unix.cHardlinks;
759 pDst->Attr.u.Unix.INodeIdDevice = pSrc->Attr.u.Unix.INodeIdDevice;
760 pDst->Attr.u.Unix.INodeId = pSrc->Attr.u.Unix.INodeId;
761 pDst->Attr.u.Unix.fFlags = pSrc->Attr.u.Unix.fFlags;
762 pDst->Attr.u.Unix.GenerationId = pSrc->Attr.u.Unix.GenerationId;
763 pDst->Attr.u.Unix.Device = pSrc->Attr.u.Unix.Device;
764 break;
765
766 case RTFSOBJATTRADD_EASIZE:
767 pDst->Attr.enmAdditional = SHFLFSOBJATTRADD_EASIZE;
768 pDst->Attr.u.EASize.cb = pSrc->Attr.u.EASize.cb;
769 break;
770 }
771}
772
773
774/** Result of an open/create request.
775 * Along with handle value the result code
776 * identifies what has happened while
777 * trying to open the object.
778 */
779typedef enum _SHFLCREATERESULT
780{
781 SHFL_NO_RESULT,
782 /** Specified path does not exist. */
783 SHFL_PATH_NOT_FOUND,
784 /** Path to file exists, but the last component does not. */
785 SHFL_FILE_NOT_FOUND,
786 /** File already exists and either has been opened or not. */
787 SHFL_FILE_EXISTS,
788 /** New file was created. */
789 SHFL_FILE_CREATED,
790 /** Existing file was replaced or overwritten. */
791 SHFL_FILE_REPLACED,
792 /** Blow the type up to 32-bit. */
793 SHFL_32BIT_HACK = 0x7fffffff
794} SHFLCREATERESULT;
795AssertCompile(SHFL_NO_RESULT == 0);
796AssertCompileSize(SHFLCREATERESULT, 4);
797
798
799/** @name Open/create flags.
800 * @{
801 */
802
803/** No flags. Initialization value. */
804#define SHFL_CF_NONE (0x00000000)
805
806/** Lookup only the object, do not return a handle. All other flags are ignored. */
807#define SHFL_CF_LOOKUP (0x00000001)
808
809/** Open parent directory of specified object.
810 * Useful for the corresponding Windows FSD flag
811 * and for opening paths like \\dir\\*.* to search the 'dir'.
812 * @todo possibly not needed???
813 */
814#define SHFL_CF_OPEN_TARGET_DIRECTORY (0x00000002)
815
816/** Create/open a directory. */
817#define SHFL_CF_DIRECTORY (0x00000004)
818
819/** Open/create action to do if object exists
820 * and if the object does not exists.
821 * REPLACE file means atomically DELETE and CREATE.
822 * OVERWRITE file means truncating the file to 0 and
823 * setting new size.
824 * When opening an existing directory REPLACE and OVERWRITE
825 * actions are considered invalid, and cause returning
826 * FILE_EXISTS with NIL handle.
827 */
828#define SHFL_CF_ACT_MASK_IF_EXISTS (0x000000F0)
829#define SHFL_CF_ACT_MASK_IF_NEW (0x00000F00)
830
831/** What to do if object exists. */
832#define SHFL_CF_ACT_OPEN_IF_EXISTS (0x00000000)
833#define SHFL_CF_ACT_FAIL_IF_EXISTS (0x00000010)
834#define SHFL_CF_ACT_REPLACE_IF_EXISTS (0x00000020)
835#define SHFL_CF_ACT_OVERWRITE_IF_EXISTS (0x00000030)
836
837/** What to do if object does not exist. */
838#define SHFL_CF_ACT_CREATE_IF_NEW (0x00000000)
839#define SHFL_CF_ACT_FAIL_IF_NEW (0x00000100)
840
841/** Read/write requested access for the object. */
842#define SHFL_CF_ACCESS_MASK_RW (0x00003000)
843
844/** No access requested. */
845#define SHFL_CF_ACCESS_NONE (0x00000000)
846/** Read access requested. */
847#define SHFL_CF_ACCESS_READ (0x00001000)
848/** Write access requested. */
849#define SHFL_CF_ACCESS_WRITE (0x00002000)
850/** Read/Write access requested. */
851#define SHFL_CF_ACCESS_READWRITE (SHFL_CF_ACCESS_READ | SHFL_CF_ACCESS_WRITE)
852
853/** Requested share access for the object. */
854#define SHFL_CF_ACCESS_MASK_DENY (0x0000C000)
855
856/** Allow any access. */
857#define SHFL_CF_ACCESS_DENYNONE (0x00000000)
858/** Do not allow read. */
859#define SHFL_CF_ACCESS_DENYREAD (0x00004000)
860/** Do not allow write. */
861#define SHFL_CF_ACCESS_DENYWRITE (0x00008000)
862/** Do not allow access. */
863#define SHFL_CF_ACCESS_DENYALL (SHFL_CF_ACCESS_DENYREAD | SHFL_CF_ACCESS_DENYWRITE)
864
865/** Requested access to attributes of the object. */
866#define SHFL_CF_ACCESS_MASK_ATTR (0x00030000)
867
868/** No access requested. */
869#define SHFL_CF_ACCESS_ATTR_NONE (0x00000000)
870/** Read access requested. */
871#define SHFL_CF_ACCESS_ATTR_READ (0x00010000)
872/** Write access requested. */
873#define SHFL_CF_ACCESS_ATTR_WRITE (0x00020000)
874/** Read/Write access requested. */
875#define SHFL_CF_ACCESS_ATTR_READWRITE (SHFL_CF_ACCESS_ATTR_READ | SHFL_CF_ACCESS_ATTR_WRITE)
876
877/** The file is opened in append mode. Ignored if SHFL_CF_ACCESS_WRITE is not set. */
878#define SHFL_CF_ACCESS_APPEND (0x00040000)
879
880/** @} */
881
882#pragma pack(1)
883typedef struct _SHFLCREATEPARMS
884{
885 /* Returned handle of opened object. */
886 SHFLHANDLE Handle;
887
888 /* Returned result of the operation */
889 SHFLCREATERESULT Result;
890
891 /* SHFL_CF_* */
892 uint32_t CreateFlags;
893
894 /* Attributes of object to create and
895 * returned actual attributes of opened/created object.
896 */
897 SHFLFSOBJINFO Info;
898
899} SHFLCREATEPARMS;
900#pragma pack()
901
902typedef SHFLCREATEPARMS *PSHFLCREATEPARMS;
903
904
905/** @name Shared Folders mappings.
906 * @{
907 */
908
909/** The mapping has been added since last query. */
910#define SHFL_MS_NEW (1)
911/** The mapping has been deleted since last query. */
912#define SHFL_MS_DELETED (2)
913
914typedef struct _SHFLMAPPING
915{
916 /** Mapping status.
917 * @note Currently always set to SHFL_MS_NEW. */
918 uint32_t u32Status;
919 /** Root handle. */
920 SHFLROOT root;
921} SHFLMAPPING;
922/** Pointer to a SHFLMAPPING structure. */
923typedef SHFLMAPPING *PSHFLMAPPING;
924
925/** @} */
926
927
928/** @name Shared Folder directory information
929 * @{
930 */
931
932typedef struct _SHFLDIRINFO
933{
934 /** Full information about the object. */
935 SHFLFSOBJINFO Info;
936 /** The length of the short field (number of RTUTF16 chars).
937 * It is 16-bit for reasons of alignment. */
938 uint16_t cucShortName;
939 /** The short name for 8.3 compatibility.
940 * Empty string if not available.
941 */
942 RTUTF16 uszShortName[14];
943 /** @todo malc, a description, please. */
944 SHFLSTRING name;
945} SHFLDIRINFO, *PSHFLDIRINFO;
946
947
948/**
949 * Shared folder filesystem properties.
950 */
951typedef struct SHFLFSPROPERTIES
952{
953 /** The maximum size of a filesystem object name.
954 * This does not include the '\\0'. */
955 uint32_t cbMaxComponent;
956
957 /** True if the filesystem is remote.
958 * False if the filesystem is local. */
959 bool fRemote;
960
961 /** True if the filesystem is case sensitive.
962 * False if the filesystem is case insensitive. */
963 bool fCaseSensitive;
964
965 /** True if the filesystem is mounted read only.
966 * False if the filesystem is mounted read write. */
967 bool fReadOnly;
968
969 /** True if the filesystem can encode unicode object names.
970 * False if it can't. */
971 bool fSupportsUnicode;
972
973 /** True if the filesystem is compresses.
974 * False if it isn't or we don't know. */
975 bool fCompressed;
976
977 /** True if the filesystem compresses of individual files.
978 * False if it doesn't or we don't know. */
979 bool fFileCompression;
980
981 /** @todo more? */
982} SHFLFSPROPERTIES;
983AssertCompileSize(SHFLFSPROPERTIES, 12);
984/** Pointer to a shared folder filesystem properties structure. */
985typedef SHFLFSPROPERTIES *PSHFLFSPROPERTIES;
986/** Pointer to a const shared folder filesystem properties structure. */
987typedef SHFLFSPROPERTIES const *PCSHFLFSPROPERTIES;
988
989
990/**
991 * Copy file system properties from IPRT to shared folder format.
992 *
993 * @param pDst The shared folder structure.
994 * @param pSrc The IPRT structure.
995 */
996DECLINLINE(void) vbfsCopyFsPropertiesFromIprt(PSHFLFSPROPERTIES pDst, PCRTFSPROPERTIES pSrc)
997{
998 RT_ZERO(*pDst); /* zap the implicit padding. */
999 pDst->cbMaxComponent = pSrc->cbMaxComponent;
1000 pDst->fRemote = pSrc->fRemote;
1001 pDst->fCaseSensitive = pSrc->fCaseSensitive;
1002 pDst->fReadOnly = pSrc->fReadOnly;
1003 pDst->fSupportsUnicode = pSrc->fSupportsUnicode;
1004 pDst->fCompressed = pSrc->fCompressed;
1005 pDst->fFileCompression = pSrc->fFileCompression;
1006}
1007
1008
1009typedef struct _SHFLVOLINFO
1010{
1011 RTFOFF ullTotalAllocationBytes;
1012 RTFOFF ullAvailableAllocationBytes;
1013 uint32_t ulBytesPerAllocationUnit;
1014 uint32_t ulBytesPerSector;
1015 uint32_t ulSerial;
1016 SHFLFSPROPERTIES fsProperties;
1017} SHFLVOLINFO, *PSHFLVOLINFO;
1018
1019/** @} */
1020
1021
1022/** @defgroup grp_vbox_shfl_params Function parameter structures.
1023 * @{
1024 */
1025
1026/** @name SHFL_FN_QUERY_MAPPINGS
1027 * @{
1028 */
1029/** Validation mask. Needs to be adjusted
1030 * whenever a new SHFL_MF_ flag is added. */
1031#define SHFL_MF_MASK (0x00000011)
1032/** UTF-16 enconded strings. */
1033#define SHFL_MF_UCS2 (0x00000000)
1034/** Guest uses UTF8 strings, if not set then the strings are unicode (UCS2). */
1035#define SHFL_MF_UTF8 (0x00000001)
1036/** Just handle the auto-mounted folders. */
1037#define SHFL_MF_AUTOMOUNT (0x00000010)
1038
1039/** Parameters structure. */
1040typedef struct _VBoxSFQueryMappings
1041{
1042 VBGLIOCHGCMCALL callInfo;
1043
1044 /** 32bit, in:
1045 * Flags describing various client needs.
1046 */
1047 HGCMFunctionParameter flags;
1048
1049 /** 32bit, in/out:
1050 * Number of mappings the client expects.
1051 * This is the number of elements in the
1052 * mappings array.
1053 */
1054 HGCMFunctionParameter numberOfMappings;
1055
1056 /** pointer, in/out:
1057 * Points to array of SHFLMAPPING structures.
1058 */
1059 HGCMFunctionParameter mappings;
1060
1061} VBoxSFQueryMappings;
1062
1063/** Number of parameters */
1064#define SHFL_CPARMS_QUERY_MAPPINGS (3)
1065/** @} */
1066
1067
1068/** @name SHFL_FN_QUERY_MAP_NAME
1069 * @{
1070 */
1071
1072/** Parameters structure. */
1073typedef struct _VBoxSFQueryMapName
1074{
1075 VBGLIOCHGCMCALL callInfo;
1076
1077 /** 32bit, in: SHFLROOT
1078 * Root handle of the mapping which name is queried.
1079 */
1080 HGCMFunctionParameter root;
1081
1082 /** pointer, in/out:
1083 * Points to SHFLSTRING buffer.
1084 */
1085 HGCMFunctionParameter name;
1086
1087} VBoxSFQueryMapName;
1088
1089/** Number of parameters */
1090#define SHFL_CPARMS_QUERY_MAP_NAME (2)
1091/** @} */
1092
1093
1094/** @name SHFL_FN_MAP_FOLDER_OLD
1095 * @{
1096 */
1097
1098/** Parameters structure. */
1099typedef struct _VBoxSFMapFolder_Old
1100{
1101 VBGLIOCHGCMCALL callInfo;
1102
1103 /** pointer, in:
1104 * Points to SHFLSTRING buffer.
1105 */
1106 HGCMFunctionParameter path;
1107
1108 /** pointer, out: SHFLROOT
1109 * Root handle of the mapping which name is queried.
1110 */
1111 HGCMFunctionParameter root;
1112
1113 /** pointer, in: RTUTF16
1114 * Path delimiter
1115 */
1116 HGCMFunctionParameter delimiter;
1117
1118} VBoxSFMapFolder_Old;
1119
1120/** Number of parameters */
1121#define SHFL_CPARMS_MAP_FOLDER_OLD (3)
1122/** @} */
1123
1124
1125/** @name SHFL_FN_MAP_FOLDER
1126 * @{
1127 */
1128
1129/** SHFL_FN_MAP_FOLDER parameters. */
1130typedef struct VBoxSFParmMapFolder
1131{
1132 /** pointer, in: SHFLSTRING with the name of the folder to map. */
1133 HGCMFunctionParameter pStrName;
1134 /** value32, out: The root ID (SHFLROOT) of the mapping. */
1135 HGCMFunctionParameter id32Root;
1136 /** value32, in: Path delimiter code point. */
1137 HGCMFunctionParameter uc32Delimiter;
1138 /** value32, in: case senstive flag */
1139 HGCMFunctionParameter fCaseSensitive;
1140} VBoxSFParmMapFolder;
1141
1142/** Parameters structure. */
1143typedef struct _VBoxSFMapFolder
1144{
1145 VBGLIOCHGCMCALL callInfo;
1146
1147 /** pointer, in:
1148 * Points to SHFLSTRING buffer.
1149 */
1150 HGCMFunctionParameter path;
1151
1152 /** pointer, out: SHFLROOT
1153 * Root handle of the mapping which name is queried.
1154 */
1155 HGCMFunctionParameter root;
1156
1157 /** pointer, in: RTUTF16
1158 * Path delimiter
1159 */
1160 HGCMFunctionParameter delimiter;
1161
1162 /** pointer, in: SHFLROOT
1163 * Case senstive flag
1164 */
1165 HGCMFunctionParameter fCaseSensitive;
1166
1167} VBoxSFMapFolder;
1168
1169/** Number of parameters */
1170#define SHFL_CPARMS_MAP_FOLDER (4)
1171/** @} */
1172
1173
1174/** @name SHFL_FN_UNMAP_FOLDER
1175 * @{
1176 */
1177
1178/** SHFL_FN_UNMAP_FOLDER parameters. */
1179typedef struct VBoxSFParmUnmapFolder
1180{
1181 /** value32, in: SHFLROOT of the mapping to unmap */
1182 HGCMFunctionParameter id32Root;
1183} VBoxSFParmUnmapFolder;
1184
1185/** Parameters structure. */
1186typedef struct _VBoxSFUnmapFolder
1187{
1188 VBGLIOCHGCMCALL callInfo;
1189
1190 /** pointer, in: SHFLROOT
1191 * Root handle of the mapping which name is queried.
1192 */
1193 HGCMFunctionParameter root;
1194
1195} VBoxSFUnmapFolder;
1196
1197/** Number of parameters */
1198#define SHFL_CPARMS_UNMAP_FOLDER (1)
1199/** @} */
1200
1201
1202/** @name SHFL_FN_CREATE
1203 * @{
1204 */
1205
1206/** SHFL_FN_CREATE parameters. */
1207typedef struct VBoxSFParmCreate
1208{
1209 /** value32, in: SHFLROOT
1210 * Root handle of the mapping which name is queried. */
1211 HGCMFunctionParameter id32Root;
1212 /** pointer, in: Points to SHFLSTRING buffer. */
1213 HGCMFunctionParameter pStrPath;
1214 /** pointer, in/out: Points to SHFLCREATEPARMS buffer. */
1215 HGCMFunctionParameter pCreateParms;
1216} VBoxSFParmCreate;
1217
1218/** Parameters structure. */
1219typedef struct _VBoxSFCreate
1220{
1221 VBGLIOCHGCMCALL callInfo;
1222
1223 /** pointer, in: SHFLROOT
1224 * Root handle of the mapping which name is queried.
1225 */
1226 HGCMFunctionParameter root;
1227
1228 /** pointer, in:
1229 * Points to SHFLSTRING buffer.
1230 */
1231 HGCMFunctionParameter path;
1232
1233 /** pointer, in/out:
1234 * Points to SHFLCREATEPARMS buffer.
1235 */
1236 HGCMFunctionParameter parms;
1237
1238} VBoxSFCreate;
1239
1240/** Number of parameters */
1241#define SHFL_CPARMS_CREATE (3)
1242/** @} */
1243
1244
1245/** @name SHFL_FN_CLOSE
1246 * @{
1247 */
1248
1249/** SHFL_FN_CLOSE parameters. */
1250typedef struct VBoxSFParmClose
1251{
1252 /** value32, in: SHFLROOT of the mapping with the handle. */
1253 HGCMFunctionParameter id32Root;
1254 /** value64, in: SHFLHANDLE of object to close. */
1255 HGCMFunctionParameter u64Handle;
1256} VBoxSFParmClose;
1257
1258/** Parameters structure. */
1259typedef struct _VBoxSFClose
1260{
1261 VBGLIOCHGCMCALL callInfo;
1262
1263 /** pointer, in: SHFLROOT
1264 * Root handle of the mapping which name is queried.
1265 */
1266 HGCMFunctionParameter root;
1267
1268
1269 /** value64, in:
1270 * SHFLHANDLE of object to close.
1271 */
1272 HGCMFunctionParameter handle;
1273
1274} VBoxSFClose;
1275
1276/** Number of parameters */
1277#define SHFL_CPARMS_CLOSE (2)
1278/** @} */
1279
1280
1281/** @name SHFL_FN_READ
1282 * @{
1283 */
1284
1285/** SHFL_FN_READ parameters. */
1286typedef struct VBoxSFParmRead
1287{
1288 /** value32, in: SHFLROOT of the mapping with the handle. */
1289 HGCMFunctionParameter id32Root;
1290 /** value64, in: SHFLHANDLE of object to read from . */
1291 HGCMFunctionParameter u64Handle;
1292 /** value64, in: Offset to start reading from. */
1293 HGCMFunctionParameter off64Read;
1294 /** value32, in/out: How much to try read / Actually read. */
1295 HGCMFunctionParameter cb32Read;
1296 /** pointer, out: Buffer to return the data in. */
1297 HGCMFunctionParameter pBuf;
1298} VBoxSFParmRead;
1299
1300/** Parameters structure. */
1301typedef struct _VBoxSFRead
1302{
1303 VBGLIOCHGCMCALL callInfo;
1304
1305 /** pointer, in: SHFLROOT
1306 * Root handle of the mapping which name is queried.
1307 */
1308 HGCMFunctionParameter root;
1309
1310 /** value64, in:
1311 * SHFLHANDLE of object to read from.
1312 */
1313 HGCMFunctionParameter handle;
1314
1315 /** value64, in:
1316 * Offset to read from.
1317 */
1318 HGCMFunctionParameter offset;
1319
1320 /** value64, in/out:
1321 * Bytes to read/How many were read.
1322 */
1323 HGCMFunctionParameter cb;
1324
1325 /** pointer, out:
1326 * Buffer to place data to.
1327 */
1328 HGCMFunctionParameter buffer;
1329
1330} VBoxSFRead;
1331
1332/** Number of parameters */
1333#define SHFL_CPARMS_READ (5)
1334/** @} */
1335
1336
1337/** @name SHFL_FN_WRITE
1338 * @{
1339 */
1340
1341/** SHFL_FN_WRITE parameters. */
1342typedef struct VBoxSFParmWrite
1343{
1344 /** value32, in: SHFLROOT of the mapping with the handle. */
1345 HGCMFunctionParameter id32Root;
1346 /** value64, in: SHFLHANDLE of object to write to. */
1347 HGCMFunctionParameter u64Handle;
1348 /** value64, in: Offset to start writing at. */
1349 HGCMFunctionParameter off64Write;
1350 /** value32, in/out: How much to try write / Actually written. */
1351 HGCMFunctionParameter cb32Write;
1352 /** pointer, out: Buffer to return the data in. */
1353 HGCMFunctionParameter pBuf;
1354} VBoxSFParmWrite;
1355
1356/** Parameters structure. */
1357typedef struct _VBoxSFWrite
1358{
1359 VBGLIOCHGCMCALL callInfo;
1360
1361 /** pointer, in: SHFLROOT
1362 * Root handle of the mapping which name is queried.
1363 */
1364 HGCMFunctionParameter root;
1365
1366 /** value64, in:
1367 * SHFLHANDLE of object to write to.
1368 */
1369 HGCMFunctionParameter handle;
1370
1371 /** value64, in:
1372 * Offset to write to.
1373 */
1374 HGCMFunctionParameter offset;
1375
1376 /** value64, in/out:
1377 * Bytes to write/How many were written.
1378 */
1379 HGCMFunctionParameter cb;
1380
1381 /** pointer, in:
1382 * Data to write.
1383 */
1384 HGCMFunctionParameter buffer;
1385
1386} VBoxSFWrite;
1387
1388/** Number of parameters */
1389#define SHFL_CPARMS_WRITE (5)
1390/** @} */
1391
1392
1393/** @name SHFL_FN_LOCK
1394 * @remarks Lock owner is the HGCM client.
1395 * @{
1396 */
1397
1398/** Lock mode bit mask. */
1399#define SHFL_LOCK_MODE_MASK (0x3)
1400/** Cancel lock on the given range. */
1401#define SHFL_LOCK_CANCEL (0x0)
1402/** Acquire read only lock. Prevent write to the range. */
1403#define SHFL_LOCK_SHARED (0x1)
1404/** Acquire write lock. Prevent both write and read to the range. */
1405#define SHFL_LOCK_EXCLUSIVE (0x2)
1406
1407/** Do not wait for lock if it can not be acquired at the time. */
1408#define SHFL_LOCK_NOWAIT (0x0)
1409/** Wait and acquire lock. */
1410#define SHFL_LOCK_WAIT (0x4)
1411
1412/** Lock the specified range. */
1413#define SHFL_LOCK_PARTIAL (0x0)
1414/** Lock entire object. */
1415#define SHFL_LOCK_ENTIRE (0x8)
1416
1417/** Parameters structure. */
1418typedef struct _VBoxSFLock
1419{
1420 VBGLIOCHGCMCALL callInfo;
1421
1422 /** pointer, in: SHFLROOT
1423 * Root handle of the mapping which name is queried.
1424 */
1425 HGCMFunctionParameter root;
1426
1427 /** value64, in:
1428 * SHFLHANDLE of object to be locked.
1429 */
1430 HGCMFunctionParameter handle;
1431
1432 /** value64, in:
1433 * Starting offset of lock range.
1434 */
1435 HGCMFunctionParameter offset;
1436
1437 /** value64, in:
1438 * Length of range.
1439 */
1440 HGCMFunctionParameter length;
1441
1442 /** value32, in:
1443 * Lock flags SHFL_LOCK_*.
1444 */
1445 HGCMFunctionParameter flags;
1446
1447} VBoxSFLock;
1448
1449/** Number of parameters */
1450#define SHFL_CPARMS_LOCK (5)
1451/** @} */
1452
1453
1454/** @name SHFL_FN_FLUSH
1455 * @{
1456 */
1457
1458/** SHFL_FN_FLUSH parameters. */
1459typedef struct VBoxSFParmFlush
1460{
1461 /** value32, in: SHFLROOT of the mapping with the handle. */
1462 HGCMFunctionParameter id32Root;
1463 /** value64, in: SHFLHANDLE of object to flush. */
1464 HGCMFunctionParameter u64Handle;
1465} VBoxSFParmFlush;
1466
1467/** Parameters structure. */
1468typedef struct _VBoxSFFlush
1469{
1470 VBGLIOCHGCMCALL callInfo;
1471
1472 /** pointer, in: SHFLROOT
1473 * Root handle of the mapping which name is queried.
1474 */
1475 HGCMFunctionParameter root;
1476
1477 /** value64, in:
1478 * SHFLHANDLE of object to be locked.
1479 */
1480 HGCMFunctionParameter handle;
1481
1482} VBoxSFFlush;
1483
1484/** Number of parameters */
1485#define SHFL_CPARMS_FLUSH (2)
1486/** @} */
1487
1488
1489/** @name SHFL_FN_LIST
1490 * @remarks Listing information includes variable length RTDIRENTRY[EX]
1491 * structures.
1492 * @{
1493 */
1494
1495/** @todo might be necessary for future. */
1496#define SHFL_LIST_NONE 0
1497#define SHFL_LIST_RETURN_ONE 1
1498#define SHFL_LIST_RESTART 2
1499
1500/** Parameters structure. */
1501typedef struct _VBoxSFList
1502{
1503 VBGLIOCHGCMCALL callInfo;
1504
1505 /** pointer, in: SHFLROOT
1506 * Root handle of the mapping which name is queried.
1507 */
1508 HGCMFunctionParameter root;
1509
1510 /** value64, in:
1511 * SHFLHANDLE of object to be listed.
1512 */
1513 HGCMFunctionParameter handle;
1514
1515 /** value32, in:
1516 * List flags SHFL_LIST_*.
1517 */
1518 HGCMFunctionParameter flags;
1519
1520 /** value32, in/out:
1521 * Bytes to be used for listing information/How many bytes were used.
1522 */
1523 HGCMFunctionParameter cb;
1524
1525 /** pointer, in/optional
1526 * Points to SHFLSTRING buffer that specifies a search path.
1527 */
1528 HGCMFunctionParameter path;
1529
1530 /** pointer, out:
1531 * Buffer to place listing information to. (SHFLDIRINFO)
1532 */
1533 HGCMFunctionParameter buffer;
1534
1535 /** value32, in/out:
1536 * Indicates a key where the listing must be resumed.
1537 * in: 0 means start from begin of object.
1538 * out: 0 means listing completed.
1539 */
1540 HGCMFunctionParameter resumePoint;
1541
1542 /** pointer, out:
1543 * Number of files returned
1544 */
1545 HGCMFunctionParameter cFiles;
1546
1547} VBoxSFList;
1548
1549/** Number of parameters */
1550#define SHFL_CPARMS_LIST (8)
1551/** @} */
1552
1553
1554/** @name SHFL_FN_READLINK
1555 * @{
1556 */
1557
1558/** Parameters structure. */
1559typedef struct _VBoxSFReadLink
1560{
1561 VBGLIOCHGCMCALL callInfo;
1562
1563 /** pointer, in: SHFLROOT
1564 * Root handle of the mapping which name is queried.
1565 */
1566 HGCMFunctionParameter root;
1567
1568 /** pointer, in:
1569 * Points to SHFLSTRING buffer.
1570 */
1571 HGCMFunctionParameter path;
1572
1573 /** pointer, out:
1574 * Buffer to place data to.
1575 */
1576 HGCMFunctionParameter buffer;
1577
1578} VBoxSFReadLink;
1579
1580/** Number of parameters */
1581#define SHFL_CPARMS_READLINK (3)
1582/** @} */
1583
1584
1585/** @name SHFL_FN_INFORMATION
1586 * @{
1587 */
1588
1589/** Mask of Set/Get bit. */
1590#define SHFL_INFO_MODE_MASK (0x1)
1591/** Get information */
1592#define SHFL_INFO_GET (0x0)
1593/** Set information */
1594#define SHFL_INFO_SET (0x1)
1595
1596/** Get name of the object. */
1597#define SHFL_INFO_NAME (0x2)
1598/** Set size of object (extend/trucate); only applies to file objects */
1599#define SHFL_INFO_SIZE (0x4)
1600/** Get/Set file object info. */
1601#define SHFL_INFO_FILE (0x8)
1602/** Get volume information. */
1603#define SHFL_INFO_VOLUME (0x10)
1604
1605/** @todo different file info structures */
1606
1607/** SHFL_FN_INFORMATION parameters. */
1608typedef struct VBoxSFParmInformation
1609{
1610 /** value32, in: SHFLROOT of the mapping the handle belongs to. */
1611 HGCMFunctionParameter id32Root;
1612 /** value64, in: SHFLHANDLE of object to be queried/set. */
1613 HGCMFunctionParameter u64Handle;
1614 /** value32, in: SHFL_INFO_XXX */
1615 HGCMFunctionParameter f32Flags;
1616 /** value32, in/out: Bytes to be used for information/How many bytes were used. */
1617 HGCMFunctionParameter cb32;
1618 /** pointer, in/out: Information to be set/get (SHFLFSOBJINFO, SHFLVOLINFO, or SHFLSTRING).
1619 * Do not forget to set the SHFLFSOBJINFO::Attr::enmAdditional for Get operation as well. */
1620 HGCMFunctionParameter pInfo;
1621} VBoxSFParmInformation;
1622
1623
1624/** Parameters structure. */
1625typedef struct _VBoxSFInformation
1626{
1627 VBGLIOCHGCMCALL callInfo;
1628
1629 /** pointer, in: SHFLROOT
1630 * Root handle of the mapping which name is queried.
1631 */
1632 HGCMFunctionParameter root;
1633
1634 /** value64, in:
1635 * SHFLHANDLE of object to be listed.
1636 */
1637 HGCMFunctionParameter handle;
1638
1639 /** value32, in:
1640 * SHFL_INFO_*
1641 */
1642 HGCMFunctionParameter flags;
1643
1644 /** value32, in/out:
1645 * Bytes to be used for information/How many bytes were used.
1646 */
1647 HGCMFunctionParameter cb;
1648
1649 /** pointer, in/out:
1650 * Information to be set/get (SHFLFSOBJINFO or SHFLSTRING). Do not forget
1651 * to set the SHFLFSOBJINFO::Attr::enmAdditional for Get operation as well.
1652 */
1653 HGCMFunctionParameter info;
1654
1655} VBoxSFInformation;
1656
1657/** Number of parameters */
1658#define SHFL_CPARMS_INFORMATION (5)
1659/** @} */
1660
1661
1662/** @name SHFL_FN_REMOVE
1663 * @{
1664 */
1665
1666#define SHFL_REMOVE_FILE (0x1)
1667#define SHFL_REMOVE_DIR (0x2)
1668#define SHFL_REMOVE_SYMLINK (0x4)
1669
1670/** SHFL_FN_REMOVE parameters. */
1671typedef struct VBoxSFParmRemove
1672{
1673 /** value32, in: SHFLROOT of the mapping the path is relative to. */
1674 HGCMFunctionParameter id32Root;
1675 /** pointer, in: Points to SHFLSTRING buffer. */
1676 HGCMFunctionParameter pStrPath;
1677 /** value32, in: SHFL_REMOVE_XXX */
1678 HGCMFunctionParameter f32Flags;
1679} VBoxSFParmRemove;
1680
1681/** Parameters structure. */
1682typedef struct _VBoxSFRemove
1683{
1684 VBGLIOCHGCMCALL callInfo;
1685
1686 /** pointer, in: SHFLROOT
1687 * Root handle of the mapping which name is queried.
1688 */
1689 HGCMFunctionParameter root;
1690
1691 /** pointer, in:
1692 * Points to SHFLSTRING buffer.
1693 */
1694 HGCMFunctionParameter path;
1695
1696 /** value32, in:
1697 * remove flags (file/directory)
1698 */
1699 HGCMFunctionParameter flags;
1700
1701} VBoxSFRemove;
1702
1703#define SHFL_CPARMS_REMOVE (3)
1704/** @} */
1705
1706
1707/** @name SHFL_FN_RENAME
1708 * @{
1709 */
1710
1711#define SHFL_RENAME_FILE (0x1)
1712#define SHFL_RENAME_DIR (0x2)
1713#define SHFL_RENAME_REPLACE_IF_EXISTS (0x4)
1714
1715/** SHFL_FN_RENAME parameters. */
1716typedef struct VBoxSFParmRename
1717{
1718 /** value32, in: SHFLROOT of the mapping the paths are relative to. */
1719 HGCMFunctionParameter id32Root;
1720 /** pointer, in: SHFLSTRING giving the source (old) path. */
1721 HGCMFunctionParameter pStrSrcPath;
1722 /** pointer, in: SHFLSTRING giving the destination (new) path. */
1723 HGCMFunctionParameter pStrDstPath;
1724 /** value32, in: SHFL_RENAME_XXX */
1725 HGCMFunctionParameter f32Flags;
1726} VBoxSFParmRename;
1727
1728/** Parameters structure. */
1729typedef struct _VBoxSFRename
1730{
1731 VBGLIOCHGCMCALL callInfo;
1732
1733 /** pointer, in: SHFLROOT
1734 * Root handle of the mapping which name is queried.
1735 */
1736 HGCMFunctionParameter root;
1737
1738 /** pointer, in:
1739 * Points to SHFLSTRING src.
1740 */
1741 HGCMFunctionParameter src;
1742
1743 /** pointer, in:
1744 * Points to SHFLSTRING dest.
1745 */
1746 HGCMFunctionParameter dest;
1747
1748 /** value32, in:
1749 * rename flags (file/directory)
1750 */
1751 HGCMFunctionParameter flags;
1752
1753} VBoxSFRename;
1754
1755#define SHFL_CPARMS_RENAME (4)
1756/** @} */
1757
1758
1759/** @name SHFL_FN_SYMLINK
1760 * @{
1761 */
1762
1763/** Parameters structure. */
1764typedef struct _VBoxSFSymlink
1765{
1766 VBGLIOCHGCMCALL callInfo;
1767
1768 /** pointer, in: SHFLROOT
1769 * Root handle of the mapping which name is queried.
1770 */
1771 HGCMFunctionParameter root;
1772
1773 /** pointer, in:
1774 * Points to SHFLSTRING of path for the new symlink.
1775 */
1776 HGCMFunctionParameter newPath;
1777
1778 /** pointer, in:
1779 * Points to SHFLSTRING of destination for symlink.
1780 */
1781 HGCMFunctionParameter oldPath;
1782
1783 /** pointer, out:
1784 * Information about created symlink.
1785 */
1786 HGCMFunctionParameter info;
1787
1788} VBoxSFSymlink;
1789
1790#define SHFL_CPARMS_SYMLINK (4)
1791/** @} */
1792
1793
1794/** @name SHFL_FN_QUERY_MAP_INFO
1795 * @{
1796 */
1797/** Query flag: Guest prefers drive letters as mount points. */
1798#define SHFL_MIQF_DRIVE_LETTER RT_BIT_64(0)
1799/** Query flag: Guest prefers paths as mount points. */
1800#define SHFL_MIQF_PATH RT_BIT_64(1)
1801
1802/** Set if writable. */
1803#define SHFL_MIF_WRITABLE RT_BIT_64(0)
1804/** Indicates that the mapping should be auto-mounted. */
1805#define SHFL_MIF_AUTO_MOUNT RT_BIT_64(1)
1806/** Set if host is case insensitive. */
1807#define SHFL_MIF_HOST_ICASE RT_BIT_64(2)
1808/** Set if guest is case insensitive. */
1809#define SHFL_MIF_GUEST_ICASE RT_BIT_64(3)
1810/** Symbolic link creation is allowed. */
1811#define SHFL_MIF_SYMLINK_CREATION RT_BIT_64(4)
1812
1813/** Parameters structure. */
1814typedef struct VBoxSFQueryMapInfo
1815{
1816 /** Common header. */
1817 VBGLIOCHGCMCALL callInfo;
1818 /** 32-bit, in: SHFLROOT - root handle of the mapping to query. */
1819 HGCMFunctionParameter root;
1820 /** pointer, in/out: SHFLSTRING buffer for the name. */
1821 HGCMFunctionParameter name;
1822 /** pointer, in/out: SHFLSTRING buffer for the auto mount point. */
1823 HGCMFunctionParameter mountPoint;
1824 /** 64-bit, in: SHFL_MIQF_XXX; out: SHFL_MIF_XXX. */
1825 HGCMFunctionParameter flags;
1826 /** 32-bit, out: Root ID version number - root handle reuse guard. */
1827 HGCMFunctionParameter rootIdVersion;
1828} VBoxSFQueryMapInfo;
1829/** Number of parameters */
1830#define SHFL_CPARMS_QUERY_MAP_INFO (5)
1831/** @} */
1832
1833
1834/** @name SHFL_FN_WAIT_FOR_MAPPINGS_CHANGES
1835 *
1836 * Returns VINF_SUCCESS on change and VINF_TRY_AGAIN when restored from saved
1837 * state. If the guest makes too many calls (max 64) VERR_OUT_OF_RESOURCES will
1838 * be returned.
1839 *
1840 * @{
1841 */
1842/** Parameters structure. */
1843typedef struct VBoxSFWaitForMappingsChanges
1844{
1845 /** Common header. */
1846 VBGLIOCHGCMCALL callInfo;
1847 /** 32-bit, in/out: The mappings configuration version.
1848 * On input the client sets it to the last config it knows about, on return
1849 * it holds the current version. */
1850 HGCMFunctionParameter version;
1851} VBoxSFWaitForMappingsChanges;
1852/** Number of parameters */
1853#define SHFL_CPARMS_WAIT_FOR_MAPPINGS_CHANGES (1)
1854/** @} */
1855
1856
1857/** @name SHFL_FN_CANCEL_MAPPINGS_CHANGES_WAITS
1858 * @{
1859 */
1860/** Number of parameters */
1861#define SHFL_CPARMS_CANCEL_MAPPINGS_CHANGES_WAITS (0)
1862/** @} */
1863
1864
1865/** @name SHFL_FN_SET_FILE_SIZE
1866 * @{
1867 */
1868/** SHFL_FN_SET_FILE_SIZE parameters. */
1869typedef struct VBoxSFParmSetFileSize
1870{
1871 /** value32, in: SHFLROOT of the mapping the handle belongs to. */
1872 HGCMFunctionParameter id32Root;
1873 /** value64, in: SHFLHANDLE of the file to change the size of. */
1874 HGCMFunctionParameter u64Handle;
1875 /** value64, in: The new file size. */
1876 HGCMFunctionParameter cb64NewSize;
1877} VBoxSFParmSetFileSize;
1878/** Number of parameters */
1879#define SHFL_CPARMS_SET_FILE_SIZE (3)
1880/** @} */
1881
1882
1883
1884
1885
1886/** @name SHFL_FN_ADD_MAPPING
1887 * @note Host call, no guest structure is used.
1888 * @{
1889 */
1890
1891/** mapping is writable */
1892#define SHFL_ADD_MAPPING_F_WRITABLE (RT_BIT_32(0))
1893/** mapping is automounted by the guest */
1894#define SHFL_ADD_MAPPING_F_AUTOMOUNT (RT_BIT_32(1))
1895/** allow the guest to create symlinks */
1896#define SHFL_ADD_MAPPING_F_CREATE_SYMLINKS (RT_BIT_32(2))
1897/** mapping is actually missing on the host */
1898#define SHFL_ADD_MAPPING_F_MISSING (RT_BIT_32(3))
1899
1900#define SHFL_CPARMS_ADD_MAPPING (4)
1901/** @} */
1902
1903
1904/** @name SHFL_FN_REMOVE_MAPPING
1905 * @note Host call, no guest structure is used.
1906 * @{
1907 */
1908
1909#define SHFL_CPARMS_REMOVE_MAPPING (1)
1910/** @} */
1911
1912
1913/** @name SHFL_FN_SET_STATUS_LED
1914 * @note Host call, no guest structure is used.
1915 * @{
1916 */
1917
1918#define SHFL_CPARMS_SET_STATUS_LED (1)
1919/** @} */
1920
1921
1922/** @} */
1923/** @} */
1924
1925#endif
1926
Note: See TracBrowser for help on using the repository browser.

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