VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/dvm/dvmvfs.cpp@ 69942

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

iprt/vfs: Made RTVFSFILEOPS::pfnPollOne optional.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 36.0 KB
Line 
1/* $Id: dvmvfs.cpp 69942 2017-12-05 23:40:31Z vboxsync $ */
2/** @file
3 * IPRT Disk Volume Management API (DVM) - VFS glue.
4 */
5
6/*
7 * Copyright (C) 2012-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#define LOG_GROUP RTLOGGROUP_FS /** @todo fix log group */
32#include <iprt/types.h>
33#include <iprt/assert.h>
34#include <iprt/mem.h>
35#include <iprt/dvm.h>
36#include <iprt/err.h>
37#include <iprt/asm.h>
38#include <iprt/string.h>
39#include <iprt/file.h>
40#include <iprt/sg.h>
41#include <iprt/vfslowlevel.h>
42#include <iprt/poll.h>
43#include <iprt/log.h>
44#include "internal/dvm.h"
45
46
47/*********************************************************************************************************************************
48* Structures and Typedefs *
49*********************************************************************************************************************************/
50/**
51 * A volume manager VFS for use in chains (thing pseudo/devfs).
52 */
53typedef struct RTDVMVFSVOL
54{
55 /** The volume manager. */
56 RTDVM hVolMgr;
57 /** Whether to close it on success. */
58 bool fCloseDvm;
59 /** Whether the access is read-only. */
60 bool fReadOnly;
61 /** Number of volumes. */
62 uint32_t cVolumes;
63 /** Self reference. */
64 RTVFS hVfsSelf;
65} RTDVMVFSVOL;
66/** Poitner to a volume manager VFS. */
67typedef RTDVMVFSVOL *PRTDVMVFSVOL;
68
69/**
70 * The volume manager VFS (root) dir data.
71 */
72typedef struct RTDVMVFSDIR
73{
74 /** Pointer to the VFS volume. */
75 PRTDVMVFSVOL pVfsVol;
76 /** The current directory offset. */
77 uint32_t offDir;
78 /** Set if we need to try return hCurVolume again because of buffer overflow. */
79 bool fReturnCurrent;
80 /** The current DVM volume. */
81 RTDVMVOLUME hCurVolume;
82} RTDVMVFSDIR;
83/** Poitner to a volume manager VFS (root) dir. */
84typedef RTDVMVFSDIR *PRTDVMVFSDIR;
85
86/**
87 * The internal data of a DVM volume I/O stream.
88 */
89typedef struct RTVFSDVMFILE
90{
91 /** The volume the VFS file belongs to. */
92 RTDVMVOLUME hVol;
93 /** Pointer to the VFS volume. Can be NULL. */
94 PRTDVMVFSVOL pVfsVol;
95 /** Current position. */
96 uint64_t offCurPos;
97 /** Set if readable. */
98 bool fCanRead;
99 /** Set if writable. */
100 bool fCanWrite;
101} RTVFSDVMFILE;
102/** Pointer to a the internal data of a DVM volume file. */
103typedef RTVFSDVMFILE *PRTVFSDVMFILE;
104
105
106/*********************************************************************************************************************************
107* Internal Functions *
108*********************************************************************************************************************************/
109static DECLCALLBACK(int) rtDvmVfsVol_OpenRoot(void *pvThis, PRTVFSDIR phVfsDir);
110
111
112/**
113 * @interface_method_impl{RTVFSOBJOPS,pfnClose}
114 */
115static DECLCALLBACK(int) rtDvmVfsFile_Close(void *pvThis)
116{
117 PRTVFSDVMFILE pThis = (PRTVFSDVMFILE)pvThis;
118
119 RTDvmVolumeRelease(pThis->hVol);
120 return VINF_SUCCESS;
121}
122
123
124/**
125 * Worker for rtDvmVfsFile_QueryInfo, rtDvmVfsDir_QueryEntryInfo, and
126 * rtDvmVfsDir_ReadDir.
127 */
128static int rtDvmVfsFile_QueryInfoWorker(RTDVMVOLUME hVolume, RTDVM hVolMgr, bool fReadOnly,
129 PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr)
130{
131
132 pObjInfo->cbObject = RTDvmVolumeGetSize(hVolume);
133 pObjInfo->cbAllocated = pObjInfo->cbObject;
134 RTTimeSpecSetNano(&pObjInfo->AccessTime, 0);
135 RTTimeSpecSetNano(&pObjInfo->ModificationTime, 0);
136 RTTimeSpecSetNano(&pObjInfo->ChangeTime, 0);
137 RTTimeSpecSetNano(&pObjInfo->BirthTime, 0);
138 pObjInfo->Attr.fMode = RTFS_TYPE_FILE | RTFS_DOS_NT_NORMAL;
139 if (fReadOnly)
140 pObjInfo->Attr.fMode |= RTFS_DOS_READONLY | 0444;
141 else
142 pObjInfo->Attr.fMode |= 0666;
143
144 switch (enmAddAttr)
145 {
146 case RTFSOBJATTRADD_NOTHING:
147 case RTFSOBJATTRADD_UNIX:
148 pObjInfo->Attr.u.Unix.uid = (RTUID)RTDvmVolumeGetType(hVolume);
149 pObjInfo->Attr.u.Unix.gid = hVolMgr != NIL_RTDVM ? (RTGID)RTDvmMapGetFormatType(hVolMgr) : NIL_RTGID;
150 pObjInfo->Attr.u.Unix.cHardlinks = 1;
151 pObjInfo->Attr.u.Unix.INodeIdDevice = 0;
152 pObjInfo->Attr.u.Unix.INodeId = 0;
153 pObjInfo->Attr.u.Unix.fFlags = 0;
154 pObjInfo->Attr.u.Unix.GenerationId = 0;
155 pObjInfo->Attr.u.Unix.Device = 0;
156 break;
157
158 case RTFSOBJATTRADD_UNIX_OWNER:
159 {
160 RTDVMVOLTYPE enmType = RTDvmVolumeGetType(hVolume);
161 pObjInfo->Attr.u.UnixOwner.uid = (RTUID)enmType;
162 RTStrCopy(pObjInfo->Attr.u.UnixOwner.szName, sizeof(pObjInfo->Attr.u.UnixOwner.szName),
163 RTDvmVolumeTypeGetDescr(enmType));
164 break;
165 }
166
167 case RTFSOBJATTRADD_UNIX_GROUP:
168 if (hVolMgr != NIL_RTDVM)
169 {
170 pObjInfo->Attr.u.UnixGroup.gid = (RTGID)RTDvmMapGetFormatType(hVolMgr);
171 RTStrCopy(pObjInfo->Attr.u.UnixGroup.szName, sizeof(pObjInfo->Attr.u.UnixGroup.szName),
172 RTDvmMapGetFormatName(hVolMgr));
173 }
174 else
175 {
176 pObjInfo->Attr.u.UnixGroup.gid = NIL_RTGID;
177 pObjInfo->Attr.u.UnixGroup.szName[0] = '\0';
178 }
179 break;
180
181 case RTFSOBJATTRADD_EASIZE:
182 pObjInfo->Attr.u.EASize.cb = 0;
183 break;
184
185 default:
186 return VERR_INVALID_PARAMETER;
187 }
188 return VINF_SUCCESS;
189}
190
191
192/**
193 * @interface_method_impl{RTVFSOBJOPS,pfnQueryInfo}
194 */
195static DECLCALLBACK(int) rtDvmVfsFile_QueryInfo(void *pvThis, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr)
196{
197 PRTVFSDVMFILE pThis = (PRTVFSDVMFILE)pvThis;
198 return rtDvmVfsFile_QueryInfoWorker(pThis->hVol,
199 pThis->pVfsVol ? pThis->pVfsVol->hVolMgr : NIL_RTDVM,
200 pThis->pVfsVol ? pThis->pVfsVol->fReadOnly : !pThis->fCanWrite,
201 pObjInfo, enmAddAttr);
202}
203
204
205/**
206 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnRead}
207 */
208static DECLCALLBACK(int) rtDvmVfsFile_Read(void *pvThis, RTFOFF off, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbRead)
209{
210 PRTVFSDVMFILE pThis = (PRTVFSDVMFILE)pvThis;
211 int rc = VINF_SUCCESS;
212
213 Assert(pSgBuf->cSegs == 1);
214 NOREF(fBlocking);
215
216 /*
217 * Find the current position and check if it's within the volume.
218 */
219 uint64_t offUnsigned = off < 0 ? pThis->offCurPos : (uint64_t)off;
220 if (offUnsigned >= RTDvmVolumeGetSize(pThis->hVol))
221 {
222 if (pcbRead)
223 {
224 *pcbRead = 0;
225 pThis->offCurPos = offUnsigned;
226 return VINF_EOF;
227 }
228 return VERR_EOF;
229 }
230
231 size_t cbLeftToRead;
232 if (offUnsigned + pSgBuf->paSegs[0].cbSeg > RTDvmVolumeGetSize(pThis->hVol))
233 {
234 if (!pcbRead)
235 return VERR_EOF;
236 *pcbRead = cbLeftToRead = (size_t)(RTDvmVolumeGetSize(pThis->hVol) - offUnsigned);
237 }
238 else
239 {
240 cbLeftToRead = pSgBuf->paSegs[0].cbSeg;
241 if (pcbRead)
242 *pcbRead = cbLeftToRead;
243 }
244
245 /*
246 * Ok, we've got a valid stretch within the file. Do the reading.
247 */
248 if (cbLeftToRead > 0)
249 {
250 rc = RTDvmVolumeRead(pThis->hVol, offUnsigned, pSgBuf->paSegs[0].pvSeg, cbLeftToRead);
251 if (RT_SUCCESS(rc))
252 offUnsigned += cbLeftToRead;
253 }
254
255 pThis->offCurPos = offUnsigned;
256 return rc;
257}
258
259
260/**
261 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnWrite}
262 */
263static DECLCALLBACK(int) rtDvmVfsFile_Write(void *pvThis, RTFOFF off, PCRTSGBUF pSgBuf, bool fBlocking, size_t *pcbWritten)
264{
265 PRTVFSDVMFILE pThis = (PRTVFSDVMFILE)pvThis;
266 int rc = VINF_SUCCESS;
267
268 Assert(pSgBuf->cSegs == 1);
269 NOREF(fBlocking);
270
271 /*
272 * Find the current position and check if it's within the volume.
273 * Writing beyond the end of a volume is not supported.
274 */
275 uint64_t offUnsigned = off < 0 ? pThis->offCurPos : (uint64_t)off;
276 if (offUnsigned >= RTDvmVolumeGetSize(pThis->hVol))
277 {
278 if (pcbWritten)
279 {
280 *pcbWritten = 0;
281 pThis->offCurPos = offUnsigned;
282 }
283 return VERR_NOT_SUPPORTED;
284 }
285
286 size_t cbLeftToWrite;
287 if (offUnsigned + pSgBuf->paSegs[0].cbSeg > RTDvmVolumeGetSize(pThis->hVol))
288 {
289 if (!pcbWritten)
290 return VERR_EOF;
291 *pcbWritten = cbLeftToWrite = (size_t)(RTDvmVolumeGetSize(pThis->hVol) - offUnsigned);
292 }
293 else
294 {
295 cbLeftToWrite = pSgBuf->paSegs[0].cbSeg;
296 if (pcbWritten)
297 *pcbWritten = cbLeftToWrite;
298 }
299
300 /*
301 * Ok, we've got a valid stretch within the file. Do the reading.
302 */
303 if (cbLeftToWrite > 0)
304 {
305 rc = RTDvmVolumeWrite(pThis->hVol, offUnsigned, pSgBuf->paSegs[0].pvSeg, cbLeftToWrite);
306 if (RT_SUCCESS(rc))
307 offUnsigned += cbLeftToWrite;
308 }
309
310 pThis->offCurPos = offUnsigned;
311 return rc;
312}
313
314
315/**
316 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnFlush}
317 */
318static DECLCALLBACK(int) rtDvmVfsFile_Flush(void *pvThis)
319{
320 NOREF(pvThis);
321 return VINF_SUCCESS; /** @todo Implement missing DVM API. */
322}
323
324
325/**
326 * @interface_method_impl{RTVFSIOSTREAMOPS,pfnTell}
327 */
328static DECLCALLBACK(int) rtDvmVfsFile_Tell(void *pvThis, PRTFOFF poffActual)
329{
330 PRTVFSDVMFILE pThis = (PRTVFSDVMFILE)pvThis;
331 *poffActual = pThis->offCurPos;
332 return VINF_SUCCESS;
333}
334
335
336/**
337 * @interface_method_impl{RTVFSOBJSETOPS,pfnMode}
338 */
339static DECLCALLBACK(int) rtDvmVfsFile_SetMode(void *pvThis, RTFMODE fMode, RTFMODE fMask)
340{
341 NOREF(pvThis);
342 NOREF(fMode);
343 NOREF(fMask);
344 return VERR_NOT_SUPPORTED;
345}
346
347
348/**
349 * @interface_method_impl{RTVFSOBJSETOPS,pfnSetTimes}
350 */
351static DECLCALLBACK(int) rtDvmVfsFile_SetTimes(void *pvThis, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,
352 PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime)
353{
354 NOREF(pvThis);
355 NOREF(pAccessTime);
356 NOREF(pModificationTime);
357 NOREF(pChangeTime);
358 NOREF(pBirthTime);
359 return VERR_NOT_SUPPORTED;
360}
361
362
363/**
364 * @interface_method_impl{RTVFSOBJSETOPS,pfnSetOwner}
365 */
366static DECLCALLBACK(int) rtDvmVfsFile_SetOwner(void *pvThis, RTUID uid, RTGID gid)
367{
368 NOREF(pvThis);
369 NOREF(uid);
370 NOREF(gid);
371 return VERR_NOT_SUPPORTED;
372}
373
374
375/**
376 * @interface_method_impl{RTVFSFILEOPS,pfnSeek}
377 */
378static DECLCALLBACK(int) rtDvmVfsFile_Seek(void *pvThis, RTFOFF offSeek, unsigned uMethod, PRTFOFF poffActual)
379{
380 PRTVFSDVMFILE pThis = (PRTVFSDVMFILE)pvThis;
381
382 /*
383 * Seek relative to which position.
384 */
385 uint64_t offWrt;
386 switch (uMethod)
387 {
388 case RTFILE_SEEK_BEGIN:
389 offWrt = 0;
390 break;
391
392 case RTFILE_SEEK_CURRENT:
393 offWrt = pThis->offCurPos;
394 break;
395
396 case RTFILE_SEEK_END:
397 offWrt = RTDvmVolumeGetSize(pThis->hVol);
398 break;
399
400 default:
401 return VERR_INTERNAL_ERROR_5;
402 }
403
404 /*
405 * Calc new position, take care to stay within bounds.
406 *
407 * @todo: Setting position beyond the end of the volume does not make sense.
408 */
409 uint64_t offNew;
410 if (offSeek == 0)
411 offNew = offWrt;
412 else if (offSeek > 0)
413 {
414 offNew = offWrt + offSeek;
415 if ( offNew < offWrt
416 || offNew > RTFOFF_MAX)
417 offNew = RTFOFF_MAX;
418 }
419 else if ((uint64_t)-offSeek < offWrt)
420 offNew = offWrt + offSeek;
421 else
422 offNew = 0;
423
424 /*
425 * Update the state and set return value.
426 */
427 pThis->offCurPos = offNew;
428
429 *poffActual = offNew;
430 return VINF_SUCCESS;
431}
432
433
434/**
435 * @interface_method_impl{RTVFSFILEOPS,pfnQuerySize}
436 */
437static DECLCALLBACK(int) rtDvmVfsFile_QuerySize(void *pvThis, uint64_t *pcbFile)
438{
439 PRTVFSDVMFILE pThis = (PRTVFSDVMFILE)pvThis;
440 *pcbFile = RTDvmVolumeGetSize(pThis->hVol);
441 return VINF_SUCCESS;
442}
443
444
445/**
446 * Standard file operations.
447 */
448DECL_HIDDEN_CONST(const RTVFSFILEOPS) g_rtDvmVfsStdFileOps =
449{
450 { /* Stream */
451 { /* Obj */
452 RTVFSOBJOPS_VERSION,
453 RTVFSOBJTYPE_FILE,
454 "DvmFile",
455 rtDvmVfsFile_Close,
456 rtDvmVfsFile_QueryInfo,
457 RTVFSOBJOPS_VERSION
458 },
459 RTVFSIOSTREAMOPS_VERSION,
460 RTVFSIOSTREAMOPS_FEAT_NO_SG,
461 rtDvmVfsFile_Read,
462 rtDvmVfsFile_Write,
463 rtDvmVfsFile_Flush,
464 NULL /*pfnPollOne*/,
465 rtDvmVfsFile_Tell,
466 NULL /*Skip*/,
467 NULL /*ZeroFill*/,
468 RTVFSIOSTREAMOPS_VERSION,
469 },
470 RTVFSFILEOPS_VERSION,
471 /*RTVFSIOFILEOPS_FEAT_NO_AT_OFFSET*/ 0,
472 { /* ObjSet */
473 RTVFSOBJSETOPS_VERSION,
474 RT_OFFSETOF(RTVFSFILEOPS, Stream.Obj) - RT_OFFSETOF(RTVFSFILEOPS, ObjSet),
475 rtDvmVfsFile_SetMode,
476 rtDvmVfsFile_SetTimes,
477 rtDvmVfsFile_SetOwner,
478 RTVFSOBJSETOPS_VERSION
479 },
480 rtDvmVfsFile_Seek,
481 rtDvmVfsFile_QuerySize,
482 RTVFSFILEOPS_VERSION
483};
484
485
486/**
487 * Internal worker for RTDvmVolumeCreateVfsFile and rtDvmVfsDir_OpenFile.
488 *
489 * @returns IPRT status code.
490 * @param pVfsVol The VFS volume, optional.
491 * @param hVol The volume handle. (Reference not consumed.)
492 * @param fOpen RTFILE_O_XXX (valid).
493 * @param phVfsFileOut Where to return the handle to the file.
494 */
495static int rtDvmVfsCreateFileForVolume(PRTDVMVFSVOL pVfsVol, RTDVMVOLUME hVol, uint64_t fOpen, PRTVFSFILE phVfsFileOut)
496{
497 uint32_t cRefs = RTDvmVolumeRetain(hVol);
498 AssertReturn(cRefs != UINT32_MAX, VERR_INVALID_HANDLE);
499
500 /*
501 * Create the volume file.
502 */
503 RTVFSFILE hVfsFile;
504 PRTVFSDVMFILE pThis;
505 int rc = RTVfsNewFile(&g_rtDvmVfsStdFileOps, sizeof(*pThis), fOpen, NIL_RTVFS, NIL_RTVFSLOCK, &hVfsFile, (void **)&pThis);
506 if (RT_SUCCESS(rc))
507 {
508 pThis->offCurPos = 0;
509 pThis->hVol = hVol;
510 pThis->fCanRead = RT_BOOL(fOpen & RTFILE_O_READ);
511 pThis->fCanWrite = RT_BOOL(fOpen & RTFILE_O_WRITE);
512 pThis->pVfsVol = pVfsVol;
513
514 *phVfsFileOut = hVfsFile;
515 return VINF_SUCCESS;
516 }
517
518 RTDvmVolumeRelease(hVol);
519 return rc;
520}
521
522
523RTDECL(int) RTDvmVolumeCreateVfsFile(RTDVMVOLUME hVol, uint64_t fOpen, PRTVFSFILE phVfsFileOut)
524{
525 AssertPtrReturn(hVol, VERR_INVALID_HANDLE);
526 AssertPtrReturn(phVfsFileOut, VERR_INVALID_POINTER);
527 AssertReturn(fOpen & RTFILE_O_ACCESS_MASK, VERR_INVALID_FLAGS);
528 AssertReturn(!(fOpen & ~RTFILE_O_VALID_MASK), VERR_INVALID_FLAGS);
529 return rtDvmVfsCreateFileForVolume(NULL, hVol, fOpen, phVfsFileOut);
530}
531
532
533/**
534 * @interface_method_impl{RTVFSOBJOPS,pfnClose}
535 */
536static DECLCALLBACK(int) rtDvmVfsDir_Close(void *pvThis)
537{
538 PRTDVMVFSDIR pThis = (PRTDVMVFSDIR)pvThis;
539
540 if (pThis->hCurVolume != NIL_RTDVMVOLUME)
541 {
542 RTDvmVolumeRelease(pThis->hCurVolume);
543 pThis->hCurVolume = NIL_RTDVMVOLUME;
544 }
545
546 pThis->pVfsVol = NULL;
547
548 return VINF_SUCCESS;
549}
550
551
552/**
553 * @interface_method_impl{RTVFSOBJOPS,pfnQueryInfo}
554 */
555static DECLCALLBACK(int) rtDvmVfsDir_QueryInfo(void *pvThis, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr)
556{
557 PRTDVMVFSDIR pThis = (PRTDVMVFSDIR)pvThis;
558 pObjInfo->cbObject = pThis->pVfsVol->cVolumes;
559 pObjInfo->cbAllocated = pThis->pVfsVol->cVolumes;
560 RTTimeSpecSetNano(&pObjInfo->AccessTime, 0);
561 RTTimeSpecSetNano(&pObjInfo->ModificationTime, 0);
562 RTTimeSpecSetNano(&pObjInfo->ChangeTime, 0);
563 RTTimeSpecSetNano(&pObjInfo->BirthTime, 0);
564 pObjInfo->Attr.fMode = RTFS_TYPE_DIRECTORY | RTFS_DOS_DIRECTORY;
565 if (pThis->pVfsVol->fReadOnly)
566 pObjInfo->Attr.fMode |= RTFS_DOS_READONLY | 0555;
567 else
568 pObjInfo->Attr.fMode |= 0777;
569
570 switch (enmAddAttr)
571 {
572 case RTFSOBJATTRADD_NOTHING:
573 case RTFSOBJATTRADD_UNIX:
574 pObjInfo->Attr.u.Unix.uid = NIL_RTUID;
575 pObjInfo->Attr.u.Unix.gid = (RTGID)RTDvmMapGetFormatType(pThis->pVfsVol->hVolMgr);
576 pObjInfo->Attr.u.Unix.cHardlinks = pThis->pVfsVol->cVolumes;
577 pObjInfo->Attr.u.Unix.INodeIdDevice = 0;
578 pObjInfo->Attr.u.Unix.INodeId = 0;
579 pObjInfo->Attr.u.Unix.fFlags = 0;
580 pObjInfo->Attr.u.Unix.GenerationId = 0;
581 pObjInfo->Attr.u.Unix.Device = 0;
582 break;
583
584 case RTFSOBJATTRADD_UNIX_OWNER:
585 pObjInfo->Attr.u.UnixOwner.uid = NIL_RTUID;
586 pObjInfo->Attr.u.UnixOwner.szName[0] = '\0';
587 break;
588
589 case RTFSOBJATTRADD_UNIX_GROUP:
590 pObjInfo->Attr.u.UnixGroup.gid = (RTGID)RTDvmMapGetFormatType(pThis->pVfsVol->hVolMgr);
591 RTStrCopy(pObjInfo->Attr.u.UnixGroup.szName, sizeof(pObjInfo->Attr.u.UnixGroup.szName),
592 RTDvmMapGetFormatName(pThis->pVfsVol->hVolMgr));
593 break;
594
595 case RTFSOBJATTRADD_EASIZE:
596 pObjInfo->Attr.u.EASize.cb = 0;
597 break;
598
599 default:
600 return VERR_INVALID_PARAMETER;
601 }
602 return VINF_SUCCESS;
603}
604
605
606/**
607 * @interface_method_impl{RTVFSOBJSETOPS,pfnMode}
608 */
609static DECLCALLBACK(int) rtDvmVfsDir_SetMode(void *pvThis, RTFMODE fMode, RTFMODE fMask)
610{
611 NOREF(pvThis); NOREF(fMode); NOREF(fMask);
612 return VERR_NOT_SUPPORTED;
613}
614
615
616/**
617 * @interface_method_impl{RTVFSOBJSETOPS,pfnSetTimes}
618 */
619static DECLCALLBACK(int) rtDvmVfsDir_SetTimes(void *pvThis, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,
620 PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime)
621{
622 NOREF(pvThis); NOREF(pAccessTime); NOREF(pModificationTime); NOREF(pChangeTime); NOREF(pBirthTime);
623 return VERR_NOT_SUPPORTED;
624}
625
626
627/**
628 * @interface_method_impl{RTVFSOBJSETOPS,pfnSetOwner}
629 */
630static DECLCALLBACK(int) rtDvmVfsDir_SetOwner(void *pvThis, RTUID uid, RTGID gid)
631{
632 RT_NOREF(pvThis, uid, gid);
633 return VERR_NOT_SUPPORTED;
634}
635
636
637static int rtDvmVfsDir_FindEntry(PRTDVMVFSDIR pThis, const char *pszEntry, PRTDVMVOLUME phVolume)
638{
639 /*
640 * Enumerate the volumes and try match the volume name.
641 */
642 int rc;
643 PRTDVMVFSVOL pVfsVol = pThis->pVfsVol;
644 if (pVfsVol->cVolumes > 0)
645 {
646 /* The first volume. */
647 uint32_t iVol = 0;
648 RTDVMVOLUME hVol;
649 rc = RTDvmMapQueryFirstVolume(pThis->pVfsVol->hVolMgr, &hVol);
650 while (RT_SUCCESS(rc))
651 {
652 /* Match the name. */
653 bool fMatch;
654 char *pszVolName;
655 rc = RTDvmVolumeQueryName(hVol, &pszVolName);
656 if (RT_SUCCESS(rc))
657 {
658 fMatch = RTStrCmp(pszEntry, pszVolName) == 0 && *pszVolName != '\0';
659 RTStrFree(pszVolName);
660 }
661 else if (rc == VERR_NOT_SUPPORTED)
662 fMatch = false;
663 else
664 {
665 RTDvmVolumeRelease(hVol);
666 break;
667 }
668
669 /* Match the sequential volume number. */
670 if (!fMatch)
671 {
672 char szTmp[16];
673 RTStrPrintf(szTmp, sizeof(szTmp), "vol%u", iVol);
674 fMatch = RTStrCmp(pszEntry, szTmp) == 0;
675 }
676
677 if (fMatch)
678 {
679 *phVolume = hVol;
680 return VINF_SUCCESS;
681 }
682
683 /* More volumes? */
684 iVol++;
685 if (iVol >= pVfsVol->cVolumes)
686 {
687 RTDvmVolumeRelease(hVol);
688 rc = VERR_FILE_NOT_FOUND;
689 break;
690 }
691
692 /* Get the next volume. */
693 RTDVMVOLUME hVolNext;
694 rc = RTDvmMapQueryNextVolume(pThis->pVfsVol->hVolMgr, hVol, &hVolNext);
695 RTDvmVolumeRelease(hVol);
696 hVol = hVolNext;
697 }
698 }
699 else
700 rc = VERR_FILE_NOT_FOUND;
701 return rc;
702}
703
704
705/**
706 * @interface_method_impl{RTVFSDIROPS,pfnOpen}
707 */
708static DECLCALLBACK(int) rtDvmVfsDir_Open(void *pvThis, const char *pszEntry, uint64_t fOpen, uint32_t fFlags, PRTVFSOBJ phVfsObj)
709{
710 PRTDVMVFSDIR pThis = (PRTDVMVFSDIR)pvThis;
711
712 /*
713 * Special case: '.' and '..'
714 */
715 if ( pszEntry[0] == '.'
716 && ( pszEntry[1] == '\0'
717 || ( pszEntry[1] == '.'
718 && pszEntry[2] == '\0')))
719 {
720 if ( (fOpen & RTFILE_O_ACTION_MASK) == RTFILE_O_OPEN
721 || (fOpen & RTFILE_O_ACTION_MASK) == RTFILE_O_OPEN_CREATE
722 || (fOpen & RTFILE_O_ACTION_MASK) == RTFILE_O_CREATE_REPLACE)
723 {
724 if (fFlags & RTVFSOBJ_F_OPEN_DIRECTORY)
725 {
726 RTVFSDIR hVfsDir;
727 int rc = rtDvmVfsVol_OpenRoot(pThis->pVfsVol, &hVfsDir);
728 if (RT_SUCCESS(rc))
729 {
730 *phVfsObj = RTVfsObjFromDir(hVfsDir);
731 RTVfsDirRelease(hVfsDir);
732 AssertStmt(*phVfsObj != NIL_RTVFSOBJ, rc = VERR_INTERNAL_ERROR_3);
733 }
734 return rc;
735 }
736 return VERR_IS_A_DIRECTORY;
737 }
738 return VERR_ACCESS_DENIED;
739 }
740
741 /*
742 * Open volume file.
743 */
744 RTDVMVOLUME hVolume = NIL_RTDVMVOLUME;
745 int rc = rtDvmVfsDir_FindEntry(pThis, pszEntry, &hVolume);
746 if (RT_SUCCESS(rc))
747 {
748 if ( (fOpen & RTFILE_O_ACTION_MASK) == RTFILE_O_OPEN
749 || (fOpen & RTFILE_O_ACTION_MASK) == RTFILE_O_OPEN_CREATE
750 || (fOpen & RTFILE_O_ACTION_MASK) == RTFILE_O_CREATE_REPLACE)
751 {
752 if (fFlags & (RTVFSOBJ_F_OPEN_FILE | RTVFSOBJ_F_OPEN_DEV_BLOCK))
753 {
754 if ( !(fOpen & RTFILE_O_WRITE)
755 || !pThis->pVfsVol->fReadOnly)
756 {
757 RTVFSFILE hVfsFile;
758 rc = rtDvmVfsCreateFileForVolume(pThis->pVfsVol, hVolume, fOpen, &hVfsFile);
759 if (RT_SUCCESS(rc))
760 {
761 *phVfsObj = RTVfsObjFromFile(hVfsFile);
762 RTVfsFileRelease(hVfsFile);
763 AssertStmt(*phVfsObj != NIL_RTVFSOBJ, rc = VERR_INTERNAL_ERROR_3);
764 }
765 }
766 else
767 rc = VERR_WRITE_PROTECT;
768 }
769 else
770 rc = VERR_IS_A_FILE;
771 }
772 else
773 rc = VERR_ALREADY_EXISTS;
774 RTDvmVolumeRelease(hVolume);
775 }
776 return rc;
777}
778
779
780/**
781 * @interface_method_impl{RTVFSDIROPS,pfnOpenFile}
782 */
783static DECLCALLBACK(int) rtDvmVfsDir_OpenFile(void *pvThis, const char *pszFilename, uint64_t fOpen, PRTVFSFILE phVfsFile)
784{
785 RTVFSOBJ hVfsObj;
786 int rc = rtDvmVfsDir_Open(pvThis, pszFilename, fOpen, RTVFSOBJ_F_OPEN_FILE, &hVfsObj);
787 if (RT_SUCCESS(rc))
788 {
789 *phVfsFile = RTVfsObjToFile(hVfsObj);
790 RTVfsObjRelease(hVfsObj);
791 }
792 return rc;
793}
794
795
796/**
797 * @interface_method_impl{RTVFSDIROPS,pfnCreateDir}
798 */
799static DECLCALLBACK(int) rtDvmVfsDir_CreateDir(void *pvThis, const char *pszSubDir, RTFMODE fMode, PRTVFSDIR phVfsDir)
800{
801 RT_NOREF(pvThis, pszSubDir, fMode, phVfsDir);
802 return VERR_NOT_SUPPORTED;
803}
804
805
806/**
807 * @interface_method_impl{RTVFSDIROPS,pfnOpenSymlink}
808 */
809static DECLCALLBACK(int) rtDvmVfsDir_OpenSymlink(void *pvThis, const char *pszSymlink, PRTVFSSYMLINK phVfsSymlink)
810{
811 RT_NOREF(pvThis, pszSymlink, phVfsSymlink);
812 return VERR_NOT_SUPPORTED;
813}
814
815
816/**
817 * @interface_method_impl{RTVFSDIROPS,pfnCreateSymlink}
818 */
819static DECLCALLBACK(int) rtDvmVfsDir_CreateSymlink(void *pvThis, const char *pszSymlink, const char *pszTarget,
820 RTSYMLINKTYPE enmType, PRTVFSSYMLINK phVfsSymlink)
821{
822 RT_NOREF(pvThis, pszSymlink, pszTarget, enmType, phVfsSymlink);
823 return VERR_NOT_SUPPORTED;
824}
825
826
827/**
828 * @interface_method_impl{RTVFSDIROPS,pfnUnlinkEntry}
829 */
830static DECLCALLBACK(int) rtDvmVfsDir_UnlinkEntry(void *pvThis, const char *pszEntry, RTFMODE fType)
831{
832 RT_NOREF(pvThis, pszEntry, fType);
833 return VERR_NOT_IMPLEMENTED;
834}
835
836
837/**
838 * @interface_method_impl{RTVFSDIROPS,pfnRenameEntry}
839 */
840static DECLCALLBACK(int) rtDvmVfsDir_RenameEntry(void *pvThis, const char *pszEntry, RTFMODE fType, const char *pszNewName)
841{
842 RT_NOREF(pvThis, pszEntry, fType, pszNewName);
843 return VERR_NOT_IMPLEMENTED;
844}
845
846
847/**
848 * @interface_method_impl{RTVFSDIROPS,pfnRewindDir}
849 */
850static DECLCALLBACK(int) rtDvmVfsDir_RewindDir(void *pvThis)
851{
852 PRTDVMVFSDIR pThis = (PRTDVMVFSDIR)pvThis;
853
854 if (pThis->hCurVolume != NIL_RTDVMVOLUME)
855 {
856 RTDvmVolumeRelease(pThis->hCurVolume);
857 pThis->hCurVolume = NIL_RTDVMVOLUME;
858 }
859 pThis->fReturnCurrent = false;
860 pThis->offDir = 0;
861
862 return VINF_SUCCESS;
863}
864
865
866/**
867 * @interface_method_impl{RTVFSDIROPS,pfnReadDir}
868 */
869static DECLCALLBACK(int) rtDvmVfsDir_ReadDir(void *pvThis, PRTDIRENTRYEX pDirEntry, size_t *pcbDirEntry,
870 RTFSOBJATTRADD enmAddAttr)
871{
872 PRTDVMVFSDIR pThis = (PRTDVMVFSDIR)pvThis;
873 PRTDVMVFSVOL pVfsVol = pThis->pVfsVol;
874 int rc;
875
876 /*
877 * Get the volume to return info about.
878 */
879 if (!pThis->fReturnCurrent)
880 {
881 if (pThis->offDir < pVfsVol->cVolumes)
882 {
883 RTDVMVOLUME hNextVolume;
884 if (pThis->offDir == 0)
885 rc = RTDvmMapQueryFirstVolume(pVfsVol->hVolMgr, &hNextVolume);
886 else
887 rc = RTDvmMapQueryNextVolume(pVfsVol->hVolMgr, pThis->hCurVolume, &hNextVolume);
888 if (RT_FAILURE(rc))
889 return rc;
890 RTDvmVolumeRelease(pThis->hCurVolume);
891 pThis->hCurVolume = hNextVolume;
892 }
893 else
894 {
895 RTDvmVolumeRelease(pThis->hCurVolume);
896 pThis->hCurVolume = NIL_RTDVMVOLUME;
897 return VERR_NO_MORE_FILES;
898 }
899 }
900
901 /*
902 * Figure out the name length.
903 */
904 char szVolNo[16];
905 RTStrPrintf(szVolNo, sizeof(szVolNo), "vol%u", pThis->offDir);
906
907 char *pszVolName;
908 rc = RTDvmVolumeQueryName(pThis->hCurVolume, &pszVolName);
909 if ( RT_SUCCESS(rc)
910 || rc == VERR_NOT_SUPPORTED)
911 {
912 if (rc == VERR_NOT_SUPPORTED)
913 pszVolName = szVolNo;
914 else if (*pszVolName == '\0')
915 {
916 RTStrFree(pszVolName);
917 pszVolName = szVolNo;
918 }
919
920 size_t cchVolName = strlen(pszVolName);
921 size_t cbNeeded = RT_OFFSETOF(RTDIRENTRYEX, szName[cchVolName + 1]);
922 if (cbNeeded <= *pcbDirEntry)
923 {
924 *pcbDirEntry = cbNeeded;
925
926 /* Do the names. */
927 pDirEntry->cbName = (uint16_t)cchVolName;
928 memcpy(pDirEntry->szName, pszVolName, cchVolName + 1);
929 if (pszVolName != szVolNo)
930 {
931 RTStrFree(pszVolName);
932
933 PRTUTF16 pwszShortName = pDirEntry->wszShortName;
934 size_t cwcShortName = 0;
935 rc = RTStrToUtf16Ex(szVolNo, RTSTR_MAX, &pwszShortName, RT_ELEMENTS(pDirEntry->wszShortName), &cwcShortName);
936 AssertRC(rc);
937 pDirEntry->cwcShortName = (uint16_t)cwcShortName;
938 }
939 else
940 {
941 pDirEntry->cwcShortName = 0;
942 pDirEntry->wszShortName[0] = '\0';
943 }
944
945 /* Do the rest. */
946 rc = rtDvmVfsFile_QueryInfoWorker(pThis->hCurVolume, pVfsVol->hVolMgr, pVfsVol->fReadOnly,
947 &pDirEntry->Info, enmAddAttr);
948 pThis->fReturnCurrent = !RT_SUCCESS(rc);
949 pThis->offDir += RT_SUCCESS(rc);
950 return rc;
951 }
952
953 *pcbDirEntry = cbNeeded;
954 rc = VERR_BUFFER_OVERFLOW;
955
956 if (pszVolName != szVolNo)
957 RTStrFree(pszVolName);
958 }
959
960 pThis->fReturnCurrent = true;
961 return rc;
962}
963
964
965/**
966 * DVM (root) directory operations.
967 */
968static const RTVFSDIROPS g_rtDvmVfsDirOps =
969{
970 { /* Obj */
971 RTVFSOBJOPS_VERSION,
972 RTVFSOBJTYPE_DIR,
973 "DvmDir",
974 rtDvmVfsDir_Close,
975 rtDvmVfsDir_QueryInfo,
976 RTVFSOBJOPS_VERSION
977 },
978 RTVFSDIROPS_VERSION,
979 0,
980 { /* ObjSet */
981 RTVFSOBJSETOPS_VERSION,
982 RT_OFFSETOF(RTVFSDIROPS, Obj) - RT_OFFSETOF(RTVFSDIROPS, ObjSet),
983 rtDvmVfsDir_SetMode,
984 rtDvmVfsDir_SetTimes,
985 rtDvmVfsDir_SetOwner,
986 RTVFSOBJSETOPS_VERSION
987 },
988 rtDvmVfsDir_Open,
989 NULL /* pfnFollowAbsoluteSymlink */,
990 rtDvmVfsDir_OpenFile,
991 NULL /* pfnOpenDir */,
992 rtDvmVfsDir_CreateDir,
993 rtDvmVfsDir_OpenSymlink,
994 rtDvmVfsDir_CreateSymlink,
995 NULL /* pfnQueryEntryInfo */,
996 rtDvmVfsDir_UnlinkEntry,
997 rtDvmVfsDir_RenameEntry,
998 rtDvmVfsDir_RewindDir,
999 rtDvmVfsDir_ReadDir,
1000 RTVFSDIROPS_VERSION,
1001};
1002
1003
1004
1005/**
1006 * @interface_method_impl{RTVFSOBJOPS::Obj,pfnClose}
1007 */
1008static DECLCALLBACK(int) rtDvmVfsVol_Close(void *pvThis)
1009{
1010 PRTDVMVFSVOL pThis = (PRTDVMVFSVOL)pvThis;
1011 LogFlow(("rtDvmVfsVol_Close(%p)\n", pThis));
1012
1013 if ( pThis->fCloseDvm
1014 && pThis->hVolMgr != NIL_RTDVM )
1015 RTDvmRelease(pThis->hVolMgr);
1016 pThis->hVolMgr = NIL_RTDVM;
1017
1018 return VINF_SUCCESS;
1019}
1020
1021
1022/**
1023 * @interface_method_impl{RTVFSOBJOPS::Obj,pfnQueryInfo}
1024 */
1025static DECLCALLBACK(int) rtDvmVfsVol_QueryInfo(void *pvThis, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr)
1026{
1027 RT_NOREF(pvThis, pObjInfo, enmAddAttr);
1028 return VERR_WRONG_TYPE;
1029}
1030
1031
1032/**
1033 * @interface_method_impl{RTVFSOPS,pfnOpenRoot}
1034 */
1035static DECLCALLBACK(int) rtDvmVfsVol_OpenRoot(void *pvThis, PRTVFSDIR phVfsDir)
1036{
1037 PRTDVMVFSVOL pThis = (PRTDVMVFSVOL)pvThis;
1038
1039 PRTDVMVFSDIR pNewDir;
1040 int rc = RTVfsNewDir(&g_rtDvmVfsDirOps, sizeof(*pNewDir), 0 /*fFlags*/, pThis->hVfsSelf,
1041 NIL_RTVFSLOCK /*use volume lock*/, phVfsDir, (void **)&pNewDir);
1042 if (RT_SUCCESS(rc))
1043 {
1044 pNewDir->offDir = 0;
1045 pNewDir->pVfsVol = pThis;
1046 pNewDir->fReturnCurrent = false;
1047 pNewDir->hCurVolume = NIL_RTDVMVOLUME;
1048 }
1049 return rc;
1050}
1051
1052
1053/**
1054 * @interface_method_impl{RTVFSOPS,pfnQueryRangeState}
1055 */
1056static DECLCALLBACK(int) rtDvmVfsVol_QueryRangeState(void *pvThis, uint64_t off, size_t cb, bool *pfUsed)
1057{
1058 RT_NOREF(pvThis, off, cb, pfUsed);
1059 return VERR_NOT_IMPLEMENTED;
1060}
1061
1062
1063DECL_HIDDEN_CONST(const RTVFSOPS) g_rtDvmVfsVolOps =
1064{
1065 { /* Obj */
1066 RTVFSOBJOPS_VERSION,
1067 RTVFSOBJTYPE_VFS,
1068 "DvmVol",
1069 rtDvmVfsVol_Close,
1070 rtDvmVfsVol_QueryInfo,
1071 RTVFSOBJOPS_VERSION
1072 },
1073 RTVFSOPS_VERSION,
1074 0 /* fFeatures */,
1075 rtDvmVfsVol_OpenRoot,
1076 rtDvmVfsVol_QueryRangeState,
1077 RTVFSOPS_VERSION
1078};
1079
1080
1081
1082/**
1083 * @interface_method_impl{RTVFSCHAINELEMENTREG,pfnValidate}
1084 */
1085static DECLCALLBACK(int) rtDvmVfsChain_Validate(PCRTVFSCHAINELEMENTREG pProviderReg, PRTVFSCHAINSPEC pSpec,
1086 PRTVFSCHAINELEMSPEC pElement, uint32_t *poffError, PRTERRINFO pErrInfo)
1087{
1088 RT_NOREF(pProviderReg, pSpec);
1089
1090 /*
1091 * Basic checks.
1092 */
1093 if (pElement->enmTypeIn != RTVFSOBJTYPE_FILE)
1094 return pElement->enmTypeIn == RTVFSOBJTYPE_INVALID ? VERR_VFS_CHAIN_CANNOT_BE_FIRST_ELEMENT : VERR_VFS_CHAIN_TAKES_FILE;
1095 if (pElement->enmType != RTVFSOBJTYPE_VFS)
1096 return VERR_VFS_CHAIN_ONLY_VFS;
1097
1098 if (pElement->cArgs > 1)
1099 return VERR_VFS_CHAIN_AT_MOST_ONE_ARG;
1100
1101 /*
1102 * Parse the flag if present, save in pElement->uProvider.
1103 */
1104 /** @todo allow specifying sector size */
1105 bool fReadOnly = (pSpec->fOpenFile & RTFILE_O_ACCESS_MASK) == RTFILE_O_READ;
1106 if (pElement->cArgs > 0)
1107 {
1108 const char *psz = pElement->paArgs[0].psz;
1109 if (*psz)
1110 {
1111 if ( !strcmp(psz, "ro")
1112 || !strcmp(psz, "r"))
1113 fReadOnly = true;
1114 else if (!strcmp(psz, "rw"))
1115 fReadOnly = false;
1116 else
1117 {
1118 *poffError = pElement->paArgs[0].offSpec;
1119 return RTErrInfoSet(pErrInfo, VERR_VFS_CHAIN_INVALID_ARGUMENT, "Expected 'ro' or 'rw' as argument");
1120 }
1121 }
1122 }
1123
1124 pElement->uProvider = fReadOnly;
1125 return VINF_SUCCESS;
1126}
1127
1128
1129/**
1130 * @interface_method_impl{RTVFSCHAINELEMENTREG,pfnInstantiate}
1131 */
1132static DECLCALLBACK(int) rtDvmVfsChain_Instantiate(PCRTVFSCHAINELEMENTREG pProviderReg, PCRTVFSCHAINSPEC pSpec,
1133 PCRTVFSCHAINELEMSPEC pElement, RTVFSOBJ hPrevVfsObj,
1134 PRTVFSOBJ phVfsObj, uint32_t *poffError, PRTERRINFO pErrInfo)
1135{
1136 RT_NOREF(pProviderReg, pSpec, poffError, pErrInfo);
1137 AssertReturn(hPrevVfsObj != NIL_RTVFSOBJ, VERR_VFS_CHAIN_IPE);
1138
1139 /*
1140 * Instantiate the volume manager and open the map stuff.
1141 */
1142 RTVFSFILE hPrevVfsFile = RTVfsObjToFile(hPrevVfsObj);
1143 AssertReturn(hPrevVfsFile != NIL_RTVFSFILE, VERR_VFS_CHAIN_CAST_FAILED);
1144
1145 RTDVM hVolMgr;
1146 int rc = RTDvmCreate(&hVolMgr, hPrevVfsFile, 512, 0 /*fFlags*/);
1147 RTVfsFileRelease(hPrevVfsFile);
1148 if (RT_SUCCESS(rc))
1149 {
1150 rc = RTDvmMapOpen(hVolMgr);
1151 if (RT_SUCCESS(rc))
1152 {
1153 /*
1154 * Create a VFS instance for the volume manager.
1155 */
1156 RTVFS hVfs = NIL_RTVFS;
1157 PRTDVMVFSVOL pThis = NULL;
1158 rc = RTVfsNew(&g_rtDvmVfsVolOps, sizeof(RTDVMVFSVOL), NIL_RTVFS, RTVFSLOCK_CREATE_RW, &hVfs, (void **)&pThis);
1159 if (RT_SUCCESS(rc))
1160 {
1161 pThis->hVolMgr = hVolMgr;
1162 pThis->fCloseDvm = true;
1163 pThis->fReadOnly = pElement->uProvider == (uint64_t)true;
1164 pThis->cVolumes = RTDvmMapGetValidVolumes(hVolMgr);
1165 pThis->hVfsSelf = hVfs;
1166
1167 *phVfsObj = RTVfsObjFromVfs(hVfs);
1168 RTVfsRelease(hVfs);
1169 return *phVfsObj != NIL_RTVFSOBJ ? VINF_SUCCESS : VERR_VFS_CHAIN_CAST_FAILED;
1170 }
1171 }
1172 else
1173 rc = RTErrInfoSetF(pErrInfo, rc, "RTDvmMapOpen failed: %Rrc", rc);
1174 RTDvmRelease(hVolMgr);
1175 }
1176 else
1177 rc = RTErrInfoSetF(pErrInfo, rc, "RTDvmCreate failed: %Rrc", rc);
1178 return rc;
1179}
1180
1181
1182/**
1183 * @interface_method_impl{RTVFSCHAINELEMENTREG,pfnCanReuseElement}
1184 */
1185static DECLCALLBACK(bool) rtDvmVfsChain_CanReuseElement(PCRTVFSCHAINELEMENTREG pProviderReg,
1186 PCRTVFSCHAINSPEC pSpec, PCRTVFSCHAINELEMSPEC pElement,
1187 PCRTVFSCHAINSPEC pReuseSpec, PCRTVFSCHAINELEMSPEC pReuseElement)
1188{
1189 RT_NOREF(pProviderReg, pSpec, pElement, pReuseSpec, pReuseElement);
1190 return false;
1191}
1192
1193
1194/** VFS chain element 'file'. */
1195static RTVFSCHAINELEMENTREG g_rtVfsChainIsoFsVolReg =
1196{
1197 /* uVersion = */ RTVFSCHAINELEMENTREG_VERSION,
1198 /* fReserved = */ 0,
1199 /* pszName = */ "dvm",
1200 /* ListEntry = */ { NULL, NULL },
1201 /* pszHelp = */ "Opens a container image using the VD API.\n"
1202 "Optionally takes one parameter 'ro' (read only) or 'rw' (read write).\n",
1203 /* pfnValidate = */ rtDvmVfsChain_Validate,
1204 /* pfnInstantiate = */ rtDvmVfsChain_Instantiate,
1205 /* pfnCanReuseElement = */ rtDvmVfsChain_CanReuseElement,
1206 /* uEndMarker = */ RTVFSCHAINELEMENTREG_VERSION
1207};
1208
1209RTVFSCHAIN_AUTO_REGISTER_ELEMENT_PROVIDER(&g_rtVfsChainIsoFsVolReg, rtVfsChainIsoFsVolReg);
1210
Note: See TracBrowser for help on using the repository browser.

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