2 * Shared Folders: Common header for host service and guest clients.
6 * Copyright (C) 2006-2017 Oracle Corporation
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
26 #ifndef ___VBox_shflsvc_h
27 #define ___VBox_shflsvc_h
29 #include <VBox/VMMDevCoreTypes.h>
30 #include <VBox/VBoxGuestCoreTypes.h>
31 #include <VBox/hgcmsvc.h>
33 #include <iprt/assert.h>
36 /** @name Some bit flag manipulation macros.
39 #define BIT_FLAG(__Field,__Flag) ((__Field) & (__Flag))
43 #define BIT_FLAG_SET(__Field,__Flag) ((__Field) |= (__Flag))
46 #ifndef BIT_FLAG_CLEAR
47 #define BIT_FLAG_CLEAR(__Field,__Flag) ((__Field) &= ~(__Flag))
53 * Structures shared between guest and the service
54 * can be relocated and use offsets to point to variable
59 * Shared folders protocol works with handles.
60 * Before doing any action on a file system object,
61 * one have to obtain the object handle via a SHFL_FN_CREATE
62 * request. A handle must be closed with SHFL_FN_CLOSE.
65 /** Shared Folders service functions. (guest)
69 /** Query mappings changes. */
70 #define SHFL_FN_QUERY_MAPPINGS (1)
71 /** Query mappings changes. */
72 #define SHFL_FN_QUERY_MAP_NAME (2)
73 /** Open/create object. */
74 #define SHFL_FN_CREATE (3)
75 /** Close object handle. */
76 #define SHFL_FN_CLOSE (4)
77 /** Read object content. */
78 #define SHFL_FN_READ (5)
79 /** Write new object content. */
80 #define SHFL_FN_WRITE (6)
81 /** Lock/unlock a range in the object. */
82 #define SHFL_FN_LOCK (7)
83 /** List object content. */
84 #define SHFL_FN_LIST (8)
85 /** Query/set object information. */
86 #define SHFL_FN_INFORMATION (9)
88 #define SHFL_FN_REMOVE (11)
89 /** Map folder (legacy) */
90 #define SHFL_FN_MAP_FOLDER_OLD (12)
92 #define SHFL_FN_UNMAP_FOLDER (13)
93 /** Rename object (possibly moving it to another directory) */
94 #define SHFL_FN_RENAME (14)
96 #define SHFL_FN_FLUSH (15)
97 /** @todo macl, a description, please. */
98 #define SHFL_FN_SET_UTF8 (16)
100 #define SHFL_FN_MAP_FOLDER (17)
101 /** Read symlink destination (as of VBox 4.0) */
102 #define SHFL_FN_READLINK (18)
103 /** Create symlink (as of VBox 4.0) */
104 #define SHFL_FN_SYMLINK (19)
105 /** Ask host to show symlinks (as of VBox 4.0) */
106 #define SHFL_FN_SET_SYMLINKS (20)
110 /** Shared Folders service functions. (host)
114 /** Add shared folder mapping. */
115 #define SHFL_FN_ADD_MAPPING (1)
116 /** Remove shared folder mapping. */
117 #define SHFL_FN_REMOVE_MAPPING (2)
118 /** Set the led status light address. */
119 #define SHFL_FN_SET_STATUS_LED (3)
120 /** Allow the guest to create symbolic links (as of VBox 4.0) */
121 #define SHFL_FN_ALLOW_SYMLINKS_CREATE (4)
124 /** Root handle for a mapping. Root handles are unique.
126 * Function parameters structures consider
127 * the root handle as 32 bit value. If the typedef
128 * will be changed, then function parameters must be
129 * changed accordingly. All those parameters are marked
130 * with SHFLROOT in comments.
132 typedef uint32_t SHFLROOT
;
134 #define SHFL_ROOT_NIL ((SHFLROOT)~0)
137 /** A shared folders handle for an opened object. */
138 typedef uint64_t SHFLHANDLE
;
140 #define SHFL_HANDLE_NIL ((SHFLHANDLE)~0LL)
141 #define SHFL_HANDLE_ROOT ((SHFLHANDLE)0LL)
143 /** Hardcoded maximum length (in chars) of a shared folder name. */
144 #define SHFL_MAX_LEN (256)
145 /** Hardcoded maximum number of shared folder mapping available to the guest. */
146 #define SHFL_MAX_MAPPINGS (64)
148 /** @name Shared Folders strings. They can be either UTF-8 or UTF-16.
153 * Shared folder string buffer structure.
155 typedef struct _SHFLSTRING
157 /** Allocated size of the String member in bytes. */
160 /** Length of string without trailing nul in bytes. */
163 /** UTF-8 or UTF-16 string. Nul terminated. */
169 uint16_t ucs2
[1]; /**< misnomer, use utf16. */
171 uint8_t utf8
[RT_FLEXIBLE_ARRAY_IN_NESTED_UNION
];
172 RTUTF16 utf16
[RT_FLEXIBLE_ARRAY_IN_NESTED_UNION
];
173 RTUTF16 ucs2
[RT_FLEXIBLE_ARRAY_IN_NESTED_UNION
]; /**< misnomer, use utf16. */
177 AssertCompileSize(RTUTF16
, 2);
178 AssertCompileSize(SHFLSTRING
, 6);
179 AssertCompileMemberOffset(SHFLSTRING
, String
, 4);
180 /** The size of SHFLSTRING w/o the string part. */
181 #define SHFLSTRING_HEADER_SIZE 4
182 AssertCompileMemberOffset(SHFLSTRING
, String
, SHFLSTRING_HEADER_SIZE
);
184 /** Pointer to a shared folder string buffer. */
185 typedef SHFLSTRING
*PSHFLSTRING
;
186 /** Pointer to a const shared folder string buffer. */
187 typedef const SHFLSTRING
*PCSHFLSTRING
;
189 /** Calculate size of the string. */
190 DECLINLINE(uint32_t) ShflStringSizeOfBuffer(PCSHFLSTRING pString
)
192 return pString
? (uint32_t)(SHFLSTRING_HEADER_SIZE
+ pString
->u16Size
) : 0;
195 DECLINLINE(uint32_t) ShflStringLength(PCSHFLSTRING pString
)
197 return pString
? pString
->u16Length
: 0;
200 DECLINLINE(PSHFLSTRING
) ShflStringInitBuffer(void *pvBuffer
, uint32_t u32Size
)
202 PSHFLSTRING pString
= NULL
;
203 const uint32_t u32HeaderSize
= SHFLSTRING_HEADER_SIZE
;
206 * Check that the buffer size is big enough to hold a zero sized string
207 * and is not too big to fit into 16 bit variables.
209 if (u32Size
>= u32HeaderSize
&& u32Size
- u32HeaderSize
<= 0xFFFF)
211 pString
= (PSHFLSTRING
)pvBuffer
;
212 pString
->u16Size
= (uint16_t)(u32Size
- u32HeaderSize
);
213 pString
->u16Length
= 0;
214 if (pString
->u16Size
>= sizeof(pString
->String
.ucs2
[0]))
215 pString
->String
.ucs2
[0] = 0;
216 else if (pString
->u16Size
>= sizeof(pString
->String
.utf8
[0]))
217 pString
->String
.utf8
[0] = 0;
224 * Validates a HGCM string output parameter.
226 * @returns true if valid, false if not.
228 * @param pString The string buffer pointer.
229 * @param cbBuf The buffer size from the parameter.
231 DECLINLINE(bool) ShflStringIsValidOut(PCSHFLSTRING pString
, uint32_t cbBuf
)
233 if (RT_LIKELY(cbBuf
> RT_UOFFSETOF(SHFLSTRING
, String
)))
234 if (RT_LIKELY((uint32_t)pString
->u16Size
+ RT_UOFFSETOF(SHFLSTRING
, String
) <= cbBuf
))
235 if (RT_LIKELY(pString
->u16Length
< pString
->u16Size
))
241 * Validates a HGCM string input parameter.
243 * @returns true if valid, false if not.
245 * @param pString The string buffer pointer.
246 * @param cbBuf The buffer size from the parameter.
247 * @param fUtf8Not16 Set if UTF-8 encoding, clear if UTF-16 encoding.
249 DECLINLINE(bool) ShflStringIsValidIn(PCSHFLSTRING pString
, uint32_t cbBuf
, bool fUtf8Not16
)
252 if (RT_LIKELY(cbBuf
> RT_UOFFSETOF(SHFLSTRING
, String
)))
254 if (RT_LIKELY((uint32_t)pString
->u16Size
+ RT_UOFFSETOF(SHFLSTRING
, String
) <= cbBuf
))
259 if (RT_LIKELY(pString
->u16Length
< pString
->u16Size
))
261 rc
= RTStrValidateEncodingEx((const char *)&pString
->String
.utf8
[0], pString
->u16Length
+ 1,
262 RTSTR_VALIDATE_ENCODING_EXACT_LENGTH
| RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED
);
270 if (RT_LIKELY(!(pString
->u16Length
& 1)))
272 if (RT_LIKELY((uint32_t)sizeof(RTUTF16
) + pString
->u16Length
<= pString
->u16Size
))
274 rc
= RTUtf16ValidateEncodingEx(&pString
->String
.ucs2
[0], pString
->u16Length
/ 2 + 1,
275 RTSTR_VALIDATE_ENCODING_EXACT_LENGTH
276 | RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED
);
288 * Validates an optional HGCM string input parameter.
290 * @returns true if valid, false if not.
292 * @param pString The string buffer pointer. Can be NULL.
293 * @param cbBuf The buffer size from the parameter.
294 * @param fUtf8Not16 Set if UTF-8 encoding, clear if UTF-16 encoding.
296 DECLINLINE(bool) ShflStringIsValidOrNullIn(PCSHFLSTRING pString
, uint32_t cbBuf
, bool fUtf8Not16
)
299 return ShflStringIsValidIn(pString
, cbBuf
, fUtf8Not16
);
300 if (RT_LIKELY(cbBuf
== 0))
309 * The available additional information in a SHFLFSOBJATTR object.
311 typedef enum SHFLFSOBJATTRADD
313 /** No additional information is available / requested. */
314 SHFLFSOBJATTRADD_NOTHING
= 1,
315 /** The additional unix attributes (SHFLFSOBJATTR::u::Unix) are
316 * available / requested. */
317 SHFLFSOBJATTRADD_UNIX
,
318 /** The additional extended attribute size (SHFLFSOBJATTR::u::EASize) is
319 * available / requested. */
320 SHFLFSOBJATTRADD_EASIZE
,
321 /** The last valid item (inclusive).
322 * The valid range is SHFLFSOBJATTRADD_NOTHING thru
323 * SHFLFSOBJATTRADD_LAST. */
324 SHFLFSOBJATTRADD_LAST
= SHFLFSOBJATTRADD_EASIZE
,
326 /** The usual 32-bit hack. */
327 SHFLFSOBJATTRADD_32BIT_SIZE_HACK
= 0x7fffffff
331 /* Assert sizes of the IRPT types we're using below. */
332 AssertCompileSize(RTFMODE
, 4);
333 AssertCompileSize(RTFOFF
, 8);
334 AssertCompileSize(RTINODE
, 8);
335 AssertCompileSize(RTTIMESPEC
, 8);
336 AssertCompileSize(RTDEV
, 4);
337 AssertCompileSize(RTUID
, 4);
340 * Shared folder filesystem object attributes.
343 typedef struct SHFLFSOBJATTR
345 /** Mode flags (st_mode). RTFS_UNIX_*, RTFS_TYPE_*, and RTFS_DOS_*.
346 * @remarks We depend on a number of RTFS_ defines to remain unchanged.
347 * Fortuntately, these are depending on windows, dos and unix
348 * standard values, so this shouldn't be much of a pain. */
351 /** The additional attributes available. */
352 SHFLFSOBJATTRADD enmAdditional
;
355 * Additional attributes.
357 * Unless explicitly specified to an API, the API can provide additional
358 * data as it is provided by the underlying OS.
360 union SHFLFSOBJATTRUNION
362 /** Additional Unix Attributes
363 * These are available when SHFLFSOBJATTRADD is set in fUnix.
365 struct SHFLFSOBJATTRUNIX
367 /** The user owning the filesystem object (st_uid).
368 * This field is ~0U if not supported. */
371 /** The group the filesystem object is assigned (st_gid).
372 * This field is ~0U if not supported. */
375 /** Number of hard links to this filesystem object (st_nlink).
376 * This field is 1 if the filesystem doesn't support hardlinking or
377 * the information isn't available.
381 /** The device number of the device which this filesystem object resides on (st_dev).
382 * This field is 0 if this information is not available. */
385 /** The unique identifier (within the filesystem) of this filesystem object (st_ino).
386 * Together with INodeIdDevice, this field can be used as a OS wide unique id
387 * when both their values are not 0.
388 * This field is 0 if the information is not available. */
391 /** User flags (st_flags).
392 * This field is 0 if this information is not available. */
395 /** The current generation number (st_gen).
396 * This field is 0 if this information is not available. */
397 uint32_t GenerationId
;
399 /** The device number of a character or block device type object (st_rdev).
400 * This field is 0 if the file isn't of a character or block device type and
401 * when the OS doesn't subscribe to the major+minor device idenfication scheme. */
406 * Extended attribute size.
408 struct SHFLFSOBJATTREASIZE
416 AssertCompileSize(SHFLFSOBJATTR
, 44);
417 /** Pointer to a shared folder filesystem object attributes structure. */
418 typedef SHFLFSOBJATTR
*PSHFLFSOBJATTR
;
419 /** Pointer to a const shared folder filesystem object attributes structure. */
420 typedef const SHFLFSOBJATTR
*PCSHFLFSOBJATTR
;
424 * Filesystem object information structure.
427 typedef struct SHFLFSOBJINFO
429 /** Logical size (st_size).
430 * For normal files this is the size of the file.
431 * For symbolic links, this is the length of the path name contained
432 * in the symbolic link.
433 * For other objects this fields needs to be specified.
437 /** Disk allocation size (st_blocks * DEV_BSIZE). */
440 /** Time of last access (st_atime).
441 * @remarks Here (and other places) we depend on the IPRT timespec to
442 * remain unchanged. */
443 RTTIMESPEC AccessTime
;
445 /** Time of last data modification (st_mtime). */
446 RTTIMESPEC ModificationTime
;
448 /** Time of last status change (st_ctime).
449 * If not available this is set to ModificationTime.
451 RTTIMESPEC ChangeTime
;
453 /** Time of file birth (st_birthtime).
454 * If not available this is set to ChangeTime.
456 RTTIMESPEC BirthTime
;
463 AssertCompileSize(SHFLFSOBJINFO
, 92);
464 /** Pointer to a shared folder filesystem object information structure. */
465 typedef SHFLFSOBJINFO
*PSHFLFSOBJINFO
;
466 /** Pointer to a const shared folder filesystem object information
468 typedef const SHFLFSOBJINFO
*PCSHFLFSOBJINFO
;
472 * Copy file system objinfo from IPRT to shared folder format.
474 * @param pDst The shared folder structure.
475 * @param pSrc The IPRT structure.
477 DECLINLINE(void) vbfsCopyFsObjInfoFromIprt(PSHFLFSOBJINFO pDst
, PCRTFSOBJINFO pSrc
)
479 pDst
->cbObject
= pSrc
->cbObject
;
480 pDst
->cbAllocated
= pSrc
->cbAllocated
;
481 pDst
->AccessTime
= pSrc
->AccessTime
;
482 pDst
->ModificationTime
= pSrc
->ModificationTime
;
483 pDst
->ChangeTime
= pSrc
->ChangeTime
;
484 pDst
->BirthTime
= pSrc
->BirthTime
;
485 pDst
->Attr
.fMode
= pSrc
->Attr
.fMode
;
486 /* Clear bits which we don't pass through for security reasons. */
487 pDst
->Attr
.fMode
&= ~(RTFS_UNIX_ISUID
| RTFS_UNIX_ISGID
| RTFS_UNIX_ISTXT
);
488 RT_ZERO(pDst
->Attr
.u
);
489 switch (pSrc
->Attr
.enmAdditional
)
492 case RTFSOBJATTRADD_NOTHING
:
493 pDst
->Attr
.enmAdditional
= SHFLFSOBJATTRADD_NOTHING
;
496 case RTFSOBJATTRADD_UNIX
:
497 pDst
->Attr
.enmAdditional
= SHFLFSOBJATTRADD_UNIX
;
498 pDst
->Attr
.u
.Unix
.uid
= pSrc
->Attr
.u
.Unix
.uid
;
499 pDst
->Attr
.u
.Unix
.gid
= pSrc
->Attr
.u
.Unix
.gid
;
500 pDst
->Attr
.u
.Unix
.cHardlinks
= pSrc
->Attr
.u
.Unix
.cHardlinks
;
501 pDst
->Attr
.u
.Unix
.INodeIdDevice
= pSrc
->Attr
.u
.Unix
.INodeIdDevice
;
502 pDst
->Attr
.u
.Unix
.INodeId
= pSrc
->Attr
.u
.Unix
.INodeId
;
503 pDst
->Attr
.u
.Unix
.fFlags
= pSrc
->Attr
.u
.Unix
.fFlags
;
504 pDst
->Attr
.u
.Unix
.GenerationId
= pSrc
->Attr
.u
.Unix
.GenerationId
;
505 pDst
->Attr
.u
.Unix
.Device
= pSrc
->Attr
.u
.Unix
.Device
;
508 case RTFSOBJATTRADD_EASIZE
:
509 pDst
->Attr
.enmAdditional
= SHFLFSOBJATTRADD_EASIZE
;
510 pDst
->Attr
.u
.EASize
.cb
= pSrc
->Attr
.u
.EASize
.cb
;
516 /** Result of an open/create request.
517 * Along with handle value the result code
518 * identifies what has happened while
519 * trying to open the object.
521 typedef enum _SHFLCREATERESULT
524 /** Specified path does not exist. */
526 /** Path to file exists, but the last component does not. */
528 /** File already exists and either has been opened or not. */
530 /** New file was created. */
532 /** Existing file was replaced or overwritten. */
537 /** Open/create flags.
541 /** No flags. Initialization value. */
542 #define SHFL_CF_NONE (0x00000000)
544 /** Lookup only the object, do not return a handle. All other flags are ignored. */
545 #define SHFL_CF_LOOKUP (0x00000001)
547 /** Open parent directory of specified object.
548 * Useful for the corresponding Windows FSD flag
549 * and for opening paths like \\dir\\*.* to search the 'dir'.
550 * @todo possibly not needed???
552 #define SHFL_CF_OPEN_TARGET_DIRECTORY (0x00000002)
554 /** Create/open a directory. */
555 #define SHFL_CF_DIRECTORY (0x00000004)
557 /** Open/create action to do if object exists
558 * and if the object does not exists.
559 * REPLACE file means atomically DELETE and CREATE.
560 * OVERWRITE file means truncating the file to 0 and
562 * When opening an existing directory REPLACE and OVERWRITE
563 * actions are considered invalid, and cause returning
564 * FILE_EXISTS with NIL handle.
566 #define SHFL_CF_ACT_MASK_IF_EXISTS (0x000000F0)
567 #define SHFL_CF_ACT_MASK_IF_NEW (0x00000F00)
569 /** What to do if object exists. */
570 #define SHFL_CF_ACT_OPEN_IF_EXISTS (0x00000000)
571 #define SHFL_CF_ACT_FAIL_IF_EXISTS (0x00000010)
572 #define SHFL_CF_ACT_REPLACE_IF_EXISTS (0x00000020)
573 #define SHFL_CF_ACT_OVERWRITE_IF_EXISTS (0x00000030)
575 /** What to do if object does not exist. */
576 #define SHFL_CF_ACT_CREATE_IF_NEW (0x00000000)
577 #define SHFL_CF_ACT_FAIL_IF_NEW (0x00000100)
579 /** Read/write requested access for the object. */
580 #define SHFL_CF_ACCESS_MASK_RW (0x00003000)
582 /** No access requested. */
583 #define SHFL_CF_ACCESS_NONE (0x00000000)
584 /** Read access requested. */
585 #define SHFL_CF_ACCESS_READ (0x00001000)
586 /** Write access requested. */
587 #define SHFL_CF_ACCESS_WRITE (0x00002000)
588 /** Read/Write access requested. */
589 #define SHFL_CF_ACCESS_READWRITE (SHFL_CF_ACCESS_READ | SHFL_CF_ACCESS_WRITE)
591 /** Requested share access for the object. */
592 #define SHFL_CF_ACCESS_MASK_DENY (0x0000C000)
594 /** Allow any access. */
595 #define SHFL_CF_ACCESS_DENYNONE (0x00000000)
596 /** Do not allow read. */
597 #define SHFL_CF_ACCESS_DENYREAD (0x00004000)
598 /** Do not allow write. */
599 #define SHFL_CF_ACCESS_DENYWRITE (0x00008000)
600 /** Do not allow access. */
601 #define SHFL_CF_ACCESS_DENYALL (SHFL_CF_ACCESS_DENYREAD | SHFL_CF_ACCESS_DENYWRITE)
603 /** Requested access to attributes of the object. */
604 #define SHFL_CF_ACCESS_MASK_ATTR (0x00030000)
606 /** No access requested. */
607 #define SHFL_CF_ACCESS_ATTR_NONE (0x00000000)
608 /** Read access requested. */
609 #define SHFL_CF_ACCESS_ATTR_READ (0x00010000)
610 /** Write access requested. */
611 #define SHFL_CF_ACCESS_ATTR_WRITE (0x00020000)
612 /** Read/Write access requested. */
613 #define SHFL_CF_ACCESS_ATTR_READWRITE (SHFL_CF_ACCESS_ATTR_READ | SHFL_CF_ACCESS_ATTR_WRITE)
615 /** The file is opened in append mode. Ignored if SHFL_CF_ACCESS_WRITE is not set. */
616 #define SHFL_CF_ACCESS_APPEND (0x00040000)
621 typedef struct _SHFLCREATEPARMS
623 /* Returned handle of opened object. */
626 /* Returned result of the operation */
627 SHFLCREATERESULT Result
;
630 uint32_t CreateFlags
;
632 /* Attributes of object to create and
633 * returned actual attributes of opened/created object.
640 typedef SHFLCREATEPARMS
*PSHFLCREATEPARMS
;
643 /** Shared Folders mappings.
647 /** The mapping has been added since last query. */
648 #define SHFL_MS_NEW (1)
649 /** The mapping has been deleted since last query. */
650 #define SHFL_MS_DELETED (2)
652 typedef struct _SHFLMAPPING
654 /** Mapping status. */
659 /** Pointer to a SHFLMAPPING structure. */
660 typedef SHFLMAPPING
*PSHFLMAPPING
;
664 /** Shared Folder directory information
668 typedef struct _SHFLDIRINFO
670 /** Full information about the object. */
672 /** The length of the short field (number of RTUTF16 chars).
673 * It is 16-bit for reasons of alignment. */
674 uint16_t cucShortName
;
675 /** The short name for 8.3 compatibility.
676 * Empty string if not available.
678 RTUTF16 uszShortName
[14];
679 /** @todo malc, a description, please. */
681 } SHFLDIRINFO
, *PSHFLDIRINFO
;
685 * Shared folder filesystem properties.
687 typedef struct SHFLFSPROPERTIES
689 /** The maximum size of a filesystem object name.
690 * This does not include the '\\0'. */
691 uint32_t cbMaxComponent
;
693 /** True if the filesystem is remote.
694 * False if the filesystem is local. */
697 /** True if the filesystem is case sensitive.
698 * False if the filesystem is case insensitive. */
701 /** True if the filesystem is mounted read only.
702 * False if the filesystem is mounted read write. */
705 /** True if the filesystem can encode unicode object names.
706 * False if it can't. */
707 bool fSupportsUnicode
;
709 /** True if the filesystem is compresses.
710 * False if it isn't or we don't know. */
713 /** True if the filesystem compresses of individual files.
714 * False if it doesn't or we don't know. */
715 bool fFileCompression
;
719 AssertCompileSize(SHFLFSPROPERTIES
, 12);
720 /** Pointer to a shared folder filesystem properties structure. */
721 typedef SHFLFSPROPERTIES
*PSHFLFSPROPERTIES
;
722 /** Pointer to a const shared folder filesystem properties structure. */
723 typedef SHFLFSPROPERTIES
const *PCSHFLFSPROPERTIES
;
727 * Copy file system properties from IPRT to shared folder format.
729 * @param pDst The shared folder structure.
730 * @param pSrc The IPRT structure.
732 DECLINLINE(void) vbfsCopyFsPropertiesFromIprt(PSHFLFSPROPERTIES pDst
, PCRTFSPROPERTIES pSrc
)
734 RT_ZERO(*pDst
); /* zap the implicit padding. */
735 pDst
->cbMaxComponent
= pSrc
->cbMaxComponent
;
736 pDst
->fRemote
= pSrc
->fRemote
;
737 pDst
->fCaseSensitive
= pSrc
->fCaseSensitive
;
738 pDst
->fReadOnly
= pSrc
->fReadOnly
;
739 pDst
->fSupportsUnicode
= pSrc
->fSupportsUnicode
;
740 pDst
->fCompressed
= pSrc
->fCompressed
;
741 pDst
->fFileCompression
= pSrc
->fFileCompression
;
745 typedef struct _SHFLVOLINFO
747 RTFOFF ullTotalAllocationBytes
;
748 RTFOFF ullAvailableAllocationBytes
;
749 uint32_t ulBytesPerAllocationUnit
;
750 uint32_t ulBytesPerSector
;
752 SHFLFSPROPERTIES fsProperties
;
753 } SHFLVOLINFO
, *PSHFLVOLINFO
;
757 /** Function parameter structures.
762 * SHFL_FN_QUERY_MAPPINGS
764 /** Validation mask. Needs to be adjusted
765 * whenever a new SHFL_MF_ flag is added. */
766 #define SHFL_MF_MASK (0x00000011)
767 /** UC2 enconded strings. */
768 #define SHFL_MF_UCS2 (0x00000000)
769 /** Guest uses UTF8 strings, if not set then the strings are unicode (UCS2). */
770 #define SHFL_MF_UTF8 (0x00000001)
771 /** Just handle the auto-mounted folders. */
772 #define SHFL_MF_AUTOMOUNT (0x00000010)
774 /** Type of guest system. For future system dependent features. */
775 #define SHFL_MF_SYSTEM_MASK (0x0000FF00)
776 #define SHFL_MF_SYSTEM_NONE (0x00000000)
777 #define SHFL_MF_SYSTEM_WINDOWS (0x00000100)
778 #define SHFL_MF_SYSTEM_LINUX (0x00000200)
780 /** Parameters structure. */
781 typedef struct _VBoxSFQueryMappings
783 VBGLIOCHGCMCALL callInfo
;
786 * Flags describing various client needs.
788 HGCMFunctionParameter flags
;
791 * Number of mappings the client expects.
792 * This is the number of elements in the
795 HGCMFunctionParameter numberOfMappings
;
798 * Points to array of SHFLMAPPING structures.
800 HGCMFunctionParameter mappings
;
802 } VBoxSFQueryMappings
;
804 /** Number of parameters */
805 #define SHFL_CPARMS_QUERY_MAPPINGS (3)
810 * SHFL_FN_QUERY_MAP_NAME
813 /** Parameters structure. */
814 typedef struct _VBoxSFQueryMapName
816 VBGLIOCHGCMCALL callInfo
;
818 /** 32bit, in: SHFLROOT
819 * Root handle of the mapping which name is queried.
821 HGCMFunctionParameter root
;
824 * Points to SHFLSTRING buffer.
826 HGCMFunctionParameter name
;
828 } VBoxSFQueryMapName
;
830 /** Number of parameters */
831 #define SHFL_CPARMS_QUERY_MAP_NAME (2)
834 * SHFL_FN_MAP_FOLDER_OLD
837 /** Parameters structure. */
838 typedef struct _VBoxSFMapFolder_Old
840 VBGLIOCHGCMCALL callInfo
;
843 * Points to SHFLSTRING buffer.
845 HGCMFunctionParameter path
;
847 /** pointer, out: SHFLROOT
848 * Root handle of the mapping which name is queried.
850 HGCMFunctionParameter root
;
852 /** pointer, in: RTUTF16
855 HGCMFunctionParameter delimiter
;
857 } VBoxSFMapFolder_Old
;
859 /** Number of parameters */
860 #define SHFL_CPARMS_MAP_FOLDER_OLD (3)
866 /** Parameters structure. */
867 typedef struct _VBoxSFMapFolder
869 VBGLIOCHGCMCALL callInfo
;
872 * Points to SHFLSTRING buffer.
874 HGCMFunctionParameter path
;
876 /** pointer, out: SHFLROOT
877 * Root handle of the mapping which name is queried.
879 HGCMFunctionParameter root
;
881 /** pointer, in: RTUTF16
884 HGCMFunctionParameter delimiter
;
886 /** pointer, in: SHFLROOT
889 HGCMFunctionParameter fCaseSensitive
;
893 /** Number of parameters */
894 #define SHFL_CPARMS_MAP_FOLDER (4)
897 * SHFL_FN_UNMAP_FOLDER
900 /** Parameters structure. */
901 typedef struct _VBoxSFUnmapFolder
903 VBGLIOCHGCMCALL callInfo
;
905 /** pointer, in: SHFLROOT
906 * Root handle of the mapping which name is queried.
908 HGCMFunctionParameter root
;
912 /** Number of parameters */
913 #define SHFL_CPARMS_UNMAP_FOLDER (1)
920 /** Parameters structure. */
921 typedef struct _VBoxSFCreate
923 VBGLIOCHGCMCALL callInfo
;
925 /** pointer, in: SHFLROOT
926 * Root handle of the mapping which name is queried.
928 HGCMFunctionParameter root
;
931 * Points to SHFLSTRING buffer.
933 HGCMFunctionParameter path
;
936 * Points to SHFLCREATEPARMS buffer.
938 HGCMFunctionParameter parms
;
942 /** Number of parameters */
943 #define SHFL_CPARMS_CREATE (3)
950 /** Parameters structure. */
951 typedef struct _VBoxSFClose
953 VBGLIOCHGCMCALL callInfo
;
955 /** pointer, in: SHFLROOT
956 * Root handle of the mapping which name is queried.
958 HGCMFunctionParameter root
;
962 * SHFLHANDLE of object to close.
964 HGCMFunctionParameter handle
;
968 /** Number of parameters */
969 #define SHFL_CPARMS_CLOSE (2)
976 /** Parameters structure. */
977 typedef struct _VBoxSFRead
979 VBGLIOCHGCMCALL callInfo
;
981 /** pointer, in: SHFLROOT
982 * Root handle of the mapping which name is queried.
984 HGCMFunctionParameter root
;
987 * SHFLHANDLE of object to read from.
989 HGCMFunctionParameter handle
;
992 * Offset to read from.
994 HGCMFunctionParameter offset
;
997 * Bytes to read/How many were read.
999 HGCMFunctionParameter cb
;
1002 * Buffer to place data to.
1004 HGCMFunctionParameter buffer
;
1008 /** Number of parameters */
1009 #define SHFL_CPARMS_READ (5)
1017 /** Parameters structure. */
1018 typedef struct _VBoxSFWrite
1020 VBGLIOCHGCMCALL callInfo
;
1022 /** pointer, in: SHFLROOT
1023 * Root handle of the mapping which name is queried.
1025 HGCMFunctionParameter root
;
1028 * SHFLHANDLE of object to write to.
1030 HGCMFunctionParameter handle
;
1033 * Offset to write to.
1035 HGCMFunctionParameter offset
;
1037 /** value64, in/out:
1038 * Bytes to write/How many were written.
1040 HGCMFunctionParameter cb
;
1045 HGCMFunctionParameter buffer
;
1049 /** Number of parameters */
1050 #define SHFL_CPARMS_WRITE (5)
1058 /** Lock owner is the HGCM client. */
1060 /** Lock mode bit mask. */
1061 #define SHFL_LOCK_MODE_MASK (0x3)
1062 /** Cancel lock on the given range. */
1063 #define SHFL_LOCK_CANCEL (0x0)
1064 /** Acquire read only lock. Prevent write to the range. */
1065 #define SHFL_LOCK_SHARED (0x1)
1066 /** Acquire write lock. Prevent both write and read to the range. */
1067 #define SHFL_LOCK_EXCLUSIVE (0x2)
1069 /** Do not wait for lock if it can not be acquired at the time. */
1070 #define SHFL_LOCK_NOWAIT (0x0)
1071 /** Wait and acquire lock. */
1072 #define SHFL_LOCK_WAIT (0x4)
1074 /** Lock the specified range. */
1075 #define SHFL_LOCK_PARTIAL (0x0)
1076 /** Lock entire object. */
1077 #define SHFL_LOCK_ENTIRE (0x8)
1079 /** Parameters structure. */
1080 typedef struct _VBoxSFLock
1082 VBGLIOCHGCMCALL callInfo
;
1084 /** pointer, in: SHFLROOT
1085 * Root handle of the mapping which name is queried.
1087 HGCMFunctionParameter root
;
1090 * SHFLHANDLE of object to be locked.
1092 HGCMFunctionParameter handle
;
1095 * Starting offset of lock range.
1097 HGCMFunctionParameter offset
;
1102 HGCMFunctionParameter length
;
1105 * Lock flags SHFL_LOCK_*.
1107 HGCMFunctionParameter flags
;
1111 /** Number of parameters */
1112 #define SHFL_CPARMS_LOCK (5)
1120 /** Parameters structure. */
1121 typedef struct _VBoxSFFlush
1123 VBGLIOCHGCMCALL callInfo
;
1125 /** pointer, in: SHFLROOT
1126 * Root handle of the mapping which name is queried.
1128 HGCMFunctionParameter root
;
1131 * SHFLHANDLE of object to be locked.
1133 HGCMFunctionParameter handle
;
1137 /** Number of parameters */
1138 #define SHFL_CPARMS_FLUSH (2)
1144 /** Listing information includes variable length RTDIRENTRY[EX] structures. */
1146 /** @todo might be necessary for future. */
1147 #define SHFL_LIST_NONE 0
1148 #define SHFL_LIST_RETURN_ONE 1
1150 /** Parameters structure. */
1151 typedef struct _VBoxSFList
1153 VBGLIOCHGCMCALL callInfo
;
1155 /** pointer, in: SHFLROOT
1156 * Root handle of the mapping which name is queried.
1158 HGCMFunctionParameter root
;
1161 * SHFLHANDLE of object to be listed.
1163 HGCMFunctionParameter handle
;
1166 * List flags SHFL_LIST_*.
1168 HGCMFunctionParameter flags
;
1170 /** value32, in/out:
1171 * Bytes to be used for listing information/How many bytes were used.
1173 HGCMFunctionParameter cb
;
1175 /** pointer, in/optional
1176 * Points to SHFLSTRING buffer that specifies a search path.
1178 HGCMFunctionParameter path
;
1181 * Buffer to place listing information to. (SHFLDIRINFO)
1183 HGCMFunctionParameter buffer
;
1185 /** value32, in/out:
1186 * Indicates a key where the listing must be resumed.
1187 * in: 0 means start from begin of object.
1188 * out: 0 means listing completed.
1190 HGCMFunctionParameter resumePoint
;
1193 * Number of files returned
1195 HGCMFunctionParameter cFiles
;
1199 /** Number of parameters */
1200 #define SHFL_CPARMS_LIST (8)
1208 /** Parameters structure. */
1209 typedef struct _VBoxSFReadLink
1211 VBGLIOCHGCMCALL callInfo
;
1213 /** pointer, in: SHFLROOT
1214 * Root handle of the mapping which name is queried.
1216 HGCMFunctionParameter root
;
1219 * Points to SHFLSTRING buffer.
1221 HGCMFunctionParameter path
;
1224 * Buffer to place data to.
1226 HGCMFunctionParameter buffer
;
1230 /** Number of parameters */
1231 #define SHFL_CPARMS_READLINK (3)
1236 * SHFL_FN_INFORMATION
1239 /** Mask of Set/Get bit. */
1240 #define SHFL_INFO_MODE_MASK (0x1)
1241 /** Get information */
1242 #define SHFL_INFO_GET (0x0)
1243 /** Set information */
1244 #define SHFL_INFO_SET (0x1)
1246 /** Get name of the object. */
1247 #define SHFL_INFO_NAME (0x2)
1248 /** Set size of object (extend/trucate); only applies to file objects */
1249 #define SHFL_INFO_SIZE (0x4)
1250 /** Get/Set file object info. */
1251 #define SHFL_INFO_FILE (0x8)
1252 /** Get volume information. */
1253 #define SHFL_INFO_VOLUME (0x10)
1255 /** @todo different file info structures */
1258 /** Parameters structure. */
1259 typedef struct _VBoxSFInformation
1261 VBGLIOCHGCMCALL callInfo
;
1263 /** pointer, in: SHFLROOT
1264 * Root handle of the mapping which name is queried.
1266 HGCMFunctionParameter root
;
1269 * SHFLHANDLE of object to be listed.
1271 HGCMFunctionParameter handle
;
1276 HGCMFunctionParameter flags
;
1278 /** value32, in/out:
1279 * Bytes to be used for information/How many bytes were used.
1281 HGCMFunctionParameter cb
;
1283 /** pointer, in/out:
1284 * Information to be set/get (SHFLFSOBJINFO or SHFLSTRING). Do not forget
1285 * to set the SHFLFSOBJINFO::Attr::enmAdditional for Get operation as well.
1287 HGCMFunctionParameter info
;
1289 } VBoxSFInformation
;
1291 /** Number of parameters */
1292 #define SHFL_CPARMS_INFORMATION (5)
1299 #define SHFL_REMOVE_FILE (0x1)
1300 #define SHFL_REMOVE_DIR (0x2)
1301 #define SHFL_REMOVE_SYMLINK (0x4)
1303 /** Parameters structure. */
1304 typedef struct _VBoxSFRemove
1306 VBGLIOCHGCMCALL callInfo
;
1308 /** pointer, in: SHFLROOT
1309 * Root handle of the mapping which name is queried.
1311 HGCMFunctionParameter root
;
1314 * Points to SHFLSTRING buffer.
1316 HGCMFunctionParameter path
;
1319 * remove flags (file/directory)
1321 HGCMFunctionParameter flags
;
1325 #define SHFL_CPARMS_REMOVE (3)
1332 #define SHFL_RENAME_FILE (0x1)
1333 #define SHFL_RENAME_DIR (0x2)
1334 #define SHFL_RENAME_REPLACE_IF_EXISTS (0x4)
1336 /** Parameters structure. */
1337 typedef struct _VBoxSFRename
1339 VBGLIOCHGCMCALL callInfo
;
1341 /** pointer, in: SHFLROOT
1342 * Root handle of the mapping which name is queried.
1344 HGCMFunctionParameter root
;
1347 * Points to SHFLSTRING src.
1349 HGCMFunctionParameter src
;
1352 * Points to SHFLSTRING dest.
1354 HGCMFunctionParameter dest
;
1357 * rename flags (file/directory)
1359 HGCMFunctionParameter flags
;
1363 #define SHFL_CPARMS_RENAME (4)
1370 /** Parameters structure. */
1371 typedef struct _VBoxSFSymlink
1373 VBGLIOCHGCMCALL callInfo
;
1375 /** pointer, in: SHFLROOT
1376 * Root handle of the mapping which name is queried.
1378 HGCMFunctionParameter root
;
1381 * Points to SHFLSTRING of path for the new symlink.
1383 HGCMFunctionParameter newPath
;
1386 * Points to SHFLSTRING of destination for symlink.
1388 HGCMFunctionParameter oldPath
;
1391 * Information about created symlink.
1393 HGCMFunctionParameter info
;
1397 #define SHFL_CPARMS_SYMLINK (4)
1402 * SHFL_FN_ADD_MAPPING
1403 * Host call, no guest structure is used.
1406 /** mapping is writable */
1407 #define SHFL_ADD_MAPPING_F_WRITABLE (RT_BIT_32(0))
1408 /** mapping is automounted by the guest */
1409 #define SHFL_ADD_MAPPING_F_AUTOMOUNT (RT_BIT_32(1))
1410 /** allow the guest to create symlinks */
1411 #define SHFL_ADD_MAPPING_F_CREATE_SYMLINKS (RT_BIT_32(2))
1412 /** mapping is actually missing on the host */
1413 #define SHFL_ADD_MAPPING_F_MISSING (RT_BIT_32(3))
1415 #define SHFL_CPARMS_ADD_MAPPING (3)
1418 * SHFL_FN_REMOVE_MAPPING
1419 * Host call, no guest structure is used.
1422 #define SHFL_CPARMS_REMOVE_MAPPING (1)
1426 * SHFL_FN_SET_STATUS_LED
1427 * Host call, no guest structure is used.
1430 #define SHFL_CPARMS_SET_STATUS_LED (1)