VirtualBox

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

最後變更 在這個檔案從76146是 76146,由 vboxsync 提交於 6 年 前

SharedFolders,os2/VBoxSF: Continued hacking on replacements for VbglR0SfXxxx using OS/2 as testbed. Some simple read+write optimizations. bugref:9172

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

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