1 | /** $Id: VBoxSFFile.cpp 75337 2018-11-09 01:39:01Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxSF - OS/2 Shared Folders, the file level IFS EPs.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (c) 2007-2018 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 |
|
---|
32 | /*********************************************************************************************************************************
|
---|
33 | * Header Files *
|
---|
34 | *********************************************************************************************************************************/
|
---|
35 | #define LOG_GROUP LOG_GROUP_DEFAULT
|
---|
36 | #include "VBoxSFInternal.h"
|
---|
37 |
|
---|
38 | #include <VBox/log.h>
|
---|
39 | #include <iprt/asm.h>
|
---|
40 | #include <iprt/assert.h>
|
---|
41 | #include <iprt/mem.h>
|
---|
42 |
|
---|
43 |
|
---|
44 |
|
---|
45 | DECLASM(APIRET)
|
---|
46 | FS32_OPENCREATE(PCDFSI pCdFsi, PVBOXSFCD pCdFsd, PCSZ pszName, LONG offCurDirEnd,
|
---|
47 | PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd, ULONG fOpenMode, USHORT fOpenFlags,
|
---|
48 | PUSHORT puAction, ULONG fAttribs, BYTE const *pbEaBuf, PUSHORT pfGenFlag)
|
---|
49 | {
|
---|
50 | LogFlow(("FS32_OPENCREATE: pCdFsi=%p pCdFsd=%p pszName=%p:{%s} offCurDirEnd=%d pSfFsi=%p pSfFsd=%p fOpenMode=%#x fOpenFlags=%#x puAction=%p fAttribs=%#x pbEaBuf=%p pfGenFlag=%p\n",
|
---|
51 | pCdFsi, pCdFsd, pszName, pszName, offCurDirEnd, pSfFsi, pSfFsd, fOpenMode, fOpenFlags, puAction, fAttribs, pbEaBuf, pfGenFlag));
|
---|
52 | RT_NOREF(pfGenFlag);
|
---|
53 |
|
---|
54 | /*
|
---|
55 | * Validate and convert parameters.
|
---|
56 | */
|
---|
57 | /* No EAs. */
|
---|
58 | if (!pbEaBuf)
|
---|
59 | { /* likely */ }
|
---|
60 | else
|
---|
61 | {
|
---|
62 | LogRel(("FS32_OPENCREATE: Returns ERROR_EAS_NOT_SUPPORTED [%p];\n", pbEaBuf));
|
---|
63 | return ERROR_EAS_NOT_SUPPORTED;
|
---|
64 | }
|
---|
65 |
|
---|
66 | /* No direct access. */
|
---|
67 | if (!(fOpenMode & OPEN_FLAGS_DASD))
|
---|
68 | { /* likely */ }
|
---|
69 | else
|
---|
70 | {
|
---|
71 | LogRel(("FS32_OPENCREATE: Returns ERROR_ACCESS_DENIED [DASD];\n"));
|
---|
72 | return ERROR_ACCESS_DENIED;
|
---|
73 | }
|
---|
74 |
|
---|
75 | SHFLCREATEPARMS *pParams = (SHFLCREATEPARMS *)VbglR0PhysHeapAlloc(sizeof(*pParams));
|
---|
76 | if (!pParams)
|
---|
77 | return ERROR_NOT_ENOUGH_MEMORY;
|
---|
78 | RT_ZERO(*pParams);
|
---|
79 |
|
---|
80 | /* access: */
|
---|
81 | if (fOpenMode & OPEN_ACCESS_READWRITE)
|
---|
82 | pParams->CreateFlags = SHFL_CF_ACCESS_READWRITE | SHFL_CF_ACCESS_ATTR_READWRITE;
|
---|
83 | else if (fOpenMode & OPEN_ACCESS_WRITEONLY)
|
---|
84 | pParams->CreateFlags = SHFL_CF_ACCESS_WRITE | SHFL_CF_ACCESS_ATTR_WRITE;
|
---|
85 | else
|
---|
86 | pParams->CreateFlags = SHFL_CF_ACCESS_READ | SHFL_CF_ACCESS_ATTR_READ; /* read or/and exec */
|
---|
87 |
|
---|
88 | /* Sharing: */
|
---|
89 | switch (fOpenMode & (OPEN_SHARE_DENYNONE | OPEN_SHARE_DENYREADWRITE | OPEN_SHARE_DENYREAD | OPEN_SHARE_DENYWRITE))
|
---|
90 | {
|
---|
91 | case OPEN_SHARE_DENYNONE: pParams->CreateFlags |= SHFL_CF_ACCESS_DENYNONE; break;
|
---|
92 | case OPEN_SHARE_DENYWRITE: pParams->CreateFlags |= SHFL_CF_ACCESS_DENYWRITE; break;
|
---|
93 | case OPEN_SHARE_DENYREAD: pParams->CreateFlags |= SHFL_CF_ACCESS_DENYREAD; break;
|
---|
94 | case OPEN_SHARE_DENYREADWRITE: pParams->CreateFlags |= SHFL_CF_ACCESS_DENYALL; break;
|
---|
95 | case 0: pParams->CreateFlags |= SHFL_CF_ACCESS_DENYWRITE; break; /* compatibility */
|
---|
96 | default:
|
---|
97 | LogRel(("FS32_OPENCREATE: Invalid file sharing mode: %#x\n", fOpenMode));
|
---|
98 | VbglR0PhysHeapFree(pParams);
|
---|
99 | return VERR_INVALID_PARAMETER;
|
---|
100 |
|
---|
101 | }
|
---|
102 |
|
---|
103 | /* How to open the file: */
|
---|
104 | switch (fOpenFlags & 0x13)
|
---|
105 | {
|
---|
106 | case OPEN_ACTION_FAIL_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW: /* 0x00 */
|
---|
107 | pParams->CreateFlags |= SHFL_CF_ACT_FAIL_IF_EXISTS | SHFL_CF_ACT_FAIL_IF_NEW;
|
---|
108 | break;
|
---|
109 | case OPEN_ACTION_FAIL_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW: /* 0x10 */
|
---|
110 | pParams->CreateFlags |= SHFL_CF_ACT_FAIL_IF_EXISTS | SHFL_CF_ACT_CREATE_IF_NEW;
|
---|
111 | break;
|
---|
112 | case OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW: /* 0x01 */
|
---|
113 | pParams->CreateFlags |= SHFL_CF_ACT_OPEN_IF_EXISTS | SHFL_CF_ACT_FAIL_IF_NEW;
|
---|
114 | break;
|
---|
115 | case OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW: /* 0x11 */
|
---|
116 | pParams->CreateFlags |= SHFL_CF_ACT_OPEN_IF_EXISTS | SHFL_CF_ACT_CREATE_IF_NEW;
|
---|
117 | break;
|
---|
118 | case OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW: /* 0x02 */
|
---|
119 | pParams->CreateFlags |= SHFL_CF_ACT_REPLACE_IF_EXISTS | SHFL_CF_ACT_FAIL_IF_NEW;
|
---|
120 | break;
|
---|
121 | case OPEN_ACTION_REPLACE_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW: /* 0x12 */
|
---|
122 | pParams->CreateFlags |= SHFL_CF_ACT_REPLACE_IF_EXISTS | SHFL_CF_ACT_CREATE_IF_NEW;
|
---|
123 | break;
|
---|
124 | default:
|
---|
125 | LogRel(("FS32_OPENCREATE: Invalid file open flags: %#x\n", fOpenFlags));
|
---|
126 | VbglR0PhysHeapFree(pParams);
|
---|
127 | return VERR_INVALID_PARAMETER;
|
---|
128 | }
|
---|
129 |
|
---|
130 | /* Misc: cache, etc? There seems to be no API for that. */
|
---|
131 |
|
---|
132 | /* Attributes: */
|
---|
133 | pParams->Info.Attr.fMode = ((uint32_t)fAttribs << RTFS_DOS_SHIFT) & RTFS_DOS_MASK_OS2;
|
---|
134 |
|
---|
135 | /* Initial size: */
|
---|
136 | if (pSfFsi->sfi_sizel > 0)
|
---|
137 | pParams->Info.cbObject = pSfFsi->sfi_sizel;
|
---|
138 |
|
---|
139 | /*
|
---|
140 | * Resolve path to a folder and folder relative path.
|
---|
141 | */
|
---|
142 | PVBOXSFFOLDER pFolder;
|
---|
143 | PSHFLSTRING pStrFolderPath;
|
---|
144 | RT_NOREF(pCdFsi);
|
---|
145 | APIRET rc = vboxSfOs2ResolvePath(pszName, pCdFsd, offCurDirEnd, &pFolder, &pStrFolderPath);
|
---|
146 | LogFlow(("FS32_OPENCREATE: vboxSfOs2ResolvePath: -> %u pFolder=%p\n", rc, pFolder));
|
---|
147 | if (rc == NO_ERROR)
|
---|
148 | {
|
---|
149 | /*
|
---|
150 | * Try open the file.
|
---|
151 | */
|
---|
152 | int vrc = VbglR0SfCreate(&g_SfClient, &pFolder->hHostFolder, pStrFolderPath, pParams);
|
---|
153 | LogFlow(("FS32_OPENCREATE: VbglR0SfCreate -> %Rrc Result=%d fMode=%#x\n", vrc, pParams->Result, pParams->Info.Attr.fMode));
|
---|
154 | if (RT_SUCCESS(vrc))
|
---|
155 | {
|
---|
156 | switch (pParams->Result)
|
---|
157 | {
|
---|
158 | case SHFL_FILE_EXISTS:
|
---|
159 | if (pParams->Handle == SHFL_HANDLE_NIL)
|
---|
160 | {
|
---|
161 | rc = ERROR_FILE_EXISTS;
|
---|
162 | break;
|
---|
163 | }
|
---|
164 | RT_FALL_THRU();
|
---|
165 | case SHFL_FILE_CREATED:
|
---|
166 | case SHFL_FILE_REPLACED:
|
---|
167 | if ( pParams->Info.cbObject < _2G
|
---|
168 | || (fOpenMode & OPEN_FLAGS_LARGEFILE))
|
---|
169 | {
|
---|
170 | pSfFsd->u32Magic = VBOXSFSYFI_MAGIC;
|
---|
171 | pSfFsd->pSelf = pSfFsd;
|
---|
172 | pSfFsd->hHostFile = pParams->Handle;
|
---|
173 | pSfFsd->pFolder = pFolder;
|
---|
174 |
|
---|
175 | uint32_t cOpenFiles = ASMAtomicIncU32(&pFolder->cOpenFiles);
|
---|
176 | Assert(cOpenFiles < _32K);
|
---|
177 | pFolder = NULL; /* Reference now taken by pSfFsd->pFolder. */
|
---|
178 |
|
---|
179 | pSfFsi->sfi_sizel = pParams->Info.cbObject;
|
---|
180 | pSfFsi->sfi_type = STYPE_FILE;
|
---|
181 | pSfFsi->sfi_DOSattr = (uint8_t)((pParams->Info.Attr.fMode & RTFS_DOS_MASK_OS2) >> RTFS_DOS_SHIFT);
|
---|
182 | int16_t cMinLocalTimeDelta = vboxSfOs2GetLocalTimeDelta();
|
---|
183 | vboxSfOs2DateTimeFromTimeSpec(&pSfFsi->sfi_cdate, &pSfFsi->sfi_ctime, pParams->Info.BirthTime, cMinLocalTimeDelta);
|
---|
184 | vboxSfOs2DateTimeFromTimeSpec(&pSfFsi->sfi_adate, &pSfFsi->sfi_atime, pParams->Info.AccessTime, cMinLocalTimeDelta);
|
---|
185 | vboxSfOs2DateTimeFromTimeSpec(&pSfFsi->sfi_mdate, &pSfFsi->sfi_mtime, pParams->Info.ModificationTime, cMinLocalTimeDelta);
|
---|
186 | if (pParams->Result == SHFL_FILE_CREATED)
|
---|
187 | pSfFsi->sfi_tstamp |= ST_PCREAT | ST_SCREAT | ST_PWRITE | ST_SWRITE | ST_PREAD | ST_SREAD;
|
---|
188 |
|
---|
189 | *puAction = pParams->Result == SHFL_FILE_CREATED ? FILE_CREATED
|
---|
190 | : pParams->Result == SHFL_FILE_EXISTS ? FILE_EXISTED
|
---|
191 | : FILE_TRUNCATED;
|
---|
192 |
|
---|
193 | Log(("FS32_OPENCREATE: hHandle=%#RX64 for '%s'\n", pSfFsd->hHostFile, pszName));
|
---|
194 | rc = NO_ERROR;
|
---|
195 | }
|
---|
196 | else
|
---|
197 | {
|
---|
198 | LogRel(("FS32_OPENCREATE: cbObject=%#RX64 no OPEN_FLAGS_LARGEFILE (%s)\n", pParams->Info.cbObject, pszName));
|
---|
199 | VbglR0SfClose(&g_SfClient, &pFolder->hHostFolder, pParams->Handle);
|
---|
200 | rc = ERROR_ACCESS_DENIED;
|
---|
201 | }
|
---|
202 | break;
|
---|
203 |
|
---|
204 | case SHFL_PATH_NOT_FOUND:
|
---|
205 | rc = ERROR_PATH_NOT_FOUND;
|
---|
206 | break;
|
---|
207 |
|
---|
208 | default:
|
---|
209 | case SHFL_FILE_NOT_FOUND:
|
---|
210 | rc = ERROR_FILE_NOT_FOUND;
|
---|
211 | break;
|
---|
212 | }
|
---|
213 | }
|
---|
214 | else if (rc == VERR_ALREADY_EXISTS)
|
---|
215 | rc = ERROR_ACCESS_DENIED;
|
---|
216 | else
|
---|
217 | rc = vboxSfOs2ConvertStatusToOs2(vrc, ERROR_PATH_NOT_FOUND);
|
---|
218 | vboxSfOs2ReleasePathAndFolder(pStrFolderPath, pFolder);
|
---|
219 | }
|
---|
220 | VbglR0PhysHeapFree(pParams);
|
---|
221 | LogFlow(("FS32_OPENCREATE: returns %u\n", rc));
|
---|
222 | return rc;
|
---|
223 | }
|
---|
224 |
|
---|
225 |
|
---|
226 | DECLASM(APIRET)
|
---|
227 | FS32_CLOSE(ULONG uType, ULONG fIoFlags, PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd)
|
---|
228 | {
|
---|
229 | LogFlow(("FS32_CLOSE: uType=%#x fIoFlags=%#x pSfFsi=%p pSfFsd=%p:{%#x}\n", uType, fIoFlags, pSfFsi, pSfFsd, pSfFsd->u32Magic));
|
---|
230 |
|
---|
231 | /*
|
---|
232 | * Validate input.
|
---|
233 | */
|
---|
234 | AssertReturn(pSfFsd->u32Magic == VBOXSFSYFI_MAGIC, ERROR_SYS_INTERNAL);
|
---|
235 | AssertReturn(pSfFsd->pSelf == pSfFsd, ERROR_SYS_INTERNAL);
|
---|
236 | PVBOXSFFOLDER pFolder = pSfFsd->pFolder;
|
---|
237 | AssertReturn(pFolder != NULL, ERROR_SYS_INTERNAL);
|
---|
238 | Assert(pFolder->u32Magic == VBOXSFFOLDER_MAGIC);
|
---|
239 | Assert(pFolder->cOpenFiles > 0);
|
---|
240 |
|
---|
241 | /*
|
---|
242 | * We only care for when the system is done truly with the file
|
---|
243 | * and we can close it.
|
---|
244 | */
|
---|
245 | if (uType != FS_CL_FORSYS)
|
---|
246 | return NO_ERROR;
|
---|
247 |
|
---|
248 | /** @todo flush file if fIoFlags says so? */
|
---|
249 | RT_NOREF(fIoFlags);
|
---|
250 |
|
---|
251 | int vrc = VbglR0SfClose(&g_SfClient, &pFolder->hHostFolder, pSfFsd->hHostFile);
|
---|
252 | AssertRC(vrc);
|
---|
253 |
|
---|
254 | pSfFsd->hHostFile = SHFL_HANDLE_NIL;
|
---|
255 | pSfFsd->pSelf = NULL;
|
---|
256 | pSfFsd->u32Magic = ~VBOXSFSYFI_MAGIC;
|
---|
257 | pSfFsd->pFolder = NULL;
|
---|
258 |
|
---|
259 | ASMAtomicDecU32(&pFolder->cOpenFiles);
|
---|
260 | vboxSfOs2ReleaseFolder(pFolder);
|
---|
261 |
|
---|
262 | RT_NOREF(pSfFsi);
|
---|
263 | LogFlow(("FS32_CLOSE: returns NO_ERROR\n"));
|
---|
264 | return NO_ERROR;
|
---|
265 | }
|
---|
266 |
|
---|
267 |
|
---|
268 | DECLASM(APIRET)
|
---|
269 | FS32_COMMIT(ULONG uType, ULONG fIoFlags, PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd)
|
---|
270 | {
|
---|
271 | LogFlow(("FS32_COMMIT: uType=%#x fIoFlags=%#x pSfFsi=%p pSfFsd=%p:{%#x}\n", uType, fIoFlags, pSfFsi, pSfFsd, pSfFsd->u32Magic));
|
---|
272 |
|
---|
273 | /*
|
---|
274 | * Validate input.
|
---|
275 | */
|
---|
276 | AssertReturn(pSfFsd->u32Magic == VBOXSFSYFI_MAGIC, ERROR_SYS_INTERNAL);
|
---|
277 | AssertReturn(pSfFsd->pSelf == pSfFsd, ERROR_SYS_INTERNAL);
|
---|
278 | PVBOXSFFOLDER pFolder = pSfFsd->pFolder;
|
---|
279 | AssertReturn(pFolder != NULL, ERROR_SYS_INTERNAL);
|
---|
280 | Assert(pFolder->u32Magic == VBOXSFFOLDER_MAGIC);
|
---|
281 | Assert(pFolder->cOpenFiles > 0);
|
---|
282 | RT_NOREF(pFolder);
|
---|
283 |
|
---|
284 | /*
|
---|
285 | * We only need to flush writable files.
|
---|
286 | */
|
---|
287 | if ( (pSfFsi->sfi_mode & SFMODE_OPEN_ACCESS) == SFMODE_OPEN_WRITEONLY
|
---|
288 | || (pSfFsi->sfi_mode & SFMODE_OPEN_ACCESS) == SFMODE_OPEN_READWRITE)
|
---|
289 | {
|
---|
290 | int vrc = VbglR0SfFlush(&g_SfClient, &pFolder->hHostFolder, pSfFsd->hHostFile);
|
---|
291 | if (RT_FAILURE(vrc))
|
---|
292 | {
|
---|
293 | LogRel(("FS32_COMMIT: VbglR0SfFlush failed: %Rrc\n", vrc));
|
---|
294 | return ERROR_FLUSHBUF_FAILED;
|
---|
295 | }
|
---|
296 | }
|
---|
297 |
|
---|
298 | NOREF(uType); NOREF(fIoFlags); NOREF(pSfFsi);
|
---|
299 | LogFlow(("FS32_COMMIT: returns NO_ERROR\n"));
|
---|
300 | return NO_ERROR;
|
---|
301 | }
|
---|
302 |
|
---|
303 |
|
---|
304 | extern "C" APIRET APIENTRY
|
---|
305 | FS32_CHGFILEPTRL(PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd, LONGLONG off, ULONG uMethod, ULONG fIoFlags)
|
---|
306 | {
|
---|
307 | LogFlow(("FS32_CHGFILEPTRL: pSfFsi=%p pSfFsd=%p off=%RI64 (%#RX64) uMethod=%u fIoFlags=%#x\n",
|
---|
308 | pSfFsi, pSfFsd, off, off, uMethod, fIoFlags));
|
---|
309 |
|
---|
310 | /*
|
---|
311 | * Validate input.
|
---|
312 | */
|
---|
313 | AssertReturn(pSfFsd->u32Magic == VBOXSFSYFI_MAGIC, ERROR_SYS_INTERNAL);
|
---|
314 | AssertReturn(pSfFsd->pSelf == pSfFsd, ERROR_SYS_INTERNAL);
|
---|
315 | PVBOXSFFOLDER pFolder = pSfFsd->pFolder;
|
---|
316 | AssertReturn(pFolder != NULL, ERROR_SYS_INTERNAL);
|
---|
317 | Assert(pFolder->u32Magic == VBOXSFFOLDER_MAGIC);
|
---|
318 | Assert(pFolder->cOpenFiles > 0);
|
---|
319 |
|
---|
320 | /*
|
---|
321 | * Calc absolute offset.
|
---|
322 | */
|
---|
323 | int64_t offNew;
|
---|
324 | switch (uMethod)
|
---|
325 | {
|
---|
326 | case CFP_RELBEGIN:
|
---|
327 | if (off >= 0)
|
---|
328 | {
|
---|
329 | offNew = off;
|
---|
330 | break;
|
---|
331 | }
|
---|
332 | Log(("FS32_CHGFILEPTRL: Negative seek (BEGIN): %RI64\n", off));
|
---|
333 | return ERROR_NEGATIVE_SEEK;
|
---|
334 |
|
---|
335 | case CFP_RELCUR:
|
---|
336 | offNew = pSfFsi->sfi_positionl + off;
|
---|
337 | if (offNew >= 0)
|
---|
338 | break;
|
---|
339 | Log(("FS32_CHGFILEPTRL: Negative seek (RELCUR): %RU64 + %RI64\n", pSfFsi->sfi_positionl, off));
|
---|
340 | return ERROR_NEGATIVE_SEEK;
|
---|
341 |
|
---|
342 | case CFP_RELEND:
|
---|
343 | {
|
---|
344 | /* Have to consult the host to get the current file size. */
|
---|
345 |
|
---|
346 | PSHFLFSOBJINFO pObjInfo = (PSHFLFSOBJINFO)VbglR0PhysHeapAlloc(sizeof(*pObjInfo));
|
---|
347 | if (!pObjInfo)
|
---|
348 | return ERROR_NOT_ENOUGH_MEMORY;
|
---|
349 | RT_ZERO(*pObjInfo);
|
---|
350 | uint32_t cbObjInfo = sizeof(*pObjInfo);
|
---|
351 |
|
---|
352 | int vrc = VbglR0SfFsInfo(&g_SfClient, &pFolder->hHostFolder, pSfFsd->hHostFile,
|
---|
353 | SHFL_INFO_FILE | SHFL_INFO_GET, &cbObjInfo, (PSHFLDIRINFO)pObjInfo);
|
---|
354 | if (RT_SUCCESS(vrc))
|
---|
355 | {
|
---|
356 | if (pSfFsi->sfi_mode & SFMODE_LARGE_FILE)
|
---|
357 | pSfFsi->sfi_sizel = pObjInfo->cbObject;
|
---|
358 | else
|
---|
359 | pSfFsi->sfi_sizel = RT_MIN(pObjInfo->cbObject, _2G - 1);
|
---|
360 | }
|
---|
361 | else
|
---|
362 | LogRel(("FS32_CHGFILEPTRL/CFP_RELEND: VbglR0SfFsInfo failed: %Rrc\n", vrc));
|
---|
363 | VbglR0PhysHeapFree(pObjInfo);
|
---|
364 |
|
---|
365 | offNew = pSfFsi->sfi_sizel + off;
|
---|
366 | if (offNew >= 0)
|
---|
367 | break;
|
---|
368 | Log(("FS32_CHGFILEPTRL: Negative seek (CFP_RELEND): %RI64 + %RI64\n", pSfFsi->sfi_sizel, off));
|
---|
369 | return ERROR_NEGATIVE_SEEK;
|
---|
370 | }
|
---|
371 |
|
---|
372 |
|
---|
373 | default:
|
---|
374 | LogRel(("FS32_CHGFILEPTRL: Unknown seek method: %#x\n", uMethod));
|
---|
375 | return ERROR_INVALID_FUNCTION;
|
---|
376 | }
|
---|
377 |
|
---|
378 | /*
|
---|
379 | * Commit the seek.
|
---|
380 | */
|
---|
381 | pSfFsi->sfi_positionl = offNew;
|
---|
382 | LogFlow(("FS32_CHGFILEPTRL: returns; sfi_positionl=%RI64\n", offNew));
|
---|
383 | RT_NOREF_PV(fIoFlags);
|
---|
384 | return NO_ERROR;
|
---|
385 | }
|
---|
386 |
|
---|
387 |
|
---|
388 | /** Forwards the call to FS32_CHGFILEPTRL. */
|
---|
389 | DECLASM(APIRET)
|
---|
390 | FS32_CHGFILEPTR(PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd, LONG off, ULONG uMethod, ULONG fIoFlags)
|
---|
391 | {
|
---|
392 | return FS32_CHGFILEPTRL(pSfFsi, pSfFsd, off, uMethod, fIoFlags);
|
---|
393 | }
|
---|
394 |
|
---|
395 |
|
---|
396 | /**
|
---|
397 | * Worker for FS32_PATHINFO that handles file stat setting.
|
---|
398 | *
|
---|
399 | * @returns OS/2 status code
|
---|
400 | * @param pFolder The folder.
|
---|
401 | * @param pSfFsi The file system independent file structure. We'll
|
---|
402 | * update the timestamps and size here.
|
---|
403 | * @param pSfFsd Out file data.
|
---|
404 | * @param uLevel The information level.
|
---|
405 | * @param pbData The stat data to set.
|
---|
406 | * @param cbData The uLevel specific input size.
|
---|
407 | */
|
---|
408 | static APIRET
|
---|
409 | vboxSfOs2SetFileInfo(PVBOXSFFOLDER pFolder, PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd, ULONG uLevel, PBYTE pbData, ULONG cbData)
|
---|
410 | {
|
---|
411 | APIRET rc;
|
---|
412 |
|
---|
413 | /*
|
---|
414 | * Data buffer both for caching user data and for issuing the
|
---|
415 | * change request to the host.
|
---|
416 | */
|
---|
417 | struct SetFileInfoBuf
|
---|
418 | {
|
---|
419 | union
|
---|
420 | {
|
---|
421 | FILESTATUS Lvl1;
|
---|
422 | FILESTATUS3L Lvl1L;
|
---|
423 | };
|
---|
424 | SHFLFSOBJINFO ObjInfo;
|
---|
425 |
|
---|
426 | } *pBuf = (struct SetFileInfoBuf *)VbglR0PhysHeapAlloc(sizeof(*pBuf));
|
---|
427 | if (pBuf)
|
---|
428 | {
|
---|
429 | /* Copy in the data. */
|
---|
430 | rc = KernCopyIn(&pBuf->Lvl1, pbData, cbData);
|
---|
431 | if (rc == NO_ERROR)
|
---|
432 | {
|
---|
433 | /*
|
---|
434 | * Join paths with FS32_PATHINFO and FS32_FILEATTRIBUTE.
|
---|
435 | */
|
---|
436 | rc = vboxSfOs2SetInfoCommonWorker(pFolder, pSfFsd->hHostFile,
|
---|
437 | uLevel == FI_LVL_STANDARD ? pBuf->Lvl1.attrFile : pBuf->Lvl1L.attrFile,
|
---|
438 | &pBuf->Lvl1, &pBuf->ObjInfo);
|
---|
439 | if (rc == NO_ERROR)
|
---|
440 | {
|
---|
441 | /*
|
---|
442 | * Update the timestamps in the independent file data with what
|
---|
443 | * the host returned:
|
---|
444 | */
|
---|
445 | pSfFsi->sfi_tstamp |= ST_PCREAT | ST_PWRITE | ST_PREAD;
|
---|
446 | pSfFsi->sfi_tstamp &= ~(ST_SCREAT | ST_SWRITE| ST_SREAD);
|
---|
447 | uint16_t cDelta = vboxSfOs2GetLocalTimeDelta();
|
---|
448 | vboxSfOs2DateTimeFromTimeSpec(&pSfFsi->sfi_cdate, &pSfFsi->sfi_ctime, pBuf->ObjInfo.BirthTime, cDelta);
|
---|
449 | vboxSfOs2DateTimeFromTimeSpec(&pSfFsi->sfi_adate, &pSfFsi->sfi_atime, pBuf->ObjInfo.AccessTime, cDelta);
|
---|
450 | vboxSfOs2DateTimeFromTimeSpec(&pSfFsi->sfi_mdate, &pSfFsi->sfi_mtime, pBuf->ObjInfo.ModificationTime, cDelta);
|
---|
451 |
|
---|
452 | /* And the size field as we're at it: */
|
---|
453 | pSfFsi->sfi_sizel = pBuf->ObjInfo.cbObject;
|
---|
454 | }
|
---|
455 | else
|
---|
456 | rc = ERROR_INVALID_PARAMETER;
|
---|
457 | }
|
---|
458 |
|
---|
459 | VbglR0PhysHeapFree(pBuf);
|
---|
460 | }
|
---|
461 | else
|
---|
462 | rc = ERROR_NOT_ENOUGH_MEMORY;
|
---|
463 | return rc;
|
---|
464 | }
|
---|
465 |
|
---|
466 |
|
---|
467 | /**
|
---|
468 | * Worker for FS32_PATHINFO that handles file stat queries.
|
---|
469 | *
|
---|
470 | * @returns OS/2 status code
|
---|
471 | * @param pFolder The folder.
|
---|
472 | * @param pSfFsi The file system independent file structure. We'll
|
---|
473 | * update the timestamps and size here.
|
---|
474 | * @param pSfFsd Out file data.
|
---|
475 | * @param uLevel The information level.
|
---|
476 | * @param pbData Where to return the data (user address).
|
---|
477 | * @param cbData The amount of data to produce.
|
---|
478 | */
|
---|
479 | static APIRET
|
---|
480 | vboxSfOs2QueryFileInfo(PVBOXSFFOLDER pFolder, PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd, ULONG uLevel, PBYTE pbData, ULONG cbData)
|
---|
481 | {
|
---|
482 | APIRET rc;
|
---|
483 | PSHFLFSOBJINFO pObjInfo = (PSHFLFSOBJINFO)VbglR0PhysHeapAlloc(sizeof(*pObjInfo));
|
---|
484 | if (pObjInfo)
|
---|
485 | {
|
---|
486 | RT_ZERO(*pObjInfo);
|
---|
487 | uint32_t cbObjInfo = sizeof(*pObjInfo);
|
---|
488 |
|
---|
489 | int vrc = VbglR0SfFsInfo(&g_SfClient, &pFolder->hHostFolder, pSfFsd->hHostFile,
|
---|
490 | SHFL_INFO_FILE | SHFL_INFO_GET, &cbObjInfo, (PSHFLDIRINFO)pObjInfo);
|
---|
491 | if (RT_SUCCESS(vrc))
|
---|
492 | {
|
---|
493 | rc = vboxSfOs2FileStatusFromObjInfo(pbData, cbData, uLevel, pObjInfo);
|
---|
494 | if (rc == NO_ERROR)
|
---|
495 | {
|
---|
496 | /* Update the timestamps in the independent file data: */
|
---|
497 | int16_t cMinLocalTimeDelta = vboxSfOs2GetLocalTimeDelta();
|
---|
498 | vboxSfOs2DateTimeFromTimeSpec(&pSfFsi->sfi_cdate, &pSfFsi->sfi_ctime, pObjInfo->BirthTime, cMinLocalTimeDelta);
|
---|
499 | vboxSfOs2DateTimeFromTimeSpec(&pSfFsi->sfi_adate, &pSfFsi->sfi_atime, pObjInfo->AccessTime, cMinLocalTimeDelta);
|
---|
500 | vboxSfOs2DateTimeFromTimeSpec(&pSfFsi->sfi_mdate, &pSfFsi->sfi_mtime, pObjInfo->ModificationTime, cMinLocalTimeDelta);
|
---|
501 |
|
---|
502 | /* And the size field as we're at it: */
|
---|
503 | pSfFsi->sfi_sizel = pObjInfo->cbObject;
|
---|
504 | }
|
---|
505 | }
|
---|
506 | else
|
---|
507 | {
|
---|
508 | Log(("vboxSfOs2QueryFileInfo: VbglR0SfFsInfo failed: %Rrc\n", vrc));
|
---|
509 | rc = vboxSfOs2ConvertStatusToOs2(vrc, ERROR_GEN_FAILURE);
|
---|
510 | }
|
---|
511 | }
|
---|
512 | else
|
---|
513 | rc = ERROR_NOT_ENOUGH_MEMORY;
|
---|
514 | return rc;
|
---|
515 | }
|
---|
516 |
|
---|
517 |
|
---|
518 | DECLASM(APIRET)
|
---|
519 | FS32_FILEINFO(ULONG fFlags, PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd, ULONG uLevel,
|
---|
520 | PBYTE pbData, ULONG cbData, ULONG fIoFlags)
|
---|
521 | {
|
---|
522 | LogFlow(("FS32_FILEINFO: fFlags=%#x pSfFsi=%p pSfFsd=%p uLevel=%p pbData=%p cbData=%#x fIoFlags=%#x\n",
|
---|
523 | fFlags, pSfFsi, pSfFsd, uLevel, pbData, cbData, fIoFlags));
|
---|
524 |
|
---|
525 | /*
|
---|
526 | * Validate input.
|
---|
527 | */
|
---|
528 | AssertReturn(pSfFsd->u32Magic == VBOXSFSYFI_MAGIC, ERROR_SYS_INTERNAL);
|
---|
529 | AssertReturn(pSfFsd->pSelf == pSfFsd, ERROR_SYS_INTERNAL);
|
---|
530 | PVBOXSFFOLDER pFolder = pSfFsd->pFolder;
|
---|
531 | AssertReturn(pFolder != NULL, ERROR_SYS_INTERNAL);
|
---|
532 | Assert(pFolder->u32Magic == VBOXSFFOLDER_MAGIC);
|
---|
533 | Assert(pFolder->cOpenFiles > 0);
|
---|
534 |
|
---|
535 | /*
|
---|
536 | * Check the level.
|
---|
537 | * Note! See notes in FS32_PATHINFO.
|
---|
538 | */
|
---|
539 | ULONG cbMinData;
|
---|
540 | switch (uLevel)
|
---|
541 | {
|
---|
542 | case FI_LVL_STANDARD:
|
---|
543 | cbMinData = sizeof(FILESTATUS);
|
---|
544 | AssertCompileSize(FILESTATUS, 0x16);
|
---|
545 | break;
|
---|
546 | case FI_LVL_STANDARD_64:
|
---|
547 | cbMinData = sizeof(FILESTATUS3L);
|
---|
548 | AssertCompileSize(FILESTATUS3L, 0x20); /* cbFile and cbFileAlloc are misaligned. */
|
---|
549 | break;
|
---|
550 | case FI_LVL_STANDARD_EASIZE:
|
---|
551 | cbMinData = sizeof(FILESTATUS2);
|
---|
552 | AssertCompileSize(FILESTATUS2, 0x1a);
|
---|
553 | break;
|
---|
554 | case FI_LVL_STANDARD_EASIZE_64:
|
---|
555 | cbMinData = sizeof(FILESTATUS4L);
|
---|
556 | AssertCompileSize(FILESTATUS4L, 0x24); /* cbFile and cbFileAlloc are misaligned. */
|
---|
557 | break;
|
---|
558 | case FI_LVL_EAS_FROM_LIST:
|
---|
559 | case FI_LVL_EAS_FULL:
|
---|
560 | case FI_LVL_EAS_FULL_5:
|
---|
561 | case FI_LVL_EAS_FULL_8:
|
---|
562 | cbMinData = sizeof(EAOP);
|
---|
563 | break;
|
---|
564 | default:
|
---|
565 | LogRel(("FS32_PATHINFO: Unsupported info level %u!\n", uLevel));
|
---|
566 | return ERROR_INVALID_LEVEL;
|
---|
567 | }
|
---|
568 | if (cbData < cbMinData || pbData == NULL)
|
---|
569 | {
|
---|
570 | Log(("FS32_FILEINFO: ERROR_BUFFER_OVERFLOW (cbMinData=%#x, cbData=%#x)\n", cbMinData, cbData));
|
---|
571 | return ERROR_BUFFER_OVERFLOW;
|
---|
572 | }
|
---|
573 |
|
---|
574 | /*
|
---|
575 | * Query information.
|
---|
576 | */
|
---|
577 | APIRET rc;
|
---|
578 | if (fFlags == FI_RETRIEVE)
|
---|
579 | {
|
---|
580 | switch (uLevel)
|
---|
581 | {
|
---|
582 | case FI_LVL_STANDARD:
|
---|
583 | case FI_LVL_STANDARD_EASIZE:
|
---|
584 | case FI_LVL_STANDARD_64:
|
---|
585 | case FI_LVL_STANDARD_EASIZE_64:
|
---|
586 | rc = vboxSfOs2QueryFileInfo(pFolder, pSfFsi, pSfFsd, uLevel, pbData, cbMinData);
|
---|
587 | break;
|
---|
588 |
|
---|
589 | /*
|
---|
590 | * We don't do EAs and we "just" need to return no-EAs.
|
---|
591 | * However, that's not as easy as you might think.
|
---|
592 | */
|
---|
593 | case FI_LVL_EAS_FROM_LIST:
|
---|
594 | case FI_LVL_EAS_FULL:
|
---|
595 | case FI_LVL_EAS_FULL_5:
|
---|
596 | case FI_LVL_EAS_FULL_8:
|
---|
597 | rc = vboxSfOs2MakeEmptyEaList((PEAOP)pbData, uLevel);
|
---|
598 | break;
|
---|
599 |
|
---|
600 | default:
|
---|
601 | AssertFailed();
|
---|
602 | rc = ERROR_GEN_FAILURE;
|
---|
603 | break;
|
---|
604 | }
|
---|
605 | }
|
---|
606 | /*
|
---|
607 | * Update information.
|
---|
608 | */
|
---|
609 | else if (fFlags == FI_SET)
|
---|
610 | {
|
---|
611 | switch (uLevel)
|
---|
612 | {
|
---|
613 | case FI_LVL_STANDARD:
|
---|
614 | case FI_LVL_STANDARD_64:
|
---|
615 | rc = vboxSfOs2SetFileInfo(pFolder, pSfFsi, pSfFsd, uLevel, pbData, cbMinData);
|
---|
616 | break;
|
---|
617 |
|
---|
618 | case FI_LVL_STANDARD_EASIZE:
|
---|
619 | rc = ERROR_EAS_NOT_SUPPORTED;
|
---|
620 | break;
|
---|
621 |
|
---|
622 | case FI_LVL_STANDARD_EASIZE_64:
|
---|
623 | case FI_LVL_EAS_FROM_LIST:
|
---|
624 | case FI_LVL_EAS_FULL:
|
---|
625 | case FI_LVL_EAS_FULL_5:
|
---|
626 | case FI_LVL_EAS_FULL_8:
|
---|
627 | rc = ERROR_INVALID_LEVEL;
|
---|
628 | break;
|
---|
629 |
|
---|
630 | default:
|
---|
631 | AssertFailed();
|
---|
632 | rc = ERROR_GEN_FAILURE;
|
---|
633 | break;
|
---|
634 | }
|
---|
635 | }
|
---|
636 | else
|
---|
637 | {
|
---|
638 | LogRel(("FS32_FILEINFO: Unknown flags value: %#x\n", fFlags));
|
---|
639 | rc = ERROR_INVALID_PARAMETER;
|
---|
640 | }
|
---|
641 | RT_NOREF_PV(fIoFlags);
|
---|
642 | return rc;
|
---|
643 | }
|
---|
644 |
|
---|
645 |
|
---|
646 | DECLASM(APIRET)
|
---|
647 | FS32_NEWSIZEL(PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd, LONGLONG cbFile, ULONG fIoFlags)
|
---|
648 | {
|
---|
649 | LogFlow(("FS32_NEWSIZEL: pSfFsi=%p pSfFsd=%p cbFile=%RI64 (%#RX64) fIoFlags=%#x\n", pSfFsi, pSfFsd, cbFile, cbFile, fIoFlags));
|
---|
650 |
|
---|
651 | /*
|
---|
652 | * Validate input.
|
---|
653 | */
|
---|
654 | AssertReturn(pSfFsd->u32Magic == VBOXSFSYFI_MAGIC, ERROR_SYS_INTERNAL);
|
---|
655 | AssertReturn(pSfFsd->pSelf == pSfFsd, ERROR_SYS_INTERNAL);
|
---|
656 | PVBOXSFFOLDER pFolder = pSfFsd->pFolder;
|
---|
657 | AssertReturn(pFolder != NULL, ERROR_SYS_INTERNAL);
|
---|
658 | Assert(pFolder->u32Magic == VBOXSFFOLDER_MAGIC);
|
---|
659 | Assert(pFolder->cOpenFiles > 0);
|
---|
660 | if (cbFile < 0)
|
---|
661 | {
|
---|
662 | LogRel(("FS32_NEWSIZEL: Negative size: %RI64\n", cbFile));
|
---|
663 | return ERROR_INVALID_PARAMETER;
|
---|
664 | }
|
---|
665 |
|
---|
666 | /*
|
---|
667 | * This should only be possible on a file that is writable.
|
---|
668 | */
|
---|
669 | APIRET rc;
|
---|
670 | if ( (pSfFsi->sfi_mode & SFMODE_OPEN_ACCESS) == SFMODE_OPEN_WRITEONLY
|
---|
671 | || (pSfFsi->sfi_mode & SFMODE_OPEN_ACCESS) == SFMODE_OPEN_READWRITE)
|
---|
672 | {
|
---|
673 | /*
|
---|
674 | * Call the host. We need a full object info structure here to pass
|
---|
675 | * a 64-bit unsigned integer value. Sigh.
|
---|
676 | */
|
---|
677 | /** @todo Shared folders: New SET_FILE_SIZE API. */
|
---|
678 | PSHFLFSOBJINFO pObjInfo = (PSHFLFSOBJINFO)VbglR0PhysHeapAlloc(sizeof(*pObjInfo));
|
---|
679 | if (pObjInfo)
|
---|
680 | {
|
---|
681 | RT_ZERO(*pObjInfo);
|
---|
682 | pObjInfo->cbObject = cbFile;
|
---|
683 | uint32_t cbObjInfo = sizeof(*pObjInfo);
|
---|
684 | int vrc = VbglR0SfFsInfo(&g_SfClient, &pFolder->hHostFolder, pSfFsd->hHostFile,
|
---|
685 | SHFL_INFO_SIZE | SHFL_INFO_SET, &cbObjInfo, (PSHFLDIRINFO)pObjInfo);
|
---|
686 | if (RT_SUCCESS(vrc))
|
---|
687 | {
|
---|
688 | pSfFsi->sfi_sizel = cbFile;
|
---|
689 | rc = NO_ERROR;
|
---|
690 | }
|
---|
691 | else
|
---|
692 | {
|
---|
693 | LogRel(("FS32_NEWSIZEL: VbglR0SfFsInfo failed: %Rrc\n", vrc));
|
---|
694 | if (vrc == VERR_DISK_FULL)
|
---|
695 | rc = ERROR_DISK_FULL;
|
---|
696 | else
|
---|
697 | rc = ERROR_GEN_FAILURE;
|
---|
698 | }
|
---|
699 | VbglR0PhysHeapFree(pObjInfo);
|
---|
700 | }
|
---|
701 | else
|
---|
702 | rc = ERROR_NOT_ENOUGH_MEMORY;
|
---|
703 | }
|
---|
704 | else
|
---|
705 | rc = ERROR_ACCESS_DENIED;
|
---|
706 | LogFlow(("FS32_NEWSIZEL: returns %u\n", rc));
|
---|
707 | return rc;
|
---|
708 | }
|
---|
709 |
|
---|
710 |
|
---|
711 | extern "C" APIRET APIENTRY
|
---|
712 | FS32_READ(PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd, PVOID pvData, PULONG pcb, ULONG fIoFlags)
|
---|
713 | {
|
---|
714 | LogFlow(("FS32_READ: pSfFsi=%p pSfFsd=%p pvData=%p pcb=%p:{%#x} fIoFlags=%#x\n", pSfFsi, pSfFsd, pvData, pcb, *pcb, fIoFlags));
|
---|
715 |
|
---|
716 | /*
|
---|
717 | * Validate input.
|
---|
718 | */
|
---|
719 | AssertReturn(pSfFsd->u32Magic == VBOXSFSYFI_MAGIC, ERROR_SYS_INTERNAL);
|
---|
720 | AssertReturn(pSfFsd->pSelf == pSfFsd, ERROR_SYS_INTERNAL);
|
---|
721 | PVBOXSFFOLDER pFolder = pSfFsd->pFolder;
|
---|
722 | AssertReturn(pFolder != NULL, ERROR_SYS_INTERNAL);
|
---|
723 | Assert(pFolder->u32Magic == VBOXSFFOLDER_MAGIC);
|
---|
724 | Assert(pFolder->cOpenFiles > 0);
|
---|
725 | RT_NOREF(pFolder);
|
---|
726 |
|
---|
727 | /*
|
---|
728 | * If the read request is small enough, go thru a temporary buffer to
|
---|
729 | * avoid locking/unlocking user memory.
|
---|
730 | */
|
---|
731 | uint64_t offRead = pSfFsi->sfi_positionl;
|
---|
732 | uint32_t cbRead = *pcb;
|
---|
733 | uint32_t cbActual = cbRead;
|
---|
734 | if (cbRead <= _8K - ALLOC_HDR_SIZE)
|
---|
735 | {
|
---|
736 | void *pvBuf = VbglR0PhysHeapAlloc(cbRead);
|
---|
737 | if (pvBuf != NULL)
|
---|
738 | {
|
---|
739 | APIRET rc;
|
---|
740 | int vrc = VbglR0SfRead(&g_SfClient, &pFolder->hHostFolder, pSfFsd->hHostFile,
|
---|
741 | offRead, &cbActual, (uint8_t *)pvBuf, true /*fLocked*/);
|
---|
742 | if (RT_SUCCESS(vrc))
|
---|
743 | {
|
---|
744 | AssertStmt(cbActual <= cbRead, cbActual = cbRead);
|
---|
745 | rc = KernCopyOut(pvData, pvBuf, cbActual);
|
---|
746 | if (rc == NO_ERROR)
|
---|
747 | {
|
---|
748 | *pcb = cbActual;
|
---|
749 | pSfFsi->sfi_positionl = offRead + cbActual;
|
---|
750 | if (pSfFsi->sfi_sizel < offRead + cbActual)
|
---|
751 | pSfFsi->sfi_sizel = offRead + cbActual;
|
---|
752 | pSfFsi->sfi_tstamp |= ST_SREAD | ST_PREAD;
|
---|
753 | LogFlow(("FS32_READ: returns; cbActual=%#x sfi_positionl=%RI64 [copy]\n", cbActual, pSfFsi->sfi_positionl));
|
---|
754 | }
|
---|
755 | }
|
---|
756 | else
|
---|
757 | {
|
---|
758 | Log(("FS32_READ: VbglR0SfRead(off=%#x,cb=%#x) -> %Rrc [copy]\n", offRead, cbRead, vrc));
|
---|
759 | rc = ERROR_BAD_NET_RESP;
|
---|
760 | }
|
---|
761 | VbglR0PhysHeapFree(pvBuf);
|
---|
762 | return rc;
|
---|
763 | }
|
---|
764 | }
|
---|
765 |
|
---|
766 | /*
|
---|
767 | * Do the read directly on the buffer, Vbgl will do the locking for us.
|
---|
768 | */
|
---|
769 | int vrc = VbglR0SfRead(&g_SfClient, &pFolder->hHostFolder, pSfFsd->hHostFile,
|
---|
770 | offRead, &cbActual, (uint8_t *)pvData, false /*fLocked*/);
|
---|
771 | if (RT_SUCCESS(vrc))
|
---|
772 | {
|
---|
773 | AssertStmt(cbActual <= cbRead, cbActual = cbRead);
|
---|
774 | *pcb = cbActual;
|
---|
775 | pSfFsi->sfi_positionl = offRead + cbActual;
|
---|
776 | if (pSfFsi->sfi_sizel < offRead + cbActual)
|
---|
777 | pSfFsi->sfi_sizel = offRead + cbActual;
|
---|
778 | pSfFsi->sfi_tstamp |= ST_SREAD | ST_PREAD;
|
---|
779 | LogFlow(("FS32_READ: returns; cbActual=%#x sfi_positionl=%RI64 [direct]\n", cbActual, pSfFsi->sfi_positionl));
|
---|
780 | return NO_ERROR;
|
---|
781 | }
|
---|
782 | Log(("FS32_READ: VbglR0SfRead(off=%#x,cb=%#x) -> %Rrc [direct]\n", offRead, cbRead, vrc));
|
---|
783 | RT_NOREF_PV(fIoFlags);
|
---|
784 | return ERROR_BAD_NET_RESP;
|
---|
785 | }
|
---|
786 |
|
---|
787 |
|
---|
788 | extern "C" APIRET APIENTRY
|
---|
789 | FS32_WRITE(PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd, void const *pvData, PULONG pcb, ULONG fIoFlags)
|
---|
790 | {
|
---|
791 | /*
|
---|
792 | * Validate input.
|
---|
793 | */
|
---|
794 | AssertReturn(pSfFsd->u32Magic == VBOXSFSYFI_MAGIC, ERROR_SYS_INTERNAL);
|
---|
795 | AssertReturn(pSfFsd->pSelf == pSfFsd, ERROR_SYS_INTERNAL);
|
---|
796 | PVBOXSFFOLDER pFolder = pSfFsd->pFolder;
|
---|
797 | AssertReturn(pFolder != NULL, ERROR_SYS_INTERNAL);
|
---|
798 | Assert(pFolder->u32Magic == VBOXSFFOLDER_MAGIC);
|
---|
799 | Assert(pFolder->cOpenFiles > 0);
|
---|
800 | RT_NOREF(pFolder);
|
---|
801 |
|
---|
802 | /*
|
---|
803 | * If the write request is small enough, go thru a temporary buffer to
|
---|
804 | * avoid locking/unlocking user memory.
|
---|
805 | */
|
---|
806 | uint64_t offWrite = pSfFsi->sfi_positionl;
|
---|
807 | uint32_t cbWrite = *pcb;
|
---|
808 | uint32_t cbActual = cbWrite;
|
---|
809 | if (cbWrite <= _8K - ALLOC_HDR_SIZE)
|
---|
810 | {
|
---|
811 | void *pvBuf = VbglR0PhysHeapAlloc(cbWrite);
|
---|
812 | if (pvBuf != NULL)
|
---|
813 | {
|
---|
814 | APIRET rc = KernCopyIn(pvBuf, pvData, cbWrite);
|
---|
815 | if (rc == NO_ERROR)
|
---|
816 | {
|
---|
817 | int vrc = VbglR0SfWrite(&g_SfClient, &pFolder->hHostFolder, pSfFsd->hHostFile,
|
---|
818 | offWrite, &cbActual, (uint8_t *)pvBuf, true /*fLocked*/);
|
---|
819 | if (RT_SUCCESS(vrc))
|
---|
820 | {
|
---|
821 | AssertStmt(cbActual <= cbWrite, cbActual = cbWrite);
|
---|
822 | *pcb = cbActual;
|
---|
823 | pSfFsi->sfi_positionl = offWrite + cbActual;
|
---|
824 | if (pSfFsi->sfi_sizel < offWrite + cbActual)
|
---|
825 | pSfFsi->sfi_sizel = offWrite + cbActual;
|
---|
826 | pSfFsi->sfi_tstamp |= ST_SWRITE | ST_PWRITE;
|
---|
827 | LogFlow(("FS32_READ: returns; cbActual=%#x sfi_positionl=%RI64 [copy]\n", cbActual, pSfFsi->sfi_positionl));
|
---|
828 | }
|
---|
829 | else
|
---|
830 | {
|
---|
831 | Log(("FS32_READ: VbglR0SfWrite(off=%#x,cb=%#x) -> %Rrc [copy]\n", offWrite, cbWrite, vrc));
|
---|
832 | rc = ERROR_BAD_NET_RESP;
|
---|
833 | }
|
---|
834 | }
|
---|
835 | VbglR0PhysHeapFree(pvBuf);
|
---|
836 | return rc;
|
---|
837 | }
|
---|
838 | }
|
---|
839 |
|
---|
840 | /*
|
---|
841 | * Do the write directly on the buffer, Vbgl will do the locking for us.
|
---|
842 | */
|
---|
843 | int vrc = VbglR0SfWrite(&g_SfClient, &pFolder->hHostFolder, pSfFsd->hHostFile,
|
---|
844 | offWrite, &cbActual, (uint8_t *)pvData, false /*fLocked*/);
|
---|
845 | if (RT_SUCCESS(vrc))
|
---|
846 | {
|
---|
847 | AssertStmt(cbActual <= cbWrite, cbActual = cbWrite);
|
---|
848 | *pcb = cbActual;
|
---|
849 | pSfFsi->sfi_positionl = offWrite + cbActual;
|
---|
850 | if (pSfFsi->sfi_sizel < offWrite + cbActual)
|
---|
851 | pSfFsi->sfi_sizel = offWrite + cbActual;
|
---|
852 | pSfFsi->sfi_tstamp |= ST_SWRITE | ST_PWRITE;
|
---|
853 | LogFlow(("FS32_READ: returns; cbActual=%#x sfi_positionl=%RI64 [direct]\n", cbActual, pSfFsi->sfi_positionl));
|
---|
854 | return NO_ERROR;
|
---|
855 | }
|
---|
856 | Log(("FS32_READ: VbglR0SfWrite(off=%#x,cb=%#x) -> %Rrc [direct]\n", offWrite, cbWrite, vrc));
|
---|
857 | RT_NOREF_PV(fIoFlags);
|
---|
858 | return ERROR_BAD_NET_RESP;
|
---|
859 | }
|
---|
860 |
|
---|
861 |
|
---|
862 | extern "C" APIRET APIENTRY
|
---|
863 | FS32_READFILEATCACHE(PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd, ULONG fIoFlags, LONGLONG off, ULONG pcb, KernCacheList_t **ppCacheList)
|
---|
864 | {
|
---|
865 | /*
|
---|
866 | * Validate input.
|
---|
867 | */
|
---|
868 | AssertReturn(pSfFsd->u32Magic == VBOXSFSYFI_MAGIC, ERROR_SYS_INTERNAL);
|
---|
869 | AssertReturn(pSfFsd->pSelf == pSfFsd, ERROR_SYS_INTERNAL);
|
---|
870 | PVBOXSFFOLDER pFolder = pSfFsd->pFolder;
|
---|
871 | AssertReturn(pFolder != NULL, ERROR_SYS_INTERNAL);
|
---|
872 | Assert(pFolder->u32Magic == VBOXSFFOLDER_MAGIC);
|
---|
873 | Assert(pFolder->cOpenFiles > 0);
|
---|
874 | RT_NOREF(pFolder);
|
---|
875 |
|
---|
876 | /* I think this is used for sendfile(). */
|
---|
877 |
|
---|
878 | NOREF(pSfFsi); NOREF(pSfFsd); NOREF(fIoFlags); NOREF(off); NOREF(pcb); NOREF(ppCacheList);
|
---|
879 | return ERROR_NOT_SUPPORTED;
|
---|
880 | }
|
---|
881 |
|
---|
882 |
|
---|
883 | extern "C" APIRET APIENTRY
|
---|
884 | FS32_RETURNFILECACHE(KernCacheList_t *pCacheList)
|
---|
885 | {
|
---|
886 | NOREF(pCacheList);
|
---|
887 | return ERROR_NOT_SUPPORTED;
|
---|
888 | }
|
---|
889 |
|
---|
890 |
|
---|
891 | /* oddments */
|
---|
892 |
|
---|
893 | DECLASM(APIRET)
|
---|
894 | FS32_CANCELLOCKREQUESTL(PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd, struct filelockl *pLockRange)
|
---|
895 | {
|
---|
896 | /*
|
---|
897 | * Validate input.
|
---|
898 | */
|
---|
899 | AssertReturn(pSfFsd->u32Magic == VBOXSFSYFI_MAGIC, ERROR_SYS_INTERNAL);
|
---|
900 | AssertReturn(pSfFsd->pSelf == pSfFsd, ERROR_SYS_INTERNAL);
|
---|
901 | PVBOXSFFOLDER pFolder = pSfFsd->pFolder;
|
---|
902 | AssertReturn(pFolder != NULL, ERROR_SYS_INTERNAL);
|
---|
903 | Assert(pFolder->u32Magic == VBOXSFFOLDER_MAGIC);
|
---|
904 | Assert(pFolder->cOpenFiles > 0);
|
---|
905 | RT_NOREF(pFolder);
|
---|
906 |
|
---|
907 | NOREF(pSfFsi); NOREF(pSfFsd); NOREF(pLockRange);
|
---|
908 | return ERROR_NOT_SUPPORTED;
|
---|
909 | }
|
---|
910 |
|
---|
911 |
|
---|
912 | DECLASM(APIRET)
|
---|
913 | FS32_CANCELLOCKREQUEST(PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd, struct filelock *pLockRange)
|
---|
914 | {
|
---|
915 | /*
|
---|
916 | * Validate input.
|
---|
917 | */
|
---|
918 | AssertReturn(pSfFsd->u32Magic == VBOXSFSYFI_MAGIC, ERROR_SYS_INTERNAL);
|
---|
919 | AssertReturn(pSfFsd->pSelf == pSfFsd, ERROR_SYS_INTERNAL);
|
---|
920 | PVBOXSFFOLDER pFolder = pSfFsd->pFolder;
|
---|
921 | AssertReturn(pFolder != NULL, ERROR_SYS_INTERNAL);
|
---|
922 | Assert(pFolder->u32Magic == VBOXSFFOLDER_MAGIC);
|
---|
923 | Assert(pFolder->cOpenFiles > 0);
|
---|
924 | RT_NOREF(pFolder);
|
---|
925 |
|
---|
926 | NOREF(pSfFsi); NOREF(pSfFsd); NOREF(pLockRange);
|
---|
927 | return ERROR_NOT_SUPPORTED;
|
---|
928 | }
|
---|
929 |
|
---|
930 |
|
---|
931 | DECLASM(APIRET)
|
---|
932 | FS32_FILELOCKSL(PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd, struct filelockl *pUnLockRange,
|
---|
933 | struct filelockl *pLockRange, ULONG cMsTimeout, ULONG fFlags)
|
---|
934 | {
|
---|
935 | /*
|
---|
936 | * Validate input.
|
---|
937 | */
|
---|
938 | AssertReturn(pSfFsd->u32Magic == VBOXSFSYFI_MAGIC, ERROR_SYS_INTERNAL);
|
---|
939 | AssertReturn(pSfFsd->pSelf == pSfFsd, ERROR_SYS_INTERNAL);
|
---|
940 | PVBOXSFFOLDER pFolder = pSfFsd->pFolder;
|
---|
941 | AssertReturn(pFolder != NULL, ERROR_SYS_INTERNAL);
|
---|
942 | Assert(pFolder->u32Magic == VBOXSFFOLDER_MAGIC);
|
---|
943 | Assert(pFolder->cOpenFiles > 0);
|
---|
944 | RT_NOREF(pFolder);
|
---|
945 |
|
---|
946 | NOREF(pSfFsi); NOREF(pSfFsd); NOREF(pUnLockRange); NOREF(pLockRange); NOREF(cMsTimeout); NOREF(fFlags);
|
---|
947 | return ERROR_NOT_SUPPORTED;
|
---|
948 | }
|
---|
949 |
|
---|
950 |
|
---|
951 | DECLASM(APIRET)
|
---|
952 | FS32_FILELOCKS(PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd, struct filelock *pUnLockRange,
|
---|
953 | struct filelock *pLockRange, ULONG cMsTimeout, ULONG fFlags)
|
---|
954 | {
|
---|
955 | /*
|
---|
956 | * Validate input.
|
---|
957 | */
|
---|
958 | AssertReturn(pSfFsd->u32Magic == VBOXSFSYFI_MAGIC, ERROR_SYS_INTERNAL);
|
---|
959 | AssertReturn(pSfFsd->pSelf == pSfFsd, ERROR_SYS_INTERNAL);
|
---|
960 | PVBOXSFFOLDER pFolder = pSfFsd->pFolder;
|
---|
961 | AssertReturn(pFolder != NULL, ERROR_SYS_INTERNAL);
|
---|
962 | Assert(pFolder->u32Magic == VBOXSFFOLDER_MAGIC);
|
---|
963 | Assert(pFolder->cOpenFiles > 0);
|
---|
964 | RT_NOREF(pFolder);
|
---|
965 |
|
---|
966 | NOREF(pSfFsi); NOREF(pSfFsd); NOREF(pUnLockRange); NOREF(pLockRange); NOREF(cMsTimeout); NOREF(fFlags);
|
---|
967 | return ERROR_NOT_SUPPORTED;
|
---|
968 | }
|
---|
969 |
|
---|
970 |
|
---|
971 | DECLASM(APIRET)
|
---|
972 | FS32_IOCTL(PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd, USHORT uCategory, USHORT uFunction,
|
---|
973 | PVOID pvParm, USHORT cbParm, PUSHORT pcbParmIO,
|
---|
974 | PVOID pvData, USHORT cbData, PUSHORT pcbDataIO)
|
---|
975 | {
|
---|
976 | /*
|
---|
977 | * Validate input.
|
---|
978 | */
|
---|
979 | AssertReturn(pSfFsd->u32Magic == VBOXSFSYFI_MAGIC, ERROR_SYS_INTERNAL);
|
---|
980 | AssertReturn(pSfFsd->pSelf == pSfFsd, ERROR_SYS_INTERNAL);
|
---|
981 | PVBOXSFFOLDER pFolder = pSfFsd->pFolder;
|
---|
982 | AssertReturn(pFolder != NULL, ERROR_SYS_INTERNAL);
|
---|
983 | Assert(pFolder->u32Magic == VBOXSFFOLDER_MAGIC);
|
---|
984 | Assert(pFolder->cOpenFiles > 0);
|
---|
985 | RT_NOREF(pFolder);
|
---|
986 |
|
---|
987 | NOREF(pSfFsi); NOREF(pSfFsd); NOREF(uCategory); NOREF(uFunction); NOREF(pvParm); NOREF(cbParm); NOREF(pcbParmIO);
|
---|
988 | NOREF(pvData); NOREF(cbData); NOREF(pcbDataIO);
|
---|
989 | return ERROR_NOT_SUPPORTED;
|
---|
990 | }
|
---|
991 |
|
---|
992 |
|
---|
993 | DECLASM(APIRET)
|
---|
994 | FS32_FILEIO(PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd, PBYTE pbCmdList, USHORT cbCmdList,
|
---|
995 | PUSHORT poffError, USHORT fIoFlag)
|
---|
996 | {
|
---|
997 | /*
|
---|
998 | * Validate input.
|
---|
999 | */
|
---|
1000 | AssertReturn(pSfFsd->u32Magic == VBOXSFSYFI_MAGIC, ERROR_SYS_INTERNAL);
|
---|
1001 | AssertReturn(pSfFsd->pSelf == pSfFsd, ERROR_SYS_INTERNAL);
|
---|
1002 | PVBOXSFFOLDER pFolder = pSfFsd->pFolder;
|
---|
1003 | AssertReturn(pFolder != NULL, ERROR_SYS_INTERNAL);
|
---|
1004 | Assert(pFolder->u32Magic == VBOXSFFOLDER_MAGIC);
|
---|
1005 | Assert(pFolder->cOpenFiles > 0);
|
---|
1006 | RT_NOREF(pFolder);
|
---|
1007 |
|
---|
1008 | NOREF(pSfFsi); NOREF(pSfFsd); NOREF(pbCmdList); NOREF(cbCmdList); NOREF(poffError); NOREF(fIoFlag);
|
---|
1009 | return ERROR_NOT_SUPPORTED;
|
---|
1010 | }
|
---|
1011 |
|
---|
1012 |
|
---|
1013 | DECLASM(APIRET)
|
---|
1014 | FS32_NMPIPE(PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd, USHORT uOpType, union npoper *pOpRec,
|
---|
1015 | PBYTE pbData, PCSZ pszName)
|
---|
1016 | {
|
---|
1017 | NOREF(pSfFsi); NOREF(pSfFsd); NOREF(uOpType); NOREF(pOpRec); NOREF(pbData); NOREF(pszName);
|
---|
1018 | return ERROR_NOT_SUPPORTED;
|
---|
1019 | }
|
---|
1020 |
|
---|
1021 |
|
---|
1022 | DECLASM(APIRET)
|
---|
1023 | FS32_OPENPAGEFILE(PULONG pfFlags, PULONG pcMaxReq, PCSZ pszName, PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd,
|
---|
1024 | USHORT fOpenMode, USHORT fOpenFlags, USHORT fAttr, ULONG uReserved)
|
---|
1025 | {
|
---|
1026 | NOREF(pfFlags); NOREF(pcMaxReq); NOREF(pszName); NOREF(pSfFsi); NOREF(pSfFsd); NOREF(fOpenMode); NOREF(fOpenFlags);
|
---|
1027 | NOREF(fAttr); NOREF(uReserved);
|
---|
1028 | return ERROR_NOT_SUPPORTED;
|
---|
1029 | }
|
---|
1030 |
|
---|
1031 |
|
---|
1032 | DECLASM(APIRET)
|
---|
1033 | FS32_SETSWAP(PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd)
|
---|
1034 | {
|
---|
1035 | NOREF(pSfFsi); NOREF(pSfFsd);
|
---|
1036 | return ERROR_NOT_SUPPORTED;
|
---|
1037 | }
|
---|
1038 |
|
---|
1039 |
|
---|
1040 | DECLASM(APIRET)
|
---|
1041 | FS32_ALLOCATEPAGESPACE(PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd, ULONG cb, USHORT cbWantContig)
|
---|
1042 | {
|
---|
1043 | NOREF(pSfFsi); NOREF(pSfFsd); NOREF(cb); NOREF(cbWantContig);
|
---|
1044 | return ERROR_NOT_SUPPORTED;
|
---|
1045 | }
|
---|
1046 |
|
---|
1047 |
|
---|
1048 | DECLASM(APIRET)
|
---|
1049 | FS32_DOPAGEIO(PSFFSI pSfFsi, PVBOXSFSYFI pSfFsd, struct PageCmdHeader *pList)
|
---|
1050 | {
|
---|
1051 | NOREF(pSfFsi); NOREF(pSfFsd); NOREF(pList);
|
---|
1052 | return ERROR_NOT_SUPPORTED;
|
---|
1053 | }
|
---|
1054 |
|
---|