VirtualBox

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

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

os2/VBoxSF: Do optimized SHFL_FN_LIST, testing VMMDevHGCMParmType_ContiguousPageList.

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