VirtualBox

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

Last change on this file since 67180 was 66101, checked in by vboxsync, 8 years ago

SharedFolders: Some adjustments necessary for flexible array syntax in SHFLSTRING.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 37.4 KB
Line 
1/** @file
2 * Shared Folders: Common header for host service and guest clients.
3 */
4
5/*
6 * Copyright (C) 2006-2016 Oracle Corporation
7 *
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.
15 *
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.
21 *
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.
24 */
25
26#ifndef ___VBox_shflsvc_h
27#define ___VBox_shflsvc_h
28
29#include <VBox/types.h>
30#include <VBox/VBoxGuest2.h>
31#include <VBox/VMMDev.h>
32#include <VBox/hgcmsvc.h>
33#include <iprt/fs.h>
34#include <iprt/assert.h>
35
36
37/** @name Some bit flag manipulation macros.
38 * @{ */
39#ifndef BIT_FLAG
40#define BIT_FLAG(__Field,__Flag) ((__Field) & (__Flag))
41#endif
42
43#ifndef BIT_FLAG_SET
44#define BIT_FLAG_SET(__Field,__Flag) ((__Field) |= (__Flag))
45#endif
46
47#ifndef BIT_FLAG_CLEAR
48#define BIT_FLAG_CLEAR(__Field,__Flag) ((__Field) &= ~(__Flag))
49#endif
50/** @} */
51
52
53/**
54 * Structures shared between guest and the service
55 * can be relocated and use offsets to point to variable
56 * length parts.
57 */
58
59/**
60 * Shared folders protocol works with handles.
61 * Before doing any action on a file system object,
62 * one have to obtain the object handle via a SHFL_FN_CREATE
63 * request. A handle must be closed with SHFL_FN_CLOSE.
64 */
65
66/** Shared Folders service functions. (guest)
67 * @{
68 */
69
70/** Query mappings changes. */
71#define SHFL_FN_QUERY_MAPPINGS (1)
72/** Query mappings changes. */
73#define SHFL_FN_QUERY_MAP_NAME (2)
74/** Open/create object. */
75#define SHFL_FN_CREATE (3)
76/** Close object handle. */
77#define SHFL_FN_CLOSE (4)
78/** Read object content. */
79#define SHFL_FN_READ (5)
80/** Write new object content. */
81#define SHFL_FN_WRITE (6)
82/** Lock/unlock a range in the object. */
83#define SHFL_FN_LOCK (7)
84/** List object content. */
85#define SHFL_FN_LIST (8)
86/** Query/set object information. */
87#define SHFL_FN_INFORMATION (9)
88/** Remove object */
89#define SHFL_FN_REMOVE (11)
90/** Map folder (legacy) */
91#define SHFL_FN_MAP_FOLDER_OLD (12)
92/** Unmap folder */
93#define SHFL_FN_UNMAP_FOLDER (13)
94/** Rename object (possibly moving it to another directory) */
95#define SHFL_FN_RENAME (14)
96/** Flush file */
97#define SHFL_FN_FLUSH (15)
98/** @todo macl, a description, please. */
99#define SHFL_FN_SET_UTF8 (16)
100/** Map folder */
101#define SHFL_FN_MAP_FOLDER (17)
102/** Read symlink destination (as of VBox 4.0) */
103#define SHFL_FN_READLINK (18)
104/** Create symlink (as of VBox 4.0) */
105#define SHFL_FN_SYMLINK (19)
106/** Ask host to show symlinks (as of VBox 4.0) */
107#define SHFL_FN_SET_SYMLINKS (20)
108
109/** @} */
110
111/** Shared Folders service functions. (host)
112 * @{
113 */
114
115/** Add shared folder mapping. */
116#define SHFL_FN_ADD_MAPPING (1)
117/** Remove shared folder mapping. */
118#define SHFL_FN_REMOVE_MAPPING (2)
119/** Set the led status light address. */
120#define SHFL_FN_SET_STATUS_LED (3)
121/** Allow the guest to create symbolic links (as of VBox 4.0) */
122#define SHFL_FN_ALLOW_SYMLINKS_CREATE (4)
123/** @} */
124
125/** Root handle for a mapping. Root handles are unique.
126 * @note
127 * Function parameters structures consider
128 * the root handle as 32 bit value. If the typedef
129 * will be changed, then function parameters must be
130 * changed accordingly. All those parameters are marked
131 * with SHFLROOT in comments.
132 */
133typedef uint32_t SHFLROOT;
134
135#define SHFL_ROOT_NIL ((SHFLROOT)~0)
136
137
138/** A shared folders handle for an opened object. */
139typedef uint64_t SHFLHANDLE;
140
141#define SHFL_HANDLE_NIL ((SHFLHANDLE)~0LL)
142#define SHFL_HANDLE_ROOT ((SHFLHANDLE)0LL)
143
144/** Hardcoded maximum length (in chars) of a shared folder name. */
145#define SHFL_MAX_LEN (256)
146/** Hardcoded maximum number of shared folder mapping available to the guest. */
147#define SHFL_MAX_MAPPINGS (64)
148
149/** @name Shared Folders strings. They can be either UTF-8 or UTF-16.
150 * @{
151 */
152
153/**
154 * Shared folder string buffer structure.
155 */
156typedef struct _SHFLSTRING
157{
158 /** Allocated size of the String member in bytes. */
159 uint16_t u16Size;
160
161 /** Length of string without trailing nul in bytes. */
162 uint16_t u16Length;
163
164 /** UTF-8 or UTF-16 string. Nul terminated. */
165 union
166 {
167#if 1
168 uint8_t utf8[1];
169 RTUTF16 utf16[1];
170 uint16_t ucs2[1]; /**< misnomer, use utf16. */
171#else
172 uint8_t utf8[RT_FLEXIBLE_ARRAY_IN_NESTED_UNION];
173 RTUTF16 utf16[RT_FLEXIBLE_ARRAY_IN_NESTED_UNION];
174 RTUTF16 ucs2[RT_FLEXIBLE_ARRAY_IN_NESTED_UNION]; /**< misnomer, use utf16. */
175#endif
176 } String;
177} SHFLSTRING;
178AssertCompileSize(RTUTF16, 2);
179AssertCompileSize(SHFLSTRING, 6);
180AssertCompileMemberOffset(SHFLSTRING, String, 4);
181/** The size of SHFLSTRING w/o the string part. */
182#define SHFLSTRING_HEADER_SIZE 4
183AssertCompileMemberOffset(SHFLSTRING, String, SHFLSTRING_HEADER_SIZE);
184
185/** Pointer to a shared folder string buffer. */
186typedef SHFLSTRING *PSHFLSTRING;
187/** Pointer to a const shared folder string buffer. */
188typedef const SHFLSTRING *PCSHFLSTRING;
189
190/** Calculate size of the string. */
191DECLINLINE(uint32_t) ShflStringSizeOfBuffer(PCSHFLSTRING pString)
192{
193 return pString ? (uint32_t)(SHFLSTRING_HEADER_SIZE + pString->u16Size) : 0;
194}
195
196DECLINLINE(uint32_t) ShflStringLength(PCSHFLSTRING pString)
197{
198 return pString ? pString->u16Length : 0;
199}
200
201DECLINLINE(PSHFLSTRING) ShflStringInitBuffer(void *pvBuffer, uint32_t u32Size)
202{
203 PSHFLSTRING pString = NULL;
204 const uint32_t u32HeaderSize = SHFLSTRING_HEADER_SIZE;
205
206 /*
207 * Check that the buffer size is big enough to hold a zero sized string
208 * and is not too big to fit into 16 bit variables.
209 */
210 if (u32Size >= u32HeaderSize && u32Size - u32HeaderSize <= 0xFFFF)
211 {
212 pString = (PSHFLSTRING)pvBuffer;
213 pString->u16Size = (uint16_t)(u32Size - u32HeaderSize);
214 pString->u16Length = 0;
215 if (pString->u16Size >= sizeof(pString->String.ucs2[0]))
216 pString->String.ucs2[0] = 0;
217 else if (pString->u16Size >= sizeof(pString->String.utf8[0]))
218 pString->String.utf8[0] = 0;
219 }
220
221 return pString;
222}
223
224/**
225 * Validates a HGCM string output parameter.
226 *
227 * @returns true if valid, false if not.
228 *
229 * @param pString The string buffer pointer.
230 * @param cbBuf The buffer size from the parameter.
231 */
232DECLINLINE(bool) ShflStringIsValidOut(PCSHFLSTRING pString, uint32_t cbBuf)
233{
234 if (RT_LIKELY(cbBuf > RT_UOFFSETOF(SHFLSTRING, String)))
235 if (RT_LIKELY((uint32_t)pString->u16Size + RT_UOFFSETOF(SHFLSTRING, String) <= cbBuf))
236 if (RT_LIKELY(pString->u16Length < pString->u16Size))
237 return true;
238 return false;
239}
240
241/**
242 * Validates a HGCM string input parameter.
243 *
244 * @returns true if valid, false if not.
245 *
246 * @param pString The string buffer pointer.
247 * @param cbBuf The buffer size from the parameter.
248 * @param fUtf8Not16 Set if UTF-8 encoding, clear if UTF-16 encoding.
249 */
250DECLINLINE(bool) ShflStringIsValidIn(PCSHFLSTRING pString, uint32_t cbBuf, bool fUtf8Not16)
251{
252 int rc;
253 if (RT_LIKELY(cbBuf > RT_UOFFSETOF(SHFLSTRING, String)))
254 {
255 if (RT_LIKELY((uint32_t)pString->u16Size + RT_UOFFSETOF(SHFLSTRING, String) <= cbBuf))
256 {
257 if (fUtf8Not16)
258 {
259 /* UTF-8: */
260 if (RT_LIKELY(pString->u16Length < pString->u16Size))
261 {
262 rc = RTStrValidateEncodingEx((const char *)&pString->String.utf8[0], pString->u16Length + 1,
263 RTSTR_VALIDATE_ENCODING_EXACT_LENGTH | RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED);
264 if (RT_SUCCESS(rc))
265 return true;
266 }
267 }
268 else
269 {
270 /* UTF-16: */
271 if (RT_LIKELY(!(pString->u16Length & 1)))
272 {
273 if (RT_LIKELY((uint32_t)sizeof(RTUTF16) + pString->u16Length <= pString->u16Size))
274 {
275 rc = RTUtf16ValidateEncodingEx(&pString->String.ucs2[0], pString->u16Length / 2 + 1,
276 RTSTR_VALIDATE_ENCODING_EXACT_LENGTH
277 | RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED);
278 if (RT_SUCCESS(rc))
279 return true;
280 }
281 }
282 }
283 }
284 }
285 return false;
286}
287
288/**
289 * Validates an optional HGCM string input parameter.
290 *
291 * @returns true if valid, false if not.
292 *
293 * @param pString The string buffer pointer. Can be NULL.
294 * @param cbBuf The buffer size from the parameter.
295 * @param fUtf8Not16 Set if UTF-8 encoding, clear if UTF-16 encoding.
296 */
297DECLINLINE(bool) ShflStringIsValidOrNullIn(PCSHFLSTRING pString, uint32_t cbBuf, bool fUtf8Not16)
298{
299 if (pString)
300 return ShflStringIsValidIn(pString, cbBuf, fUtf8Not16);
301 if (RT_LIKELY(cbBuf == 0))
302 return true;
303 return false;
304}
305
306/** @} */
307
308
309/**
310 * The available additional information in a SHFLFSOBJATTR object.
311 */
312typedef enum SHFLFSOBJATTRADD
313{
314 /** No additional information is available / requested. */
315 SHFLFSOBJATTRADD_NOTHING = 1,
316 /** The additional unix attributes (SHFLFSOBJATTR::u::Unix) are
317 * available / requested. */
318 SHFLFSOBJATTRADD_UNIX,
319 /** The additional extended attribute size (SHFLFSOBJATTR::u::EASize) is
320 * available / requested. */
321 SHFLFSOBJATTRADD_EASIZE,
322 /** The last valid item (inclusive).
323 * The valid range is SHFLFSOBJATTRADD_NOTHING thru
324 * SHFLFSOBJATTRADD_LAST. */
325 SHFLFSOBJATTRADD_LAST = SHFLFSOBJATTRADD_EASIZE,
326
327 /** The usual 32-bit hack. */
328 SHFLFSOBJATTRADD_32BIT_SIZE_HACK = 0x7fffffff
329} SHFLFSOBJATTRADD;
330
331
332/* Assert sizes of the IRPT types we're using below. */
333AssertCompileSize(RTFMODE, 4);
334AssertCompileSize(RTFOFF, 8);
335AssertCompileSize(RTINODE, 8);
336AssertCompileSize(RTTIMESPEC, 8);
337AssertCompileSize(RTDEV, 4);
338AssertCompileSize(RTUID, 4);
339
340/**
341 * Shared folder filesystem object attributes.
342 */
343#pragma pack(1)
344typedef struct SHFLFSOBJATTR
345{
346 /** Mode flags (st_mode). RTFS_UNIX_*, RTFS_TYPE_*, and RTFS_DOS_*.
347 * @remarks We depend on a number of RTFS_ defines to remain unchanged.
348 * Fortuntately, these are depending on windows, dos and unix
349 * standard values, so this shouldn't be much of a pain. */
350 RTFMODE fMode;
351
352 /** The additional attributes available. */
353 SHFLFSOBJATTRADD enmAdditional;
354
355 /**
356 * Additional attributes.
357 *
358 * Unless explicitly specified to an API, the API can provide additional
359 * data as it is provided by the underlying OS.
360 */
361 union SHFLFSOBJATTRUNION
362 {
363 /** Additional Unix Attributes
364 * These are available when SHFLFSOBJATTRADD is set in fUnix.
365 */
366 struct SHFLFSOBJATTRUNIX
367 {
368 /** The user owning the filesystem object (st_uid).
369 * This field is ~0U if not supported. */
370 RTUID uid;
371
372 /** The group the filesystem object is assigned (st_gid).
373 * This field is ~0U if not supported. */
374 RTGID gid;
375
376 /** Number of hard links to this filesystem object (st_nlink).
377 * This field is 1 if the filesystem doesn't support hardlinking or
378 * the information isn't available.
379 */
380 uint32_t cHardlinks;
381
382 /** The device number of the device which this filesystem object resides on (st_dev).
383 * This field is 0 if this information is not available. */
384 RTDEV INodeIdDevice;
385
386 /** The unique identifier (within the filesystem) of this filesystem object (st_ino).
387 * Together with INodeIdDevice, this field can be used as a OS wide unique id
388 * when both their values are not 0.
389 * This field is 0 if the information is not available. */
390 RTINODE INodeId;
391
392 /** User flags (st_flags).
393 * This field is 0 if this information is not available. */
394 uint32_t fFlags;
395
396 /** The current generation number (st_gen).
397 * This field is 0 if this information is not available. */
398 uint32_t GenerationId;
399
400 /** The device number of a character or block device type object (st_rdev).
401 * This field is 0 if the file isn't of a character or block device type and
402 * when the OS doesn't subscribe to the major+minor device idenfication scheme. */
403 RTDEV Device;
404 } Unix;
405
406 /**
407 * Extended attribute size.
408 */
409 struct SHFLFSOBJATTREASIZE
410 {
411 /** Size of EAs. */
412 RTFOFF cb;
413 } EASize;
414 } u;
415} SHFLFSOBJATTR;
416#pragma pack()
417AssertCompileSize(SHFLFSOBJATTR, 44);
418/** Pointer to a shared folder filesystem object attributes structure. */
419typedef SHFLFSOBJATTR *PSHFLFSOBJATTR;
420/** Pointer to a const shared folder filesystem object attributes structure. */
421typedef const SHFLFSOBJATTR *PCSHFLFSOBJATTR;
422
423
424/**
425 * Filesystem object information structure.
426 */
427#pragma pack(1)
428typedef struct SHFLFSOBJINFO
429{
430 /** Logical size (st_size).
431 * For normal files this is the size of the file.
432 * For symbolic links, this is the length of the path name contained
433 * in the symbolic link.
434 * For other objects this fields needs to be specified.
435 */
436 RTFOFF cbObject;
437
438 /** Disk allocation size (st_blocks * DEV_BSIZE). */
439 RTFOFF cbAllocated;
440
441 /** Time of last access (st_atime).
442 * @remarks Here (and other places) we depend on the IPRT timespec to
443 * remain unchanged. */
444 RTTIMESPEC AccessTime;
445
446 /** Time of last data modification (st_mtime). */
447 RTTIMESPEC ModificationTime;
448
449 /** Time of last status change (st_ctime).
450 * If not available this is set to ModificationTime.
451 */
452 RTTIMESPEC ChangeTime;
453
454 /** Time of file birth (st_birthtime).
455 * If not available this is set to ChangeTime.
456 */
457 RTTIMESPEC BirthTime;
458
459 /** Attributes. */
460 SHFLFSOBJATTR Attr;
461
462} SHFLFSOBJINFO;
463#pragma pack()
464AssertCompileSize(SHFLFSOBJINFO, 92);
465/** Pointer to a shared folder filesystem object information structure. */
466typedef SHFLFSOBJINFO *PSHFLFSOBJINFO;
467/** Pointer to a const shared folder filesystem object information
468 * structure. */
469typedef const SHFLFSOBJINFO *PCSHFLFSOBJINFO;
470
471
472/**
473 * Copy file system objinfo from IPRT to shared folder format.
474 *
475 * @param pDst The shared folder structure.
476 * @param pSrc The IPRT structure.
477 */
478DECLINLINE(void) vbfsCopyFsObjInfoFromIprt(PSHFLFSOBJINFO pDst, PCRTFSOBJINFO pSrc)
479{
480 pDst->cbObject = pSrc->cbObject;
481 pDst->cbAllocated = pSrc->cbAllocated;
482 pDst->AccessTime = pSrc->AccessTime;
483 pDst->ModificationTime = pSrc->ModificationTime;
484 pDst->ChangeTime = pSrc->ChangeTime;
485 pDst->BirthTime = pSrc->BirthTime;
486 pDst->Attr.fMode = pSrc->Attr.fMode;
487 RT_ZERO(pDst->Attr.u);
488 switch (pSrc->Attr.enmAdditional)
489 {
490 default:
491 case RTFSOBJATTRADD_NOTHING:
492 pDst->Attr.enmAdditional = SHFLFSOBJATTRADD_NOTHING;
493 break;
494
495 case RTFSOBJATTRADD_UNIX:
496 pDst->Attr.enmAdditional = SHFLFSOBJATTRADD_UNIX;
497 pDst->Attr.u.Unix.uid = pSrc->Attr.u.Unix.uid;
498 pDst->Attr.u.Unix.gid = pSrc->Attr.u.Unix.gid;
499 pDst->Attr.u.Unix.cHardlinks = pSrc->Attr.u.Unix.cHardlinks;
500 pDst->Attr.u.Unix.INodeIdDevice = pSrc->Attr.u.Unix.INodeIdDevice;
501 pDst->Attr.u.Unix.INodeId = pSrc->Attr.u.Unix.INodeId;
502 pDst->Attr.u.Unix.fFlags = pSrc->Attr.u.Unix.fFlags;
503 pDst->Attr.u.Unix.GenerationId = pSrc->Attr.u.Unix.GenerationId;
504 pDst->Attr.u.Unix.Device = pSrc->Attr.u.Unix.Device;
505 break;
506
507 case RTFSOBJATTRADD_EASIZE:
508 pDst->Attr.enmAdditional = SHFLFSOBJATTRADD_EASIZE;
509 pDst->Attr.u.EASize.cb = pSrc->Attr.u.EASize.cb;
510 break;
511 }
512}
513
514
515/** Result of an open/create request.
516 * Along with handle value the result code
517 * identifies what has happened while
518 * trying to open the object.
519 */
520typedef enum _SHFLCREATERESULT
521{
522 SHFL_NO_RESULT,
523 /** Specified path does not exist. */
524 SHFL_PATH_NOT_FOUND,
525 /** Path to file exists, but the last component does not. */
526 SHFL_FILE_NOT_FOUND,
527 /** File already exists and either has been opened or not. */
528 SHFL_FILE_EXISTS,
529 /** New file was created. */
530 SHFL_FILE_CREATED,
531 /** Existing file was replaced or overwritten. */
532 SHFL_FILE_REPLACED
533} SHFLCREATERESULT;
534
535
536/** Open/create flags.
537 * @{
538 */
539
540/** No flags. Initialization value. */
541#define SHFL_CF_NONE (0x00000000)
542
543/** Lookup only the object, do not return a handle. All other flags are ignored. */
544#define SHFL_CF_LOOKUP (0x00000001)
545
546/** Open parent directory of specified object.
547 * Useful for the corresponding Windows FSD flag
548 * and for opening paths like \\dir\\*.* to search the 'dir'.
549 * @todo possibly not needed???
550 */
551#define SHFL_CF_OPEN_TARGET_DIRECTORY (0x00000002)
552
553/** Create/open a directory. */
554#define SHFL_CF_DIRECTORY (0x00000004)
555
556/** Open/create action to do if object exists
557 * and if the object does not exists.
558 * REPLACE file means atomically DELETE and CREATE.
559 * OVERWRITE file means truncating the file to 0 and
560 * setting new size.
561 * When opening an existing directory REPLACE and OVERWRITE
562 * actions are considered invalid, and cause returning
563 * FILE_EXISTS with NIL handle.
564 */
565#define SHFL_CF_ACT_MASK_IF_EXISTS (0x000000F0)
566#define SHFL_CF_ACT_MASK_IF_NEW (0x00000F00)
567
568/** What to do if object exists. */
569#define SHFL_CF_ACT_OPEN_IF_EXISTS (0x00000000)
570#define SHFL_CF_ACT_FAIL_IF_EXISTS (0x00000010)
571#define SHFL_CF_ACT_REPLACE_IF_EXISTS (0x00000020)
572#define SHFL_CF_ACT_OVERWRITE_IF_EXISTS (0x00000030)
573
574/** What to do if object does not exist. */
575#define SHFL_CF_ACT_CREATE_IF_NEW (0x00000000)
576#define SHFL_CF_ACT_FAIL_IF_NEW (0x00000100)
577
578/** Read/write requested access for the object. */
579#define SHFL_CF_ACCESS_MASK_RW (0x00003000)
580
581/** No access requested. */
582#define SHFL_CF_ACCESS_NONE (0x00000000)
583/** Read access requested. */
584#define SHFL_CF_ACCESS_READ (0x00001000)
585/** Write access requested. */
586#define SHFL_CF_ACCESS_WRITE (0x00002000)
587/** Read/Write access requested. */
588#define SHFL_CF_ACCESS_READWRITE (SHFL_CF_ACCESS_READ | SHFL_CF_ACCESS_WRITE)
589
590/** Requested share access for the object. */
591#define SHFL_CF_ACCESS_MASK_DENY (0x0000C000)
592
593/** Allow any access. */
594#define SHFL_CF_ACCESS_DENYNONE (0x00000000)
595/** Do not allow read. */
596#define SHFL_CF_ACCESS_DENYREAD (0x00004000)
597/** Do not allow write. */
598#define SHFL_CF_ACCESS_DENYWRITE (0x00008000)
599/** Do not allow access. */
600#define SHFL_CF_ACCESS_DENYALL (SHFL_CF_ACCESS_DENYREAD | SHFL_CF_ACCESS_DENYWRITE)
601
602/** Requested access to attributes of the object. */
603#define SHFL_CF_ACCESS_MASK_ATTR (0x00030000)
604
605/** No access requested. */
606#define SHFL_CF_ACCESS_ATTR_NONE (0x00000000)
607/** Read access requested. */
608#define SHFL_CF_ACCESS_ATTR_READ (0x00010000)
609/** Write access requested. */
610#define SHFL_CF_ACCESS_ATTR_WRITE (0x00020000)
611/** Read/Write access requested. */
612#define SHFL_CF_ACCESS_ATTR_READWRITE (SHFL_CF_ACCESS_ATTR_READ | SHFL_CF_ACCESS_ATTR_WRITE)
613
614/** The file is opened in append mode. Ignored if SHFL_CF_ACCESS_WRITE is not set. */
615#define SHFL_CF_ACCESS_APPEND (0x00040000)
616
617/** @} */
618
619#pragma pack(1)
620typedef struct _SHFLCREATEPARMS
621{
622 /* Returned handle of opened object. */
623 SHFLHANDLE Handle;
624
625 /* Returned result of the operation */
626 SHFLCREATERESULT Result;
627
628 /* SHFL_CF_* */
629 uint32_t CreateFlags;
630
631 /* Attributes of object to create and
632 * returned actual attributes of opened/created object.
633 */
634 SHFLFSOBJINFO Info;
635
636} SHFLCREATEPARMS;
637#pragma pack()
638
639typedef SHFLCREATEPARMS *PSHFLCREATEPARMS;
640
641
642/** Shared Folders mappings.
643 * @{
644 */
645
646/** The mapping has been added since last query. */
647#define SHFL_MS_NEW (1)
648/** The mapping has been deleted since last query. */
649#define SHFL_MS_DELETED (2)
650
651typedef struct _SHFLMAPPING
652{
653 /** Mapping status. */
654 uint32_t u32Status;
655 /** Root handle. */
656 SHFLROOT root;
657} SHFLMAPPING;
658/** Pointer to a SHFLMAPPING structure. */
659typedef SHFLMAPPING *PSHFLMAPPING;
660
661/** @} */
662
663/** Shared Folder directory information
664 * @{
665 */
666
667typedef struct _SHFLDIRINFO
668{
669 /** Full information about the object. */
670 SHFLFSOBJINFO Info;
671 /** The length of the short field (number of RTUTF16 chars).
672 * It is 16-bit for reasons of alignment. */
673 uint16_t cucShortName;
674 /** The short name for 8.3 compatibility.
675 * Empty string if not available.
676 */
677 RTUTF16 uszShortName[14];
678 /** @todo malc, a description, please. */
679 SHFLSTRING name;
680} SHFLDIRINFO, *PSHFLDIRINFO;
681
682
683/**
684 * Shared folder filesystem properties.
685 */
686typedef struct SHFLFSPROPERTIES
687{
688 /** The maximum size of a filesystem object name.
689 * This does not include the '\\0'. */
690 uint32_t cbMaxComponent;
691
692 /** True if the filesystem is remote.
693 * False if the filesystem is local. */
694 bool fRemote;
695
696 /** True if the filesystem is case sensitive.
697 * False if the filesystem is case insensitive. */
698 bool fCaseSensitive;
699
700 /** True if the filesystem is mounted read only.
701 * False if the filesystem is mounted read write. */
702 bool fReadOnly;
703
704 /** True if the filesystem can encode unicode object names.
705 * False if it can't. */
706 bool fSupportsUnicode;
707
708 /** True if the filesystem is compresses.
709 * False if it isn't or we don't know. */
710 bool fCompressed;
711
712 /** True if the filesystem compresses of individual files.
713 * False if it doesn't or we don't know. */
714 bool fFileCompression;
715
716 /** @todo more? */
717} SHFLFSPROPERTIES;
718AssertCompileSize(SHFLFSPROPERTIES, 12);
719/** Pointer to a shared folder filesystem properties structure. */
720typedef SHFLFSPROPERTIES *PSHFLFSPROPERTIES;
721/** Pointer to a const shared folder filesystem properties structure. */
722typedef SHFLFSPROPERTIES const *PCSHFLFSPROPERTIES;
723
724
725/**
726 * Copy file system properties from IPRT to shared folder format.
727 *
728 * @param pDst The shared folder structure.
729 * @param pSrc The IPRT structure.
730 */
731DECLINLINE(void) vbfsCopyFsPropertiesFromIprt(PSHFLFSPROPERTIES pDst, PCRTFSPROPERTIES pSrc)
732{
733 RT_ZERO(*pDst); /* zap the implicit padding. */
734 pDst->cbMaxComponent = pSrc->cbMaxComponent;
735 pDst->fRemote = pSrc->fRemote;
736 pDst->fCaseSensitive = pSrc->fCaseSensitive;
737 pDst->fReadOnly = pSrc->fReadOnly;
738 pDst->fSupportsUnicode = pSrc->fSupportsUnicode;
739 pDst->fCompressed = pSrc->fCompressed;
740 pDst->fFileCompression = pSrc->fFileCompression;
741}
742
743
744typedef struct _SHFLVOLINFO
745{
746 RTFOFF ullTotalAllocationBytes;
747 RTFOFF ullAvailableAllocationBytes;
748 uint32_t ulBytesPerAllocationUnit;
749 uint32_t ulBytesPerSector;
750 uint32_t ulSerial;
751 SHFLFSPROPERTIES fsProperties;
752} SHFLVOLINFO, *PSHFLVOLINFO;
753
754/** @} */
755
756/** Function parameter structures.
757 * @{
758 */
759
760/**
761 * SHFL_FN_QUERY_MAPPINGS
762 */
763/** Validation mask. Needs to be adjusted
764 * whenever a new SHFL_MF_ flag is added. */
765#define SHFL_MF_MASK (0x00000011)
766/** UC2 enconded strings. */
767#define SHFL_MF_UCS2 (0x00000000)
768/** Guest uses UTF8 strings, if not set then the strings are unicode (UCS2). */
769#define SHFL_MF_UTF8 (0x00000001)
770/** Just handle the auto-mounted folders. */
771#define SHFL_MF_AUTOMOUNT (0x00000010)
772
773/** Type of guest system. For future system dependent features. */
774#define SHFL_MF_SYSTEM_MASK (0x0000FF00)
775#define SHFL_MF_SYSTEM_NONE (0x00000000)
776#define SHFL_MF_SYSTEM_WINDOWS (0x00000100)
777#define SHFL_MF_SYSTEM_LINUX (0x00000200)
778
779/** Parameters structure. */
780typedef struct _VBoxSFQueryMappings
781{
782 VBoxGuestHGCMCallInfo callInfo;
783
784 /** 32bit, in:
785 * Flags describing various client needs.
786 */
787 HGCMFunctionParameter flags;
788
789 /** 32bit, in/out:
790 * Number of mappings the client expects.
791 * This is the number of elements in the
792 * mappings array.
793 */
794 HGCMFunctionParameter numberOfMappings;
795
796 /** pointer, in/out:
797 * Points to array of SHFLMAPPING structures.
798 */
799 HGCMFunctionParameter mappings;
800
801} VBoxSFQueryMappings;
802
803/** Number of parameters */
804#define SHFL_CPARMS_QUERY_MAPPINGS (3)
805
806
807
808/**
809 * SHFL_FN_QUERY_MAP_NAME
810 */
811
812/** Parameters structure. */
813typedef struct _VBoxSFQueryMapName
814{
815 VBoxGuestHGCMCallInfo callInfo;
816
817 /** 32bit, in: SHFLROOT
818 * Root handle of the mapping which name is queried.
819 */
820 HGCMFunctionParameter root;
821
822 /** pointer, in/out:
823 * Points to SHFLSTRING buffer.
824 */
825 HGCMFunctionParameter name;
826
827} VBoxSFQueryMapName;
828
829/** Number of parameters */
830#define SHFL_CPARMS_QUERY_MAP_NAME (2)
831
832/**
833 * SHFL_FN_MAP_FOLDER_OLD
834 */
835
836/** Parameters structure. */
837typedef struct _VBoxSFMapFolder_Old
838{
839 VBoxGuestHGCMCallInfo callInfo;
840
841 /** pointer, in:
842 * Points to SHFLSTRING buffer.
843 */
844 HGCMFunctionParameter path;
845
846 /** pointer, out: SHFLROOT
847 * Root handle of the mapping which name is queried.
848 */
849 HGCMFunctionParameter root;
850
851 /** pointer, in: RTUTF16
852 * Path delimiter
853 */
854 HGCMFunctionParameter delimiter;
855
856} VBoxSFMapFolder_Old;
857
858/** Number of parameters */
859#define SHFL_CPARMS_MAP_FOLDER_OLD (3)
860
861/**
862 * SHFL_FN_MAP_FOLDER
863 */
864
865/** Parameters structure. */
866typedef struct _VBoxSFMapFolder
867{
868 VBoxGuestHGCMCallInfo callInfo;
869
870 /** pointer, in:
871 * Points to SHFLSTRING buffer.
872 */
873 HGCMFunctionParameter path;
874
875 /** pointer, out: SHFLROOT
876 * Root handle of the mapping which name is queried.
877 */
878 HGCMFunctionParameter root;
879
880 /** pointer, in: RTUTF16
881 * Path delimiter
882 */
883 HGCMFunctionParameter delimiter;
884
885 /** pointer, in: SHFLROOT
886 * Case senstive flag
887 */
888 HGCMFunctionParameter fCaseSensitive;
889
890} VBoxSFMapFolder;
891
892/** Number of parameters */
893#define SHFL_CPARMS_MAP_FOLDER (4)
894
895/**
896 * SHFL_FN_UNMAP_FOLDER
897 */
898
899/** Parameters structure. */
900typedef struct _VBoxSFUnmapFolder
901{
902 VBoxGuestHGCMCallInfo callInfo;
903
904 /** pointer, in: SHFLROOT
905 * Root handle of the mapping which name is queried.
906 */
907 HGCMFunctionParameter root;
908
909} VBoxSFUnmapFolder;
910
911/** Number of parameters */
912#define SHFL_CPARMS_UNMAP_FOLDER (1)
913
914
915/**
916 * SHFL_FN_CREATE
917 */
918
919/** Parameters structure. */
920typedef struct _VBoxSFCreate
921{
922 VBoxGuestHGCMCallInfo callInfo;
923
924 /** pointer, in: SHFLROOT
925 * Root handle of the mapping which name is queried.
926 */
927 HGCMFunctionParameter root;
928
929 /** pointer, in:
930 * Points to SHFLSTRING buffer.
931 */
932 HGCMFunctionParameter path;
933
934 /** pointer, in/out:
935 * Points to SHFLCREATEPARMS buffer.
936 */
937 HGCMFunctionParameter parms;
938
939} VBoxSFCreate;
940
941/** Number of parameters */
942#define SHFL_CPARMS_CREATE (3)
943
944
945/**
946 * SHFL_FN_CLOSE
947 */
948
949/** Parameters structure. */
950typedef struct _VBoxSFClose
951{
952 VBoxGuestHGCMCallInfo callInfo;
953
954 /** pointer, in: SHFLROOT
955 * Root handle of the mapping which name is queried.
956 */
957 HGCMFunctionParameter root;
958
959
960 /** value64, in:
961 * SHFLHANDLE of object to close.
962 */
963 HGCMFunctionParameter handle;
964
965} VBoxSFClose;
966
967/** Number of parameters */
968#define SHFL_CPARMS_CLOSE (2)
969
970
971/**
972 * SHFL_FN_READ
973 */
974
975/** Parameters structure. */
976typedef struct _VBoxSFRead
977{
978 VBoxGuestHGCMCallInfo callInfo;
979
980 /** pointer, in: SHFLROOT
981 * Root handle of the mapping which name is queried.
982 */
983 HGCMFunctionParameter root;
984
985 /** value64, in:
986 * SHFLHANDLE of object to read from.
987 */
988 HGCMFunctionParameter handle;
989
990 /** value64, in:
991 * Offset to read from.
992 */
993 HGCMFunctionParameter offset;
994
995 /** value64, in/out:
996 * Bytes to read/How many were read.
997 */
998 HGCMFunctionParameter cb;
999
1000 /** pointer, out:
1001 * Buffer to place data to.
1002 */
1003 HGCMFunctionParameter buffer;
1004
1005} VBoxSFRead;
1006
1007/** Number of parameters */
1008#define SHFL_CPARMS_READ (5)
1009
1010
1011
1012/**
1013 * SHFL_FN_WRITE
1014 */
1015
1016/** Parameters structure. */
1017typedef struct _VBoxSFWrite
1018{
1019 VBoxGuestHGCMCallInfo callInfo;
1020
1021 /** pointer, in: SHFLROOT
1022 * Root handle of the mapping which name is queried.
1023 */
1024 HGCMFunctionParameter root;
1025
1026 /** value64, in:
1027 * SHFLHANDLE of object to write to.
1028 */
1029 HGCMFunctionParameter handle;
1030
1031 /** value64, in:
1032 * Offset to write to.
1033 */
1034 HGCMFunctionParameter offset;
1035
1036 /** value64, in/out:
1037 * Bytes to write/How many were written.
1038 */
1039 HGCMFunctionParameter cb;
1040
1041 /** pointer, in:
1042 * Data to write.
1043 */
1044 HGCMFunctionParameter buffer;
1045
1046} VBoxSFWrite;
1047
1048/** Number of parameters */
1049#define SHFL_CPARMS_WRITE (5)
1050
1051
1052
1053/**
1054 * SHFL_FN_LOCK
1055 */
1056
1057/** Lock owner is the HGCM client. */
1058
1059/** Lock mode bit mask. */
1060#define SHFL_LOCK_MODE_MASK (0x3)
1061/** Cancel lock on the given range. */
1062#define SHFL_LOCK_CANCEL (0x0)
1063/** Acquire read only lock. Prevent write to the range. */
1064#define SHFL_LOCK_SHARED (0x1)
1065/** Acquire write lock. Prevent both write and read to the range. */
1066#define SHFL_LOCK_EXCLUSIVE (0x2)
1067
1068/** Do not wait for lock if it can not be acquired at the time. */
1069#define SHFL_LOCK_NOWAIT (0x0)
1070/** Wait and acquire lock. */
1071#define SHFL_LOCK_WAIT (0x4)
1072
1073/** Lock the specified range. */
1074#define SHFL_LOCK_PARTIAL (0x0)
1075/** Lock entire object. */
1076#define SHFL_LOCK_ENTIRE (0x8)
1077
1078/** Parameters structure. */
1079typedef struct _VBoxSFLock
1080{
1081 VBoxGuestHGCMCallInfo callInfo;
1082
1083 /** pointer, in: SHFLROOT
1084 * Root handle of the mapping which name is queried.
1085 */
1086 HGCMFunctionParameter root;
1087
1088 /** value64, in:
1089 * SHFLHANDLE of object to be locked.
1090 */
1091 HGCMFunctionParameter handle;
1092
1093 /** value64, in:
1094 * Starting offset of lock range.
1095 */
1096 HGCMFunctionParameter offset;
1097
1098 /** value64, in:
1099 * Length of range.
1100 */
1101 HGCMFunctionParameter length;
1102
1103 /** value32, in:
1104 * Lock flags SHFL_LOCK_*.
1105 */
1106 HGCMFunctionParameter flags;
1107
1108} VBoxSFLock;
1109
1110/** Number of parameters */
1111#define SHFL_CPARMS_LOCK (5)
1112
1113
1114
1115/**
1116 * SHFL_FN_FLUSH
1117 */
1118
1119/** Parameters structure. */
1120typedef struct _VBoxSFFlush
1121{
1122 VBoxGuestHGCMCallInfo callInfo;
1123
1124 /** pointer, in: SHFLROOT
1125 * Root handle of the mapping which name is queried.
1126 */
1127 HGCMFunctionParameter root;
1128
1129 /** value64, in:
1130 * SHFLHANDLE of object to be locked.
1131 */
1132 HGCMFunctionParameter handle;
1133
1134} VBoxSFFlush;
1135
1136/** Number of parameters */
1137#define SHFL_CPARMS_FLUSH (2)
1138
1139/**
1140 * SHFL_FN_LIST
1141 */
1142
1143/** Listing information includes variable length RTDIRENTRY[EX] structures. */
1144
1145/** @todo might be necessary for future. */
1146#define SHFL_LIST_NONE 0
1147#define SHFL_LIST_RETURN_ONE 1
1148
1149/** Parameters structure. */
1150typedef struct _VBoxSFList
1151{
1152 VBoxGuestHGCMCallInfo callInfo;
1153
1154 /** pointer, in: SHFLROOT
1155 * Root handle of the mapping which name is queried.
1156 */
1157 HGCMFunctionParameter root;
1158
1159 /** value64, in:
1160 * SHFLHANDLE of object to be listed.
1161 */
1162 HGCMFunctionParameter handle;
1163
1164 /** value32, in:
1165 * List flags SHFL_LIST_*.
1166 */
1167 HGCMFunctionParameter flags;
1168
1169 /** value32, in/out:
1170 * Bytes to be used for listing information/How many bytes were used.
1171 */
1172 HGCMFunctionParameter cb;
1173
1174 /** pointer, in/optional
1175 * Points to SHFLSTRING buffer that specifies a search path.
1176 */
1177 HGCMFunctionParameter path;
1178
1179 /** pointer, out:
1180 * Buffer to place listing information to. (SHFLDIRINFO)
1181 */
1182 HGCMFunctionParameter buffer;
1183
1184 /** value32, in/out:
1185 * Indicates a key where the listing must be resumed.
1186 * in: 0 means start from begin of object.
1187 * out: 0 means listing completed.
1188 */
1189 HGCMFunctionParameter resumePoint;
1190
1191 /** pointer, out:
1192 * Number of files returned
1193 */
1194 HGCMFunctionParameter cFiles;
1195
1196} VBoxSFList;
1197
1198/** Number of parameters */
1199#define SHFL_CPARMS_LIST (8)
1200
1201
1202
1203/**
1204 * SHFL_FN_READLINK
1205 */
1206
1207/** Parameters structure. */
1208typedef struct _VBoxSFReadLink
1209{
1210 VBoxGuestHGCMCallInfo callInfo;
1211
1212 /** pointer, in: SHFLROOT
1213 * Root handle of the mapping which name is queried.
1214 */
1215 HGCMFunctionParameter root;
1216
1217 /** pointer, in:
1218 * Points to SHFLSTRING buffer.
1219 */
1220 HGCMFunctionParameter path;
1221
1222 /** pointer, out:
1223 * Buffer to place data to.
1224 */
1225 HGCMFunctionParameter buffer;
1226
1227} VBoxSFReadLink;
1228
1229/** Number of parameters */
1230#define SHFL_CPARMS_READLINK (3)
1231
1232
1233
1234/**
1235 * SHFL_FN_INFORMATION
1236 */
1237
1238/** Mask of Set/Get bit. */
1239#define SHFL_INFO_MODE_MASK (0x1)
1240/** Get information */
1241#define SHFL_INFO_GET (0x0)
1242/** Set information */
1243#define SHFL_INFO_SET (0x1)
1244
1245/** Get name of the object. */
1246#define SHFL_INFO_NAME (0x2)
1247/** Set size of object (extend/trucate); only applies to file objects */
1248#define SHFL_INFO_SIZE (0x4)
1249/** Get/Set file object info. */
1250#define SHFL_INFO_FILE (0x8)
1251/** Get volume information. */
1252#define SHFL_INFO_VOLUME (0x10)
1253
1254/** @todo different file info structures */
1255
1256
1257/** Parameters structure. */
1258typedef struct _VBoxSFInformation
1259{
1260 VBoxGuestHGCMCallInfo callInfo;
1261
1262 /** pointer, in: SHFLROOT
1263 * Root handle of the mapping which name is queried.
1264 */
1265 HGCMFunctionParameter root;
1266
1267 /** value64, in:
1268 * SHFLHANDLE of object to be listed.
1269 */
1270 HGCMFunctionParameter handle;
1271
1272 /** value32, in:
1273 * SHFL_INFO_*
1274 */
1275 HGCMFunctionParameter flags;
1276
1277 /** value32, in/out:
1278 * Bytes to be used for information/How many bytes were used.
1279 */
1280 HGCMFunctionParameter cb;
1281
1282 /** pointer, in/out:
1283 * Information to be set/get (SHFLFSOBJINFO or SHFLSTRING). Do not forget
1284 * to set the SHFLFSOBJINFO::Attr::enmAdditional for Get operation as well.
1285 */
1286 HGCMFunctionParameter info;
1287
1288} VBoxSFInformation;
1289
1290/** Number of parameters */
1291#define SHFL_CPARMS_INFORMATION (5)
1292
1293
1294/**
1295 * SHFL_FN_REMOVE
1296 */
1297
1298#define SHFL_REMOVE_FILE (0x1)
1299#define SHFL_REMOVE_DIR (0x2)
1300#define SHFL_REMOVE_SYMLINK (0x4)
1301
1302/** Parameters structure. */
1303typedef struct _VBoxSFRemove
1304{
1305 VBoxGuestHGCMCallInfo callInfo;
1306
1307 /** pointer, in: SHFLROOT
1308 * Root handle of the mapping which name is queried.
1309 */
1310 HGCMFunctionParameter root;
1311
1312 /** pointer, in:
1313 * Points to SHFLSTRING buffer.
1314 */
1315 HGCMFunctionParameter path;
1316
1317 /** value32, in:
1318 * remove flags (file/directory)
1319 */
1320 HGCMFunctionParameter flags;
1321
1322} VBoxSFRemove;
1323
1324#define SHFL_CPARMS_REMOVE (3)
1325
1326
1327/**
1328 * SHFL_FN_RENAME
1329 */
1330
1331#define SHFL_RENAME_FILE (0x1)
1332#define SHFL_RENAME_DIR (0x2)
1333#define SHFL_RENAME_REPLACE_IF_EXISTS (0x4)
1334
1335/** Parameters structure. */
1336typedef struct _VBoxSFRename
1337{
1338 VBoxGuestHGCMCallInfo callInfo;
1339
1340 /** pointer, in: SHFLROOT
1341 * Root handle of the mapping which name is queried.
1342 */
1343 HGCMFunctionParameter root;
1344
1345 /** pointer, in:
1346 * Points to SHFLSTRING src.
1347 */
1348 HGCMFunctionParameter src;
1349
1350 /** pointer, in:
1351 * Points to SHFLSTRING dest.
1352 */
1353 HGCMFunctionParameter dest;
1354
1355 /** value32, in:
1356 * rename flags (file/directory)
1357 */
1358 HGCMFunctionParameter flags;
1359
1360} VBoxSFRename;
1361
1362#define SHFL_CPARMS_RENAME (4)
1363
1364
1365/**
1366 * SHFL_FN_SYMLINK
1367 */
1368
1369/** Parameters structure. */
1370typedef struct _VBoxSFSymlink
1371{
1372 VBoxGuestHGCMCallInfo callInfo;
1373
1374 /** pointer, in: SHFLROOT
1375 * Root handle of the mapping which name is queried.
1376 */
1377 HGCMFunctionParameter root;
1378
1379 /** pointer, in:
1380 * Points to SHFLSTRING of path for the new symlink.
1381 */
1382 HGCMFunctionParameter newPath;
1383
1384 /** pointer, in:
1385 * Points to SHFLSTRING of destination for symlink.
1386 */
1387 HGCMFunctionParameter oldPath;
1388
1389 /** pointer, out:
1390 * Information about created symlink.
1391 */
1392 HGCMFunctionParameter info;
1393
1394} VBoxSFSymlink;
1395
1396#define SHFL_CPARMS_SYMLINK (4)
1397
1398
1399
1400/**
1401 * SHFL_FN_ADD_MAPPING
1402 * Host call, no guest structure is used.
1403 */
1404
1405/** mapping is writable */
1406#define SHFL_ADD_MAPPING_F_WRITABLE (RT_BIT_32(0))
1407/** mapping is automounted by the guest */
1408#define SHFL_ADD_MAPPING_F_AUTOMOUNT (RT_BIT_32(1))
1409/** allow the guest to create symlinks */
1410#define SHFL_ADD_MAPPING_F_CREATE_SYMLINKS (RT_BIT_32(2))
1411/** mapping is actually missing on the host */
1412#define SHFL_ADD_MAPPING_F_MISSING (RT_BIT_32(3))
1413
1414#define SHFL_CPARMS_ADD_MAPPING (3)
1415
1416/**
1417 * SHFL_FN_REMOVE_MAPPING
1418 * Host call, no guest structure is used.
1419 */
1420
1421#define SHFL_CPARMS_REMOVE_MAPPING (1)
1422
1423
1424/**
1425 * SHFL_FN_SET_STATUS_LED
1426 * Host call, no guest structure is used.
1427 */
1428
1429#define SHFL_CPARMS_SET_STATUS_LED (1)
1430
1431/** @} */
1432
1433#endif
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