Index: trunk/include/VBox/GuestHost/GuestControl.h
===================================================================
--- trunk/include/VBox/GuestHost/GuestControl.h	(revision 98514)
+++ trunk/include/VBox/GuestHost/GuestControl.h	(revision 98526)
@@ -43,4 +43,5 @@
 #endif
 
+#include <iprt/time.h>
 #include <iprt/types.h>
 
@@ -142,4 +143,31 @@
 /** @} */
 
+/** @name GSTCTL_CREATETEMP_F_XXX - Guest temporary directory/file creation flags.
+ * @{
+ */
+/** Does not specify anything. */
+#define GSTCTL_CREATETEMP_F_NONE            UINT32_C(0)
+/** Creates a directory instead of a file. */
+#define GSTCTL_CREATETEMP_F_DIRECTORY       RT_BIT(0)
+/** Creates a secure temporary file / directory.
+ *  Might not be supported on all (guest) OSes.
+ *
+ *  @sa IPRT's implementation of RTDirCreateTempSecure() / RTFileCreateTempSecumre(). */
+#define GSTCTL_CREATETEMP_F_SECURE          RT_BIT(1)
+/** Mask of valid flags. */
+#define GSTCTL_CREATETEMP_F_VALID_MASK      UINT32_C(0x00000003)
+/** @} */
+
+/** @name GSTCTL_CREATEDIRECTORY_F_XXX - Guest directory creation flags.
+ * @{
+ */
+/** Does not specify anything. */
+#define GSTCTL_CREATEDIRECTORY_F_NONE       UINT32_C(0)
+/** Also creates parent directories if they don't exist yet. */
+#define GSTCTL_CREATEDIRECTORY_F_PARENTS    RT_BIT(0)
+/** Mask of valid flags. */
+#define GSTCTL_CREATEDIRECTORY_F_VALID_MASK UINT32_C(0x00000001)
+/** @} */
+
 /** @name GUEST_SHUTDOWN_FLAG_XXX - Guest shutdown flags.
  * Must match Main's GuestShutdownFlag_ definitions.
@@ -229,5 +257,279 @@
 };
 
-
+/**
+ * Guest file system object -- additional information in a GSTCTLFSOBJATTR object.
+ */
+enum GSTCTLFSOBJATTRADD
+{
+    /** No additional information is available / requested. */
+    GSTCTLFSOBJATTRADD_NOTHING = 1,
+    /** The additional unix attributes (RTFSOBJATTR::u::Unix) are available /
+     *  requested. */
+    GSTCTLFSOBJATTRADD_UNIX,
+    /** The additional unix attributes (RTFSOBJATTR::u::UnixOwner) are
+     * available / requested. */
+    GSTCTLFSOBJATTRADD_UNIX_OWNER,
+    /** The additional unix attributes (RTFSOBJATTR::u::UnixGroup) are
+     * available / requested. */
+    GSTCTLFSOBJATTRADD_UNIX_GROUP,
+    /** The additional extended attribute size (RTFSOBJATTR::u::EASize) is available / requested. */
+    GSTCTLFSOBJATTRADD_EASIZE,
+    /** The last valid item (inclusive).
+     * The valid range is RTFSOBJATTRADD_NOTHING thru RTFSOBJATTRADD_LAST.  */
+    GSTCTLFSOBJATTRADD_LAST = GSTCTLFSOBJATTRADD_EASIZE,
+
+    /** The usual 32-bit hack. */
+    GSTCTLFSOBJATTRADD_32BIT_SIZE_HACK = 0x7fffffff
+};
+
+/** The number of bytes reserved for the additional attribute union. */
+#define GSTCTLFSOBJATTRUNION_MAX_SIZE       128
+
+/**
+ * Additional Unix Attributes (GSTCTLFSOBJATTRADD_UNIX).
+ */
+typedef struct GSTCTLFSOBJATTRUNIX
+{
+    /** The user owning the filesystem object (st_uid).
+     * This field is NIL_RTUID if not supported. */
+    RTUID           uid;
+
+    /** The group the filesystem object is assigned (st_gid).
+     * This field is NIL_RTGID if not supported. */
+    RTGID           gid;
+
+    /** Number of hard links to this filesystem object (st_nlink).
+     * This field is 1 if the filesystem doesn't support hardlinking or
+     * the information isn't available.
+     */
+    uint32_t        cHardlinks;
+
+    /** The device number of the device which this filesystem object resides on (st_dev).
+     * This field is 0 if this information is not available. */
+    RTDEV           INodeIdDevice;
+
+    /** The unique identifier (within the filesystem) of this filesystem object (st_ino).
+     * Together with INodeIdDevice, this field can be used as a OS wide unique id
+     * when both their values are not 0.
+     * This field is 0 if the information is not available.
+     *
+     * @remarks  The special '..' dir always shows up with 0 on NTFS/Windows. */
+    RTINODE         INodeId;
+
+    /** User flags (st_flags).
+     * This field is 0 if this information is not available. */
+    uint32_t        fFlags;
+
+    /** The current generation number (st_gen).
+     * This field is 0 if this information is not available. */
+    uint32_t        GenerationId;
+
+    /** The device number of a character or block device type object (st_rdev).
+     * This field is 0 if the file isn't of a character or block device type and
+     * when the OS doesn't subscribe to the major+minor device idenfication scheme. */
+    RTDEV           Device;
+} GSTCTLFSOBJATTRUNIX;
+
+/**
+ * Additional guest Unix attributes (GSTCTLFSOBJATTRADD_UNIX_OWNER).
+ */
+typedef struct GSTCTLFSOBJATTRUNIXOWNER
+{
+    /** The user owning the filesystem object (st_uid).
+     * This field is NIL_RTUID if not supported. */
+    RTUID           uid;
+    /** The user name.
+     * Empty if not available or not supported, truncated if too long. */
+    char            szName[GSTCTLFSOBJATTRUNION_MAX_SIZE - sizeof(RTUID)];
+} GSTCTLFSOBJATTRUNIXOWNER;
+
+/**
+ * Additional guest Unix attributes (GSTCTLFSOBJATTRADD_UNIX_GROUP).
+ */
+typedef struct GSTCTLFSOBJATTRUNIXGROUP
+{
+    /** The user owning the filesystem object (st_uid).
+     * This field is NIL_RTUID if not supported. */
+    RTGID           gid;
+    /** The group name.
+     * Empty if not available or not supported, truncated if too long. */
+    char            szName[GSTCTLFSOBJATTRUNION_MAX_SIZE - sizeof(RTGID)];
+} GSTCTLFSOBJATTRUNIXGROUP;
+
+/**
+ * Guest filesystem object attributes.
+ */
+#pragma pack(1)
+typedef struct GSTCTLFSOBJATTR
+{
+    /** Mode flags (st_mode). RTFS_UNIX_*, RTFS_TYPE_*, and RTFS_DOS_*. */
+    RTFMODE                     fMode;
+
+    /** The additional attributes available. */
+    GSTCTLFSOBJATTRADD          enmAdditional;
+
+    /**
+     * Additional attributes.
+     *
+     * Unless explicitly specified to an API, the API can provide additional
+     * data as it is provided by the underlying OS.
+     */
+    union GSTCTLFSOBJATTRUNION
+    {
+        /** Additional Unix Attributes - GUEST_FSOBJATTRADD_UNIX. */
+        GSTCTLFSOBJATTRUNIX         Unix;
+        /** Additional Unix Owner Attributes - GUEST_FSOBJATTRADD_UNIX_OWNER. */
+        GSTCTLFSOBJATTRUNIXOWNER    UnixOwner;
+        /** Additional Unix Group Attributes - GUEST_FSOBJATTRADD_UNIX_GROUP. */
+        GSTCTLFSOBJATTRUNIXGROUP    UnixGroup;
+
+        /**
+         * Extended attribute size is available when RTFS_DOS_HAVE_EA_SIZE is set.
+         */
+        struct GSTCTLFSOBJATTREASIZE
+        {
+            /** Size of EAs. */
+            RTFOFF          cb;
+        } EASize;
+        /** Reserved space. */
+        uint8_t         abReserveSpace[128];
+    } u;
+} GSTCTLFSOBJATTR;
+#pragma pack()
+/** Pointer to a guest filesystem object attributes structure. */
+typedef GSTCTLFSOBJATTR *PGSTCTLFSOBJATTR;
+/** Pointer to a const guest filesystem object attributes structure. */
+typedef const GSTCTLFSOBJATTR *PCGSTCTLFSOBJATTR;
+
+/** @name GSTCTL_QUERYINFO_F_XXX - Generic flags for querying guest file system information.
+ * @{ */
+/** No guest stat flags specified. */
+#define GSTCTL_QUERYINFO_F_NONE               UINT32_C(0)
+/** Last component: Work on the link. */
+#define GSTCTL_QUERYINFO_F_ON_LINK            RT_BIT_32(0)
+/** Last component: Follow if link. */
+#define GSTCTL_QUERYINFO_F_FOLLOW_LINK        RT_BIT_32(1)
+/** Don't allow symbolic links as part of the path.
+ * @remarks this flag is currently not implemented and will be ignored. */
+#define GSTCTL_QUERYINFO_F_NO_SYMLINKS        RT_BIT_32(2)
+/** GSTCTL_QUERYINFO_F_XXX flag valid mask. */
+#define GSTCTL_QUERYINFO_F_VALID_MASK         UINT32_C(0x00000007)
+/** @} */
+
+/**
+ * Filter option for HOST_MSG_DIR_OPEN.
+ */
+typedef enum GSTCTLDIRFILTER
+{
+    /** The usual invalid 0 entry. */
+    GSTCTLDIRFILTER_INVALID = 0,
+    /** No filter should be applied (and none was specified). */
+    GSTCTLDIRFILTER_NONE,
+    /** The Windows NT filter.
+     * The following wildcard chars: *, ?, <, > and "
+     * The matching is done on the uppercased strings.  */
+    GSTCTLDIRFILTER_WINNT,
+    /** The UNIX filter.
+     * The following wildcard chars: *, ?, [..]
+     * The matching is done on exact case. */
+    GSTCTLDIRFILTER_UNIX,
+    /** The UNIX filter, uppercased matching.
+     * Same as GSTCTLDIRFILTER_UNIX except that the strings are uppercased before comparing. */
+    GSTCTLDIRFILTER_UNIX_UPCASED,
+
+    /** The usual full 32-bit value. */
+    GSTCTLDIRFILTER_32BIT_HACK = 0x7fffffff
+} GSTCTLDIRFILTER;
+
+/** @name GSTCTLDIR_F_XXX - Directory flags for HOST_MSG_DIR_OPEN.
+ * @{ */
+/** Don't allow symbolic links as part of the path.
+ * @remarks this flag is currently not implemented and will be ignored. */
+#define GSTCTLDIR_F_NO_SYMLINKS     RT_BIT_32(0)
+/** Deny relative opening of anything above this directory. */
+#define GSTCTLDIR_F_DENY_ASCENT     RT_BIT_32(1)
+/** Don't follow symbolic links in the final component. */
+#define GSTCTLDIR_F_NO_FOLLOW       RT_BIT_32(2)
+/** Long path hack: Don't apply RTPathAbs to the path. */
+#define GSTCTLDIR_F_NO_ABS_PATH     RT_BIT_32(3)
+/** Valid flag mask.   */
+#define GSTCTLDIR_F_VALID_MASK      UINT32_C(0x0000000f)
+
+/**
+ * Guest filesystem object information structure.
+ *
+ * This is returned by
+ *     - GUEST_FS_NOTIFYTYPE_QUERY_INFO
+ *     - GUEST_DIR_NOTIFYTYPE_READ
+ */
+#pragma pack(1)
+typedef struct GSTCTLFSOBJINFO
+{
+   /** Logical size (st_size).
+    * For normal files this is the size of the file.
+    * For symbolic links, this is the length of the path name contained
+    * in the symbolic link.
+    * For other objects this fields needs to be specified.
+    */
+   RTFOFF           cbObject;
+
+   /** Disk allocation size (st_blocks * DEV_BSIZE). */
+   RTFOFF           cbAllocated;
+
+   /** Time of last access (st_atime). */
+   RTTIMESPEC       AccessTime;
+
+   /** Time of last data modification (st_mtime). */
+   RTTIMESPEC       ModificationTime;
+
+   /** Time of last status change (st_ctime).
+    * If not available this is set to ModificationTime.
+    */
+   RTTIMESPEC       ChangeTime;
+
+   /** Time of file birth (st_birthtime).
+    * If not available this is set to ChangeTime.
+    */
+   RTTIMESPEC       BirthTime;
+
+   /** Attributes. */
+   GSTCTLFSOBJATTR  Attr;
+
+} GSTCTLFSOBJINFO;
+#pragma pack()
+/** Pointer to a guest filesystem object information structure. */
+typedef GSTCTLFSOBJINFO *PGSTCTLFSOBJINFO;
+/** Pointer to a const guest filesystem object information structure. */
+typedef const GSTCTLFSOBJINFO *PCGSTCTLFSOBJINFO;
+
+/**
+ * Guest directory entry with extended information.
+ *
+ * This is inspired by IPRT + the PC interfaces.
+ */
+#pragma pack(1)
+typedef struct GSTCTLDIRENTRYEX
+{
+    /** Full information about the guest object. */
+    GSTCTLFSOBJINFO  Info;
+    /** The length of the short field (number of RTUTF16 entries (not chars)).
+     * It is 16-bit for reasons of alignment. */
+    uint16_t        cwcShortName;
+    /** The short name for 8.3 compatibility.
+     * Empty string if not available.
+     * Since the length is a bit tricky for a UTF-8 encoded name, and since this
+     * is practically speaking only a windows thing, it is encoded as UCS-2. */
+    RTUTF16         wszShortName[14];
+    /** The length of the filename. */
+    uint16_t        cbName;
+    /** The filename. (no path)
+     * Using the pcbDirEntry parameter of RTDirReadEx makes this field variable in size. */
+    char            szName[260];
+} GSTCTLDIRENTRYEX;
+#pragma pack()
+/** Pointer to a guest directory entry. */
+typedef GSTCTLDIRENTRYEX *PGSTCTLDIRENTRYEX;
+/** Pointer to a const guest directory entry. */
+typedef GSTCTLDIRENTRYEX const *PCGSTCTLDIRENTRYEX;
 
 } /* namespace guestControl */
Index: trunk/include/VBox/HostServices/GuestControlSvc.h
===================================================================
--- trunk/include/VBox/HostServices/GuestControlSvc.h	(revision 98514)
+++ trunk/include/VBox/HostServices/GuestControlSvc.h	(revision 98526)
@@ -41,8 +41,10 @@
 #endif
 
+#include <iprt/assert.h>
+#include <VBox/hgcmsvc.h>
+
 #include <VBox/VMMDevCoreTypes.h>
+#include <VBox/GuestHost/GuestControl.h>
 #include <VBox/VBoxGuestCoreTypes.h>
-#include <VBox/hgcmsvc.h>
-#include <iprt/assert.h>
 
 /* Everything defined in this file lives in this namespace. */
@@ -200,9 +202,35 @@
      * Gets the current file position of an opened guest file.
      */
-    HOST_MSG_FILE_TELL,
+    HOST_MSG_FILE_TELL = 271,
     /**
      * Changes the file size.
      */
-    HOST_MSG_FILE_SET_SIZE,
+    HOST_MSG_FILE_SET_SIZE = 272,
+#ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
+    /**
+     * Removes a file on the guest.
+     */
+    HOST_MSG_FILE_REMOVE = 273,
+    /**
+     * Opens (creates) a directory on the guest.
+     */
+    HOST_MSG_DIR_OPEN = 310,
+    /**
+     * Closes a directory on the guest.
+     */
+    HOST_MSG_DIR_CLOSE = 311,
+    /**
+     * Reads the next directory entry on the guest.
+     */
+    HOST_MSG_DIR_READ = 312,
+    /**
+     * Rewinds and restarts the directory reading on the guest.
+     */
+    HOST_MSG_DIR_REWIND = 313,
+    /**
+     * Creates a directory on the guest.
+     */
+    HOST_MSG_DIR_CREATE = 314,
+#endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */
     /**
      * Removes a directory on the guest.
@@ -216,14 +244,23 @@
      * Retrieves the user's documents directory.
      */
-    HOST_MSG_PATH_USER_DOCUMENTS,
+    HOST_MSG_PATH_USER_DOCUMENTS = 331,
     /**
      * Retrieves the user's home directory.
      */
-    HOST_MSG_PATH_USER_HOME,
+    HOST_MSG_PATH_USER_HOME = 332,
     /**
      * Issues a shutdown / reboot of the guest OS.
      */
-    HOST_MSG_SHUTDOWN,
-
+    HOST_MSG_SHUTDOWN = 333,
+#ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
+    /**
+     * Retrieves information about a file system object.
+     */
+    HOST_MSG_FS_QUERY_INFO = 334,
+    /**
+     * Creates a temporary file or directory.
+     */
+    HOST_MSG_FS_CREATE_TEMP = 335,
+#endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */
     /** Blow the type up to 32-bits. */
     HOST_MSG_32BIT_HACK = 0x7fffffff
@@ -258,4 +295,12 @@
         RT_CASE_RET_STR(HOST_MSG_FILE_TELL);
         RT_CASE_RET_STR(HOST_MSG_FILE_SET_SIZE);
+#ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
+        RT_CASE_RET_STR(HOST_MSG_FILE_REMOVE);
+        RT_CASE_RET_STR(HOST_MSG_DIR_OPEN);
+        RT_CASE_RET_STR(HOST_MSG_DIR_CLOSE);
+        RT_CASE_RET_STR(HOST_MSG_DIR_READ);
+        RT_CASE_RET_STR(HOST_MSG_DIR_REWIND);
+        RT_CASE_RET_STR(HOST_MSG_DIR_CREATE);
+#endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */
         RT_CASE_RET_STR(HOST_MSG_DIR_REMOVE);
         RT_CASE_RET_STR(HOST_MSG_PATH_RENAME);
@@ -263,4 +308,8 @@
         RT_CASE_RET_STR(HOST_MSG_PATH_USER_HOME);
         RT_CASE_RET_STR(HOST_MSG_SHUTDOWN);
+#ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
+        RT_CASE_RET_STR(HOST_MSG_FS_QUERY_INFO);
+        RT_CASE_RET_STR(HOST_MSG_FS_CREATE_TEMP);
+#endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */
         RT_CASE_RET_STR(HOST_MSG_32BIT_HACK);
     }
@@ -579,5 +628,17 @@
      * @todo proper docs.
      */
-    GUEST_MSG_FILE_NOTIFY = 240
+    GUEST_MSG_FILE_NOTIFY = 240,
+#ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
+    /**
+     *  Guest notifies the host about some file system event.
+     *
+     * @retval  VINF_SUCCESS on success.
+     * @retval  VERR_INVALID_CLIENT_ID
+     * @retval  VERR_WRONG_PARAMETER_COUNT
+     * @retval  VERR_WRONG_PARAMETER_TYPE
+     * @since   7.1
+     */
+    GUEST_MSG_FS_NOTIFY  = 241
+#endif
 };
 
@@ -618,8 +679,10 @@
         RT_CASE_RET_STR(GUEST_MSG_DIR_NOTIFY);
         RT_CASE_RET_STR(GUEST_MSG_FILE_NOTIFY);
+#ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
+        RT_CASE_RET_STR(GUEST_MSG_FS_NOTIFY);
+#endif
     }
     return "Unknown";
 }
-
 
 /**
@@ -650,5 +713,5 @@
 /**
  * Guest directory notification types.
- * @sa HGCMMsgDirNotify.
+ * @sa HGCMMsgReplyDirNotify.
  */
 enum GUEST_DIR_NOTIFYTYPE
@@ -661,4 +724,10 @@
     /** Guest directory closed. */
     GUEST_DIR_NOTIFYTYPE_CLOSE = 20,
+#ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
+    /** Guest directory read. */
+    GUEST_DIR_NOTIFYTYPE_READ = 21,
+    /** Guest directory was rewind. */
+    GUEST_DIR_NOTIFYTYPE_REWIND = 22,
+#endif
     /** Information about an open guest directory. */
     GUEST_DIR_NOTIFYTYPE_INFO = 40,
@@ -686,4 +755,19 @@
     GUEST_FILE_NOTIFYTYPE_TELL = 60,
     GUEST_FILE_NOTIFYTYPE_SET_SIZE
+};
+
+/**
+ * Guest file system notification types.
+ */
+enum GUEST_FS_NOTIFYTYPE
+{
+    /** Unknown fs notification type; do not use. */
+    GUEST_FS_NOTIFYTYPE_UNKNOWN     = 0,
+    /** File system query information notification from the guest.
+     *  @since 7.1 */
+    GUEST_FS_NOTIFYTYPE_QUERY_INFO  = 2,
+    /** Temporary directory creation notification from the guest.
+     *  @since 7.1 */
+    GUEST_FS_NOTIFYTYPE_CREATE_TEMP = 1,
 };
 
@@ -716,4 +800,10 @@
 /** Supports shutting down / rebooting the guest. */
 #define VBOX_GUESTCTRL_GF_0_SHUTDOWN                RT_BIT_64(3)
+/** VBoxService' toolbox commands (vbox_rm, vbox_stat, ++) are supported by
+ * dedicated built-in HGCM commands.
+ *
+ * The toolbox commands now are being marked as deprecated.
+ * @since 7.1 */
+# define VBOX_GUESTCTRL_GF_0_TOOLBOX_AS_CMDS        RT_BIT_64(4)
 /** Bit that must be set in the 2nd parameter, will be cleared if the host reponds
  * correctly (old hosts might not). */
@@ -804,5 +894,11 @@
 } HGCMMsgCancelPendingWaits;
 
-typedef struct HGCMMsgReply
+/**
+ * Generic reply header for reply-based messages.
+ *
+ * @note Be careful when changing this, as older Guest Additions might depend on this
+ *       and other stuff can break, too. So better leave this alone.
+ */
+typedef struct HGCMReplyHdr
 {
     VBGLIOCHGCMCALL hdr;
@@ -813,7 +909,65 @@
     /** IPRT result of overall operation. */
     HGCMFunctionParameter rc;
-    /** Optional payload to this reply. */
+} HGCMReplyHdr;
+
+/** Number of HGCM parameters the HGCMReplyHdr has. */
+#define GSTCTL_HGCM_REPLY_HDR_PARMS     3
+
+/**
+ * Generic reply message from guest to the host.
+ */
+typedef struct HGCMMsgReply
+{
+    VBGLIOCHGCMCALL hdr;
+    /** Context ID. */
+    HGCMFunctionParameter context;
+    /** Message type. */
+    HGCMFunctionParameter type;
+    /** IPRT result of overall operation. */
+    HGCMFunctionParameter rc;
+    /** Optional payload to this reply
+     *  Uses the REPLY_PAYLOAD_XXX structs. */
     HGCMFunctionParameter payload;
 } HGCMMsgReply;
+
+#ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
+/**
+ * Creates a temporary directory / file on the guest.
+ */
+typedef struct HGCMMsgFsCreateTemp
+{
+    VBGLIOCHGCMCALL hdr;
+    /** Context ID. */
+    HGCMFunctionParameter context;
+    /** Template name to use for file/directory creation.
+     *  If \a tmpdir is set, this path will be relative to \a tmpdir and  must not be an absolute path. */
+    HGCMFunctionParameter template_name;
+    /** Temporary directory to use.
+     *  If empty, the guest OS' temporary directory will be determined via IPRT on the guest side. */
+    HGCMFunctionParameter tmpdir;
+    /** Creation flags.
+     *  See GSTCTL_CREATETEMP_F_XXX. */
+    HGCMFunctionParameter flags;
+    /** File mode to use for creation (ignored if GSTCTL_CREATETEMP_F_SECURE is defined).
+     *  See GSTCTL_CREATETEMP_F_XXX. */
+    HGCMFunctionParameter mode;
+} HGCMMsgFsCreateTemp;
+
+/**
+ * Queries information for a file system object on the guest.
+ */
+typedef struct HGCMMsgFsQueryInfo
+{
+    VBGLIOCHGCMCALL hdr;
+    /** Context ID. */
+    HGCMFunctionParameter context;
+    /** Path to query information for. */
+    HGCMFunctionParameter path;
+    /** Additional file system attributes to lookup (GSTCTLFSOBJATTRADD). */
+    HGCMFunctionParameter add_attributes;
+    /** Flags (GSTCTL_QUERYINFO_F_XXX). */
+    HGCMFunctionParameter flags;
+} HGCMMsgFsQueryInfo;
+#endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */
 
 /**
@@ -863,4 +1017,82 @@
     HGCMFunctionParameter result;
 } HGCMMsgSessionNotify;
+
+#ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
+/**
+ * Opens a guest directory.
+ */
+typedef struct HGCMMsgDirOpen
+{
+    VBGLIOCHGCMCALL hdr;
+    /** Context ID. */
+    HGCMFunctionParameter context;
+    /** Path of directory to open. */
+    HGCMFunctionParameter path;
+    /** Filter string to use (wildcard style). */
+    HGCMFunctionParameter filter;
+    /** Filter type to use when walking the directory (GSTCTLDIRFILTER). */
+    HGCMFunctionParameter filter_type;
+    /** Directory open flags (GSTCTLDIR_F_XXX). */
+    HGCMFunctionParameter flags;
+} HGCMMsgDirOpen;
+
+/**
+ * Closes a guest directory.
+ */
+typedef struct HGCMMsgDirClose
+{
+    VBGLIOCHGCMCALL hdr;
+    /** Context ID. */
+    HGCMFunctionParameter context;
+    /** Directory handle to close. */
+    HGCMFunctionParameter handle;
+} HGCMMsgDirClose;
+
+/**
+ * Reads the next entry of a guest directory.
+ */
+typedef struct HGCMMsgDirRead
+{
+    VBGLIOCHGCMCALL hdr;
+    /** Context ID. */
+    HGCMFunctionParameter context;
+    /** Handle of directory listing to read the next entry for. */
+    HGCMFunctionParameter handle;
+    /** Custom directory entry size (in bytes) to use. */
+    HGCMFunctionParameter entry_size;
+    /** Additional directory attributes to use (GSTCTLFSOBJATTRADD). */
+    HGCMFunctionParameter add_attributes;
+    /** Directory reading flags. */
+    HGCMFunctionParameter flags;
+} HGCMMsgDirRead;
+
+/**
+ * Rewinds the listing of a guest directory.
+ */
+typedef struct HGCMMsgDirRewind
+{
+    VBGLIOCHGCMCALL hdr;
+    /** Context ID. */
+    HGCMFunctionParameter context;
+    /** Handle of directory listing to rewind. */
+    HGCMFunctionParameter handle;
+} HGCMMsgDirRewind;
+
+/**
+ * Creates a directory on the guest.
+ */
+typedef struct HGCMMsgDirCreate
+{
+    VBGLIOCHGCMCALL hdr;
+    /** Context ID. */
+    HGCMFunctionParameter context;
+    /** Path of directory to create. */
+    HGCMFunctionParameter path;
+    /** Creation mode. */
+    HGCMFunctionParameter mode;
+    /** Creation flags (GSTCTL_CREATEDIRECTORY_F_XXX). */
+    HGCMFunctionParameter flags;
+} HGCMMsgDirCreate;
+#endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */
 
 typedef struct HGCMMsgPathRename
@@ -1214,4 +1446,18 @@
 } HGCMMsgFileSetSize;
 
+/**
+ * Removes (deletes) a guest file.
+ *
+ * @since 7.1
+ */
+typedef struct HGCMMsgFileRemove
+{
+    VBGLIOCHGCMCALL       hdr;
+    /** UInt32: Context ID. */
+    HGCMFunctionParameter context;
+    /** File to open. */
+    HGCMFunctionParameter filename;
+} HGCMMsgFileRemove;
+
 
 /******************************************************************************
@@ -1278,18 +1524,14 @@
 typedef struct HGCMReplyDirNotify
 {
-    VBGLIOCHGCMCALL hdr;
-    /** Context ID. */
-    HGCMFunctionParameter context;
-    /** Notification type. */
-    HGCMFunctionParameter type;
-    /** IPRT result of overall operation. */
-    HGCMFunctionParameter rc;
+    /** The generic reply header. */
+    HGCMReplyHdr reply_hdr;
+    /** Union based on \a reply_hdr.type. */
     union
     {
-        struct
-        {
-            /** Directory information. */
-            HGCMFunctionParameter objInfo;
-        } info;
+        /**
+         * Parameters used for \a type GUEST_DIR_NOTIFYTYPE_OPEN.
+         *
+         * @since 7.1
+         */
         struct
         {
@@ -1297,15 +1539,74 @@
             HGCMFunctionParameter handle;
         } open;
-        struct
-        {
-            /** Current read directory entry. */
+        /**
+         * Parameters used for \a type GUEST_DIR_NOTIFYTYPE_READ.
+         *
+         * @since 7.1
+         */
+        struct
+        {
+            /** Current read directory entry (GSTCTLDIRENTRYEX). */
             HGCMFunctionParameter entry;
-            /** Extended entry object information. Optional. */
-            HGCMFunctionParameter objInfo;
+            /** Resolved user ID as a string (uid). */
+            HGCMFunctionParameter user;
+            /** Resolved group IDs as a string.
+             *
+             *  Multiple groups are delimited by "\r\n", whereas
+             *  the first group always is the primary group. */
+            HGCMFunctionParameter groups;
+            /** @todo ACL; not implemented yet.
+             * Windows ACL, defined in SDDL. */
+            HGCMFunctionParameter acl;
         } read;
     } u;
 } HGCMReplyDirNotify;
 
+/**
+ * Reply to a HOST_MSG_FS_QUERY_INFO or HOST_MSG_FS_CREATE_TEMP message.
+ *
+ * @since 7.1
+ */
+typedef struct HGCMReplyFsNotify
+{
+    /** The generic reply header. */
+    HGCMReplyHdr reply_hdr;
+    /** Union based on \a reply_hdr.type. */
+    union
+    {
+        /**
+         * Parameters used for \a type GUEST_FS_NOTIFYTYPE_QUERY_INFO.
+         *
+         * @since 7.1
+         */
+        struct
+        {
+            /** File system object information (GSTCTLFSOBJINFO). */
+            HGCMFunctionParameter obj_info;
+            /** Resolved user ID as a string (uid). */
+            HGCMFunctionParameter user;
+            /** Resolved group IDs as a string.
+             *
+             *  Multiple groups are delimited by "\r\n", whereas
+             *  the first group always is the primary group. */
+            HGCMFunctionParameter groups;
+            /** @todo ACL; not implemented yet.
+             * Windows ACL, defined in SDDL. */
+            HGCMFunctionParameter acl;
+        } queryinfo;
+        /**
+         * Parameters used for \a type GUEST_FS_NOTIFYTYPE_CREATE_TEMP.
+         *
+         * @since 7.1
+         */
+        struct
+        {
+            /** The create temporary file / directory when \a rc
+             *  indicates success. */
+            HGCMFunctionParameter path;
+        } createtemp;
+    } u;
+} HGCMReplyFsNotify;
 #pragma pack ()
+
 
 /******************************************************************************
@@ -1421,8 +1722,6 @@
         struct
         {
-            /** Size (in bytes) of directory information. */
-            uint32_t cbObjInfo;
             /** Pointer to directory information. */
-            void *pvObjInfo;
+            PGSTCTLFSOBJINFO pObjInfo;
         } info;
         struct
@@ -1435,11 +1734,7 @@
         {
             /** Size (in bytes) of directory entry information. */
-            uint32_t cbEntry;
+            uint32_t          cbEntry;
             /** Pointer to directory entry information. */
-            void *pvEntry;
-            /** Size (in bytes) of directory entry object information. */
-            uint32_t cbObjInfo;
-            /** Pointer to directory entry object information. */
-            void *pvObjInfo;
+            GSTCTLDIRENTRYEX *pEntry;
         } read;
     } u;
@@ -1495,4 +1790,17 @@
 } CALLBACKDATA_FILE_NOTIFY, *PCALLBACKDATA_FILE_NOTIFY;
 
+
+/*******************************************************************************
+* Payload structures for the generic reply message (HGCMMsgReply).             *
+*                                                                              *
+* The name suffix must match the host command name, e.g.                       *
+*     Host command HOST_MSG_FOO_BAR -> REPLY_PAYLOAD_FOO_BAR                   *
+*******************************************************************************/
+
+typedef struct REPLY_PAYLOAD_FS_QUERY_INFO
+{
+    GSTCTLFSOBJINFO objInfo;
+
+} REPLY_PAYLOAD_FS_QUERY_INFO;
 } /* namespace guestControl */
 
Index: trunk/include/VBox/VBoxGuestLib.h
===================================================================
--- trunk/include/VBox/VBoxGuestLib.h	(revision 98514)
+++ trunk/include/VBox/VBoxGuestLib.h	(revision 98526)
@@ -40,4 +40,8 @@
 #  include <VBox/GuestHost/DragAndDrop.h>
 #  include <VBox/GuestHost/DragAndDropDefs.h>
+# endif
+# ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
+#  include <VBox/GuestHost/GuestControl.h>
+   using namespace guestControl;
 # endif
 # ifdef VBOX_WITH_SHARED_CLIPBOARD
@@ -1079,4 +1083,6 @@
 VBGLR3DECL(int) VbglR3GuestCtrlSessionGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx, PVBGLR3GUESTCTRLSESSIONSTARTUPINFO *ppStartupInfo);
 VBGLR3DECL(int) VbglR3GuestCtrlSessionGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *pfFlags, uint32_t *pidSession);
+VBGLR3DECL(int) VbglR3GuestCtrlFileGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle);
+VBGLR3DECL(int) VbglR3GuestCtrlFileGetRead(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle, uint32_t *puToRead);
 /* Guest path handling. */
 VBGLR3DECL(int) VbglR3GuestCtrlPathGetRename(PVBGLR3GUESTCTRLCMDCTX pCtx, char *pszSource, uint32_t cbSource, char *pszDest,
@@ -1084,4 +1090,12 @@
 VBGLR3DECL(int) VbglR3GuestCtrlPathGetUserDocuments(PVBGLR3GUESTCTRLCMDCTX pCtx);
 VBGLR3DECL(int) VbglR3GuestCtrlPathGetUserHome(PVBGLR3GUESTCTRLCMDCTX pCtx);
+#  ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
+/** @name Guest Control file system functions.
+ * @{
+ */
+VBGLR3DECL(int) VbglR3GuestCtrlFsGetQueryInfo(PVBGLR3GUESTCTRLCMDCTX pCtx, char *pszPath, uint32_t cbPath, GSTCTLFSOBJATTRADD *penmAddAttrib, uint32_t *pfFlags);
+VBGLR3DECL(int) VbglR3GuestCtrlFsGetCreateTemp(PVBGLR3GUESTCTRLCMDCTX pCtx, char *pszTemplate, uint32_t cbTemplate, char *pszPath, uint32_t cbPath, uint32_t *pfFlags, uint32_t *pfMode);
+/** @} */
+#  endif
 VBGLR3DECL(int) VbglR3GuestCtrlGetShutdown(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *pfAction);
 /* Guest process execution. */
@@ -1099,4 +1113,15 @@
                                               uint32_t *puTimeoutMS);
 /* Guest native directory handling. */
+#  ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
+/** @name Guest Control directory functions.
+ * @{
+ */
+VBGLR3DECL(int) VbglR3GuestCtrlDirGetCreate(PVBGLR3GUESTCTRLCMDCTX pCtx, char *pszPath, uint32_t cbPath, uint32_t *pfMode, uint32_t *pfFlags);
+VBGLR3DECL(int) VbglR3GuestCtrlDirGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx, char *pszPath, uint32_t cbPath, uint32_t *pfFlags, GSTCTLDIRFILTER *penmFilter);
+VBGLR3DECL(int) VbglR3GuestCtrlDirGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle);
+VBGLR3DECL(int) VbglR3GuestCtrlDirGetRead(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle, uint32_t *pcbDirEntry, uint32_t *penmAddAttrib, uint32_t *pfFlags);
+VBGLR3DECL(int) VbglR3GuestCtrlDirGetRewind(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle);
+/** @} */
+#  endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */
 VBGLR3DECL(int) VbglR3GuestCtrlDirGetRemove(PVBGLR3GUESTCTRLCMDCTX pCtx, char *pszPath, uint32_t cbPath, uint32_t *pfFlags);
 /* Guest native file handling. */
@@ -1116,12 +1141,26 @@
 VBGLR3DECL(int) VbglR3GuestCtrlFileGetTell(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle);
 VBGLR3DECL(int) VbglR3GuestCtrlFileGetSetSize(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle, uint64_t *pcbNew);
+#  ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
+VBGLR3DECL(int) VbglR3GuestCtrlFileGetRemove(PVBGLR3GUESTCTRLCMDCTX pCtx, char *pszFileName, uint32_t cbFileName);
+#  endif
 
 /* Guest -> Host. */
+#  ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
+/** @name Guest Control directory callbacks.
+ * @{
+ */
+VBGLR3DECL(int) VbglR3GuestCtrlDirCbOpen(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, uint32_t uFileHandle);
+VBGLR3DECL(int) VbglR3GuestCtrlDirCbClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc);
+VBGLR3DECL(int) VbglR3GuestCtrlDirCbReadEx(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, PGSTCTLDIRENTRYEX pEntry, uint32_t cbSize, char *pszUser, char *pszGroups, void *pvACL, size_t cbACL);
+VBGLR3DECL(int) VbglR3GuestCtrlDirCbRead(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, PGSTCTLDIRENTRYEX pEntry, uint32_t cbSize);
+VBGLR3DECL(int) VbglR3GuestCtrlDirCbRewind(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc);
+/** @} */
+#  endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */
+
 VBGLR3DECL(int) VbglR3GuestCtrlFileCbOpen(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, uint32_t uFileHandle);
 VBGLR3DECL(int) VbglR3GuestCtrlFileCbClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc);
 VBGLR3DECL(int) VbglR3GuestCtrlFileCbError(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc);
 VBGLR3DECL(int) VbglR3GuestCtrlFileCbRead(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, void *pvData, uint32_t cbData);
-VBGLR3DECL(int) VbglR3GuestCtrlFileCbReadOffset(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc,
-                                                void *pvData, uint32_t cbData, int64_t offNew);
+VBGLR3DECL(int) VbglR3GuestCtrlFileCbReadOffset(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, void *pvData, uint32_t cbData, int64_t offNew);
 VBGLR3DECL(int) VbglR3GuestCtrlFileCbWrite(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, uint32_t cbWritten);
 VBGLR3DECL(int) VbglR3GuestCtrlFileCbWriteOffset(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, uint32_t cbWritten, int64_t offNew);
@@ -1130,12 +1169,18 @@
 VBGLR3DECL(int) VbglR3GuestCtrlFileCbTell(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, uint64_t offCurrent);
 VBGLR3DECL(int) VbglR3GuestCtrlFileCbSetSize(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, uint64_t cbNew);
-VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatus(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uPID, uint32_t uStatus, uint32_t fFlags,
-                                            void *pvData, uint32_t cbData);
-VBGLR3DECL(int) VbglR3GuestCtrlProcCbOutput(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uPID, uint32_t uHandle, uint32_t fFlags,
-                                            void *pvData, uint32_t cbData);
-VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatusInput(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t u32PID, uint32_t uStatus,
-                                                 uint32_t fFlags, uint32_t cbWritten);
-
-/** @}  */
+
+#  ifdef VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS
+/** @name Guest Control file system callbacks.
+ * @{
+ */
+VBGLR3DECL(int) VbglR3GuestCtrlFsCbQueryInfoEx(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, PGSTCTLFSOBJINFO pObjInfo, char *pszUser, char *pszGroups, void *pvACL, uint32_t cbACL);
+VBGLR3DECL(int) VbglR3GuestCtrlFsCbQueryInfo(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, PGSTCTLFSOBJINFO pObjInfo);
+VBGLR3DECL(int) VbglR3GuestCtrlFsCbCreateTemp(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uRc, const char *pszPath);
+/** @} */
+#  endif /* VBOX_WITH_GSTCTL_TOOLBOX_AS_CMDS */
+
+VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatus(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uPID, uint32_t uStatus, uint32_t fFlags, void *pvData, uint32_t cbData);
+VBGLR3DECL(int) VbglR3GuestCtrlProcCbOutput(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t uPID, uint32_t uHandle, uint32_t fFlags, void *pvData, uint32_t cbData);
+VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatusInput(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t u32PID, uint32_t uStatus, uint32_t fFlags, uint32_t cbWritten);
 # endif /* VBOX_WITH_GUEST_CONTROL defined */
 
Index: trunk/include/VBox/log.h
===================================================================
--- trunk/include/VBox/log.h	(revision 98514)
+++ trunk/include/VBox/log.h	(revision 98526)
@@ -491,4 +491,6 @@
     /** Main group, IGuestDirectory. */
     LOG_GROUP_MAIN_GUESTDIRECTORY,
+    /** Main group, IGuestDirectoryEvent. */
+    LOG_GROUP_MAIN_GUESTDIRECTORYEVENT,
     /** Main group, IGuestDnDSource. */
     LOG_GROUP_MAIN_GUESTDNDSOURCE,
@@ -1063,4 +1065,5 @@
     "MAIN_GUESTDEBUGCONTROL", \
     "MAIN_GUESTDIRECTORY", \
+    "MAIN_GUESTDIRECTORYEVENT", \
     "MAIN_GUESTDNDSOURCE", \
     "MAIN_GUESTDNDTARGET", \
