1 | /** $Id: VBoxSFInternal.h 75337 2018-11-09 01:39:01Z 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 | */
|
---|
59 | typedef 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 folder name. */
|
---|
81 | uint8_t cchName;
|
---|
82 | /** The shared folder name. */
|
---|
83 | char szName[RT_FLEXIBLE_ARRAY];
|
---|
84 | } VBOXSFFOLDER;
|
---|
85 | /** Pointer to a shared folder. */
|
---|
86 | typedef VBOXSFFOLDER *PVBOXSFFOLDER;
|
---|
87 | /** Magic value for VBOXSFVP (Neal Town Stephenson). */
|
---|
88 | #define VBOXSFFOLDER_MAGIC UINT32_C(0x19591031)
|
---|
89 |
|
---|
90 | /** The shared mutex protecting folders list, drives and the connection. */
|
---|
91 | extern MutexLock_t g_MtxFolders;
|
---|
92 | /** List of active folder (PVBOXSFFOLDER). */
|
---|
93 | extern RTLISTANCHOR g_FolderHead;
|
---|
94 |
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * VBoxSF Volume Parameter Structure.
|
---|
98 | *
|
---|
99 | * @remarks Overlays the 36 byte VPFSD structure (fsd.h).
|
---|
100 | * @note No self pointer as the kernel may reallocate these.
|
---|
101 | */
|
---|
102 | typedef struct VBOXSFVP
|
---|
103 | {
|
---|
104 | /** Magic value (VBOXSFVP_MAGIC). */
|
---|
105 | uint32_t u32Magic;
|
---|
106 | /** The folder. */
|
---|
107 | PVBOXSFFOLDER pFolder;
|
---|
108 | } VBOXSFVP;
|
---|
109 | AssertCompile(sizeof(VBOXSFVP) <= sizeof(VPFSD));
|
---|
110 | /** Pointer to a VBOXSFVP struct. */
|
---|
111 | typedef VBOXSFVP *PVBOXSFVP;
|
---|
112 | /** Magic value for VBOXSFVP (Laurence van Cott Niven). */
|
---|
113 | #define VBOXSFVP_MAGIC UINT32_C(0x19380430)
|
---|
114 |
|
---|
115 |
|
---|
116 | /**
|
---|
117 | * VBoxSF Current Directory Structure.
|
---|
118 | *
|
---|
119 | * @remark Overlays the 8 byte CDFSD structure (fsd.h).
|
---|
120 | */
|
---|
121 | typedef struct VBOXSFCD
|
---|
122 | {
|
---|
123 | uint32_t u32Dummy;
|
---|
124 | } VBOXSFCD;
|
---|
125 | AssertCompile(sizeof(VBOXSFCD) <= sizeof(CDFSD));
|
---|
126 | /** Pointer to a VBOXSFCD struct. */
|
---|
127 | typedef VBOXSFCD *PVBOXSFCD;
|
---|
128 |
|
---|
129 |
|
---|
130 | /**
|
---|
131 | * VBoxSF System File Structure.
|
---|
132 | *
|
---|
133 | * @remark Overlays the 30 byte SFFSD structure (fsd.h).
|
---|
134 | */
|
---|
135 | typedef struct VBOXSFSYFI
|
---|
136 | {
|
---|
137 | /** Magic value (VBOXSFSYFI_MAGIC). */
|
---|
138 | uint32_t u32Magic;
|
---|
139 | /** Self pointer for quick 16:16 to flat translation. */
|
---|
140 | struct VBOXSFSYFI *pSelf;
|
---|
141 | /** The host file handle. */
|
---|
142 | SHFLHANDLE hHostFile;
|
---|
143 | /** The shared folder (referenced). */
|
---|
144 | PVBOXSFFOLDER pFolder;
|
---|
145 | } VBOXSFSYFI;
|
---|
146 | AssertCompile(sizeof(VBOXSFSYFI) <= sizeof(SFFSD));
|
---|
147 | /** Pointer to a VBOXSFSYFI struct. */
|
---|
148 | typedef VBOXSFSYFI *PVBOXSFSYFI;
|
---|
149 | /** Magic value for VBOXSFSYFI (Jon Ellis Meacham). */
|
---|
150 | #define VBOXSFSYFI_MAGIC UINT32_C(0x19690520)
|
---|
151 |
|
---|
152 |
|
---|
153 | /**
|
---|
154 | * VBoxSF File Search Buffer (header).
|
---|
155 | */
|
---|
156 | typedef struct VBOXSFFSBUF
|
---|
157 | {
|
---|
158 | /** A magic number (VBOXSFFSBUF_MAGIC). */
|
---|
159 | uint32_t u32Magic;
|
---|
160 | /** Amount of buffer space allocated after this header. */
|
---|
161 | uint32_t cbBuf;
|
---|
162 | /** The filter string (full path), NULL if all files are request. */
|
---|
163 | PSHFLSTRING pFilter;
|
---|
164 | /** Must have attributes (shifted down DOS attributes). */
|
---|
165 | uint8_t fMustHaveAttribs;
|
---|
166 | /** Non-matching attributes (shifted down DOS attributes). */
|
---|
167 | uint8_t fExcludedAttribs;
|
---|
168 | /** Set if FF_ATTR_LONG_FILENAME. */
|
---|
169 | bool fLongFilenames : 1;
|
---|
170 | uint8_t bPadding1;
|
---|
171 | /** The local time offset to use for this search. */
|
---|
172 | int16_t cMinLocalTimeDelta;
|
---|
173 | uint8_t abPadding2[2];
|
---|
174 | /** Number of valid bytes in the buffer. */
|
---|
175 | uint32_t cbValid;
|
---|
176 | /** Number of entries left in the buffer. */
|
---|
177 | uint32_t cEntriesLeft;
|
---|
178 | /** The next entry. */
|
---|
179 | PSHFLDIRINFO pEntry;
|
---|
180 | /** Staging area for staging a full FILEFINDBUF4L (+ 32 safe bytes). */
|
---|
181 | uint8_t abStaging[RT_ALIGN_32(sizeof(FILEFINDBUF4L) + 32, 8)];
|
---|
182 | /** For temporary convertion to UTF-8 so we can use KernStrFromUcs to get
|
---|
183 | * string encoded according to the process codepage. */
|
---|
184 | RTUTF16 wszTmp[260];
|
---|
185 | } VBOXSFFSBUF;
|
---|
186 | AssertCompileSizeAlignment(VBOXSFFSBUF, 8);
|
---|
187 | /** Pointer to a file search buffer. */
|
---|
188 | typedef VBOXSFFSBUF *PVBOXSFFSBUF;
|
---|
189 | /** Magic number for VBOXSFFSBUF (Robert Anson Heinlein). */
|
---|
190 | #define VBOXSFFSBUF_MAGIC UINT32_C(0x19070707)
|
---|
191 | /** Minimum buffer size. */
|
---|
192 | #define VBOXSFFSBUF_MIN_SIZE ( RT_ALIGN_32(sizeof(VBOXSFFSBUF) + sizeof(SHFLDIRINFO) + CCHMAXPATHCOMP * 4 + ALLOC_HDR_SIZE, 64) \
|
---|
193 | - ALLOC_HDR_SIZE)
|
---|
194 |
|
---|
195 |
|
---|
196 | /**
|
---|
197 | * VBoxSF File Search Structure.
|
---|
198 | *
|
---|
199 | * @remark Overlays the 24 byte FSFSD structure (fsd.h).
|
---|
200 | * @note No self pointer as the kernel may reallocate these.
|
---|
201 | */
|
---|
202 | typedef struct VBOXSFFS
|
---|
203 | {
|
---|
204 | /** Magic value (VBOXSFFS_MAGIC). */
|
---|
205 | uint32_t u32Magic;
|
---|
206 | /** The last file position position. */
|
---|
207 | uint32_t offLastFile;
|
---|
208 | /** The host directory handle. */
|
---|
209 | SHFLHANDLE hHostDir;
|
---|
210 | /** The shared folder (referenced). */
|
---|
211 | PVBOXSFFOLDER pFolder;
|
---|
212 | /** Search data buffer. */
|
---|
213 | PVBOXSFFSBUF pBuf;
|
---|
214 | } VBOXSFFS;
|
---|
215 | AssertCompile(sizeof(VBOXSFFS) <= sizeof(FSFSD));
|
---|
216 | /** Pointer to a VBOXSFFS struct. */
|
---|
217 | typedef VBOXSFFS *PVBOXSFFS;
|
---|
218 | /** Magic number for VBOXSFFS (Isaak Azimov). */
|
---|
219 | #define VBOXSFFS_MAGIC UINT32_C(0x19200102)
|
---|
220 |
|
---|
221 |
|
---|
222 | extern VBGLSFCLIENT g_SfClient;
|
---|
223 |
|
---|
224 | PSHFLSTRING vboxSfOs2StrAlloc(size_t cchLength);
|
---|
225 | PSHFLSTRING vboxSfOs2StrDup(const char *pachSrc, size_t cchSrc);
|
---|
226 | void vboxSfOs2StrFree(PSHFLSTRING pStr);
|
---|
227 |
|
---|
228 | APIRET vboxSfOs2ResolvePath(const char *pszPath, PVBOXSFCD pCdFsd, LONG offCurDirEnd,
|
---|
229 | PVBOXSFFOLDER *ppFolder, PSHFLSTRING *ppStrFolderPath);
|
---|
230 | void vboxSfOs2ReleasePathAndFolder(PSHFLSTRING pStrPath, PVBOXSFFOLDER pFolder);
|
---|
231 | void vboxSfOs2ReleaseFolder(PVBOXSFFOLDER pFolder);
|
---|
232 | APIRET vboxSfOs2ConvertStatusToOs2(int vrc, APIRET rcDefault);
|
---|
233 | int16_t vboxSfOs2GetLocalTimeDelta(void);
|
---|
234 | void vboxSfOs2DateTimeFromTimeSpec(FDATE *pDosDate, FTIME *pDosTime, RTTIMESPEC SrcTimeSpec, int16_t cMinLocalTimeDelta);
|
---|
235 | PRTTIMESPEC vboxSfOs2DateTimeToTimeSpec(FDATE DosDate, FTIME DosTime, int16_t cMinLocalTimeDelta, PRTTIMESPEC pDstTimeSpec);
|
---|
236 | APIRET vboxSfOs2FileStatusFromObjInfo(PBYTE pbDst, ULONG cbDst, ULONG uLevel, SHFLFSOBJINFO const *pSrc);
|
---|
237 | APIRET vboxSfOs2SetInfoCommonWorker(PVBOXSFFOLDER pFolder, SHFLHANDLE hHostFile, ULONG fAttribs,
|
---|
238 | PFILESTATUS pTimestamps, PSHFLFSOBJINFO pObjInfoBuf);
|
---|
239 | APIRET vboxSfOs2MakeEmptyEaList(PEAOP pEaOp, ULONG uLevel);
|
---|
240 | APIRET vboxSfOs2MakeEmptyEaListEx(PEAOP pEaOp, ULONG uLevel, uint32_t *pcbWritten, ULONG *poffError);
|
---|
241 |
|
---|
242 | DECLASM(PVBOXSFVP) Fsh32GetVolParams(USHORT hVbp, PVPFSI *ppVpFsi /*optional*/);
|
---|
243 |
|
---|
244 | #endif
|
---|
245 |
|
---|