VirtualBox

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

Last change on this file since 75851 was 75707, checked in by vboxsync, 6 years ago

VBox/shflsvc.h: String stuff for ring-0 too. bugref:4666

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

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