VirtualBox

source: vbox/trunk/src/VBox/Additions/darwin/vboxfs/vboxvfs.h@ 62514

Last change on this file since 62514 was 58203, checked in by vboxsync, 9 years ago

VBoxGuestR0LibSharedFolders.h: Moved from VBoxGuestLib to include/VBox/VBoxGuestLibSharedFolders.h where it belongs (not merging it into VBoxGuestLib.h because it includes VBox/shflsvc.h.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.1 KB
Line 
1/* $Id: vboxvfs.h 58203 2015-10-12 15:56:32Z vboxsync $ */
2/** @file
3 * VBoxVFS - common header used across all the driver source files.
4 */
5
6/*
7 * Copyright (C) 2013-2015 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#define MODULE_NAME "VBoxVFS"
28
29#ifdef KERNEL
30# include <libkern/libkern.h>
31# include <sys/lock.h>
32#endif
33
34#define PINFO(fmt, args...) \
35 printf(MODULE_NAME ": INFO: " fmt "\n", ## args)
36#define PDEBUG(fmt, args...) \
37 printf(MODULE_NAME ": %s(): DEBUG: " fmt "\n", __FUNCTION__, ## args)
38#define PERROR(fmt, args...) \
39 printf(MODULE_NAME ": ERROR: " fmt "\n", ## args)
40
41#define VBOXVBFS_NAME "vboxvfs"
42#define VBOXVFS_MOUNTINFO_MAGIC (0xCAFE)
43
44#ifdef KERNEL
45
46#include <iprt/types.h>
47#undef PVM
48#include <sys/vnode.h>
49
50#include <VBox/VBoxGuestLibSharedFolders.h>
51
52
53/** Global refernce to host service connection */
54extern VBGLSFCLIENT g_vboxSFClient;
55
56/** Private data assigned to each mounted shared folder. Assigned to mp structure. */
57typedef struct vboxvfs_mount_data
58{
59 VBSFMAP pMap; /** Shared folder mapping */
60 SHFLSTRING *pShareName; /** VBoxVFS share name */
61 uint64_t cFileIdCounter; /** Counter that used in order to assign unique ID to each vnode within mounted share */
62 vnode_t pRootVnode; /** VFS object: vnode that corresponds shared folder root */
63 uint8_t volatile fRootVnodeState; /** Sync flag that used in order to safely allocate pRootVnode */
64 uid_t owner; /** User ID tha mounted shared folder */
65 lck_grp_t *pLockGroup; /** BSD locking stuff */
66 lck_grp_attr_t *pLockGroupAttr; /** BSD locking stuff */
67} vboxvfs_mount_t;
68
69/** Private data assigned to each vnode object. */
70typedef struct vboxvfs_vnode_data
71{
72 SHFLHANDLE pHandle; /** VBoxVFS object handle. */
73 PSHFLSTRING pPath; /** Path within shared folder */
74 lck_attr_t *pLockAttr; /** BSD locking stuff */
75 lck_rw_t *pLock; /** BSD locking stuff */
76} vboxvfs_vnode_t;
77
78/**
79 * Helper function to create XNU VFS vnode object.
80 *
81 * @param mp Mount data structure
82 * @param type vnode type (directory, regular file, etc)
83 * @param pParent Parent vnode object (NULL for VBoxVFS root vnode)
84 * @param fIsRoot Flag that indicates if created vnode object is
85 * VBoxVFS root vnode (TRUE for VBoxVFS root vnode, FALSE
86 * for all aother vnodes)
87 * @param Path within Shared Folder
88 * @param ret Returned newly created vnode
89 *
90 * @return 0 on success, error code otherwise
91 */
92extern int vboxvfs_create_vnode_internal(struct mount *mp, enum vtype type, vnode_t pParent, int fIsRoot, PSHFLSTRING Path, vnode_t *ret);
93
94/**
95 * Convert guest absolute VFS path (starting from VFS root) to a host path
96 * within mounted shared folder (returning it as a char *).
97 *
98 * @param mp Mount data structure
99 * @param pszGuestPath Guest absolute VFS path (starting from VFS root)
100 * @param cbGuestPath Size of pszGuestPath
101 * @param pszHostPath Returned char * wich contains host path
102 * @param cbHostPath Returned pszHostPath size
103 *
104 * @return 0 on success, error code otherwise
105 */
106extern int vboxvfs_guest_path_to_char_path_internal(mount_t mp, char *pszGuestPath, int cbGuestPath, char **pszHostPath, int *cbHostPath);
107
108/**
109 * Convert guest absolute VFS path (starting from VFS root) to a host path
110 * within mounted shared folder.
111 *
112 * @param mp Mount data structure
113 * @param pszGuestPath Guest absolute VFS path (starting from VFS root)
114 * @param cbGuestPath Size of pszGuestPath
115 * @param ppResult Returned PSHFLSTRING object wich contains host path
116 *
117 * @return 0 on success, error code otherwise
118 */
119extern int vboxvfs_guest_path_to_shflstring_path_internal(mount_t mp, char *pszGuestPath, int cbGuestPath, PSHFLSTRING *ppResult);
120
121/**
122 * Wrapper function for vboxvfs_guest_path_to_char_path_internal() which
123 * converts guest path to host path using vnode object information.
124 *
125 * @param vnode Guest's VFS object
126 * @param ppPath Allocated char * which contain a path
127 * @param pcbPath Size of ppPath
128 *
129 * @return 0 on success, error code otherwise.
130 */
131extern int vboxvfs_guest_vnode_to_char_path_internal(vnode_t vnode, char **ppHostPath, int *pcbHostPath);
132
133/**
134 * Wrapper function for vboxvfs_guest_path_to_shflstring_path_internal() which
135 * converts guest path to host path using vnode object information.
136 *
137 * @param vnode Guest's VFS object
138 * @param ppResult Allocated PSHFLSTRING object which contain a path
139 *
140 * @return 0 on success, error code otherwise.
141 */
142extern int vboxvfs_guest_vnode_to_shflstring_path_internal(vnode_t vnode, PSHFLSTRING *ppResult);
143
144/**
145 * Free resources allocated by vboxvfs_path_internal() and vboxvfs_guest_vnode_to_shflstring_path_internal().
146 *
147 * @param ppHandle Reference to object to be freed.
148 */
149extern void vboxvfs_put_path_internal(void **ppHandle);
150
151/**
152 * Open existing VBoxVFS object and return its handle.
153 *
154 * @param pMount Mount session data.
155 * @param pPath VFS path to the object relative to mount point.
156 * @param fFlags For directory object it should be
157 * SHFL_CF_DIRECTORY and 0 for any other object.
158 * @param pHandle Returned handle.
159 *
160 * @return 0 on success, error code otherwise.
161 */
162extern int vboxvfs_open_internal(vboxvfs_mount_t *pMount, PSHFLSTRING pPath, uint32_t fFlags, SHFLHANDLE *pHandle);
163
164/**
165 * Release VBoxVFS object handle openned by vboxvfs_open_internal().
166 *
167 * @param pMount Mount session data.
168 * @param pHandle Handle to close.
169 *
170 * @return 0 on success, IPRT error code otherwise.
171 */
172extern int vboxvfs_close_internal(vboxvfs_mount_t *pMount, SHFLHANDLE pHandle);
173
174/**
175 * Get information about host VFS object.
176 *
177 * @param mp Mount point data
178 * @param pSHFLDPath Path to VFS object within mounted shared folder
179 * @param Info Returned info
180 *
181 * @return 0 on success, error code otherwise.
182 */
183extern int vboxvfs_get_info_internal(mount_t mp, PSHFLSTRING pSHFLDPath, PSHFLFSOBJINFO Info);
184
185/**
186 * Check if VFS object exists on a host side.
187 *
188 * @param vnode Guest VFS vnode that corresponds to host VFS object
189 *
190 * @return 1 if exists, 0 otherwise.
191 */
192extern int vboxvfs_exist_internal(vnode_t vnode);
193
194/**
195 * Convert host VFS object mode flags into guest ones.
196 *
197 * @param fHostMode Host flags
198 *
199 * @return Guest flags
200 */
201extern mode_t vboxvfs_h2g_mode_inernal(RTFMODE fHostMode);
202
203/**
204 * Convert guest VFS object mode flags into host ones.
205 *
206 * @param fGuestMode Host flags
207 *
208 * @return Host flags
209 */
210extern uint32_t vboxvfs_g2h_mode_inernal(mode_t fGuestMode);
211
212extern SHFLSTRING *vboxvfs_construct_shflstring(char *szName, size_t cbName);
213
214#endif /* KERNEL */
215
216extern int vboxvfs_register_filesystem(void);
217extern int vboxvfs_unregister_filesystem(void);
218
219/* VFS options */
220extern struct vfsops g_oVBoxVFSOpts;
221
222extern int (**g_VBoxVFSVnodeDirOpsVector)(void *);
223extern int g_cVBoxVFSVnodeOpvDescListSize;
224extern struct vnodeopv_desc *g_VBoxVFSVnodeOpvDescList[];
225
226/* Mount info */
227struct vboxvfs_mount_info
228{
229 uint32_t magic;
230 char name[MAXPATHLEN]; /* share name */
231};
232
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