VirtualBox

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

最後變更 在這個檔案從51997是 51997,由 vboxsync 提交於 11 年 前

include,Main,Additions: SHFLSTRING cleanup.

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette