VirtualBox

source: vbox/trunk/include/VBox/GuestHost/GuestControl.h@ 104384

Last change on this file since 104384 was 104003, checked in by vboxsync, 8 months ago

Guest Control/Main: Added a new define GSTCTL_DEFAULT_TIMEOUT_MS and replaced most of the hardcoded timeout values with it.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 25.1 KB
Line 
1/* $Id: GuestControl.h 104003 2024-03-22 16:13:12Z vboxsync $ */
2/** @file
3 * Guest Control - Common Guest and Host Code.
4 *
5 * @todo r=bird: Just merge this with GuestControlSvc.h!
6 */
7
8/*
9 * Copyright (C) 2016-2023 Oracle and/or its affiliates.
10 *
11 * This file is part of VirtualBox base platform packages, as
12 * available from https://www.virtualbox.org.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation, in version 3 of the
17 * License.
18 *
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see <https://www.gnu.org/licenses>.
26 *
27 * The contents of this file may alternatively be used under the terms
28 * of the Common Development and Distribution License Version 1.0
29 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
30 * in the VirtualBox distribution, in which case the provisions of the
31 * CDDL are applicable instead of those of the GPL.
32 *
33 * You may elect to license modified versions of this file under the
34 * terms and conditions of either the GPL or the CDDL or both.
35 *
36 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
37 */
38
39#ifndef VBOX_INCLUDED_GuestHost_GuestControl_h
40#define VBOX_INCLUDED_GuestHost_GuestControl_h
41#ifndef RT_WITHOUT_PRAGMA_ONCE
42# pragma once
43#endif
44
45#include <iprt/time.h>
46#include <iprt/path.h>
47#include <iprt/types.h>
48
49/* Everything defined in this file lives in this namespace. */
50namespace guestControl {
51
52/** Default timeout (in ms) for guest control operations. */
53#define GSTCTL_DEFAULT_TIMEOUT_MS RT_MS_30SEC
54
55/**
56 * Process status when executed in the guest.
57 */
58enum eProcessStatus
59{
60 /** Process is in an undefined state. */
61 PROC_STS_UNDEFINED = 0,
62 /** Process has been started. */
63 PROC_STS_STARTED = 1,
64 /** Process terminated normally. */
65 PROC_STS_TEN = 2,
66 /** Process terminated via signal. */
67 PROC_STS_TES = 3,
68 /** Process terminated abnormally. */
69 PROC_STS_TEA = 4,
70 /** Process timed out and was killed. */
71 PROC_STS_TOK = 5,
72 /** Process timed out and was not killed successfully. */
73 PROC_STS_TOA = 6,
74 /** Service/OS is stopping, process was killed. */
75 PROC_STS_DWN = 7,
76 /** Something went wrong (error code in flags). */
77 PROC_STS_ERROR = 8
78};
79
80/**
81 * Input flags, set by the host. This is needed for
82 * handling flags on the guest side.
83 * Note: Has to match Main's ProcessInputFlag_* flags!
84 */
85#define GUEST_PROC_IN_FLAG_NONE 0x0
86#define GUEST_PROC_IN_FLAG_EOF RT_BIT(0)
87
88/**
89 * Guest session creation flags.
90 * Only handled internally at the moment.
91 */
92#define SESSIONCREATIONFLAG_NONE 0x0
93
94/** @name DIRREMOVEREC_FLAG_XXX - Guest directory removement flags.
95 * Essentially using what IPRT's RTDIRRMREC_F_
96 * defines have to offer.
97 * @{
98 */
99/** No remove flags specified. */
100#define DIRREMOVEREC_FLAG_NONE UINT32_C(0x0)
101/** Recursively deletes the directory contents. */
102#define DIRREMOVEREC_FLAG_RECURSIVE RT_BIT(0)
103/** Delete the content of the directory and the directory itself. */
104#define DIRREMOVEREC_FLAG_CONTENT_AND_DIR RT_BIT(1)
105/** Only delete the content of the directory, omit the directory it self. */
106#define DIRREMOVEREC_FLAG_CONTENT_ONLY RT_BIT(2)
107/** Mask of valid flags. */
108#define DIRREMOVEREC_FLAG_VALID_MASK UINT32_C(0x00000007)
109/** @} */
110
111/** @name GUEST_PROC_CREATE_FLAG_XXX - Guest process creation flags.
112 * @note Has to match Main's ProcessCreateFlag_* flags!
113 * @{
114 */
115#define GUEST_PROC_CREATE_FLAG_NONE UINT32_C(0x0)
116#define GUEST_PROC_CREATE_FLAG_WAIT_START RT_BIT(0)
117#define GUEST_PROC_CREATE_FLAG_IGNORE_ORPHANED RT_BIT(1)
118#define GUEST_PROC_CREATE_FLAG_HIDDEN RT_BIT(2)
119#define GUEST_PROC_CREATE_FLAG_PROFILE RT_BIT(3)
120#define GUEST_PROC_CREATE_FLAG_WAIT_STDOUT RT_BIT(4)
121#define GUEST_PROC_CREATE_FLAG_WAIT_STDERR RT_BIT(5)
122#define GUEST_PROC_CREATE_FLAG_EXPAND_ARGUMENTS RT_BIT(6)
123#define GUEST_PROC_CREATE_FLAG_UNQUOTED_ARGS RT_BIT(7)
124/** @} */
125
126/** @name GUEST_PROC_OUT_H_XXX - Pipe handle IDs used internally for referencing
127 * to a certain pipe buffer.
128 * @{
129 */
130#define GUEST_PROC_OUT_H_STDOUT_DEPRECATED 0 /**< Needed for VBox hosts < 4.1.0. */
131#define GUEST_PROC_OUT_H_STDOUT 1
132#define GUEST_PROC_OUT_H_STDERR 2
133/** @} */
134
135/** @name PATHRENAME_FLAG_XXX - Guest path rename flags.
136 * Essentially using what IPRT's RTPATHRENAME_FLAGS_XXX have to offer.
137 * @{
138 */
139/** Do not replace anything. */
140#define PATHRENAME_FLAG_NO_REPLACE UINT32_C(0)
141/** This will replace attempt any target which isn't a directory. */
142#define PATHRENAME_FLAG_REPLACE RT_BIT(0)
143/** Don't allow symbolic links as part of the path. */
144#define PATHRENAME_FLAG_NO_SYMLINKS RT_BIT(1)
145/** Mask of valid flags. */
146#define PATHRENAME_FLAG_VALID_MASK UINT32_C(0x00000003)
147/** @} */
148
149/** @name GSTCTL_CREATETEMP_F_XXX - Guest temporary directory/file creation flags.
150 * @{
151 */
152/** Does not specify anything. */
153#define GSTCTL_CREATETEMP_F_NONE UINT32_C(0)
154/** Creates a directory instead of a file. */
155#define GSTCTL_CREATETEMP_F_DIRECTORY RT_BIT(0)
156/** Creates a secure temporary file / directory.
157 * Might not be supported on all (guest) OSes.
158 *
159 * @sa IPRT's implementation of RTDirCreateTempSecure() / RTFileCreateTempSecure(). */
160#define GSTCTL_CREATETEMP_F_SECURE RT_BIT(1)
161/** Mask of valid flags. */
162#define GSTCTL_CREATETEMP_F_VALID_MASK UINT32_C(0x00000003)
163/** @} */
164
165/** @name GSTCTL_CREATEDIRECTORY_F_XXX - Guest directory creation flags.
166 * @{
167 */
168/** Does not specify anything. */
169#define GSTCTL_CREATEDIRECTORY_F_NONE UINT32_C(0)
170/** Also creates parent directories if they don't exist yet. */
171#define GSTCTL_CREATEDIRECTORY_F_PARENTS RT_BIT(0)
172/** Don't allow symbolic links as part of the path. */
173#define GSTCTL_CREATEDIRECTORY_F_NO_SYMLINKS RT_BIT(1)
174/** Set the not-content-indexed flag (default). Windows only atm. */
175#define GSTCTL_CREATEDIRECTORY_F_NOT_CONTENT_INDEXED_DONT_SET RT_BIT(2)
176/** Ignore errors setting the not-content-indexed flag. Windows only atm. */
177#define GSTCTL_CREATEDIRECTORY_F_NOT_CONTENT_INDEXED_NOT_CRITICAL RT_BIT(3)
178/** Ignore umask when applying the mode. */
179#define GSTCTL_CREATEDIRECTORY_F_IGNORE_UMASK RT_BIT(4)
180/** Mask of valid flags. */
181#define GSTCTL_CREATEDIRECTORY_F_VALID_MASK UINT32_C(0x0000001F)
182/** @} */
183
184/** @name GUEST_SHUTDOWN_FLAG_XXX - Guest shutdown flags.
185 *
186 * @note Must match Main's GuestShutdownFlag_ definitions.
187 * @{
188 */
189#define GUEST_SHUTDOWN_FLAG_NONE UINT32_C(0)
190#define GUEST_SHUTDOWN_FLAG_POWER_OFF RT_BIT(0)
191#define GUEST_SHUTDOWN_FLAG_REBOOT RT_BIT(1)
192#define GUEST_SHUTDOWN_FLAG_FORCE RT_BIT(2)
193/** @} */
194
195/** @name Defines for default (initial) guest process buffer lengths.
196 * Note: These defaults were the maximum values before; so be careful when raising those in order to
197 * not break running with older Guest Additions.
198 * @{
199 */
200#define GUEST_PROC_DEF_CMD_LEN _1K
201#define GUEST_PROC_DEF_CWD_LEN _1K
202#define GUEST_PROC_DEF_ARGS_LEN _1K
203#define GUEST_PROC_DEF_ENV_LEN _1K
204#define GUEST_PROC_DEF_USER_LEN 128
205#define GUEST_PROC_DEF_PASSWORD_LEN 128
206#define GUEST_PROC_DEF_DOMAIN_LEN 256
207/** @} */
208
209/** @name Defines for maximum guest process buffer lengths.
210 * @{
211 */
212#define GUEST_PROC_MAX_CMD_LEN _1M
213#define GUEST_PROC_MAX_CWD_LEN RTPATH_MAX
214#define GUEST_PROC_MAX_ARGS_LEN _2M
215#define GUEST_PROC_MAX_ENV_LEN _4M
216#define GUEST_PROC_MAX_USER_LEN _64K
217#define GUEST_PROC_MAX_PASSWORD_LEN _64K
218#define GUEST_PROC_MAX_DOMAIN_LEN _64K
219/** @} */
220
221/** @name Internal tools built into VBoxService which are used in order
222 * to accomplish tasks host<->guest.
223 *
224 * @deprecated Since 7.1 the built-in VBoxService tools aren't used anymore.
225 * @{
226 */
227#define VBOXSERVICE_TOOL_CAT "vbox_cat"
228#define VBOXSERVICE_TOOL_LS "vbox_ls"
229#define VBOXSERVICE_TOOL_RM "vbox_rm"
230#define VBOXSERVICE_TOOL_MKDIR "vbox_mkdir"
231#define VBOXSERVICE_TOOL_MKTEMP "vbox_mktemp"
232#define VBOXSERVICE_TOOL_STAT "vbox_stat"
233/** @} */
234
235/** Special process exit codes for "vbox_cat".
236 *
237 * @deprecated Since 7.1 the built-in VBoxService tools aren't used anymore.
238 */
239typedef enum VBOXSERVICETOOLBOX_CAT_EXITCODE
240{
241 VBOXSERVICETOOLBOX_CAT_EXITCODE_ACCESS_DENIED = RTEXITCODE_END,
242 VBOXSERVICETOOLBOX_CAT_EXITCODE_FILE_NOT_FOUND,
243 VBOXSERVICETOOLBOX_CAT_EXITCODE_PATH_NOT_FOUND,
244 VBOXSERVICETOOLBOX_CAT_EXITCODE_SHARING_VIOLATION,
245 VBOXSERVICETOOLBOX_CAT_EXITCODE_IS_A_DIRECTORY,
246 /** The usual 32-bit type hack. */
247 VBOXSERVICETOOLBOX_CAT_32BIT_HACK = 0x7fffffff
248} VBOXSERVICETOOLBOX_CAT_EXITCODE;
249
250/** Special process exit codes for "vbox_stat".
251 *
252 * @deprecated Since 7.1 the built-in VBoxService tools aren't used anymore.
253 */
254typedef enum VBOXSERVICETOOLBOX_STAT_EXITCODE
255{
256 VBOXSERVICETOOLBOX_STAT_EXITCODE_ACCESS_DENIED = RTEXITCODE_END,
257 VBOXSERVICETOOLBOX_STAT_EXITCODE_FILE_NOT_FOUND,
258 VBOXSERVICETOOLBOX_STAT_EXITCODE_PATH_NOT_FOUND,
259 VBOXSERVICETOOLBOX_STAT_EXITCODE_NET_PATH_NOT_FOUND,
260 VBOXSERVICETOOLBOX_STAT_EXITCODE_INVALID_NAME,
261 /** The usual 32-bit type hack. */
262 VBOXSERVICETOOLBOX_STAT_32BIT_HACK = 0x7fffffff
263} VBOXSERVICETOOLBOX_STAT_EXITCODE;
264
265/**
266 * Input status, reported by the client.
267 */
268enum eInputStatus
269{
270 /** Input is in an undefined state. */
271 INPUT_STS_UNDEFINED = 0,
272 /** Input was written (partially, see cbProcessed). */
273 INPUT_STS_WRITTEN = 1,
274 /** Input failed with an error (see flags for rc). */
275 INPUT_STS_ERROR = 20,
276 /** Process has abandoned / terminated input handling. */
277 INPUT_STS_TERMINATED = 21,
278 /** Too much input data. */
279 INPUT_STS_OVERFLOW = 30
280};
281
282/** @name Guest filesystem flags.
283 *
284 * @{
285 */
286/** No guest file system flags set. */
287#define GSTCTLFSINFO_F_NONE UINT32_C(0)
288/** If the filesystem is remote or not. */
289#define GSTCTLFSINFO_F_IS_REMOTE RT_BIT(0)
290/** If the filesystem is case sensitive or not. */
291#define GSTCTLFSINFO_F_IS_CASE_SENSITIVE RT_BIT(1)
292/** If the filesystem is mounted read only or not. */
293#define GSTCTLFSINFO_F_IS_READ_ONLY RT_BIT(2)
294/** If the filesystem is compressed or not. */
295#define GSTCTLFSINFO_F_IS_COMPRESSED RT_BIT(3)
296/** Valid mask. */
297#define GSTCTLFSINFO_F_VALID_MASK 0xF
298/** @} */
299
300/** @name Guest filesystem feature flags.
301 *
302 * @{
303 */
304/** No guest file system feature flags set. */
305#define GSTCTLFSINFO_FEATURE_F_NONE UINT32_C(0)
306/** If the filesystem can handle Unicode or not. */
307#define GSTCTLFSINFO_FEATURE_F_UNICODE RT_BIT(0)
308/** If the filesystem supports sparse files or not. */
309#define GSTCTLFSINFO_FEATURE_F_SPARSE_FILES RT_BIT(1)
310/** If the filesystem features compression of individual files or not. */
311#define GSTCTLFSINFO_FEATURE_F_FILE_COMPRESSION RT_BIT(2)
312/** Valid mask. */
313#define GSTCTLFSINFO_FEATURE_F_VALID_MASK 0x7
314/** @} */
315
316/** Maximum length (in characters) of a guest file name. */
317#define GSTCTL_FS_NAME_MAX 255
318/** Maximum length (in characters) of a guest file label. */
319#define GSTCTL_FS_LABEL_MAX 255
320/** Maximum length (in characters) of a guest filesystem mount point. */
321#define GSTCTL_FS_MOUNTPOINT_MAX RTPATH_MAX
322
323/**
324 * Guest filesystem information.
325 */
326#pragma pack(1)
327typedef struct GSTCTLFSINFO
328{
329 /** Remaining free space (in bytes) of the filesystem. */
330 uint64_t cbFree;
331 /** Total space (in bytes) of the filesystem. */
332 uint64_t cbTotalSize;
333 /** Block size (in bytes) of the filesystem. */
334 uint32_t cbBlockSize;
335 /** Sector size (in bytes) of the filesystem. */
336 uint32_t cbSectorSize;
337 /** Serial number of the filesystem. */
338 uint32_t uSerialNumber;
339 /** Flags (of type GSTCTLFSINFO_F_XXX). */
340 uint32_t fFlags;
341 /** Feature flags (of type GSTCTLFSINFO_FEATURE_F_XXX). */
342 uint32_t fFeatures;
343 /** The maximum size (in characters) of a filesystem object name. */
344 uint32_t cMaxComponent;
345 /** Name of the filesystem type. */
346 char szName[GSTCTL_FS_NAME_MAX];
347 /** Label of the filesystem. */
348 char szLabel[GSTCTL_FS_LABEL_MAX];
349 /** Size (in bytes) of \a szMountpoint. */
350 uint16_t cbMountpoint;
351 /** Mount point of the filesystem.
352 * Will be dynamically allocated, based on \a cbMountpoint. */
353 char szMountpoint[1];
354} GSTCTLFSINFO;
355#pragma pack()
356AssertCompileSize(GSTCTLFSINFO, 553);
357/** Pointer to a guest filesystem structure. */
358typedef GSTCTLFSINFO *PGSTCTLFSINFO;
359/** Pointer to a const guest filesystem structure. */
360typedef const GSTCTLFSINFO *PCGSTCTLFSINFO;
361
362/**
363 * Guest file system object -- additional information in a GSTCTLFSOBJATTR object.
364 */
365enum GSTCTLFSOBJATTRADD
366{
367 /** No additional information is available / requested. */
368 GSTCTLFSOBJATTRADD_NOTHING = 1,
369 /** The additional unix attributes (RTFSOBJATTR::u::Unix) are available /
370 * requested. */
371 GSTCTLFSOBJATTRADD_UNIX,
372 /** The additional unix attributes (RTFSOBJATTR::u::UnixOwner) are
373 * available / requested. */
374 GSTCTLFSOBJATTRADD_UNIX_OWNER,
375 /** The additional unix attributes (RTFSOBJATTR::u::UnixGroup) are
376 * available / requested. */
377 GSTCTLFSOBJATTRADD_UNIX_GROUP,
378 /** The additional extended attribute size (RTFSOBJATTR::u::EASize) is available / requested. */
379 GSTCTLFSOBJATTRADD_EASIZE,
380 /** The last valid item (inclusive).
381 * The valid range is RTFSOBJATTRADD_NOTHING thru RTFSOBJATTRADD_LAST. */
382 GSTCTLFSOBJATTRADD_LAST = GSTCTLFSOBJATTRADD_EASIZE,
383
384 /** The usual 32-bit hack. */
385 GSTCTLFSOBJATTRADD_32BIT_SIZE_HACK = 0x7fffffff
386};
387
388/** The number of bytes reserved for the additional attribute union. */
389#define GSTCTLFSOBJATTRUNION_MAX_SIZE 128
390
391/* Validate stuff used in the structures used below. */
392AssertCompileSize(RTINODE, 8);
393AssertCompileSize(RTDEV, 4);
394AssertCompileSize(RTGID, 4);
395AssertCompileSize(RTUID, 4);
396
397/**
398 * Additional Unix Attributes (GSTCTLFSOBJATTRADD_UNIX).
399 */
400#pragma pack(1)
401typedef struct GSTCTLFSOBJATTRUNIX
402{
403 /** The user owning the filesystem object (st_uid).
404 * This field is NIL_RTUID if not supported. */
405 RTUID uid;
406
407 /** The group the filesystem object is assigned (st_gid).
408 * This field is NIL_RTGID if not supported. */
409 RTGID gid;
410
411 /** Number of hard links to this filesystem object (st_nlink).
412 * This field is 1 if the filesystem doesn't support hardlinking or
413 * the information isn't available.
414 */
415 uint32_t cHardlinks;
416
417 /** The device number of the device which this filesystem object resides on (st_dev).
418 * This field is 0 if this information is not available. */
419 RTDEV INodeIdDevice;
420
421 /** The unique identifier (within the filesystem) of this filesystem object (st_ino).
422 * Together with INodeIdDevice, this field can be used as a OS wide unique id
423 * when both their values are not 0.
424 * This field is 0 if the information is not available.
425 *
426 * @remarks The special '..' dir always shows up with 0 on NTFS/Windows. */
427 RTINODE INodeId;
428
429 /** User flags (st_flags).
430 * This field is 0 if this information is not available. */
431 uint32_t fFlags;
432
433 /** The current generation number (st_gen).
434 * This field is 0 if this information is not available. */
435 uint32_t GenerationId;
436
437 /** The device number of a character or block device type object (st_rdev).
438 * This field is 0 if the file isn't of a character or block device type and
439 * when the OS doesn't subscribe to the major+minor device idenfication scheme. */
440 RTDEV Device;
441} GSTCTLFSOBJATTRUNIX;
442#pragma pack()
443AssertCompileSize(GSTCTLFSOBJATTRUNIX, 36);
444
445/**
446 * Additional guest Unix attributes (GSTCTLFSOBJATTRADD_UNIX_OWNER).
447 */
448typedef struct GSTCTLFSOBJATTRUNIXOWNER
449{
450 /** The user owning the filesystem object (st_uid).
451 * This field is NIL_RTUID if not supported. */
452 RTUID uid;
453 /** The user name.
454 * Empty if not available or not supported, truncated if too long. */
455 char szName[GSTCTLFSOBJATTRUNION_MAX_SIZE - sizeof(RTUID)];
456} GSTCTLFSOBJATTRUNIXOWNER;
457AssertCompileSize(GSTCTLFSOBJATTRUNIXOWNER, 128);
458
459/**
460 * Additional guest Unix attributes (GSTCTLFSOBJATTRADD_UNIX_GROUP).
461 */
462typedef struct GSTCTLFSOBJATTRUNIXGROUP
463{
464 /** The user owning the filesystem object (st_uid).
465 * This field is NIL_RTUID if not supported. */
466 RTGID gid;
467 /** The group name.
468 * Empty if not available or not supported, truncated if too long. */
469 char szName[GSTCTLFSOBJATTRUNION_MAX_SIZE - sizeof(RTGID)];
470} GSTCTLFSOBJATTRUNIXGROUP;
471AssertCompileSize(GSTCTLFSOBJATTRUNIXGROUP, 128);
472
473/**
474 * Guest filesystem object attributes.
475 */
476typedef struct GSTCTLFSOBJATTR
477{
478 /** Mode flags (st_mode). RTFS_UNIX_*, RTFS_TYPE_*, and RTFS_DOS_*. */
479 RTFMODE fMode;
480
481 /** The additional attributes available. */
482 GSTCTLFSOBJATTRADD enmAdditional;
483
484 /**
485 * Additional attributes.
486 *
487 * Unless explicitly specified to an API, the API can provide additional
488 * data as it is provided by the underlying OS.
489 */
490 union GSTCTLFSOBJATTRUNION
491 {
492 /** Additional Unix Attributes - GUEST_FSOBJATTRADD_UNIX. */
493 GSTCTLFSOBJATTRUNIX Unix;
494 /** Additional Unix Owner Attributes - GUEST_FSOBJATTRADD_UNIX_OWNER. */
495 GSTCTLFSOBJATTRUNIXOWNER UnixOwner;
496 /** Additional Unix Group Attributes - GUEST_FSOBJATTRADD_UNIX_GROUP. */
497 GSTCTLFSOBJATTRUNIXGROUP UnixGroup;
498
499 /**
500 * Extended attribute size is available when RTFS_DOS_HAVE_EA_SIZE is set.
501 */
502 struct GSTCTLFSOBJATTREASIZE
503 {
504 /** Size of EAs. */
505 RTFOFF cb;
506 } EASize;
507 /** Reserved space. */
508 uint8_t abReserveSpace[128];
509 } u;
510} GSTCTLFSOBJATTR;
511AssertCompileSize(GSTCTLFSOBJATTR /* 136 */, sizeof(RTFMODE) + sizeof(GSTCTLFSOBJATTRADD) + 128);
512/** Pointer to a guest filesystem object attributes structure. */
513typedef GSTCTLFSOBJATTR *PGSTCTLFSOBJATTR;
514/** Pointer to a const guest filesystem object attributes structure. */
515typedef const GSTCTLFSOBJATTR *PCGSTCTLFSOBJATTR;
516
517/** @name GSTCTL_PATH_F_XXX - Generic flags for querying guest file system information.
518 * @{ */
519/** No guest stat flags specified. */
520#define GSTCTL_PATH_F_NONE UINT32_C(0)
521/** Last component: Work on the link. */
522#define GSTCTL_PATH_F_ON_LINK RT_BIT_32(0)
523/** Last component: Follow if link. */
524#define GSTCTL_PATH_F_FOLLOW_LINK RT_BIT_32(1)
525/** Don't allow symbolic links as part of the path. */
526#define GSTCTL_PATH_F_NO_SYMLINKS RT_BIT_32(2)
527/** GSTCTL_PATH_F_XXX flag valid mask. */
528#define GSTCTL_PATH_F_VALID_MASK UINT32_C(0x00000007)
529/** @} */
530
531/** @name GSTCTL_DIRLIST_F_XXX - Flags for guest directory listings.
532 * @{ */
533/** No guest listing flags specified. */
534#define GSTCTL_DIRLIST_F_NONE UINT32_C(0)
535/** GSTCTL_DIRLIST_F_XXX valid mask. */
536#define GSTCTL_DIRLIST_F_VALID_MASK UINT32_C(0x00000000)
537/** @} */
538
539/**
540 * Filter option for HOST_MSG_DIR_OPEN.
541 */
542typedef enum GSTCTLDIRFILTER
543{
544 /** The usual invalid 0 entry. */
545 GSTCTLDIRFILTER_INVALID = 0,
546 /** No filter should be applied (and none was specified). */
547 GSTCTLDIRFILTER_NONE,
548 /** The Windows NT filter.
549 * The following wildcard chars: *, ?, <, > and "
550 * The matching is done on the uppercased strings. */
551 GSTCTLDIRFILTER_WINNT,
552 /** The UNIX filter.
553 * The following wildcard chars: *, ?, [..]
554 * The matching is done on exact case. */
555 GSTCTLDIRFILTER_UNIX,
556 /** The UNIX filter, uppercased matching.
557 * Same as GSTCTLDIRFILTER_UNIX except that the strings are uppercased before comparing. */
558 GSTCTLDIRFILTER_UNIX_UPCASED,
559
560 /** The usual full 32-bit value. */
561 GSTCTLDIRFILTER_32BIT_HACK = 0x7fffffff
562} GSTCTLDIRFILTER;
563
564/** @name GSTCTLDIR_F_XXX - Directory flags for HOST_MSG_DIR_OPEN.
565 * @{ */
566/** No directory open flags specified. */
567#define GSTCTLDIR_F_NONE UINT32_C(0)
568/** Don't allow symbolic links as part of the path.
569 * @remarks this flag is currently not implemented and will be ignored. */
570#define GSTCTLDIR_F_NO_SYMLINKS RT_BIT_32(0)
571/** Deny relative opening of anything above this directory. */
572#define GSTCTLDIR_F_DENY_ASCENT RT_BIT_32(1)
573/** Don't follow symbolic links in the final component. */
574#define GSTCTLDIR_F_NO_FOLLOW RT_BIT_32(2)
575/** Long path hack: Don't apply RTPathAbs to the path. */
576#define GSTCTLDIR_F_NO_ABS_PATH RT_BIT_32(3)
577/** Valid flag mask. */
578#define GSTCTLDIR_F_VALID_MASK UINT32_C(0x0000000f)
579
580/**
581 * Guest filesystem object information structure.
582 *
583 * This is returned by
584 * - GUEST_FS_NOTIFYTYPE_QUERY_INFO
585 * - GUEST_DIR_NOTIFYTYPE_READ
586 */
587typedef struct GSTCTLFSOBJINFO
588{
589 /** Logical size (st_size).
590 * For normal files this is the size of the file.
591 * For symbolic links, this is the length of the path name contained
592 * in the symbolic link.
593 * For other objects this fields needs to be specified.
594 */
595 RTFOFF cbObject;
596
597 /** Disk allocation size (st_blocks * DEV_BSIZE). */
598 RTFOFF cbAllocated;
599
600 /** Time of last access (st_atime). */
601 RTTIMESPEC AccessTime;
602
603 /** Time of last data modification (st_mtime). */
604 RTTIMESPEC ModificationTime;
605
606 /** Time of last status change (st_ctime).
607 * If not available this is set to ModificationTime.
608 */
609 RTTIMESPEC ChangeTime;
610
611 /** Time of file birth (st_birthtime).
612 * If not available this is set to ChangeTime.
613 */
614 RTTIMESPEC BirthTime;
615
616 /** Attributes. */
617 GSTCTLFSOBJATTR Attr;
618
619} GSTCTLFSOBJINFO;
620AssertCompileSize(GSTCTLFSOBJINFO /* 184 */, 48 + sizeof(GSTCTLFSOBJATTR));
621/** Pointer to a guest filesystem object information structure. */
622typedef GSTCTLFSOBJINFO *PGSTCTLFSOBJINFO;
623/** Pointer to a const guest filesystem object information structure. */
624typedef const GSTCTLFSOBJINFO *PCGSTCTLFSOBJINFO;
625
626/**
627 * Guest directory entry with extended information.
628 *
629 * This is inspired by IPRT + the PC interfaces.
630 */
631#pragma pack(1)
632typedef struct GSTCTLDIRENTRYEX
633{
634 /** Full information about the guest object. */
635 GSTCTLFSOBJINFO Info;
636 /** The length of the short field (number of RTUTF16 entries (not chars)).
637 * It is 16-bit for reasons of alignment. */
638 uint16_t cwcShortName;
639 /** The short name for 8.3 compatibility.
640 * Empty string if not available.
641 * Since the length is a bit tricky for a UTF-8 encoded name, and since this
642 * is practically speaking only a windows thing, it is encoded as UCS-2. */
643 RTUTF16 wszShortName[14];
644 /** The length of the filename. */
645 uint16_t cbName;
646 /** The filename. (no path)
647 * Using the pcbDirEntry parameter of RTDirReadEx makes this field variable in size. */
648 char szName[260];
649} GSTCTLDIRENTRYEX;
650#pragma pack()
651AssertCompileSize(GSTCTLDIRENTRYEX, sizeof(GSTCTLFSOBJINFO) + 292);
652/** Pointer to a guest directory entry. */
653typedef GSTCTLDIRENTRYEX *PGSTCTLDIRENTRYEX;
654/** Pointer to a const guest directory entry. */
655typedef GSTCTLDIRENTRYEX const *PCGSTCTLDIRENTRYEX;
656
657/** The maximum size (in bytes) of an entry file name (at least RT_UOFFSETOF(GSTCTLDIRENTRYEX, szName[2]). */
658#define GSTCTL_DIRENTRY_MAX_SIZE 4096
659/** Maximum characters of the resolved user name. Including terminator. */
660#define GSTCTL_DIRENTRY_MAX_USER_NAME 255
661/** Maximum characters of the resolved user groups list. Including terminator. */
662#define GSTCTL_DIRENTRY_MAX_USER_GROUPS _1K
663/** The resolved user groups delimiter as a string. */
664#define GSTCTL_DIRENTRY_GROUPS_DELIMITER_STR "\r\n"
665
666/**
667 * Guest directory entry header.
668 *
669 * This is needed for (un-)packing multiple directory entries with its resolved user name + groups
670 * with the HOST_MSG_DIR_LIST command.
671 *
672 * The order of the attributes also mark their packed order, so be careful when changing this!
673 *
674 * @since 7.1
675 */
676#pragma pack(1)
677typedef struct GSTCTLDIRENTRYLISTHDR
678{
679 /** Size (in bytes) of the directory header). */
680 uint32_t cbDirEntryEx;
681 /** Size (in bytes) of the resolved user name as a string
682 * Includes terminator. */
683 uint32_t cbUser;
684 /** Size (in bytes) of the resolved user groups as a string.
685 * Delimited by GSTCTL_DIRENTRY_GROUPS_DELIMITER_STR. Includes terminator. */
686 uint32_t cbGroups;
687} GSTCTLDIRENTRYBLOCK;
688/** Pointer to a guest directory header entry. */
689typedef GSTCTLDIRENTRYLISTHDR *PGSTCTLDIRENTRYLISTHDR;
690#pragma pack()
691} /* namespace guestControl */
692
693#endif /* !VBOX_INCLUDED_GuestHost_GuestControl_h */
694
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