VirtualBox

source: vbox/trunk/src/VBox/Additions/os2/VBoxSF/VBoxSFUtil.cpp@ 75461

Last change on this file since 75461 was 75461, checked in by vboxsync, 7 years ago

os2/VBoxSF: warnings / gcc.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 21.6 KB
Line 
1/** $Id: VBoxSFUtil.cpp 75461 2018-11-14 19:51:23Z vboxsync $ */
2/** @file
3 * VBoxSF - OS/2 Shared Folders, Utility for attaching and testing.
4 */
5
6/*
7 * Copyright (c) 2016-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#include <string.h>
36#include <stdio.h>
37#include <stdint.h>
38#include <stdlib.h>
39#define INCL_BASE
40#define OS2EMX_PLAIN_CHAR
41#include <os2.h>
42
43
44/*********************************************************************************************************************************
45* Internal Functions *
46*********************************************************************************************************************************/
47extern "C" APIRET __cdecl CallDosQFileMode(const char *pszFilename, PUSHORT pfAttr, ULONG ulReserved);
48
49
50
51int vboxSfOs2UtilUse(int argc, char **argv)
52{
53 /*
54 * Continue parsing.
55 */
56 if (argc != 3)
57 {
58 fprintf(stderr, "syntax error: Expected three arguments to 'use' command\n");
59 return 2;
60 }
61
62 /* The drive letter. */
63 const char *pszDrive = argv[1];
64 if ( ( (pszDrive[0] >= 'A' && pszDrive[0] <= 'Z')
65 || (pszDrive[0] >= 'a' && pszDrive[0] <= 'z'))
66 && pszDrive[1] == ':'
67 && pszDrive[2] == '\0')
68 { /* likely */ }
69 else
70 {
71 fprintf(stderr, "syntax error: Invalid drive specification '%s', expected something like 'K:'.\n", pszDrive);
72 return 2;
73 }
74
75 /* The shared folder. */
76 const char *pszFolder = argv[2];
77 size_t cchFolder = strlen(pszFolder);
78 if (cchFolder <= 80 && cchFolder != 0)
79 { /* likely */ }
80 else
81 {
82 fprintf(stderr, "syntax error: Shared folder name '%s' is too %s!\n", pszFolder, cchFolder >= 1 ? "long" : "short");
83 return 2;
84 }
85
86 /*
87 * Try attach it.
88 */
89 APIRET rc = DosFSAttach(pszDrive, "VBOXSF", (void *)pszFolder, cchFolder + 1, FS_ATTACH);
90 if (rc == NO_ERROR)
91 {
92 printf("done\n");
93 return 0;
94 }
95 fprintf(stderr, "error: DosFSAttach failed: %lu\n", rc);
96 return 1;
97}
98
99
100int vboxSfOs2UtilQPathInfo(int argc, char **argv)
101{
102 for (int i = 1; i < argc; i++)
103 {
104 union
105 {
106 USHORT fAttribs;
107 FILESTATUS Lvl1r1;
108 FILESTATUS3 Lvl1r3;
109 FILESTATUS3L Lvl11;
110 FILESTATUS2 Lvl2r2;
111 FILESTATUS4 Lvl2r4;
112 FILESTATUS4L Lvl12;
113 FEA2LIST FeaList;
114 char szFullName[260];
115 //char szTest1[sizeof(FILESTATUS3) == sizeof(FILESTATUS)];
116 //char szTest2[sizeof(FILESTATUS4) == sizeof(FILESTATUS2)];
117 } u;
118
119 u.fAttribs = 0xffff;
120 int rc = CallDosQFileMode(argv[i], &u.fAttribs, 0 /* reserved */);
121 printf("%s: DosQFileMode -> %u, %#x\n", argv[i], rc, u.fAttribs);
122
123 memset(&u, 0xaa, sizeof(u));
124 rc = DosQueryPathInfo(argv[i], FIL_STANDARD, &u.Lvl1r1, sizeof(u.Lvl1r1));
125 printf("%s: FIL_STANDARD/%#x -> %u\n", argv[i], sizeof(u.Lvl1r1), rc);
126#define D(x) (*(uint16_t *)&(x))
127#define T(x) (*(uint16_t *)&(x))
128 if (rc == NO_ERROR)
129 {
130 printf(" Lvl1r1: creation=%u:%u write=%u:%u access=%u:%u\n",
131 D(u.Lvl1r1.fdateCreation), T(u.Lvl1r1.ftimeCreation), D(u.Lvl1r1.fdateLastWrite), T(u.Lvl1r1.ftimeLastWrite),
132 D(u.Lvl1r1.fdateLastAccess), T(u.Lvl1r1.ftimeLastAccess));
133 printf(" Lvl1r1: attrib=%#x size=%lu alloc=%lu\n", u.Lvl1r1.attrFile, u.Lvl1r1.cbFile, u.Lvl1r1.cbFileAlloc);
134
135 }
136
137 memset(&u, 0xbb, sizeof(u));
138 rc = DosQueryPathInfo(argv[i], FIL_STANDARD, &u.Lvl1r3, sizeof(u.Lvl1r3));
139 printf("%s: FIL_STANDARD/%#x-> %u\n", argv[i], sizeof(u.Lvl1r3), rc);
140 if (rc == NO_ERROR)
141 {
142 printf(" Lvl1r3: creation=%u:%u write=%u:%u access=%u:%u\n",
143 D(u.Lvl1r3.fdateCreation), T(u.Lvl1r3.ftimeCreation), D(u.Lvl1r3.fdateLastWrite), T(u.Lvl1r3.ftimeLastWrite),
144 D(u.Lvl1r3.fdateLastAccess), T(u.Lvl1r3.ftimeLastAccess));
145 printf(" Lvl1r3: attrib=%#lx size=%lu alloc=%lu\n", u.Lvl1r3.attrFile, u.Lvl1r3.cbFile, u.Lvl1r3.cbFileAlloc);
146
147 }
148
149 memset(&u, 0xdd, sizeof(u));
150 rc = DosQueryPathInfo(argv[i], FIL_STANDARDL, &u.Lvl11, sizeof(u.Lvl11));
151 printf("%s: FIL_STANDARDL/%#x -> %u\n", argv[i], sizeof(u.Lvl11), rc);
152 if (rc == NO_ERROR)
153 {
154 printf(" Lvl11: creation=%u:%u write=%u:%u access=%u:%u\n",
155 D(u.Lvl11.fdateCreation), T(u.Lvl11.ftimeCreation), D(u.Lvl11.fdateLastWrite), T(u.Lvl11.ftimeLastWrite),
156 D(u.Lvl11.fdateLastAccess), T(u.Lvl11.ftimeLastAccess));
157 printf(" Lvl11: attrib=%#lx size=%llu alloc=%llu\n", u.Lvl11.attrFile, u.Lvl11.cbFile, u.Lvl11.cbFileAlloc);
158 }
159
160 memset(&u, 0xee, sizeof(u));
161 rc = DosQueryPathInfo(argv[i], FIL_QUERYEASIZE, &u.Lvl2r2, sizeof(u.Lvl2r2));
162 printf("%s: FIL_QUERYEASIZE/%#x -> %u\n", argv[i], sizeof(u.Lvl2r2), rc);
163 if (rc == NO_ERROR)
164 {
165 printf(" Lvl2: creation=%u:%u write=%u:%u access=%u:%u\n",
166 D(u.Lvl2r2.fdateCreation), T(u.Lvl2r2.ftimeCreation), D(u.Lvl2r2.fdateLastWrite), T(u.Lvl2r2.ftimeLastWrite),
167 D(u.Lvl2r2.fdateLastAccess), T(u.Lvl2r2.ftimeLastAccess));
168 printf(" Lvl2: attrib=%#x size=%lu alloc=%lu cbList=%#lx\n",
169 u.Lvl2r2.attrFile, u.Lvl2r2.cbFile, u.Lvl2r2.cbFileAlloc, u.Lvl2r4.cbList);
170 }
171
172 memset(&u, 0x55, sizeof(u));
173 rc = DosQueryPathInfo(argv[i], FIL_QUERYEASIZE, &u.Lvl2r4, sizeof(u.Lvl2r4));
174 printf("%s: FIL_QUERYEASIZE/%#x -> %u\n", argv[i], sizeof(u.Lvl2r4), rc);
175 if (rc == NO_ERROR)
176 {
177 printf(" Lvl2: creation=%u:%u write=%u:%u access=%u:%u\n",
178 D(u.Lvl2r4.fdateCreation), T(u.Lvl2r4.ftimeCreation), D(u.Lvl2r4.fdateLastWrite), T(u.Lvl2r4.ftimeLastWrite),
179 D(u.Lvl2r4.fdateLastAccess), T(u.Lvl2r4.ftimeLastAccess));
180 printf(" Lvl2: attrib=%#lx size=%lu alloc=%lu cbList=%#lx\n",
181 u.Lvl2r4.attrFile, u.Lvl2r4.cbFile, u.Lvl2r4.cbFileAlloc, u.Lvl2r4.cbList);
182 }
183
184 memset(&u, 0x99, sizeof(u));
185 rc = DosQueryPathInfo(argv[i], FIL_QUERYEASIZEL, &u.Lvl12, sizeof(u.Lvl12));
186 printf("%s: FIL_QUERYEASIZEL/%#x -> %u\n", argv[i], sizeof(u.Lvl12), rc);
187 if (rc == NO_ERROR)
188 {
189 printf(" Lvl12: creation=%u:%u write=%u:%u access=%u:%u\n",
190 D(u.Lvl12.fdateCreation), T(u.Lvl12.ftimeCreation), D(u.Lvl12.fdateLastWrite), T(u.Lvl12.ftimeLastWrite),
191 D(u.Lvl12.fdateLastAccess), T(u.Lvl12.ftimeLastAccess));
192 printf(" Lvl12: attrib=%#lx size=%llu alloc=%llu cbList=%#lx\n",
193 u.Lvl12.attrFile, u.Lvl12.cbFile, u.Lvl12.cbFileAlloc, u.Lvl12.cbList);
194 }
195
196 memset(&u, 0x44, sizeof(u));
197 rc = DosQueryPathInfo(argv[i], FIL_QUERYFULLNAME, &u.szFullName[0], sizeof(u.szFullName));
198 printf("%s: FIL_QUERYFULLNAME -> %u\n", argv[i], rc);
199 if (rc == NO_ERROR)
200 printf(" Lvl5: %s<eol>\n", u.szFullName);
201
202 size_t cchInput = strlen(argv[i]);
203 if (cchInput >= sizeof(u.szFullName))
204 cchInput = sizeof(u.szFullName) - 1;
205
206 /** @todo Cannot get to level 6 thru 32-bit, need 16-bit. DOSCALL1.DLL
207 * chickens out on us. Sigh. */
208 memcpy(u.szFullName, argv[i], cchInput);
209 u.szFullName[0] = '\0';
210 rc = DosQueryPathInfo(argv[i], 6 /*FIL_VERIFY_SYNTAX*/, &u.szFullName[0], sizeof(u.szFullName));
211 printf("%s: FIL_VERIFY_SYNTAX -> %u\n", argv[i], rc);
212 if (rc == NO_ERROR)
213 printf(" Lvl6: %s<eol>\n", u.szFullName);
214
215 memcpy(u.szFullName, argv[i], cchInput);
216 u.szFullName[0] = '\0';
217 rc = DosQueryPathInfo(argv[i], 16 /*FIL_VERIFY_SYNTAX_L*/, &u.szFullName[0], sizeof(u.szFullName));
218 printf("%s: FIL_VERIFY_SYNTAX_L -> %u\n", argv[i], rc);
219 if (rc == NO_ERROR)
220 printf(" Lvl6L: %s<eol>\n", u.szFullName);
221
222 memcpy(u.szFullName, argv[i], cchInput);
223 u.szFullName[0] = '\0';
224 rc = DosQueryPathInfo(argv[i], 7 /*FIL_FIX_CASE*/, &u.szFullName[0], sizeof(u.szFullName));
225 printf("%s: FIL_FIX_CASE -> %u\n", argv[i], rc);
226 if (rc == NO_ERROR)
227 printf(" Lvl7: %s<eol>\n", u.szFullName);
228
229 memcpy(u.szFullName, argv[i], cchInput);
230 u.szFullName[0] = '\0';
231 rc = DosQueryPathInfo(argv[i], 17 /*FIL_FIX_CASE_L*/, &u.szFullName[0], sizeof(u.szFullName));
232 printf("%s: FIL_FIX_CASE_L -> %u\n", argv[i], rc);
233 if (rc == NO_ERROR)
234 printf(" Lvl17: %s<eol>\n", u.szFullName);
235
236 struct
237 {
238 ULONG cbList;
239 ULONG oNext;
240 BYTE cchName;
241 char szName[10];
242 } Gea2List, Gea2ListOrg = { sizeof(Gea2List), 0, sizeof(".LONGNAME") - 1, ".LONGNAME" };
243 EAOP2 EaOp;
244 EaOp.fpGEA2List = (PGEA2LIST)memcpy(&Gea2List, &Gea2ListOrg, sizeof(Gea2List));
245 EaOp.fpFEA2List = &u.FeaList;
246 EaOp.oError = 0;
247 memset(&u, '\0', sizeof(u));
248 u.FeaList.cbList = sizeof(u);
249 rc = DosQueryPathInfo(argv[i], FIL_QUERYEASFROMLIST, &EaOp, sizeof(EaOp));
250 printf("%s: FIL_QUERYEASFROMLIST -> %u\n", argv[i], rc);
251 if (rc == NO_ERROR)
252 printf(" Lvl3: FeaList.cbList=%#lx oError=%#lx\n", u.FeaList.cbList, EaOp.oError);
253
254 EaOp.fpGEA2List = (PGEA2LIST)memcpy(&Gea2List, &Gea2ListOrg, sizeof(Gea2List));
255 EaOp.fpFEA2List = &u.FeaList;
256 EaOp.oError = 0;
257 memset(&u, '\0', sizeof(u));
258 u.FeaList.cbList = sizeof(u);
259 rc = DosQueryPathInfo(argv[i], FIL_QUERYEASFROMLISTL, &EaOp, sizeof(EaOp));
260 if (rc != ERROR_INVALID_LEVEL)
261 printf("%s: FIL_QUERYEASFROMLISTL -> %u\n", argv[i], rc);
262
263 EaOp.fpGEA2List = (PGEA2LIST)memcpy(&Gea2List, &Gea2ListOrg, sizeof(Gea2List));
264 EaOp.fpFEA2List = &u.FeaList;
265 EaOp.oError = 0;
266 memset(&u, '\0', sizeof(u));
267 u.FeaList.cbList = sizeof(u);
268 rc = DosQueryPathInfo(argv[i], 4, &EaOp, sizeof(EaOp));
269 printf("%s: FIL_QUERYALLEAS/4 -> %u\n", argv[i], rc);
270 if (rc == NO_ERROR)
271 printf(" Lvl4: FeaList.cbList=%#lx oError=%#lx\n", u.FeaList.cbList, EaOp.oError);
272
273 EaOp.fpGEA2List = (PGEA2LIST)memcpy(&Gea2List, &Gea2ListOrg, sizeof(Gea2List));
274 EaOp.fpFEA2List = &u.FeaList;
275 EaOp.oError = 0;
276 memset(&u, '\0', sizeof(u));
277 u.FeaList.cbList = sizeof(u);
278 rc = DosQueryPathInfo(argv[i], 14, &EaOp, sizeof(EaOp));
279 if (rc != ERROR_INVALID_LEVEL)
280 printf("%s: FIL_QUERYALLEASL/14 -> %u\n", argv[i], rc);
281
282 EaOp.fpGEA2List = (PGEA2LIST)memcpy(&Gea2List, &Gea2ListOrg, sizeof(Gea2List));
283 EaOp.fpFEA2List = &u.FeaList;
284 EaOp.oError = 0;
285 memset(&u, '\0', sizeof(u));
286 u.FeaList.cbList = sizeof(u);
287 rc = DosQueryPathInfo(argv[i], 8, &EaOp, sizeof(EaOp));
288 printf("%s: FIL_QUERYALLEAS/8 -> %u\n", argv[i], rc);
289 if (rc == NO_ERROR)
290 printf(" Lvl8: FeaList.cbList=%#lx oError=%#lx\n", u.FeaList.cbList, EaOp.oError);
291
292 EaOp.fpGEA2List = (PGEA2LIST)memcpy(&Gea2List, &Gea2ListOrg, sizeof(Gea2List));
293 EaOp.fpFEA2List = &u.FeaList;
294 EaOp.oError = 0;
295 memset(&u, '\0', sizeof(u));
296 u.FeaList.cbList = sizeof(u);
297 rc = DosQueryPathInfo(argv[i], 18, &EaOp, sizeof(EaOp));
298 if (rc != ERROR_INVALID_LEVEL)
299 printf("%s: FIL_QUERYALLEASL/18 -> %u\n", argv[i], rc);
300
301 EaOp.fpGEA2List = (PGEA2LIST)memcpy(&Gea2List, &Gea2ListOrg, sizeof(Gea2List));
302 EaOp.fpFEA2List = &u.FeaList;
303 EaOp.oError = 0;
304 memset(&u, '\0', sizeof(u));
305 u.FeaList.cbList = sizeof(u);
306 rc = DosQueryPathInfo(argv[i], 15, &EaOp, sizeof(EaOp));
307 if (rc != ERROR_INVALID_LEVEL)
308 printf("%s: FIL_QUERYALLEASL/15 -> %u\n", argv[i], rc);
309
310 memset(&u, '\0', sizeof(u));
311 rc = DosQueryPathInfo(argv[i], 0, &u, sizeof(u));
312 if (rc != ERROR_INVALID_LEVEL)
313 printf("%s: 0 -> %u\n", argv[i], rc);
314 }
315 return 0;
316}
317
318
319int vboxSfOs2UtilFindFile(int argc, char **argv)
320{
321 unsigned cMaxMatches = 1;
322 unsigned cbBuf = 1024;
323 unsigned uLevel = FIL_STANDARDL;
324 unsigned fAttribs = FILE_DIRECTORY | FILE_HIDDEN | FILE_SYSTEM;
325 bool fOptions = true;
326
327 uint8_t *pbBuf = NULL;
328 for (int i = 1; i < argc; i++)
329 {
330 const char *pszArg = argv[i];
331
332 /*
333 * Deal with options.
334 */
335 if (fOptions && *pszArg == '-')
336 {
337 pszArg++;
338 if (*pszArg == '-')
339 {
340 pszArg++;
341 if (!*pszArg)
342 {
343 fOptions = false;
344 continue;
345 }
346 if (strcmp(pszArg, "attribs") == 0)
347 pszArg = "a";
348 else if (strcmp(pszArg, "buffer-size") == 0)
349 pszArg = "b";
350 else if (strcmp(pszArg, "level") == 0)
351 pszArg = "l";
352 else if (strcmp(pszArg, "matches") == 0)
353 pszArg = "m";
354 else if (strcmp(pszArg, "help") == 0)
355 pszArg = "h";
356 else
357 {
358 fprintf(stderr, "syntax error: Unknown option: %s\n", argv[i]);
359 return 2;
360 }
361 }
362 do
363 {
364 const char *pszValue = NULL;
365 char chOpt = *pszArg++;
366 if (strchr("ablm", chOpt) != NULL)
367 {
368 if (*pszArg != '\0')
369 pszValue = *pszArg == ':' || *pszArg == '=' ? ++pszArg : pszArg;
370 else if (i + 1 < argc)
371 pszValue = argv[++i];
372 else
373 {
374 fprintf(stderr, "syntax error: -%c takes a value\n", chOpt);
375 return 2;
376 }
377 pszArg = "";
378 }
379 switch (chOpt)
380 {
381 case 'a':
382 fAttribs = atoi(pszValue);
383 break;
384 case 'b':
385 cbBuf = atoi(pszValue);
386 free(pbBuf);
387 pbBuf = NULL;
388 break;
389 case 'l':
390 uLevel = atoi(pszValue);
391 break;
392 case 'm':
393 cMaxMatches = atoi(pszValue);
394 break;
395 case 'h':
396 printf("usage: findfile [-a|--attribs <mask>] [-b|--buffer-size <bytes>]\n"
397 " [-l|--level <num>] [-m|--matches <num>] [--] <dir1> [dir2..N]\n");
398 return 0;
399 default:
400 fprintf(stderr, "syntax error: Unknown option '%c' (%s)\n", chOpt, argv[i - (pszValue != NULL)]);
401 return 2;
402 }
403
404 } while (pszArg && *pszArg != '\0');
405 }
406 else
407 {
408 /*
409 * Search the specified directory/whatever.
410 */
411 if (!pbBuf)
412 {
413 pbBuf = (uint8_t *)malloc(cbBuf);
414 if (!pbBuf)
415 {
416 fprintf(stderr, "error: out of memory (cbBuf=%#x)\n", cbBuf);
417 return 1;
418 }
419 }
420
421 HDIR hDir = HDIR_CREATE;
422 ULONG cMatches = cMaxMatches;
423 memset(pbBuf, 0xf6, cbBuf);
424 APIRET rc = DosFindFirst(pszArg, &hDir, fAttribs, pbBuf, cbBuf, &cMatches, uLevel);
425 printf("DosFindFirst -> %lu hDir=%#lx cMatches=%#lx\n", rc, hDir, cMatches);
426 if (rc == NO_ERROR)
427 {
428 do
429 {
430 uint8_t *pbTmp = pbBuf;
431 for (uint32_t iMatch = 0; iMatch < cMatches; iMatch++)
432 {
433 uint32_t offNext = *(uint32_t *)pbTmp;
434 switch (uLevel)
435 {
436 case FIL_STANDARD:
437 {
438 PFILEFINDBUF3 pBuf = (PFILEFINDBUF3)pbTmp;
439 printf("#%u: nx=%#lx sz=%#lx at=%#lx nm=%#x:%s\n",
440 iMatch, pBuf->oNextEntryOffset, pBuf->cbFile, pBuf->attrFile, pBuf->cchName, pBuf->achName);
441 if (strlen(pBuf->achName) != pBuf->cchName)
442 printf("Bad name length!\n");
443 break;
444 }
445 case FIL_STANDARDL:
446 {
447 PFILEFINDBUF3L pBuf = (PFILEFINDBUF3L)pbTmp;
448 printf("#%u: nx=%#lx sz=%#llx at=%#lx nm=%#x:%s\n",
449 iMatch, pBuf->oNextEntryOffset, pBuf->cbFile, pBuf->attrFile, pBuf->cchName, pBuf->achName);
450 if (strlen(pBuf->achName) != pBuf->cchName)
451 printf("Bad name length!\n");
452 break;
453 }
454 case FIL_QUERYEASIZE:
455 {
456 PFILEFINDBUF4 pBuf = (PFILEFINDBUF4)pbTmp;
457 printf("#%u: nx=%#lx sz=%#lx at=%#lx nm=%#x:%s\n",
458 iMatch, pBuf->oNextEntryOffset, pBuf->cbFile, pBuf->attrFile, pBuf->cchName, pBuf->achName);
459 if (strlen(pBuf->achName) != pBuf->cchName)
460 printf("Bad name length!\n");
461 break;
462 }
463 case FIL_QUERYEASIZEL:
464 {
465 PFILEFINDBUF4L pBuf = (PFILEFINDBUF4L)pbTmp;
466 printf("#%u: nx=%#lx sz=%#llx at=%#lx nm=%#x:%s\n",
467 iMatch, pBuf->oNextEntryOffset, pBuf->cbFile, pBuf->attrFile, pBuf->cchName, pBuf->achName);
468 if (strlen(pBuf->achName) != pBuf->cchName)
469 printf("Bad name length!\n");
470 break;
471 }
472
473 }
474
475 pbTmp += offNext;
476 }
477
478 /* Next bunch. */
479 memset(pbBuf, 0xf6, cbBuf);
480 cMatches = cMaxMatches;
481 rc = DosFindNext(hDir, pbBuf, cbBuf, &cMatches);
482 printf("DosFindNext -> %lu hDir=%#lx cMatches=%#lx\n", rc, hDir, cMatches);
483 } while (rc == NO_ERROR);
484
485 rc = DosFindClose(hDir);
486 printf("DosFindClose -> %lu\n", rc);
487 }
488 }
489 }
490 return 0;
491}
492
493
494static int vboxSfOs2UtilMkDir(int argc, char **argv)
495{
496 for (int i = 1; i < argc; i++)
497 {
498 APIRET rc = DosCreateDir(argv[i], NULL);
499 printf("DosCreateDir -> %lu for '%s'\n", rc, argv[i]);
500 }
501 return 0;
502}
503
504
505int main(int argc, char **argv)
506{
507 /*
508 * Parse input.
509 */
510 for (int i = 1; i < argc; i++)
511 {
512 const char *pszArg = argv[i];
513 if (strcmp(pszArg, "use") == 0)
514 return vboxSfOs2UtilUse(argc - i, argv + i);
515 if (strcmp(pszArg, "qpathinfo") == 0)
516 return vboxSfOs2UtilQPathInfo(argc - i, argv + i);
517 if (strcmp(pszArg, "findfile") == 0)
518 return vboxSfOs2UtilFindFile(argc - i, argv + i);
519 if (strcmp(pszArg, "mkdir") == 0)
520 return vboxSfOs2UtilMkDir(argc - i, argv + i);
521
522 fprintf(stderr, "Unknown command/option: %s\n", pszArg);
523 return 2;
524 }
525 fprintf(stderr,
526 "usage: VBoxSFUtil.exe use [drive] [shared-folder]\n"
527 " or VBoxSFUtil.exe unuse [drive|shared-folder] [..]\n"
528 " or VBoxSFUtil.exe list\n");
529 return 2;
530}
531
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette