VirtualBox

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

Last change on this file was 93071, checked in by vboxsync, 3 years ago

os2/VBoxSF: Fixed off by one check in vboxSfOs2MakeEmptyEaListEx. Fixed problem with missing FEAList length when called from vboxSfOs2ReadDirEntries. ticketref:19453

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 9.2 KB
Line 
1/** $Id: VBoxSFInternal.h 93071 2021-12-24 00:12:04Z vboxsync $ */
2/** @file
3 * VBoxSF - OS/2 Shared Folder IFS, Internal Header.
4 */
5
6/*
7 * Copyright (c) 2007 knut st. osmundsen <bird-src-spam@anduin.net>
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 GA_INCLUDED_SRC_os2_VBoxSF_VBoxSFInternal_h
32#define GA_INCLUDED_SRC_os2_VBoxSF_VBoxSFInternal_h
33#ifndef RT_WITHOUT_PRAGMA_ONCE
34# pragma once
35#endif
36
37
38#define INCL_BASE
39#define INCL_ERROR
40#define INCL_LONGLONG
41#define OS2EMX_PLAIN_CHAR
42#include <os2ddk/bsekee.h>
43#include <os2ddk/devhlp.h>
44#include <os2ddk/unikern.h>
45#include <os2ddk/fsd.h>
46#undef RT_MAX
47
48#include <iprt/types.h>
49#include <iprt/assert.h>
50#include <iprt/list.h>
51#include <VBox/VBoxGuest.h>
52#include <VBox/VBoxGuestLibSharedFoldersInline.h>
53
54
55/** Allocation header used by RTMemAlloc.
56 * This should be subtracted from round numbers. */
57#define ALLOC_HDR_SIZE (0x10 + 4)
58
59
60/**
61 * A shared folder
62 */
63typedef struct VBOXSFFOLDER
64{
65 /** For the shared folder list. */
66 RTLISTNODE ListEntry;
67 /** Magic number (VBOXSFFOLDER_MAGIC). */
68 uint32_t u32Magic;
69 /** Number of active references to this folder. */
70 uint32_t volatile cRefs;
71 /** Number of open files referencing this folder. */
72 uint32_t volatile cOpenFiles;
73 /** Number of open searches referencing this folder. */
74 uint32_t volatile cOpenSearches;
75 /** Number of drives this is attached to. */
76 uint8_t volatile cDrives;
77
78 /** The host folder handle. */
79 SHFLROOT idHostRoot;
80
81 /** OS/2 volume handle. */
82 USHORT hVpb;
83
84 /** The length of the name and tag, including zero terminators and such. */
85 uint16_t cbNameAndTag;
86 /** The length of the folder name. */
87 uint8_t cchName;
88 /** The shared folder name. If there is a tag it follows as a second string. */
89 RT_FLEXIBLE_ARRAY_EXTENSION
90 char szName[RT_FLEXIBLE_ARRAY];
91} VBOXSFFOLDER;
92/** Pointer to a shared folder. */
93typedef VBOXSFFOLDER *PVBOXSFFOLDER;
94/** Magic value for VBOXSFVP (Neal Town Stephenson). */
95#define VBOXSFFOLDER_MAGIC UINT32_C(0x19591031)
96
97/** The shared mutex protecting folders list, drives and the connection. */
98extern MutexLock_t g_MtxFolders;
99/** List of active folder (PVBOXSFFOLDER). */
100extern RTLISTANCHOR g_FolderHead;
101
102
103/**
104 * VBoxSF Volume Parameter Structure.
105 *
106 * @remarks Overlays the 36 byte VPFSD structure (fsd.h).
107 * @note No self pointer as the kernel may reallocate these.
108 */
109typedef struct VBOXSFVP
110{
111 /** Magic value (VBOXSFVP_MAGIC). */
112 uint32_t u32Magic;
113 /** The folder. */
114 PVBOXSFFOLDER pFolder;
115} VBOXSFVP;
116AssertCompile(sizeof(VBOXSFVP) <= sizeof(VPFSD));
117/** Pointer to a VBOXSFVP struct. */
118typedef VBOXSFVP *PVBOXSFVP;
119/** Magic value for VBOXSFVP (Laurence van Cott Niven). */
120#define VBOXSFVP_MAGIC UINT32_C(0x19380430)
121
122
123/**
124 * VBoxSF Current Directory Structure.
125 *
126 * @remark Overlays the 8 byte CDFSD structure (fsd.h).
127 */
128typedef struct VBOXSFCD
129{
130 uint32_t u32Dummy;
131} VBOXSFCD;
132AssertCompile(sizeof(VBOXSFCD) <= sizeof(CDFSD));
133/** Pointer to a VBOXSFCD struct. */
134typedef VBOXSFCD *PVBOXSFCD;
135
136
137/**
138 * VBoxSF System File Structure.
139 *
140 * @remark Overlays the 30 byte SFFSD structure (fsd.h).
141 */
142typedef struct VBOXSFSYFI
143{
144 /** Magic value (VBOXSFSYFI_MAGIC). */
145 uint32_t u32Magic;
146 /** Self pointer for quick 16:16 to flat translation. */
147 struct VBOXSFSYFI *pSelf;
148 /** The host file handle. */
149 SHFLHANDLE hHostFile;
150 /** The shared folder (referenced). */
151 PVBOXSFFOLDER pFolder;
152} VBOXSFSYFI;
153AssertCompile(sizeof(VBOXSFSYFI) <= sizeof(SFFSD));
154/** Pointer to a VBOXSFSYFI struct. */
155typedef VBOXSFSYFI *PVBOXSFSYFI;
156/** Magic value for VBOXSFSYFI (Jon Ellis Meacham). */
157#define VBOXSFSYFI_MAGIC UINT32_C(0x19690520)
158
159
160/**
161 * More file search data (on physical heap).
162 */
163typedef struct VBOXSFFSBUF /**< @todo rename as is no longer buffer. */
164{
165 /** The request (must be first). */
166 VBOXSFLISTDIRREQ Req;
167 /** A magic number (VBOXSFFSBUF_MAGIC). */
168 uint32_t u32Magic;
169 /** The filter string (full path), NULL if all files are request. */
170 PSHFLSTRING pFilter;
171 /** Size of the buffer for directory entries. */
172 uint32_t cbBuf;
173 /** Buffer for directory entries on the physical heap. */
174 PSHFLDIRINFO pBuf;
175 /** Must have attributes (shifted down DOS attributes). */
176 uint8_t fMustHaveAttribs;
177 /** Non-matching attributes (shifted down DOS attributes). */
178 uint8_t fExcludedAttribs;
179 /** Set if FF_ATTR_LONG_FILENAME. */
180 bool fLongFilenames : 1;
181 uint8_t bPadding1;
182 /** The local time offset to use for this search. */
183 int16_t cMinLocalTimeDelta;
184 uint8_t abPadding2[2];
185 /** Number of valid bytes in the buffer. */
186 uint32_t cbValid;
187 /** Number of entries left in the buffer. */
188 uint32_t cEntriesLeft;
189 /** The next entry. */
190 PSHFLDIRINFO pEntry;
191 //uint32_t uPadding3;
192 /** Staging area for staging a full FILEFINDBUF4L (+ 32 safe bytes). */
193 uint8_t abStaging[RT_ALIGN_32(sizeof(FILEFINDBUF4L) + 32, 8)];
194} VBOXSFFSBUF;
195/** Pointer to a file search buffer. */
196typedef VBOXSFFSBUF *PVBOXSFFSBUF;
197/** Magic number for VBOXSFFSBUF (Robert Anson Heinlein). */
198#define VBOXSFFSBUF_MAGIC UINT32_C(0x19070707)
199
200
201/**
202 * VBoxSF File Search Structure.
203 *
204 * @remark Overlays the 24 byte FSFSD structure (fsd.h).
205 * @note No self pointer as the kernel may reallocate these.
206 */
207typedef struct VBOXSFFS
208{
209 /** Magic value (VBOXSFFS_MAGIC). */
210 uint32_t u32Magic;
211 /** The last file position position. */
212 uint32_t offLastFile;
213 /** The host directory handle. */
214 SHFLHANDLE hHostDir;
215 /** The shared folder (referenced). */
216 PVBOXSFFOLDER pFolder;
217 /** Search data buffer. */
218 PVBOXSFFSBUF pBuf;
219} VBOXSFFS;
220AssertCompile(sizeof(VBOXSFFS) <= sizeof(FSFSD));
221/** Pointer to a VBOXSFFS struct. */
222typedef VBOXSFFS *PVBOXSFFS;
223/** Magic number for VBOXSFFS (Isaak Azimov). */
224#define VBOXSFFS_MAGIC UINT32_C(0x19200102)
225
226
227extern VBGLSFCLIENT g_SfClient;
228extern uint32_t g_fHostFeatures;
229
230void vboxSfOs2InitFileBuffers(void);
231PSHFLSTRING vboxSfOs2StrAlloc(size_t cwcLength);
232PSHFLSTRING vboxSfOs2StrDup(PCSHFLSTRING pSrc);
233void vboxSfOs2StrFree(PSHFLSTRING pStr);
234
235APIRET vboxSfOs2ResolvePath(const char *pszPath, PVBOXSFCD pCdFsd, LONG offCurDirEnd,
236 PVBOXSFFOLDER *ppFolder, PSHFLSTRING *ppStrFolderPath);
237APIRET vboxSfOs2ResolvePathEx(const char *pszPath, PVBOXSFCD pCdFsd, LONG offCurDirEnd, uint32_t offStrInBuf,
238 PVBOXSFFOLDER *ppFolder, void **ppvBuf);
239void vboxSfOs2ReleasePathAndFolder(PSHFLSTRING pStrPath, PVBOXSFFOLDER pFolder);
240void vboxSfOs2ReleaseFolder(PVBOXSFFOLDER pFolder);
241APIRET vboxSfOs2ConvertStatusToOs2(int vrc, APIRET rcDefault);
242int16_t vboxSfOs2GetLocalTimeDelta(void);
243void vboxSfOs2DateTimeFromTimeSpec(FDATE *pDosDate, FTIME *pDosTime, RTTIMESPEC SrcTimeSpec, int16_t cMinLocalTimeDelta);
244PRTTIMESPEC vboxSfOs2DateTimeToTimeSpec(FDATE DosDate, FTIME DosTime, int16_t cMinLocalTimeDelta, PRTTIMESPEC pDstTimeSpec);
245APIRET vboxSfOs2FileStatusFromObjInfo(PBYTE pbDst, ULONG cbDst, ULONG uLevel, SHFLFSOBJINFO const *pSrc);
246APIRET vboxSfOs2SetInfoCommonWorker(PVBOXSFFOLDER pFolder, SHFLHANDLE hHostFile, ULONG fAttribs,
247 PFILESTATUS pTimestamps, PSHFLFSOBJINFO pObjInfoBuf, uint32_t offObjInfoInAlloc);
248
249APIRET vboxSfOs2CheckEaOpForCreation(EAOP const *pEaOp);
250APIRET vboxSfOs2MakeEmptyEaList(PEAOP pEaOp, ULONG uLevel);
251APIRET vboxSfOs2MakeEmptyEaListEx(PEAOP pEaOp, ULONG uLevel, ULONG cbFullEasLeft, uint32_t *pcbWritten, ULONG *poffError);
252
253DECLASM(PVBOXSFVP) Fsh32GetVolParams(USHORT hVbp, PVPFSI *ppVpFsi /*optional*/);
254DECLASM(APIRET) SafeKernStrToUcs(PUconvObj, UniChar *, char *, LONG, LONG);
255DECLASM(APIRET) SafeKernStrFromUcs(PUconvObj, char *, UniChar *, LONG, LONG);
256
257
258#endif /* !GA_INCLUDED_SRC_os2_VBoxSF_VBoxSFInternal_h */
259
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