VirtualBox

source: vbox/trunk/src/VBox/Additions/os2/VBoxSF/VBoxSFInternal.h@ 75405

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

add/os2/VBoxSF: Added support for attach tag string.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 8.6 KB
Line 
1/** $Id: VBoxSFInternal.h 75405 2018-11-12 19:43:51Z vboxsync $ */
2/** @file
3 * VBoxSF - OS/2 Shared Folder IFS, Internal Header.
4 */
5
6/*
7 * Copyright (c) 2007 knut st. osmundsen <[email protected]>
8 *
9 * Permission is hereby granted, free of charge, to any person
10 * obtaining a copy of this software and associated documentation
11 * files (the "Software"), to deal in the Software without
12 * restriction, including without limitation the rights to use,
13 * copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following
16 * conditions:
17 *
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
29 */
30
31#ifndef ___VBoxSFInternal_h___
32#define ___VBoxSFInternal_h___
33
34
35#define INCL_BASE
36#define INCL_ERROR
37#define INCL_LONGLONG
38#define OS2EMX_PLAIN_CHAR
39#include <os2ddk/bsekee.h>
40#include <os2ddk/devhlp.h>
41#include <os2ddk/unikern.h>
42#include <os2ddk/fsd.h>
43#undef RT_MAX
44
45#include <iprt/types.h>
46#include <iprt/assert.h>
47#include <iprt/list.h>
48#include <VBox/VBoxGuestLibSharedFolders.h>
49
50
51/** Allocation header used by RTMemAlloc.
52 * This should be subtracted from round numbers. */
53#define ALLOC_HDR_SIZE (0x10 + 4)
54
55
56/**
57 * A shared folder
58 */
59typedef struct VBOXSFFOLDER
60{
61 /** For the shared folder list. */
62 RTLISTNODE ListEntry;
63 /** Magic number (VBOXSFFOLDER_MAGIC). */
64 uint32_t u32Magic;
65 /** Number of active references to this folder. */
66 uint32_t volatile cRefs;
67 /** Number of open files referencing this folder. */
68 uint32_t volatile cOpenFiles;
69 /** Number of open searches referencing this folder. */
70 uint32_t volatile cOpenSearches;
71 /** Number of drives this is attached to. */
72 uint8_t volatile cDrives;
73
74 /** The host folder handle. */
75 VBGLSFMAP hHostFolder;
76
77 /** OS/2 volume handle. */
78 USHORT hVpb;
79
80 /** The length of the name and tag, including zero terminators and such. */
81 uint16_t cbNameAndTag;
82 /** The length of the folder name. */
83 uint8_t cchName;
84 /** The shared folder name. If there is a tag it follows as a second string. */
85 char szName[RT_FLEXIBLE_ARRAY];
86} VBOXSFFOLDER;
87/** Pointer to a shared folder. */
88typedef VBOXSFFOLDER *PVBOXSFFOLDER;
89/** Magic value for VBOXSFVP (Neal Town Stephenson). */
90#define VBOXSFFOLDER_MAGIC UINT32_C(0x19591031)
91
92/** The shared mutex protecting folders list, drives and the connection. */
93extern MutexLock_t g_MtxFolders;
94/** List of active folder (PVBOXSFFOLDER). */
95extern RTLISTANCHOR g_FolderHead;
96
97
98/**
99 * VBoxSF Volume Parameter Structure.
100 *
101 * @remarks Overlays the 36 byte VPFSD structure (fsd.h).
102 * @note No self pointer as the kernel may reallocate these.
103 */
104typedef struct VBOXSFVP
105{
106 /** Magic value (VBOXSFVP_MAGIC). */
107 uint32_t u32Magic;
108 /** The folder. */
109 PVBOXSFFOLDER pFolder;
110} VBOXSFVP;
111AssertCompile(sizeof(VBOXSFVP) <= sizeof(VPFSD));
112/** Pointer to a VBOXSFVP struct. */
113typedef VBOXSFVP *PVBOXSFVP;
114/** Magic value for VBOXSFVP (Laurence van Cott Niven). */
115#define VBOXSFVP_MAGIC UINT32_C(0x19380430)
116
117
118/**
119 * VBoxSF Current Directory Structure.
120 *
121 * @remark Overlays the 8 byte CDFSD structure (fsd.h).
122 */
123typedef struct VBOXSFCD
124{
125 uint32_t u32Dummy;
126} VBOXSFCD;
127AssertCompile(sizeof(VBOXSFCD) <= sizeof(CDFSD));
128/** Pointer to a VBOXSFCD struct. */
129typedef VBOXSFCD *PVBOXSFCD;
130
131
132/**
133 * VBoxSF System File Structure.
134 *
135 * @remark Overlays the 30 byte SFFSD structure (fsd.h).
136 */
137typedef struct VBOXSFSYFI
138{
139 /** Magic value (VBOXSFSYFI_MAGIC). */
140 uint32_t u32Magic;
141 /** Self pointer for quick 16:16 to flat translation. */
142 struct VBOXSFSYFI *pSelf;
143 /** The host file handle. */
144 SHFLHANDLE hHostFile;
145 /** The shared folder (referenced). */
146 PVBOXSFFOLDER pFolder;
147} VBOXSFSYFI;
148AssertCompile(sizeof(VBOXSFSYFI) <= sizeof(SFFSD));
149/** Pointer to a VBOXSFSYFI struct. */
150typedef VBOXSFSYFI *PVBOXSFSYFI;
151/** Magic value for VBOXSFSYFI (Jon Ellis Meacham). */
152#define VBOXSFSYFI_MAGIC UINT32_C(0x19690520)
153
154
155/**
156 * VBoxSF File Search Buffer (header).
157 */
158typedef struct VBOXSFFSBUF
159{
160 /** A magic number (VBOXSFFSBUF_MAGIC). */
161 uint32_t u32Magic;
162 /** Amount of buffer space allocated after this header. */
163 uint32_t cbBuf;
164 /** The filter string (full path), NULL if all files are request. */
165 PSHFLSTRING pFilter;
166 /** Must have attributes (shifted down DOS attributes). */
167 uint8_t fMustHaveAttribs;
168 /** Non-matching attributes (shifted down DOS attributes). */
169 uint8_t fExcludedAttribs;
170 /** Set if FF_ATTR_LONG_FILENAME. */
171 bool fLongFilenames : 1;
172 uint8_t bPadding1;
173 /** The local time offset to use for this search. */
174 int16_t cMinLocalTimeDelta;
175 uint8_t abPadding2[2];
176 /** Number of valid bytes in the buffer. */
177 uint32_t cbValid;
178 /** Number of entries left in the buffer. */
179 uint32_t cEntriesLeft;
180 /** The next entry. */
181 PSHFLDIRINFO pEntry;
182 /** Staging area for staging a full FILEFINDBUF4L (+ 32 safe bytes). */
183 uint8_t abStaging[RT_ALIGN_32(sizeof(FILEFINDBUF4L) + 32, 8)];
184 /** For temporary convertion to UTF-8 so we can use KernStrFromUcs to get
185 * string encoded according to the process codepage. */
186 RTUTF16 wszTmp[260];
187} VBOXSFFSBUF;
188AssertCompileSizeAlignment(VBOXSFFSBUF, 8);
189/** Pointer to a file search buffer. */
190typedef VBOXSFFSBUF *PVBOXSFFSBUF;
191/** Magic number for VBOXSFFSBUF (Robert Anson Heinlein). */
192#define VBOXSFFSBUF_MAGIC UINT32_C(0x19070707)
193/** Minimum buffer size. */
194#define VBOXSFFSBUF_MIN_SIZE ( RT_ALIGN_32(sizeof(VBOXSFFSBUF) + sizeof(SHFLDIRINFO) + CCHMAXPATHCOMP * 4 + ALLOC_HDR_SIZE, 64) \
195 - ALLOC_HDR_SIZE)
196
197
198/**
199 * VBoxSF File Search Structure.
200 *
201 * @remark Overlays the 24 byte FSFSD structure (fsd.h).
202 * @note No self pointer as the kernel may reallocate these.
203 */
204typedef struct VBOXSFFS
205{
206 /** Magic value (VBOXSFFS_MAGIC). */
207 uint32_t u32Magic;
208 /** The last file position position. */
209 uint32_t offLastFile;
210 /** The host directory handle. */
211 SHFLHANDLE hHostDir;
212 /** The shared folder (referenced). */
213 PVBOXSFFOLDER pFolder;
214 /** Search data buffer. */
215 PVBOXSFFSBUF pBuf;
216} VBOXSFFS;
217AssertCompile(sizeof(VBOXSFFS) <= sizeof(FSFSD));
218/** Pointer to a VBOXSFFS struct. */
219typedef VBOXSFFS *PVBOXSFFS;
220/** Magic number for VBOXSFFS (Isaak Azimov). */
221#define VBOXSFFS_MAGIC UINT32_C(0x19200102)
222
223
224extern VBGLSFCLIENT g_SfClient;
225
226PSHFLSTRING vboxSfOs2StrAlloc(size_t cchLength);
227PSHFLSTRING vboxSfOs2StrDup(const char *pachSrc, size_t cchSrc);
228void vboxSfOs2StrFree(PSHFLSTRING pStr);
229
230APIRET vboxSfOs2ResolvePath(const char *pszPath, PVBOXSFCD pCdFsd, LONG offCurDirEnd,
231 PVBOXSFFOLDER *ppFolder, PSHFLSTRING *ppStrFolderPath);
232void vboxSfOs2ReleasePathAndFolder(PSHFLSTRING pStrPath, PVBOXSFFOLDER pFolder);
233void vboxSfOs2ReleaseFolder(PVBOXSFFOLDER pFolder);
234APIRET vboxSfOs2ConvertStatusToOs2(int vrc, APIRET rcDefault);
235int16_t vboxSfOs2GetLocalTimeDelta(void);
236void vboxSfOs2DateTimeFromTimeSpec(FDATE *pDosDate, FTIME *pDosTime, RTTIMESPEC SrcTimeSpec, int16_t cMinLocalTimeDelta);
237PRTTIMESPEC vboxSfOs2DateTimeToTimeSpec(FDATE DosDate, FTIME DosTime, int16_t cMinLocalTimeDelta, PRTTIMESPEC pDstTimeSpec);
238APIRET vboxSfOs2FileStatusFromObjInfo(PBYTE pbDst, ULONG cbDst, ULONG uLevel, SHFLFSOBJINFO const *pSrc);
239APIRET vboxSfOs2SetInfoCommonWorker(PVBOXSFFOLDER pFolder, SHFLHANDLE hHostFile, ULONG fAttribs,
240 PFILESTATUS pTimestamps, PSHFLFSOBJINFO pObjInfoBuf);
241APIRET vboxSfOs2MakeEmptyEaList(PEAOP pEaOp, ULONG uLevel);
242APIRET vboxSfOs2MakeEmptyEaListEx(PEAOP pEaOp, ULONG uLevel, uint32_t *pcbWritten, ULONG *poffError);
243
244DECLASM(PVBOXSFVP) Fsh32GetVolParams(USHORT hVbp, PVPFSI *ppVpFsi /*optional*/);
245
246#endif
247
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