1 | /** $Id: VBoxSFFind.cpp 76143 2018-12-10 21:24:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxSF - OS/2 Shared Folders, Find File IFS EPs.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (c) 2007-2018 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 |
|
---|
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 | #include <iprt/path.h>
|
---|
43 | #include <iprt/err.h>
|
---|
44 |
|
---|
45 |
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Checks if the given name is 8-dot-3 compatible.
|
---|
49 | *
|
---|
50 | * @returns true if compatible, false if not.
|
---|
51 | * @param pwszName The name to inspect (UTF-16).
|
---|
52 | * @param cwcName The length of the name.
|
---|
53 | * @param pszTmp Buffer for test conversions.
|
---|
54 | * @param cbTmp The size of the buffer.
|
---|
55 | */
|
---|
56 | static bool vboxSfOs2IsUtf16Name8dot3(PRTUTF16 pwszName, size_t cwcName, char *pszTmp, size_t cbTmp)
|
---|
57 | {
|
---|
58 | /* Reject names that must be too long. */
|
---|
59 | if (cwcName > 8 + 1 + 3)
|
---|
60 | return false;
|
---|
61 |
|
---|
62 | /* First char cannot be a dot, nor can it be an empty string. */
|
---|
63 | if (*pwszName == '.' || !*pwszName)
|
---|
64 | return false;
|
---|
65 |
|
---|
66 | /*
|
---|
67 | * To basic checks on code point level before doing full conversion.
|
---|
68 | */
|
---|
69 | for (unsigned off = 0; ; off++)
|
---|
70 | {
|
---|
71 | RTUTF16 wc = pwszName[off];
|
---|
72 | if (wc == '.')
|
---|
73 | {
|
---|
74 | unsigned const offMax = off + 3;
|
---|
75 | for (++off;; off++)
|
---|
76 | {
|
---|
77 | wc = pwszName[off];
|
---|
78 | if (!wc)
|
---|
79 | break;
|
---|
80 | if (wc == '.')
|
---|
81 | return false;
|
---|
82 | if (off >= offMax)
|
---|
83 | return false;
|
---|
84 | }
|
---|
85 | break;
|
---|
86 | }
|
---|
87 | if (!wc)
|
---|
88 | break;
|
---|
89 | if (off >= 8)
|
---|
90 | return false;
|
---|
91 | }
|
---|
92 |
|
---|
93 | /*
|
---|
94 | * Conver to the native code page.
|
---|
95 | */
|
---|
96 | APIRET rc = KernStrFromUcs(NULL, pszTmp, pwszName, cbTmp, cwcName);
|
---|
97 | if (rc != NO_ERROR)
|
---|
98 | {
|
---|
99 | LogRel(("vboxSfOs2IsUtf8Name8dot3: KernStrFromUcs failed: %d\n", rc));
|
---|
100 | return false;
|
---|
101 | }
|
---|
102 |
|
---|
103 | /*
|
---|
104 | * Redo the check.
|
---|
105 | * Note! This could be bogus if a DBCS leadin sequence collides with '.'.
|
---|
106 | */
|
---|
107 | for (unsigned cch = 0; ; cch++)
|
---|
108 | {
|
---|
109 | char ch = *pszTmp++;
|
---|
110 | if (ch == '.')
|
---|
111 | break;
|
---|
112 | if (ch == '\0')
|
---|
113 | return true;
|
---|
114 | if (cch >= 8)
|
---|
115 | return false;
|
---|
116 | }
|
---|
117 | for (unsigned cch = 0; ; cch++)
|
---|
118 | {
|
---|
119 | char ch = *pszTmp++;
|
---|
120 | if (ch == '\0')
|
---|
121 | return true;
|
---|
122 | if (ch != '.')
|
---|
123 | return false;
|
---|
124 | if (cch >= 3)
|
---|
125 | return false;
|
---|
126 | }
|
---|
127 | }
|
---|
128 |
|
---|
129 |
|
---|
130 | /**
|
---|
131 | * @returns Updated pbDst on success, NULL on failure.
|
---|
132 | */
|
---|
133 | static uint8_t *vboxSfOs2CopyUtf16Name(uint8_t *pbDst, PRTUTF16 pwszSrc, size_t cwcSrc)
|
---|
134 | {
|
---|
135 | char *pszDst = (char *)pbDst + 1;
|
---|
136 | APIRET rc = KernStrFromUcs(NULL, pszDst, pwszSrc, CCHMAXPATHCOMP, cwcSrc);
|
---|
137 | if (rc == NO_ERROR)
|
---|
138 | {
|
---|
139 | size_t cchDst = strlen(pszDst);
|
---|
140 | *pbDst++ = (uint8_t)cchDst;
|
---|
141 | pbDst += cchDst;
|
---|
142 | *pbDst++ = '\0';
|
---|
143 | return pbDst;
|
---|
144 | }
|
---|
145 | LogRel(("vboxSfOs2CopyUtf8Name: KernStrFromUcs failed: %d\n", rc));
|
---|
146 | return NULL;
|
---|
147 | }
|
---|
148 |
|
---|
149 |
|
---|
150 | /**
|
---|
151 | * @returns Updated pbDst on success, NULL on failure.
|
---|
152 | */
|
---|
153 | static uint8_t *vboxSfOs2CopyUtf16NameAndUpperCase(uint8_t *pbDst, PRTUTF16 pwszSrc, size_t cwcSrc)
|
---|
154 | {
|
---|
155 | char *pszDst = (char *)(pbDst + 1);
|
---|
156 | APIRET rc = KernStrFromUcs(NULL, pszDst, RTUtf16ToUpper(pwszSrc), CCHMAXPATHCOMP, cwcSrc);
|
---|
157 | if (rc == NO_ERROR)
|
---|
158 | {
|
---|
159 | size_t cchDst = strlen(pszDst);
|
---|
160 | *pbDst++ = (uint8_t)cchDst;
|
---|
161 | pbDst += cchDst;
|
---|
162 | *pbDst++ = '\0';
|
---|
163 | return pbDst;
|
---|
164 | }
|
---|
165 | LogRel(("vboxSfOs2CopyUtf16NameAndUpperCase: KernStrFromUcs failed: %#x\n", rc));
|
---|
166 | return NULL;
|
---|
167 | }
|
---|
168 |
|
---|
169 |
|
---|
170 |
|
---|
171 | /**
|
---|
172 | * Worker for FS32_FINDFIRST, FS32_FINDNEXT and FS32_FINDFROMNAME.
|
---|
173 | *
|
---|
174 | * @returns OS/2 status code.
|
---|
175 | * @param pFolder The folder we're working on.
|
---|
176 | * @param pFsFsd The search handle data.
|
---|
177 | * @param pDataBuf The search data buffer (some handle data there too).
|
---|
178 | * @param uLevel The info level to return.
|
---|
179 | * @param fFlags Position flag.
|
---|
180 | * @param pbData The output buffer.
|
---|
181 | * @param cbData The size of the output buffer.
|
---|
182 | * @param cMaxMatches The maximum number of matches to return.
|
---|
183 | * @param pcMatches Where to set the number of returned matches.
|
---|
184 | */
|
---|
185 | static APIRET vboxSfOs2ReadDirEntries(PVBOXSFFOLDER pFolder, PVBOXSFFS pFsFsd, PVBOXSFFSBUF pDataBuf, ULONG uLevel, ULONG fFlags,
|
---|
186 | PBYTE pbData, ULONG cbData, USHORT cMaxMatches, PUSHORT pcMatches)
|
---|
187 | {
|
---|
188 | APIRET rc = NO_ERROR;
|
---|
189 |
|
---|
190 | /*
|
---|
191 | * If we're doing EAs, the buffer starts with an EAOP structure.
|
---|
192 | */
|
---|
193 | EAOP EaOp;
|
---|
194 | PEAOP pEaOpUser = NULL; /* Shut up gcc */
|
---|
195 | switch (uLevel)
|
---|
196 | {
|
---|
197 | case FI_LVL_EAS_FROM_LIST:
|
---|
198 | case FI_LVL_EAS_FROM_LIST_64:
|
---|
199 | case FI_LVL_EAS_FULL:
|
---|
200 | case FI_LVL_EAS_FULL_5:
|
---|
201 | case FI_LVL_EAS_FULL_8:
|
---|
202 | if (cbData >= sizeof(EaOp))
|
---|
203 | {
|
---|
204 | rc = KernCopyIn(&EaOp, pbData, sizeof(EaOp));
|
---|
205 | if (rc == NO_ERROR)
|
---|
206 | {
|
---|
207 | EaOp.fpGEAList = (PGEALIST)KernSelToFlat((uintptr_t)EaOp.fpGEAList);
|
---|
208 | EaOp.fpFEAList = NULL;
|
---|
209 |
|
---|
210 | pEaOpUser = (PEAOP)pbData;
|
---|
211 | pbData += sizeof(*pEaOpUser);
|
---|
212 | cbData -= sizeof(*pEaOpUser);
|
---|
213 | break;
|
---|
214 | }
|
---|
215 | }
|
---|
216 | else
|
---|
217 | rc = ERROR_BUFFER_OVERFLOW;
|
---|
218 | Log(("vboxSfOs2ReadDirEntries: Failed to read EAOP: %u\n", rc));
|
---|
219 | return rc;
|
---|
220 | }
|
---|
221 |
|
---|
222 | /*
|
---|
223 | * Do the reading.
|
---|
224 | */
|
---|
225 | USHORT cMatches;
|
---|
226 | for (cMatches = 0; cMatches < cMaxMatches;)
|
---|
227 | {
|
---|
228 | /*
|
---|
229 | * Do we need to fetch more directory entries?
|
---|
230 | */
|
---|
231 | PSHFLDIRINFO pEntry = pDataBuf->pEntry;
|
---|
232 | if ( pDataBuf->cEntriesLeft == 0
|
---|
233 | || pEntry == NULL /* paranoia */)
|
---|
234 | {
|
---|
235 | pDataBuf->pEntry = pEntry = (PSHFLDIRINFO)(pDataBuf + 1);
|
---|
236 | pDataBuf->cbValid = pDataBuf->cbBuf - sizeof(*pDataBuf);
|
---|
237 | int vrc = VbglR0SfDirInfo(&g_SfClient, &pFolder->hHostFolder, pFsFsd->hHostDir, pDataBuf->pFilter,
|
---|
238 | cMaxMatches == 1 ? SHFL_LIST_RETURN_ONE : 0, 0 /*index*/, &pDataBuf->cbValid,
|
---|
239 | pEntry, &pDataBuf->cEntriesLeft);
|
---|
240 | if (RT_SUCCESS(vrc))
|
---|
241 | {
|
---|
242 | AssertReturn(pDataBuf->cbValid >= RT_UOFFSETOF(SHFLDIRINFO, name.String), ERROR_SYS_INTERNAL);
|
---|
243 | AssertReturn(pDataBuf->cbValid >= RT_UOFFSETOF(SHFLDIRINFO, name.String) + pEntry->name.u16Size, ERROR_SYS_INTERNAL);
|
---|
244 | Log4(("vboxSfOs2ReadDirEntries: VbglR0SfDirInfo returned %#x matches in %#x bytes\n", pDataBuf->cEntriesLeft, pDataBuf->cbValid));
|
---|
245 | }
|
---|
246 | else
|
---|
247 | {
|
---|
248 | if (vrc == VERR_NO_MORE_FILES)
|
---|
249 | Log(("vboxSfOs2ReadDirEntries: VbglR0SfDirInfo failed %Rrc (%d,%d)\n", vrc, pDataBuf->cEntriesLeft, pDataBuf->cbValid));
|
---|
250 | else
|
---|
251 | Log4(("vboxSfOs2ReadDirEntries: VbglR0SfDirInfo returned VERR_NO_MORE_FILES (%d,%d)\n", pDataBuf->cEntriesLeft, pDataBuf->cbValid));
|
---|
252 | pDataBuf->pEntry = NULL;
|
---|
253 | pDataBuf->cEntriesLeft = 0;
|
---|
254 | if (cMatches == 0)
|
---|
255 | {
|
---|
256 | if (vrc == VERR_NO_MORE_FILES)
|
---|
257 | rc = ERROR_NO_MORE_FILES;
|
---|
258 | else
|
---|
259 | rc = vboxSfOs2ConvertStatusToOs2(vrc, ERROR_GEN_FAILURE);
|
---|
260 | }
|
---|
261 | break;
|
---|
262 | }
|
---|
263 | }
|
---|
264 |
|
---|
265 | /*
|
---|
266 | * Do matching and stuff the return buffer.
|
---|
267 | */
|
---|
268 | if ( !((pEntry->Info.Attr.fMode >> RTFS_DOS_SHIFT) & pDataBuf->fExcludedAttribs)
|
---|
269 | && ((pEntry->Info.Attr.fMode >> RTFS_DOS_SHIFT) & pDataBuf->fMustHaveAttribs) == pDataBuf->fMustHaveAttribs
|
---|
270 | && ( pDataBuf->fLongFilenames
|
---|
271 | || pEntry->cucShortName
|
---|
272 | || vboxSfOs2IsUtf16Name8dot3(pEntry->name.String.utf16, pEntry->name.u16Length / sizeof(RTUTF16),
|
---|
273 | (char *)pDataBuf->abStaging, sizeof(pDataBuf->abStaging))))
|
---|
274 | {
|
---|
275 | /*
|
---|
276 | * We stages all but FEAs (level 3, 4, 13 and 14).
|
---|
277 | */
|
---|
278 | PBYTE const pbUserBufStart = pbData; /* In case we need to skip a bad name. */
|
---|
279 | uint8_t *pbToCopy = pDataBuf->abStaging;
|
---|
280 | uint8_t *pbDst = pbToCopy;
|
---|
281 |
|
---|
282 | /* Position (originally used for FS32_FINDFROMNAME 'position', but since reused
|
---|
283 | for FILEFINDBUF3::oNextEntryOffset and FILEFINDBUF4::oNextEntryOffset): */
|
---|
284 | if (fFlags & FF_GETPOS)
|
---|
285 | {
|
---|
286 | *(uint32_t *)pbDst = pFsFsd->offLastFile + 1;
|
---|
287 | pbDst += sizeof(uint32_t);
|
---|
288 | }
|
---|
289 |
|
---|
290 | /* Dates: Creation, Access, Write */
|
---|
291 | vboxSfOs2DateTimeFromTimeSpec((FDATE *)pbDst, (FTIME *)(pbDst + 2), pEntry->Info.BirthTime, pDataBuf->cMinLocalTimeDelta);
|
---|
292 | pbDst += sizeof(FDATE) + sizeof(FTIME);
|
---|
293 | vboxSfOs2DateTimeFromTimeSpec((FDATE *)pbDst, (FTIME *)(pbDst + 2), pEntry->Info.AccessTime, pDataBuf->cMinLocalTimeDelta);
|
---|
294 | pbDst += sizeof(FDATE) + sizeof(FTIME);
|
---|
295 | vboxSfOs2DateTimeFromTimeSpec((FDATE *)pbDst, (FTIME *)(pbDst + 2), pEntry->Info.ModificationTime, pDataBuf->cMinLocalTimeDelta);
|
---|
296 | pbDst += sizeof(FDATE) + sizeof(FTIME);
|
---|
297 |
|
---|
298 | /* File size, allocation size, attributes: */
|
---|
299 | if (uLevel >= FI_LVL_STANDARD_64)
|
---|
300 | {
|
---|
301 | *(uint64_t *)pbDst = pEntry->Info.cbObject;
|
---|
302 | pbDst += sizeof(uint64_t);
|
---|
303 | *(uint64_t *)pbDst = pEntry->Info.cbAllocated;
|
---|
304 | pbDst += sizeof(uint64_t);
|
---|
305 | *(uint32_t *)pbDst = (pEntry->Info.Attr.fMode & RTFS_DOS_MASK_OS2) >> RTFS_DOS_SHIFT;
|
---|
306 | pbDst += sizeof(uint32_t);
|
---|
307 | }
|
---|
308 | else
|
---|
309 | {
|
---|
310 | *(uint32_t *)pbDst = (uint32_t)RT_MIN(pEntry->Info.cbObject, _2G - 1);
|
---|
311 | pbDst += sizeof(uint32_t);
|
---|
312 | *(uint32_t *)pbDst = (uint32_t)RT_MIN(pEntry->Info.cbAllocated, _2G - 1);
|
---|
313 | pbDst += sizeof(uint32_t);
|
---|
314 | *(uint16_t *)pbDst = (uint16_t)((pEntry->Info.Attr.fMode & RTFS_DOS_MASK_OS2) >> RTFS_DOS_SHIFT);
|
---|
315 | pbDst += sizeof(uint16_t); /* (Curious: Who is expanding this to 32-bits for 32-bit callers? */
|
---|
316 | }
|
---|
317 |
|
---|
318 | /* Extra EA related fields: */
|
---|
319 | if ( uLevel == FI_LVL_STANDARD
|
---|
320 | || uLevel == FI_LVL_STANDARD_64)
|
---|
321 | { /* nothing */ }
|
---|
322 | else if ( uLevel == FI_LVL_STANDARD_EASIZE
|
---|
323 | || uLevel == FI_LVL_STANDARD_EASIZE_64)
|
---|
324 | {
|
---|
325 | /* EA size: */
|
---|
326 | *(uint32_t *)pbDst = 0;
|
---|
327 | pbDst += sizeof(uint32_t);
|
---|
328 | }
|
---|
329 | else
|
---|
330 | {
|
---|
331 | /* Empty FEALIST - flush pending data first: */
|
---|
332 | uint32_t cbToCopy = pbDst - pbToCopy;
|
---|
333 | if (cbToCopy < cbData)
|
---|
334 | {
|
---|
335 | rc = KernCopyOut(pbData, pbToCopy, cbToCopy);
|
---|
336 | if (rc == NO_ERROR)
|
---|
337 | {
|
---|
338 | pbData += cbToCopy;
|
---|
339 | cbData -= cbToCopy;
|
---|
340 | pbDst = pbToCopy;
|
---|
341 |
|
---|
342 | uint32_t cbWritten = 0;
|
---|
343 | EaOp.fpFEAList = (PFEALIST)pbData;
|
---|
344 | rc = vboxSfOs2MakeEmptyEaListEx(&EaOp, uLevel, &cbWritten, &pEaOpUser->oError);
|
---|
345 | if (rc == NO_ERROR)
|
---|
346 | {
|
---|
347 | cbData -= cbWritten;
|
---|
348 | pbData += cbWritten;
|
---|
349 | }
|
---|
350 | }
|
---|
351 | }
|
---|
352 | else
|
---|
353 | rc = ERROR_BUFFER_OVERFLOW;
|
---|
354 | if (rc != NO_ERROR)
|
---|
355 | break;
|
---|
356 | }
|
---|
357 |
|
---|
358 | /* The length prefixed filename. */
|
---|
359 | if (pDataBuf->fLongFilenames)
|
---|
360 | pbDst = vboxSfOs2CopyUtf16Name(pbDst, pEntry->name.String.utf16, pEntry->name.u16Length / sizeof(RTUTF16));
|
---|
361 | else if (pEntry->cucShortName == 0)
|
---|
362 | pbDst = vboxSfOs2CopyUtf16NameAndUpperCase(pbDst, pEntry->name.String.utf16, pEntry->name.u16Length / sizeof(RTUTF16));
|
---|
363 | else
|
---|
364 | pbDst = vboxSfOs2CopyUtf16NameAndUpperCase(pbDst, pEntry->uszShortName, pEntry->cucShortName);
|
---|
365 | if (pbDst)
|
---|
366 | {
|
---|
367 | /*
|
---|
368 | * Copy out the staged data.
|
---|
369 | */
|
---|
370 | uint32_t cbToCopy = pbDst - pbToCopy;
|
---|
371 | if (cbToCopy <= cbData)
|
---|
372 | {
|
---|
373 | rc = KernCopyOut(pbData, pbToCopy, cbToCopy);
|
---|
374 | if (rc == NO_ERROR)
|
---|
375 | {
|
---|
376 | Log4(("vboxSfOs2ReadDirEntries: match #%u LB %#x: '%s'\n", cMatches, cbToCopy, pEntry->name.String.utf8));
|
---|
377 | Log4(("%.*Rhxd\n", cbToCopy, pbToCopy));
|
---|
378 |
|
---|
379 | pbData += cbToCopy;
|
---|
380 | cbData -= cbToCopy;
|
---|
381 | pbDst = pbToCopy;
|
---|
382 |
|
---|
383 | cMatches++;
|
---|
384 | pFsFsd->offLastFile++;
|
---|
385 | }
|
---|
386 | else
|
---|
387 | break;
|
---|
388 | }
|
---|
389 | else
|
---|
390 | {
|
---|
391 | rc = ERROR_BUFFER_OVERFLOW;
|
---|
392 | break;
|
---|
393 | }
|
---|
394 | }
|
---|
395 | else
|
---|
396 | {
|
---|
397 | /* Name conversion issue, just skip the entry. */
|
---|
398 | Log3(("vboxSfOs2ReadDirEntries: Skipping '%s' due to name conversion issue.\n", pEntry->name.String.utf8));
|
---|
399 | cbData -= pbUserBufStart - pbData;
|
---|
400 | pbData = pbUserBufStart;
|
---|
401 | }
|
---|
402 | }
|
---|
403 | else
|
---|
404 | Log3(("vboxSfOs2ReadDirEntries: fMode=%#x filter out by %#x/%#x; '%s'\n",
|
---|
405 | pEntry->Info.Attr.fMode, pDataBuf->fMustHaveAttribs, pDataBuf->fExcludedAttribs, pEntry->name.String.utf8));
|
---|
406 |
|
---|
407 | /*
|
---|
408 | * Advance to the next directory entry from the host.
|
---|
409 | */
|
---|
410 | if (pDataBuf->cEntriesLeft-- > 1)
|
---|
411 | {
|
---|
412 | pDataBuf->pEntry = pEntry = (PSHFLDIRINFO)&pEntry->name.String.utf8[pEntry->name.u16Size];
|
---|
413 | uintptr_t offEntry = (uintptr_t)pEntry - (uintptr_t)(pDataBuf + 1);
|
---|
414 | AssertMsgReturn(offEntry + RT_UOFFSETOF(SHFLDIRINFO, name.String) <= pDataBuf->cbValid,
|
---|
415 | ("offEntry=%#x cbValid=%#x\n", offEntry, pDataBuf->cbValid), ERROR_SYS_INTERNAL);
|
---|
416 | AssertMsgReturn(offEntry + RT_UOFFSETOF(SHFLDIRINFO, name.String) + pEntry->name.u16Size <= pDataBuf->cbValid,
|
---|
417 | ("offEntry=%#x cbValid=%#x\n", offEntry, pDataBuf->cbValid), ERROR_SYS_INTERNAL);
|
---|
418 | }
|
---|
419 | else
|
---|
420 | pDataBuf->pEntry = NULL;
|
---|
421 | }
|
---|
422 |
|
---|
423 | *pcMatches = cMatches;
|
---|
424 |
|
---|
425 | /* Ignore buffer overflows if we've got matches to return. */
|
---|
426 | if (rc == ERROR_BUFFER_OVERFLOW && cMatches > 0)
|
---|
427 | rc = NO_ERROR;
|
---|
428 | return rc;
|
---|
429 | }
|
---|
430 |
|
---|
431 |
|
---|
432 | DECLASM(APIRET)
|
---|
433 | FS32_FINDFIRST(PCDFSI pCdFsi, PVBOXSFCD pCdFsd, PCSZ pszPath, LONG offCurDirEnd, ULONG fAttribs,
|
---|
434 | PFSFSI pFsFsi, PVBOXSFFS pFsFsd, PBYTE pbData, ULONG cbData, PUSHORT pcMatches, ULONG uLevel, ULONG fFlags)
|
---|
435 | {
|
---|
436 | LogFlow(("pCdFsi=%p pCdFsd=%p pszPath=%p:{%s} offCurDirEnd=%d fAttribs=%#x pFsFsi=%p pFsFsd=%p pbData=%p cbData=%#x pcMatches=%p:{%#x} uLevel=%#x fFlags=%#x\n",
|
---|
437 | pCdFsi, pCdFsd, pszPath, pszPath, offCurDirEnd, fAttribs, pFsFsi, pFsFsd, pbData, cbData, pcMatches, *pcMatches, uLevel, fFlags));
|
---|
438 | USHORT const cMaxMatches = *pcMatches;
|
---|
439 | *pcMatches = 0;
|
---|
440 |
|
---|
441 | /*
|
---|
442 | * Input validation.
|
---|
443 | */
|
---|
444 | switch (uLevel)
|
---|
445 | {
|
---|
446 | case FI_LVL_STANDARD:
|
---|
447 | case FI_LVL_STANDARD_64:
|
---|
448 | case FI_LVL_STANDARD_EASIZE:
|
---|
449 | case FI_LVL_STANDARD_EASIZE_64:
|
---|
450 | break;
|
---|
451 |
|
---|
452 | case FI_LVL_EAS_FROM_LIST:
|
---|
453 | case FI_LVL_EAS_FROM_LIST_64:
|
---|
454 | if (cbData < sizeof(EAOP))
|
---|
455 | {
|
---|
456 | Log(("FS32_FINDFIRST: Buffer smaller than EAOP: %#x\n", cbData));
|
---|
457 | return ERROR_BUFFER_OVERFLOW;
|
---|
458 | }
|
---|
459 | break;
|
---|
460 |
|
---|
461 | default:
|
---|
462 | LogRel(("FS32_FINDFIRST: Unsupported info level %u!\n", uLevel));
|
---|
463 | return ERROR_INVALID_LEVEL;
|
---|
464 | }
|
---|
465 |
|
---|
466 | /*
|
---|
467 | * Resolve path to a folder and folder relative path.
|
---|
468 | */
|
---|
469 | RT_NOREF(pCdFsi);
|
---|
470 | PVBOXSFFOLDER pFolder;
|
---|
471 | VBOXSFCREATEREQ *pReq;
|
---|
472 | APIRET rc = vboxSfOs2ResolvePathEx(pszPath, pCdFsd, offCurDirEnd, RT_UOFFSETOF(VBOXSFCREATEREQ, StrPath),
|
---|
473 | &pFolder, (void **)&pReq);
|
---|
474 | LogFlow(("FS32_FINDFIRST: vboxSfOs2ResolvePathEx: -> %u pReq=%p\n", rc, pReq));
|
---|
475 | if (rc == NO_ERROR)
|
---|
476 | {
|
---|
477 | PSHFLSTRING pStrFolderPath = &pReq->StrPath;
|
---|
478 |
|
---|
479 | /*
|
---|
480 | * Look for a wildcard filter at the end of the path, saving it all for
|
---|
481 | * later in NT filter speak if present.
|
---|
482 | */
|
---|
483 | PSHFLSTRING pFilter = NULL;
|
---|
484 | PRTUTF16 pwszFilter = RTPathFilenameUtf16(pStrFolderPath->String.utf16);
|
---|
485 | if ( pwszFilter
|
---|
486 | && ( RTUtf16Chr(pwszFilter, '*') != NULL
|
---|
487 | || RTUtf16Chr(pwszFilter, '?') != NULL))
|
---|
488 | {
|
---|
489 | if (RTUtf16CmpAscii(pwszFilter, "*.*") == 0)
|
---|
490 | {
|
---|
491 | /* All files, no filtering needed. Just drop the filter expression from the directory path. */
|
---|
492 | *pwszFilter = '\0';
|
---|
493 | pStrFolderPath->u16Length = (uint16_t)((uint8_t *)pwszFilter - &pStrFolderPath->String.utf8[0]);
|
---|
494 | }
|
---|
495 | else
|
---|
496 | {
|
---|
497 | /* Duplicate the whole path. */
|
---|
498 | pFilter = vboxSfOs2StrDup(pStrFolderPath);
|
---|
499 | if (pFilter)
|
---|
500 | {
|
---|
501 | /* Drop filter from directory path. */
|
---|
502 | *pwszFilter = '\0';
|
---|
503 | pStrFolderPath->u16Length = (uint16_t)((uint8_t *)pwszFilter - &pStrFolderPath->String.utf8[0]);
|
---|
504 |
|
---|
505 | /* Convert filter part of the copy to NT speak. */
|
---|
506 | pwszFilter = (PRTUTF16)&pFilter->String.utf8[(uint8_t *)pwszFilter - &pStrFolderPath->String.utf8[0]];
|
---|
507 | for (;;)
|
---|
508 | {
|
---|
509 | RTUTF16 wc = *pwszFilter;
|
---|
510 | if (wc == '?')
|
---|
511 | *pwszFilter = '>'; /* The DOS question mark: Matches one char, but dots and end-of-name eats them. */
|
---|
512 | else if (wc == '.')
|
---|
513 | {
|
---|
514 | RTUTF16 wc2 = pwszFilter[1];
|
---|
515 | if (wc2 == '*' || wc2 == '?')
|
---|
516 | *pwszFilter = '"'; /* The DOS dot: Matches a dot or end-of-name. */
|
---|
517 | }
|
---|
518 | else if (wc == '*')
|
---|
519 | {
|
---|
520 | if (pwszFilter[1] == '.')
|
---|
521 | *pwszFilter = '<'; /* The DOS star: Matches zero or more chars except the DOS dot.*/
|
---|
522 | }
|
---|
523 | else if (wc == '\0')
|
---|
524 | break;
|
---|
525 | pwszFilter++;
|
---|
526 | }
|
---|
527 | }
|
---|
528 | else
|
---|
529 | rc = ERROR_NOT_ENOUGH_MEMORY;
|
---|
530 | }
|
---|
531 | }
|
---|
532 | /*
|
---|
533 | * When no wildcard is specified, we're supposed to return a single entry
|
---|
534 | * with the name in the final component. Exception is the root, where we
|
---|
535 | * always list the whole thing.
|
---|
536 | *
|
---|
537 | * Not sure if we'll ever see a trailing slash here (pszFilter == NULL),
|
---|
538 | * but if we do we should accept it only for the root.
|
---|
539 | */
|
---|
540 | else if (pwszFilter)
|
---|
541 | {
|
---|
542 | /* Copy the whole path for filtering. */
|
---|
543 | pFilter = vboxSfOs2StrDup(pStrFolderPath);
|
---|
544 | if (pFilter)
|
---|
545 | {
|
---|
546 | /* Strip the filename off the one we're opening. */
|
---|
547 | pStrFolderPath->u16Length = (uint16_t)((uintptr_t)pwszFilter - (uintptr_t)pStrFolderPath->String.utf16);
|
---|
548 | pStrFolderPath->u16Size = pStrFolderPath->u16Length + (uint16_t)sizeof(RTUTF16);
|
---|
549 | pStrFolderPath->String.utf16[pStrFolderPath->u16Length / sizeof(RTUTF16)] = '\0';
|
---|
550 | }
|
---|
551 | else
|
---|
552 | rc = ERROR_NOT_ENOUGH_MEMORY;
|
---|
553 | }
|
---|
554 | else if (!pwszFilter && pStrFolderPath->u16Length > 1)
|
---|
555 | {
|
---|
556 | LogFlow(("FS32_FINDFIRST: Trailing slash (%ls)\n", pStrFolderPath->String.utf16));
|
---|
557 | rc = ERROR_PATH_NOT_FOUND;
|
---|
558 | }
|
---|
559 | else
|
---|
560 | LogFlow(("FS32_FINDFIRST: Root dir (%ls)\n", pStrFolderPath->String.utf16));
|
---|
561 |
|
---|
562 | /*
|
---|
563 | * Make sure we've got a buffer for keeping unused search results.
|
---|
564 | */
|
---|
565 | /** @todo use phys heap for this too? */
|
---|
566 | PVBOXSFFSBUF pDataBuf = NULL;
|
---|
567 | if (rc == NO_ERROR)
|
---|
568 | {
|
---|
569 | pDataBuf = (PVBOXSFFSBUF)RTMemAlloc(cMaxMatches == 1 ? VBOXSFFSBUF_MIN_SIZE : _16K - ALLOC_HDR_SIZE);
|
---|
570 | if (pDataBuf)
|
---|
571 | pDataBuf->cbBuf = cMaxMatches == 1 ? VBOXSFFSBUF_MIN_SIZE : _16K - ALLOC_HDR_SIZE;
|
---|
572 | else
|
---|
573 | {
|
---|
574 | pDataBuf = (PVBOXSFFSBUF)RTMemAlloc(VBOXSFFSBUF_MIN_SIZE);
|
---|
575 | if (pDataBuf)
|
---|
576 | pDataBuf->cbBuf = VBOXSFFSBUF_MIN_SIZE;
|
---|
577 | else
|
---|
578 | rc = ERROR_NOT_ENOUGH_MEMORY;
|
---|
579 | }
|
---|
580 | }
|
---|
581 | if (rc == NO_ERROR)
|
---|
582 | {
|
---|
583 | /*
|
---|
584 | * Now, try open the directory for reading.
|
---|
585 | */
|
---|
586 | pReq->CreateParms.CreateFlags = SHFL_CF_DIRECTORY | SHFL_CF_ACT_FAIL_IF_NEW | SHFL_CF_ACT_OPEN_IF_EXISTS
|
---|
587 | | SHFL_CF_ACCESS_READ | SHFL_CF_ACCESS_ATTR_READ | SHFL_CF_ACCESS_DENYNONE;
|
---|
588 |
|
---|
589 | int vrc = vboxSfOs2HostReqCreate(pFolder, pReq);
|
---|
590 | LogFlow(("FS32_FINDFIRST: vboxSfOs2HostReqCreate(%ls) -> %Rrc Result=%d fMode=%#x hHandle=%#RX64\n",
|
---|
591 | pStrFolderPath->String.utf16, vrc, pReq->CreateParms.Result, pReq->CreateParms.Info.Attr.fMode,
|
---|
592 | pReq->CreateParms.Handle));
|
---|
593 | if (RT_SUCCESS(vrc))
|
---|
594 | {
|
---|
595 | switch (pReq->CreateParms.Result)
|
---|
596 | {
|
---|
597 | case SHFL_FILE_EXISTS:
|
---|
598 | if (pReq->CreateParms.Handle != SHFL_HANDLE_NIL)
|
---|
599 | {
|
---|
600 | /*
|
---|
601 | * Initialize the structures.
|
---|
602 | */
|
---|
603 | pFsFsd->hHostDir = pReq->CreateParms.Handle;
|
---|
604 | pFsFsd->u32Magic = VBOXSFFS_MAGIC;
|
---|
605 | pFsFsd->pFolder = pFolder;
|
---|
606 | pFsFsd->pBuf = pDataBuf;
|
---|
607 | pFsFsd->offLastFile = 0;
|
---|
608 | pDataBuf->u32Magic = VBOXSFFSBUF_MAGIC;
|
---|
609 | pDataBuf->cbValid = 0;
|
---|
610 | pDataBuf->cEntriesLeft = 0;
|
---|
611 | pDataBuf->pEntry = NULL;
|
---|
612 | pDataBuf->pFilter = pFilter;
|
---|
613 | pDataBuf->fMustHaveAttribs = (uint8_t)((fAttribs >> 8) & (RTFS_DOS_MASK_OS2 >> RTFS_DOS_SHIFT));
|
---|
614 | pDataBuf->fExcludedAttribs = (uint8_t)(~fAttribs
|
---|
615 | & ( (RTFS_DOS_MASK_OS2 & ~(RTFS_DOS_ARCHIVED | RTFS_DOS_READONLY)
|
---|
616 | >> RTFS_DOS_SHIFT)));
|
---|
617 | pDataBuf->fLongFilenames = RT_BOOL(fAttribs & FF_ATTR_LONG_FILENAME);
|
---|
618 | pDataBuf->cMinLocalTimeDelta = vboxSfOs2GetLocalTimeDelta();
|
---|
619 |
|
---|
620 | rc = vboxSfOs2ReadDirEntries(pFolder, pFsFsd, pDataBuf, uLevel, fFlags,
|
---|
621 | pbData, cbData, cMaxMatches ? cMaxMatches : UINT16_MAX, pcMatches);
|
---|
622 | if (rc == NO_ERROR)
|
---|
623 | {
|
---|
624 | uint32_t cRefs = ASMAtomicIncU32(&pFolder->cOpenSearches);
|
---|
625 | Assert(cRefs < _4K); RT_NOREF(cRefs);
|
---|
626 |
|
---|
627 | /* We keep these on success: */
|
---|
628 | if (pFilter == pStrFolderPath)
|
---|
629 | pStrFolderPath = NULL;
|
---|
630 | pFilter = NULL;
|
---|
631 | pDataBuf = NULL;
|
---|
632 | pFolder = NULL;
|
---|
633 | }
|
---|
634 | else
|
---|
635 | {
|
---|
636 | AssertCompile(sizeof(VBOXSFCLOSEREQ) < sizeof(*pReq));
|
---|
637 | vrc = vboxSfOs2HostReqClose(pFolder, (VBOXSFCLOSEREQ *)pReq, pFsFsd->hHostDir);
|
---|
638 | AssertRC(vrc);
|
---|
639 | pFsFsd->u32Magic = ~VBOXSFFS_MAGIC;
|
---|
640 | pDataBuf->u32Magic = ~VBOXSFFSBUF_MAGIC;
|
---|
641 | pFsFsd->pFolder = NULL;
|
---|
642 | pFsFsd->hHostDir = NULL;
|
---|
643 | }
|
---|
644 | }
|
---|
645 | else
|
---|
646 | {
|
---|
647 | LogFlow(("FS32_FINDFIRST: vboxSfOs2HostReqCreate returns NIL handle for '%ls'\n",
|
---|
648 | pStrFolderPath->String.utf16));
|
---|
649 | rc = ERROR_PATH_NOT_FOUND;
|
---|
650 | }
|
---|
651 | break;
|
---|
652 |
|
---|
653 | case SHFL_PATH_NOT_FOUND:
|
---|
654 | rc = ERROR_PATH_NOT_FOUND;
|
---|
655 | break;
|
---|
656 |
|
---|
657 | default:
|
---|
658 | case SHFL_FILE_NOT_FOUND:
|
---|
659 | rc = ERROR_FILE_NOT_FOUND;
|
---|
660 | break;
|
---|
661 | }
|
---|
662 | }
|
---|
663 | else
|
---|
664 | rc = vboxSfOs2ConvertStatusToOs2(vrc, ERROR_GEN_FAILURE);
|
---|
665 | }
|
---|
666 |
|
---|
667 | RTMemFree(pDataBuf);
|
---|
668 | vboxSfOs2StrFree(pFilter);
|
---|
669 | VbglR0PhysHeapFree(pReq);
|
---|
670 | vboxSfOs2ReleaseFolder(pFolder);
|
---|
671 | }
|
---|
672 |
|
---|
673 | RT_NOREF_PV(pFsFsi);
|
---|
674 | LogFlow(("FS32_FINDFIRST: returns %u\n", rc));
|
---|
675 | return rc;
|
---|
676 | }
|
---|
677 |
|
---|
678 |
|
---|
679 | DECLASM(APIRET)
|
---|
680 | FS32_FINDFROMNAME(PFSFSI pFsFsi, PVBOXSFFS pFsFsd, PBYTE pbData, ULONG cbData, PUSHORT pcMatches,
|
---|
681 | ULONG uLevel, ULONG uPosition, PCSZ pszName, ULONG fFlags)
|
---|
682 | {
|
---|
683 | LogFlow(("FS32_FINDFROMNAME: pFsFsi=%p pFsFsd=%p pbData=%p cbData=%#x pcMatches=%p:{%#x} uLevel=%#x uPosition=%#x pszName=%p:{%s} fFlags=%#x\n",
|
---|
684 | pFsFsi, pFsFsd, pbData, cbData, pcMatches, *pcMatches, uLevel, uPosition, pszName, pszName, fFlags));
|
---|
685 |
|
---|
686 | /*
|
---|
687 | * Input validation.
|
---|
688 | */
|
---|
689 | USHORT const cMaxMatches = *pcMatches;
|
---|
690 | *pcMatches = 0;
|
---|
691 | AssertReturn(pFsFsd->u32Magic == VBOXSFFS_MAGIC, ERROR_SYS_INTERNAL);
|
---|
692 | PVBOXSFFOLDER pFolder = pFsFsd->pFolder;
|
---|
693 | AssertReturn(pFolder != NULL, ERROR_SYS_INTERNAL);
|
---|
694 | Assert(pFolder->u32Magic == VBOXSFFOLDER_MAGIC);
|
---|
695 | Assert(pFolder->cOpenSearches > 0);
|
---|
696 | PVBOXSFFSBUF pDataBuf = pFsFsd->pBuf;
|
---|
697 | AssertReturn(pDataBuf, ERROR_SYS_INTERNAL);
|
---|
698 | Assert(pDataBuf->u32Magic == VBOXSFFSBUF_MAGIC);
|
---|
699 |
|
---|
700 | switch (uLevel)
|
---|
701 | {
|
---|
702 | case FI_LVL_STANDARD:
|
---|
703 | case FI_LVL_STANDARD_64:
|
---|
704 | case FI_LVL_STANDARD_EASIZE:
|
---|
705 | case FI_LVL_STANDARD_EASIZE_64:
|
---|
706 | break;
|
---|
707 |
|
---|
708 | case FI_LVL_EAS_FROM_LIST:
|
---|
709 | case FI_LVL_EAS_FROM_LIST_64:
|
---|
710 | Log(("FS32_FINDFIRST: FI_LVL_EAS_FROM_LIST[_64] -> ERROR_EAS_NOT_SUPPORTED\n"));
|
---|
711 | return ERROR_EAS_NOT_SUPPORTED;
|
---|
712 |
|
---|
713 | default:
|
---|
714 | LogRel(("FS32_FINDFIRST: Unsupported info level %u!\n", uLevel));
|
---|
715 | return ERROR_INVALID_LEVEL;
|
---|
716 | }
|
---|
717 |
|
---|
718 | /*
|
---|
719 | * Check if we're just continuing. This is usually the case.
|
---|
720 | */
|
---|
721 | APIRET rc;
|
---|
722 | if (uPosition == pFsFsd->offLastFile)
|
---|
723 | rc = vboxSfOs2ReadDirEntries(pFolder, pFsFsd, pDataBuf, uLevel, fFlags, pbData, cbData,
|
---|
724 | cMaxMatches ? cMaxMatches : UINT16_MAX, pcMatches);
|
---|
725 | else
|
---|
726 | {
|
---|
727 | Log(("TODO: uPosition differs: %#x, expected %#x (%s)\n", uPosition, pFsFsd->offLastFile, pszName));
|
---|
728 | rc = vboxSfOs2ReadDirEntries(pFolder, pFsFsd, pDataBuf, uLevel, fFlags, pbData, cbData,
|
---|
729 | cMaxMatches ? cMaxMatches : UINT16_MAX, pcMatches);
|
---|
730 | }
|
---|
731 |
|
---|
732 | RT_NOREF(pFsFsi, pszName);
|
---|
733 | LogFlow(("FS32_FINDFROMNAME: returns %u (*pcMatches=%#x)\n", rc, *pcMatches));
|
---|
734 | return rc;
|
---|
735 | }
|
---|
736 |
|
---|
737 |
|
---|
738 | DECLASM(APIRET)
|
---|
739 | FS32_FINDNEXT(PFSFSI pFsFsi, PVBOXSFFS pFsFsd, PBYTE pbData, ULONG cbData, PUSHORT pcMatches, ULONG uLevel, ULONG fFlags)
|
---|
740 | {
|
---|
741 | LogFlow(("FS32_FINDNEXT: pFsFsi=%p pFsFsd=%p pbData=%p cbData=%#x pcMatches=%p:{%#x} uLevel=%#x fFlags=%#x\n",
|
---|
742 | pFsFsi, pFsFsd, pbData, cbData, pcMatches, *pcMatches, uLevel, fFlags));
|
---|
743 |
|
---|
744 | /*
|
---|
745 | * Input validation.
|
---|
746 | */
|
---|
747 | USHORT const cMaxMatches = *pcMatches;
|
---|
748 | *pcMatches = 0;
|
---|
749 | AssertReturn(pFsFsd->u32Magic == VBOXSFFS_MAGIC, ERROR_SYS_INTERNAL);
|
---|
750 | PVBOXSFFOLDER pFolder = pFsFsd->pFolder;
|
---|
751 | AssertReturn(pFolder != NULL, ERROR_SYS_INTERNAL);
|
---|
752 | Assert(pFolder->u32Magic == VBOXSFFOLDER_MAGIC);
|
---|
753 | Assert(pFolder->cOpenSearches > 0);
|
---|
754 | PVBOXSFFSBUF pDataBuf = pFsFsd->pBuf;
|
---|
755 | AssertReturn(pDataBuf, ERROR_SYS_INTERNAL);
|
---|
756 | Assert(pDataBuf->u32Magic == VBOXSFFSBUF_MAGIC);
|
---|
757 |
|
---|
758 | switch (uLevel)
|
---|
759 | {
|
---|
760 | case FI_LVL_STANDARD:
|
---|
761 | case FI_LVL_STANDARD_64:
|
---|
762 | case FI_LVL_STANDARD_EASIZE:
|
---|
763 | case FI_LVL_STANDARD_EASIZE_64:
|
---|
764 | break;
|
---|
765 |
|
---|
766 | case FI_LVL_EAS_FROM_LIST:
|
---|
767 | case FI_LVL_EAS_FROM_LIST_64:
|
---|
768 | Log(("FS32_FINDFIRST: FI_LVL_EAS_FROM_LIST[_64] -> ERROR_EAS_NOT_SUPPORTED\n"));
|
---|
769 | return ERROR_EAS_NOT_SUPPORTED;
|
---|
770 |
|
---|
771 | default:
|
---|
772 | LogRel(("FS32_FINDFIRST: Unsupported info level %u!\n", uLevel));
|
---|
773 | return ERROR_INVALID_LEVEL;
|
---|
774 | }
|
---|
775 |
|
---|
776 | /*
|
---|
777 | * Read more.
|
---|
778 | */
|
---|
779 | APIRET rc = vboxSfOs2ReadDirEntries(pFolder, pFsFsd, pDataBuf, uLevel, fFlags, pbData, cbData,
|
---|
780 | cMaxMatches ? cMaxMatches : UINT16_MAX, pcMatches);
|
---|
781 |
|
---|
782 | NOREF(pFsFsi);
|
---|
783 | LogFlow(("FS32_FINDNEXT: returns %u (*pcMatches=%#x)\n", rc, *pcMatches));
|
---|
784 | return rc;
|
---|
785 | }
|
---|
786 |
|
---|
787 |
|
---|
788 | DECLASM(APIRET)
|
---|
789 | FS32_FINDCLOSE(PFSFSI pFsFsi, PVBOXSFFS pFsFsd)
|
---|
790 | {
|
---|
791 | /*
|
---|
792 | * Input validation.
|
---|
793 | */
|
---|
794 | AssertReturn(pFsFsd->u32Magic == VBOXSFFS_MAGIC, ERROR_SYS_INTERNAL);
|
---|
795 | PVBOXSFFOLDER pFolder = pFsFsd->pFolder;
|
---|
796 | AssertReturn(pFolder != NULL, ERROR_SYS_INTERNAL);
|
---|
797 | Assert(pFolder->u32Magic == VBOXSFFOLDER_MAGIC);
|
---|
798 | Assert(pFolder->cOpenSearches > 0);
|
---|
799 | PVBOXSFFSBUF pDataBuf = pFsFsd->pBuf;
|
---|
800 | AssertReturn(pDataBuf, ERROR_SYS_INTERNAL);
|
---|
801 | Assert(pDataBuf->u32Magic == VBOXSFFSBUF_MAGIC);
|
---|
802 |
|
---|
803 | /*
|
---|
804 | * Close it.
|
---|
805 | */
|
---|
806 | if (pFsFsd->hHostDir != SHFL_HANDLE_NIL)
|
---|
807 | {
|
---|
808 | int vrc = vboxSfOs2HostReqCloseSimple(pFolder, pFsFsd->hHostDir);
|
---|
809 | AssertRC(vrc);
|
---|
810 | }
|
---|
811 |
|
---|
812 | pFsFsd->u32Magic = ~VBOXSFFS_MAGIC;
|
---|
813 | pFsFsd->hHostDir = SHFL_HANDLE_NIL;
|
---|
814 | pFsFsd->pFolder = NULL;
|
---|
815 | pFsFsd->pBuf = NULL;
|
---|
816 | vboxSfOs2StrFree(pDataBuf->pFilter);
|
---|
817 | pDataBuf->pFilter = NULL;
|
---|
818 | pDataBuf->u32Magic = ~VBOXSFFSBUF_MAGIC;
|
---|
819 | pDataBuf->cbBuf = 0;
|
---|
820 | RTMemFree(pDataBuf);
|
---|
821 |
|
---|
822 | uint32_t cRefs = ASMAtomicDecU32(&pFolder->cOpenSearches);
|
---|
823 | Assert(cRefs < _4K); RT_NOREF(cRefs);
|
---|
824 | vboxSfOs2ReleaseFolder(pFolder);
|
---|
825 |
|
---|
826 | RT_NOREF(pFsFsi);
|
---|
827 | LogFlow(("FS32_FINDCLOSE: returns NO_ERROR\n"));
|
---|
828 | return NO_ERROR;
|
---|
829 | }
|
---|
830 |
|
---|
831 |
|
---|
832 |
|
---|
833 |
|
---|
834 |
|
---|
835 | DECLASM(APIRET)
|
---|
836 | FS32_FINDNOTIFYFIRST(PCDFSI pCdFsi, PVBOXSFCD pCdFsd, PCSZ pszPath, LONG offCurDirEnd, ULONG fAttribs,
|
---|
837 | PUSHORT phHandle, PBYTE pbData, ULONG cbData, PUSHORT pcMatches,
|
---|
838 | ULONG uLevel, ULONG fFlags)
|
---|
839 | {
|
---|
840 | RT_NOREF(pCdFsi, pCdFsd, pszPath, offCurDirEnd, fAttribs, phHandle, pbData, cbData, pcMatches, uLevel, fFlags);
|
---|
841 | return ERROR_NOT_SUPPORTED;
|
---|
842 | }
|
---|
843 |
|
---|
844 |
|
---|
845 | DECLASM(APIRET)
|
---|
846 | FS32_FINDNOTIFYNEXT(ULONG hHandle, PBYTE pbData, ULONG cbData, PUSHORT pcMatchs, ULONG uLevel, ULONG cMsTimeout)
|
---|
847 | {
|
---|
848 | RT_NOREF(hHandle, pbData, cbData, pcMatchs, uLevel, cMsTimeout);
|
---|
849 | return ERROR_NOT_SUPPORTED;
|
---|
850 | }
|
---|
851 |
|
---|
852 |
|
---|
853 | DECLASM(APIRET)
|
---|
854 | FS32_FINDNOTIFYCLOSE(ULONG hHandle)
|
---|
855 | {
|
---|
856 | NOREF(hHandle);
|
---|
857 | return ERROR_NOT_SUPPORTED;
|
---|
858 | }
|
---|
859 |
|
---|