VirtualBox

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

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

VBoxGuestR0LibSharedFolders: VBSFMAP -> VBGLSFMAP; VBSFCLIENT -> VBGLSFCLIENT

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.3 KB
Line 
1/* $Id: vboxvfs.h 58196 2015-10-12 15:18:51Z 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
48RT_C_DECLS_BEGIN
49#if defined(__cplusplus)
50# undef __cplusplus
51# include "../../common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.h"
52# define __cplusplus
53#else
54# include "../../common/VBoxGuestLib/VBoxGuestR0LibSharedFolders.h"
55#endif
56RT_C_DECLS_END
57
58#include <sys/vnode.h>
59
60/** Global refernce to host service connection */
61extern VBGLSFCLIENT g_vboxSFClient;
62
63/** Private data assigned to each mounted shared folder. Assigned to mp structure. */
64typedef struct vboxvfs_mount_data
65{
66 VBSFMAP pMap; /** Shared folder mapping */
67 SHFLSTRING *pShareName; /** VBoxVFS share name */
68 uint64_t cFileIdCounter; /** Counter that used in order to assign unique ID to each vnode within mounted share */
69 vnode_t pRootVnode; /** VFS object: vnode that corresponds shared folder root */
70 uint8_t volatile fRootVnodeState; /** Sync flag that used in order to safely allocate pRootVnode */
71 uid_t owner; /** User ID tha mounted shared folder */
72 lck_grp_t *pLockGroup; /** BSD locking stuff */
73 lck_grp_attr_t *pLockGroupAttr; /** BSD locking stuff */
74} vboxvfs_mount_t;
75
76/** Private data assigned to each vnode object. */
77typedef struct vboxvfs_vnode_data
78{
79 SHFLHANDLE pHandle; /** VBoxVFS object handle. */
80 PSHFLSTRING pPath; /** Path within shared folder */
81 lck_attr_t *pLockAttr; /** BSD locking stuff */
82 lck_rw_t *pLock; /** BSD locking stuff */
83} vboxvfs_vnode_t;
84
85/**
86 * Helper function to create XNU VFS vnode object.
87 *
88 * @param mp Mount data structure
89 * @param type vnode type (directory, regular file, etc)
90 * @param pParent Parent vnode object (NULL for VBoxVFS root vnode)
91 * @param fIsRoot Flag that indicates if created vnode object is
92 * VBoxVFS root vnode (TRUE for VBoxVFS root vnode, FALSE
93 * for all aother vnodes)
94 * @param Path within Shared Folder
95 * @param ret Returned newly created vnode
96 *
97 * @return 0 on success, error code otherwise
98 */
99extern int vboxvfs_create_vnode_internal(struct mount *mp, enum vtype type, vnode_t pParent, int fIsRoot, PSHFLSTRING Path, vnode_t *ret);
100
101/**
102 * Convert guest absolute VFS path (starting from VFS root) to a host path
103 * within mounted shared folder (returning it as a char *).
104 *
105 * @param mp Mount data structure
106 * @param pszGuestPath Guest absolute VFS path (starting from VFS root)
107 * @param cbGuestPath Size of pszGuestPath
108 * @param pszHostPath Returned char * wich contains host path
109 * @param cbHostPath Returned pszHostPath size
110 *
111 * @return 0 on success, error code otherwise
112 */
113extern int vboxvfs_guest_path_to_char_path_internal(mount_t mp, char *pszGuestPath, int cbGuestPath, char **pszHostPath, int *cbHostPath);
114
115/**
116 * Convert guest absolute VFS path (starting from VFS root) to a host path
117 * within mounted shared folder.
118 *
119 * @param mp Mount data structure
120 * @param pszGuestPath Guest absolute VFS path (starting from VFS root)
121 * @param cbGuestPath Size of pszGuestPath
122 * @param ppResult Returned PSHFLSTRING object wich contains host path
123 *
124 * @return 0 on success, error code otherwise
125 */
126extern int vboxvfs_guest_path_to_shflstring_path_internal(mount_t mp, char *pszGuestPath, int cbGuestPath, PSHFLSTRING *ppResult);
127
128/**
129 * Wrapper function for vboxvfs_guest_path_to_char_path_internal() which
130 * converts guest path to host path using vnode object information.
131 *
132 * @param vnode Guest's VFS object
133 * @param ppPath Allocated char * which contain a path
134 * @param pcbPath Size of ppPath
135 *
136 * @return 0 on success, error code otherwise.
137 */
138extern int vboxvfs_guest_vnode_to_char_path_internal(vnode_t vnode, char **ppHostPath, int *pcbHostPath);
139
140/**
141 * Wrapper function for vboxvfs_guest_path_to_shflstring_path_internal() which
142 * converts guest path to host path using vnode object information.
143 *
144 * @param vnode Guest's VFS object
145 * @param ppResult Allocated PSHFLSTRING object which contain a path
146 *
147 * @return 0 on success, error code otherwise.
148 */
149extern int vboxvfs_guest_vnode_to_shflstring_path_internal(vnode_t vnode, PSHFLSTRING *ppResult);
150
151/**
152 * Free resources allocated by vboxvfs_path_internal() and vboxvfs_guest_vnode_to_shflstring_path_internal().
153 *
154 * @param ppHandle Reference to object to be freed.
155 */
156extern void vboxvfs_put_path_internal(void **ppHandle);
157
158/**
159 * Open existing VBoxVFS object and return its handle.
160 *
161 * @param pMount Mount session data.
162 * @param pPath VFS path to the object relative to mount point.
163 * @param fFlags For directory object it should be
164 * SHFL_CF_DIRECTORY and 0 for any other object.
165 * @param pHandle Returned handle.
166 *
167 * @return 0 on success, error code otherwise.
168 */
169extern int vboxvfs_open_internal(vboxvfs_mount_t *pMount, PSHFLSTRING pPath, uint32_t fFlags, SHFLHANDLE *pHandle);
170
171/**
172 * Release VBoxVFS object handle openned by vboxvfs_open_internal().
173 *
174 * @param pMount Mount session data.
175 * @param pHandle Handle to close.
176 *
177 * @return 0 on success, IPRT error code otherwise.
178 */
179extern int vboxvfs_close_internal(vboxvfs_mount_t *pMount, SHFLHANDLE pHandle);
180
181/**
182 * Get information about host VFS object.
183 *
184 * @param mp Mount point data
185 * @param pSHFLDPath Path to VFS object within mounted shared folder
186 * @param Info Returned info
187 *
188 * @return 0 on success, error code otherwise.
189 */
190extern int vboxvfs_get_info_internal(mount_t mp, PSHFLSTRING pSHFLDPath, PSHFLFSOBJINFO Info);
191
192/**
193 * Check if VFS object exists on a host side.
194 *
195 * @param vnode Guest VFS vnode that corresponds to host VFS object
196 *
197 * @return 1 if exists, 0 otherwise.
198 */
199extern int vboxvfs_exist_internal(vnode_t vnode);
200
201/**
202 * Convert host VFS object mode flags into guest ones.
203 *
204 * @param fHostMode Host flags
205 *
206 * @return Guest flags
207 */
208extern mode_t vboxvfs_h2g_mode_inernal(RTFMODE fHostMode);
209
210/**
211 * Convert guest VFS object mode flags into host ones.
212 *
213 * @param fGuestMode Host flags
214 *
215 * @return Host flags
216 */
217extern uint32_t vboxvfs_g2h_mode_inernal(mode_t fGuestMode);
218
219extern SHFLSTRING *vboxvfs_construct_shflstring(char *szName, size_t cbName);
220
221#endif /* KERNEL */
222
223extern int vboxvfs_register_filesystem(void);
224extern int vboxvfs_unregister_filesystem(void);
225
226/* VFS options */
227extern struct vfsops g_oVBoxVFSOpts;
228
229extern int (**g_VBoxVFSVnodeDirOpsVector)(void *);
230extern int g_cVBoxVFSVnodeOpvDescListSize;
231extern struct vnodeopv_desc *g_VBoxVFSVnodeOpvDescList[];
232
233/* Mount info */
234struct vboxvfs_mount_info
235{
236 uint32_t magic;
237 char name[MAXPATHLEN]; /* share name */
238};
239
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