VirtualBox

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

Last change on this file since 52664 was 51998, checked in by vboxsync, 10 years ago

include,Main,Additions: SHFLSTRING cleanup (gcc build fix).

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

© 2024 Oracle
ContactPrivacy/Do Not Sell My InfoTerms of Use