VirtualBox

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

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

SharedFolders: Added SHFL_LIST_RESTART flag for implementing RestartScan on NT.

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