VirtualBox

source: vbox/trunk/src/VBox/Additions/darwin/VBoxSF/VBoxSFInternal.h@ 75677

Last change on this file since 75677 was 75677, checked in by vboxsync, 6 years ago

darwin/VBoxSF: Updates.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.2 KB
Line 
1/* $Id: VBoxSFInternal.h 75677 2018-11-22 21:30:17Z vboxsync $ */
2/** @file
3 * VBoxSF - Darwin Shared Folders, internal header.
4 */
5
6/*
7 * Copyright (C) 2013-2018 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
18#ifndef ___VBoxSFInternal_h___
19#define ___VBoxSFInternal_h___
20
21
22/*********************************************************************************************************************************
23* Header Files *
24*********************************************************************************************************************************/
25#include "VBoxSFMount.h"
26
27#include <libkern/libkern.h>
28#include <iprt/types.h>
29#include <IOKit/IOLib.h>
30#include <IOKit/IOService.h>
31#include <mach/mach_port.h>
32#include <mach/kmod.h>
33#include <mach/mach_types.h>
34#include <sys/errno.h>
35#include <sys/dirent.h>
36#include <sys/lock.h>
37#include <sys/fcntl.h>
38#include <sys/mount.h>
39#include <sys/param.h>
40#include <sys/vnode.h>
41#include <vfs/vfs_support.h>
42#undef PVM
43
44#include <iprt/mem.h>
45#include <VBox/VBoxGuest.h>
46#include <VBox/VBoxGuestLibSharedFolders.h>
47
48
49/*********************************************************************************************************************************
50* Defined Constants And Macros *
51*********************************************************************************************************************************/
52
53
54/*********************************************************************************************************************************
55* Structures and Typedefs *
56*********************************************************************************************************************************/
57/**
58 * Private data we associate with a mount.
59 */
60typedef struct VBOXSFMNTDATA
61{
62 /** The shared folder mapping */
63 VBGLSFMAP hHostFolder;
64 /** The root VNode. */
65 vnode_t pVnRoot;
66 /** User that mounted shared folder (anyone but root?). */
67 uid_t uidMounter;
68 /** The mount info from the mount() call. */
69 VBOXSFDRWNMOUNTINFO MntInfo;
70} VBOXSFMNTDATA;
71/** Pointer to private mount data. */
72typedef VBOXSFMNTDATA *PVBOXSFMNTDATA;
73
74/**
75 * Private data we associate with a VNode.
76 */
77typedef struct VBOXSFDWNVNDATA
78{
79 SHFLHANDLE hHandle; /** 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} VBOXSFDWNVNDATA;
84/** Pointer to private vnode data. */
85typedef VBOXSFDWNVNDATA *PVBOXSFDWNVNDATA;
86
87
88
89/*********************************************************************************************************************************
90* Global Variables *
91*********************************************************************************************************************************/
92extern VBGLSFCLIENT g_SfClientDarwin;
93extern uint32_t volatile g_cVBoxSfMounts;
94extern struct vfsops g_VBoxSfVfsOps;
95extern struct vnodeopv_desc g_VBoxSfVnodeOpvDesc;
96extern int (**g_papfnVBoxVFSVnodeDirOpsVector)(void *);
97
98
99
100/*********************************************************************************************************************************
101* Functions *
102*********************************************************************************************************************************/
103bool vboxSfDwnConnect(void);
104vnode_t vboxSfDwnVnAlloc(mount_t pMount, enum vtype enmType, vnode_t pParent, uint64_t cbFile);
105
106
107#if 0 /* old code, rewriting. */
108
109/**
110 * Helper function to create XNU VFS vnode object.
111 *
112 * @param mp Mount data structure
113 * @param type vnode type (directory, regular file, etc)
114 * @param pParent Parent vnode object (NULL for VBoxVFS root vnode)
115 * @param fIsRoot Flag that indicates if created vnode object is
116 * VBoxVFS root vnode (TRUE for VBoxVFS root vnode, FALSE
117 * for all aother vnodes)
118 * @param Path within Shared Folder
119 * @param ret Returned newly created vnode
120 *
121 * @return 0 on success, error code otherwise
122 */
123extern int vboxvfs_create_vnode_internal(struct mount *mp, enum vtype type, vnode_t pParent, int fIsRoot, PSHFLSTRING Path, vnode_t *ret);
124
125/**
126 * Convert guest absolute VFS path (starting from VFS root) to a host path
127 * within mounted shared folder (returning it as a char *).
128 *
129 * @param mp Mount data structure
130 * @param pszGuestPath Guest absolute VFS path (starting from VFS root)
131 * @param cbGuestPath Size of pszGuestPath
132 * @param pszHostPath Returned char * wich contains host path
133 * @param cbHostPath Returned pszHostPath size
134 *
135 * @return 0 on success, error code otherwise
136 */
137extern int vboxvfs_guest_path_to_char_path_internal(mount_t mp, char *pszGuestPath, int cbGuestPath, char **pszHostPath, int *cbHostPath);
138
139/**
140 * Convert guest absolute VFS path (starting from VFS root) to a host path
141 * within mounted shared folder.
142 *
143 * @param mp Mount data structure
144 * @param pszGuestPath Guest absolute VFS path (starting from VFS root)
145 * @param cbGuestPath Size of pszGuestPath
146 * @param ppResult Returned PSHFLSTRING object wich contains host path
147 *
148 * @return 0 on success, error code otherwise
149 */
150extern int vboxvfs_guest_path_to_shflstring_path_internal(mount_t mp, char *pszGuestPath, int cbGuestPath, PSHFLSTRING *ppResult);
151
152/**
153 * Wrapper function for vboxvfs_guest_path_to_char_path_internal() which
154 * converts guest path to host path using vnode object information.
155 *
156 * @param vnode Guest's VFS object
157 * @param ppPath Allocated char * which contain a path
158 * @param pcbPath Size of ppPath
159 *
160 * @return 0 on success, error code otherwise.
161 */
162extern int vboxvfs_guest_vnode_to_char_path_internal(vnode_t vnode, char **ppHostPath, int *pcbHostPath);
163
164/**
165 * Wrapper function for vboxvfs_guest_path_to_shflstring_path_internal() which
166 * converts guest path to host path using vnode object information.
167 *
168 * @param vnode Guest's VFS object
169 * @param ppResult Allocated PSHFLSTRING object which contain a path
170 *
171 * @return 0 on success, error code otherwise.
172 */
173extern int vboxvfs_guest_vnode_to_shflstring_path_internal(vnode_t vnode, PSHFLSTRING *ppResult);
174
175/**
176 * Free resources allocated by vboxvfs_path_internal() and vboxvfs_guest_vnode_to_shflstring_path_internal().
177 *
178 * @param ppHandle Reference to object to be freed.
179 */
180extern void vboxvfs_put_path_internal(void **ppHandle);
181
182/**
183 * Open existing VBoxVFS object and return its handle.
184 *
185 * @param pMount Mount session data.
186 * @param pPath VFS path to the object relative to mount point.
187 * @param fFlags For directory object it should be
188 * SHFL_CF_DIRECTORY and 0 for any other object.
189 * @param pHandle Returned handle.
190 *
191 * @return 0 on success, error code otherwise.
192 */
193extern int vboxvfs_open_internal(vboxvfs_mount_t *pMount, PSHFLSTRING pPath, uint32_t fFlags, SHFLHANDLE *pHandle);
194
195/**
196 * Release VBoxVFS object handle openned by vboxvfs_open_internal().
197 *
198 * @param pMount Mount session data.
199 * @param pHandle Handle to close.
200 *
201 * @return 0 on success, IPRT error code otherwise.
202 */
203extern int vboxvfs_close_internal(vboxvfs_mount_t *pMount, SHFLHANDLE pHandle);
204
205/**
206 * Get information about host VFS object.
207 *
208 * @param mp Mount point data
209 * @param pSHFLDPath Path to VFS object within mounted shared folder
210 * @param Info Returned info
211 *
212 * @return 0 on success, error code otherwise.
213 */
214extern int vboxvfs_get_info_internal(mount_t mp, PSHFLSTRING pSHFLDPath, PSHFLFSOBJINFO Info);
215
216/**
217 * Check if VFS object exists on a host side.
218 *
219 * @param vnode Guest VFS vnode that corresponds to host VFS object
220 *
221 * @return 1 if exists, 0 otherwise.
222 */
223extern int vboxvfs_exist_internal(vnode_t vnode);
224
225/**
226 * Convert host VFS object mode flags into guest ones.
227 *
228 * @param fHostMode Host flags
229 *
230 * @return Guest flags
231 */
232extern mode_t vboxvfs_h2g_mode_inernal(RTFMODE fHostMode);
233
234/**
235 * Convert guest VFS object mode flags into host ones.
236 *
237 * @param fGuestMode Host flags
238 *
239 * @return Host flags
240 */
241extern uint32_t vboxvfs_g2h_mode_inernal(mode_t fGuestMode);
242
243extern SHFLSTRING *vboxvfs_construct_shflstring(const char *pszName, size_t cchName);
244#endif
245
246#endif
247
248
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