VirtualBox

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

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

*: string.h sans err.h fix. bugref:9344

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

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