diff options
author | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2022-03-17 13:29:52 +0000 |
---|---|---|
committer | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2022-03-17 13:29:52 +0000 |
commit | 8f011a6a97d46c6b8681d590c0d674e0d8220711 (patch) | |
tree | e295a2b4d0efc3006de24661652c219ea8cd325a /src/VBox | |
parent | 83fc64a82b09d8eab197dd0b70eaad5f1efbf817 (diff) | |
download | VirtualBox-svn-8f011a6a97d46c6b8681d590c0d674e0d8220711.tar.gz |
IPRT,Storage: Adding RTVfsQueryLabel and internally a generic pfnQueryInfoEx method to the RTVFSOBJOPS function table. Untested implementation of the latter for iso/udf. bugref:9781
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@94291 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'src/VBox')
26 files changed, 295 insertions, 3 deletions
diff --git a/src/VBox/Runtime/common/checksum/manifest3.cpp b/src/VBox/Runtime/common/checksum/manifest3.cpp index 08b1dc314c7..9ac4eaf100d 100644 --- a/src/VBox/Runtime/common/checksum/manifest3.cpp +++ b/src/VBox/Runtime/common/checksum/manifest3.cpp @@ -505,6 +505,7 @@ static RTVFSIOSTREAMOPS g_rtManifestPassthruIosOps = "manifest passthru I/O stream", rtManifestPtIos_Close, rtManifestPtIos_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, diff --git a/src/VBox/Runtime/common/dvm/dvmvfs.cpp b/src/VBox/Runtime/common/dvm/dvmvfs.cpp index 5530e582609..a07fb67e580 100644 --- a/src/VBox/Runtime/common/dvm/dvmvfs.cpp +++ b/src/VBox/Runtime/common/dvm/dvmvfs.cpp @@ -484,6 +484,7 @@ DECL_HIDDEN_CONST(const RTVFSFILEOPS) g_rtDvmVfsStdFileOps = "DvmFile", rtDvmVfsFile_Close, rtDvmVfsFile_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, @@ -642,6 +643,7 @@ static const RTVFSSYMLINKOPS g_rtDvmVfsSymOps = "DvmSymlink", rtDvmVfsSym_Close, rtDvmVfsSym_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSSYMLINKOPS_VERSION, @@ -1215,6 +1217,7 @@ static const RTVFSDIROPS g_rtDvmVfsDirOps = "DvmDir", rtDvmVfsDir_Close, rtDvmVfsDir_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSDIROPS_VERSION, @@ -1311,6 +1314,7 @@ DECL_HIDDEN_CONST(const RTVFSOPS) g_rtDvmVfsVolOps = "DvmVol", rtDvmVfsVol_Close, rtDvmVfsVol_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSOPS_VERSION, diff --git a/src/VBox/Runtime/common/efi/efivarstorevfs.cpp b/src/VBox/Runtime/common/efi/efivarstorevfs.cpp index 17197d7e41f..4ddca3e4a0e 100644 --- a/src/VBox/Runtime/common/efi/efivarstorevfs.cpp +++ b/src/VBox/Runtime/common/efi/efivarstorevfs.cpp @@ -1266,6 +1266,7 @@ static const RTVFSFILEOPS g_rtEfiVarStoreFileOps = "EfiVarStore File", rtEfiVarStoreFile_Close, rtEfiVarStoreFile_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, @@ -1850,6 +1851,7 @@ static const RTVFSDIROPS g_rtEfiVarStoreDirOps = "EfiVarStore Dir", rtEfiVarStoreDir_Close, rtEfiVarStoreDir_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSDIROPS_VERSION, @@ -2017,6 +2019,7 @@ DECL_HIDDEN_CONST(const RTVFSOPS) g_rtEfiVarStoreOps = /* .pszName = */ "EfiVarStore", /* .pfnClose = */ rtEfiVarStore_Close, /* .pfnQueryInfo = */ rtEfiVarStore_QueryInfo, + /* .pfnQueryInfoEx = */ NULL, /* .uEndMarker = */ RTVFSOBJOPS_VERSION }, /* .uVersion = */ RTVFSOPS_VERSION, diff --git a/src/VBox/Runtime/common/fs/extvfs.cpp b/src/VBox/Runtime/common/fs/extvfs.cpp index b8acadc9829..089a8e00f36 100644 --- a/src/VBox/Runtime/common/fs/extvfs.cpp +++ b/src/VBox/Runtime/common/fs/extvfs.cpp @@ -1909,6 +1909,7 @@ static const RTVFSFILEOPS g_rtFsExtFileOps = "EXT File", rtFsExtFile_Close, rtFsExtFile_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, @@ -2337,6 +2338,7 @@ static const RTVFSDIROPS g_rtFsExtDirOps = "EXT Dir", rtFsExtDir_Close, rtFsExtDir_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSDIROPS_VERSION, @@ -2574,6 +2576,7 @@ DECL_HIDDEN_CONST(const RTVFSOPS) g_rtFsExtVolOps = /* .pszName = */ "ExtVol", /* .pfnClose = */ rtFsExtVol_Close, /* .pfnQueryInfo = */ rtFsExtVol_QueryInfo, + /* .pfnQueryInfoEx = */ NULL, /* .uEndMarker = */ RTVFSOBJOPS_VERSION }, /* .uVersion = */ RTVFSOPS_VERSION, diff --git a/src/VBox/Runtime/common/fs/fatvfs.cpp b/src/VBox/Runtime/common/fs/fatvfs.cpp index a36b794d2c2..ec1a506cbde 100644 --- a/src/VBox/Runtime/common/fs/fatvfs.cpp +++ b/src/VBox/Runtime/common/fs/fatvfs.cpp @@ -2565,6 +2565,7 @@ DECL_HIDDEN_CONST(const RTVFSFILEOPS) g_rtFsFatFileOps = "FatFile", rtFsFatFile_Close, rtFsFatFile_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, @@ -4634,6 +4635,7 @@ static const RTVFSDIROPS g_rtFsFatDirOps = "FatDir", rtFsFatDir_Close, rtFsFatDir_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSDIROPS_VERSION, @@ -5000,6 +5002,7 @@ DECL_HIDDEN_CONST(const RTVFSOPS) g_rtFsFatVolOps = "FatVol", rtFsFatVol_Close, rtFsFatVol_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSOPS_VERSION, diff --git a/src/VBox/Runtime/common/fs/isomaker.cpp b/src/VBox/Runtime/common/fs/isomaker.cpp index a33de17eb10..a44dff12882 100644 --- a/src/VBox/Runtime/common/fs/isomaker.cpp +++ b/src/VBox/Runtime/common/fs/isomaker.cpp @@ -7453,6 +7453,7 @@ DECL_HIDDEN_CONST(const RTVFSFILEOPS) g_rtFsIsoMakerOutputFileOps = "ISO Maker Output File", rtFsIsoMakerOutFile_Close, rtFsIsoMakerOutFile_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, diff --git a/src/VBox/Runtime/common/fs/isovfs.cpp b/src/VBox/Runtime/common/fs/isovfs.cpp index f72da7941e9..210670aabda 100644 --- a/src/VBox/Runtime/common/fs/isovfs.cpp +++ b/src/VBox/Runtime/common/fs/isovfs.cpp @@ -130,11 +130,12 @@ else if ((a_pStruct)->a_Member[0] == 16) \ { \ PCRTUTF16 pwszTmp = (PCRTUTF16)&(a_pStruct)->a_Member[1]; \ - char *pszTmp = NULL; \ + char *pszTmp = NULL; \ RTUtf16BigToUtf8Ex(pwszTmp, (sizeof((a_pStruct)->a_Member) - 2) / sizeof(RTUTF16), &pszTmp, 0, NULL); \ Log2(("ISO/UDF: %-32s 16: '%s' len=%u (actual=%u)\n", #a_Member ":", pszTmp, \ (a_pStruct)->a_Member[sizeof((a_pStruct)->a_Member) - 1], \ RTUtf16NLen(pwszTmp, (sizeof((a_pStruct)->a_Member) - 2) / sizeof(RTUTF16)) * sizeof(RTUTF16) + 1 /*??*/ )); \ + RTStrFree(pszTmp); \ } \ else if (ASMMemIsZero(&(a_pStruct)->a_Member[0], sizeof((a_pStruct)->a_Member))) \ Log2(("ISO/UDF: %-32s empty\n", #a_Member ":")); \ @@ -426,8 +427,10 @@ typedef struct RTFSISOUDFVOLINFO */ typedef enum RTFSISOVOLTYPE { + /** Invalid zero value. */ + RTFSISOVOLTYPE_INVALID = 0, /** Accessing the primary ISO-9660 volume. */ - RTFSISOVOLTYPE_ISO9960 = 0, + RTFSISOVOLTYPE_ISO9960, /** Accessing the joliet volume (secondary ISO-9660). */ RTFSISOVOLTYPE_JOLIET, /** Accessing the UDF volume. */ @@ -466,6 +469,10 @@ typedef struct RTFSISOVOL uint32_t cVolumesInSet; /** The primary volume sequence ID. */ uint32_t idPrimaryVol; + /** The offset of the primary volume descriptor. */ + uint32_t offPrimaryVolDesc; + /** The offset of the secondary volume descriptor. */ + uint32_t offSecondaryVolDesc; /** Set if using UTF16-2 (joliet). */ bool fIsUtf16; /** @} */ @@ -2294,6 +2301,7 @@ DECL_HIDDEN_CONST(const RTVFSFILEOPS) g_rtFsIsoFileOps = "FatFile", rtFsIsoFile_Close, rtFsIsoFile_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, @@ -4378,6 +4386,7 @@ static const RTVFSDIROPS g_rtFsIsoDirOps = "ISO 9660 Dir", rtFsIsoDir_Close, rtFsIsoDir_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSDIROPS_VERSION, @@ -4884,6 +4893,194 @@ static DECLCALLBACK(int) rtFsIsoVol_QueryInfo(void *pvThis, PRTFSOBJINFO pObjInf } +static int rtFsIsoVol_ReturnUdfDString(const char *pachSrc, size_t cchSrc, void *pvDst, size_t cbDst, size_t *pcbRet) +{ + char *pszDst = (char *)pvDst; + + if (pachSrc[0] == 8) + { + uint8_t const cchText = RT_MIN((uint8_t)pachSrc[cchSrc - 1], cchSrc - 2); + size_t const cchActual = RTStrNLen(&pachSrc[1], cchText); + *pcbRet = cchActual + 1; + int rc = RTStrCopyEx(pszDst, cbDst, &pachSrc[1], cchActual); + if (cbDst > 0) + RTStrPurgeEncoding(pszDst); + return rc; + } + + if (pachSrc[0] == 16) + { + PCRTUTF16 pwszSrc = (PCRTUTF16)&pachSrc[1]; + if (cchSrc > 0) + return RTUtf16BigToUtf8Ex(pwszSrc, (cchSrc - 2) / sizeof(RTUTF16), &pszDst, cchSrc, pcbRet); + int rc = RTUtf16CalcUtf8LenEx(pwszSrc, (cchSrc - 2) / sizeof(RTUTF16), pcbRet); + if (RT_SUCCESS(rc)) + { + *pcbRet += 1; + return VERR_BUFFER_OVERFLOW; + } + return rc; + } + + if (ASMMemIsZero(pachSrc, cchSrc)) + { + *pcbRet = 1; + if (cbDst >= 1) + { + *pszDst = '\0'; + return VINF_SUCCESS; + } + return VERR_BUFFER_OVERFLOW; + } + + *pcbRet = 0; + return VERR_INVALID_UTF8_ENCODING; /** @todo better status here */ +} + + +/** + * For now this is a sanitized version of rtFsIsoVolGetMaybeUtf16Be, which is + * probably not correct or anything, but will have to do for now. + */ +static int rtFsIsoVol_ReturnIso9660D1String(const char *pachSrc, size_t cchSrc, void *pvDst, size_t cbDst, size_t *pcbRet) +{ + char *pszDst = (char *)pvDst; + + /* + * Check if it may be some UTF16 variant by scanning for zero bytes + * (ISO-9660 doesn't allow zeros). + */ + size_t cFirstZeros = 0; + size_t cSecondZeros = 0; + for (size_t off = 0; off + 1 < cchSrc; off += 2) + { + cFirstZeros += pachSrc[off] == '\0'; + cSecondZeros += pachSrc[off + 1] == '\0'; + } + if (cFirstZeros > cSecondZeros) + { + /* + * UTF-16BE / UTC-2BE: + */ + if (cchSrc & 1) + { + AssertReturn(pachSrc[cchSrc - 1] == '\0' || pachSrc[cchSrc - 1] == ' ', VERR_INVALID_UTF16_ENCODING); + cchSrc--; + } + while ( cchSrc >= 2 + && pachSrc[cchSrc - 1] == ' ' + && pachSrc[cchSrc - 2] == '\0') + cchSrc -= 2; + + if (cbDst > 0) + return RTUtf16BigToUtf8Ex((PCRTUTF16)pachSrc, cchSrc / sizeof(RTUTF16), &pszDst, cbDst, pcbRet); + int rc = RTUtf16BigCalcUtf8LenEx((PCRTUTF16)pachSrc, cchSrc / sizeof(RTUTF16), pcbRet); + if (RT_SUCCESS(rc)) + { + *pcbRet += 1; + return VERR_BUFFER_OVERFLOW; + } + return rc; + } + + if (cSecondZeros > 0) + { + /* + * Little endian UTF-16 / UCS-2. + */ + if (cchSrc & 1) + { + AssertReturn(pachSrc[cchSrc - 1] == '\0' || pachSrc[cchSrc - 1] == ' ', VERR_INVALID_UTF16_ENCODING); + cchSrc--; + } + while ( cchSrc >= 2 + && pachSrc[cchSrc - 1] == '\0' + && pachSrc[cchSrc - 2] == ' ') + cchSrc -= 2; + + if (cbDst) + return RTUtf16LittleToUtf8Ex((PCRTUTF16)pachSrc, cchSrc / sizeof(RTUTF16), &pszDst, cbDst, pcbRet); + int rc = RTUtf16LittleCalcUtf8LenEx((PCRTUTF16)pachSrc, cchSrc / sizeof(RTUTF16), pcbRet); + if (RT_SUCCESS(rc)) + { + *pcbRet += 1; + return VERR_BUFFER_OVERFLOW; + } + return rc; + } + + /* + * ASSUME UTF-8/ASCII. + */ + while ( cchSrc > 0 + && pachSrc[cchSrc - 1] == ' ') + cchSrc--; + + *pcbRet = cchSrc + 1; + int rc = RTStrCopyEx(pszDst, cbDst, pachSrc, cchSrc); + if (cbDst > 0) + RTStrPurgeEncoding(pszDst); + return rc; +} + + +static int rtFsIsoVol_ReturnIso9660DString(const char *pachSrc, size_t cchSrc, void *pvDst, size_t cbDst, size_t *pcbRet) +{ + /* Lazy bird: */ + return rtFsIsoVol_ReturnIso9660D1String(pachSrc, cchSrc, pvDst, cbDst, pcbRet); +} + + +/** + * @interface_method_impl{RTVFSOBJOPS::Obj,pfnQueryInfoEx} + */ +static DECLCALLBACK(int) rtFsIsoVol_QueryInfoEx(void *pvThis, RTVFSQIEX enmInfo, void *pvInfo, size_t cbInfo, size_t *pcbRet) +{ + PRTFSISOVOL pThis = (PRTFSISOVOL)pvThis; + LogFlow(("rtFsIsoVol_QueryInfo(%p, %d,, %#zx,)\n", pThis, enmInfo, cbInfo)); + + union + { + uint8_t ab[RTFSISO_MAX_LOGICAL_BLOCK_SIZE]; + ISO9660PRIMARYVOLDESC PriVolDesc; + ISO9660SUPVOLDESC SupVolDesc; + } uBuf; + + switch (enmInfo) + { + case RTVFSQIEX_VOL_LABEL: + { + if (pThis->enmType == RTFSISOVOLTYPE_UDF) + return rtFsIsoVol_ReturnUdfDString(pThis->Udf.VolInfo.achLogicalVolumeID, + sizeof(pThis->Udf.VolInfo.achLogicalVolumeID), pvInfo, cbInfo, pcbRet); + int rc = RTVfsFileReadAt(pThis->hVfsBacking, + pThis->enmType == RTFSISOVOLTYPE_ISO9960 + ? pThis->offPrimaryVolDesc : pThis->offSecondaryVolDesc, + uBuf.ab, RT_MAX(RT_MIN(pThis->cbSector, sizeof(uBuf)), sizeof(uBuf.PriVolDesc)), NULL); + AssertRCReturn(rc, rc); + switch (enmInfo) + { + case RTVFSQIEX_VOL_LABEL: + if (pThis->enmType == RTFSISOVOLTYPE_ISO9960) + return rtFsIsoVol_ReturnIso9660DString(uBuf.PriVolDesc.achVolumeId, sizeof(uBuf.PriVolDesc.achVolumeId), + pvInfo, cbInfo, pcbRet); + return rtFsIsoVol_ReturnIso9660D1String(uBuf.SupVolDesc.achVolumeId, sizeof(uBuf.SupVolDesc.achVolumeId), + pvInfo, cbInfo, pcbRet); + default: + AssertFailedReturn(VERR_INTERNAL_ERROR); + } + break; + } + + default: + return VERR_NOT_SUPPORTED; + + } + + return VINF_SUCCESS; +} + + /** * @interface_method_impl{RTVFSOPS,pfnOpenRoot} */ @@ -4914,6 +5111,7 @@ DECL_HIDDEN_CONST(const RTVFSOPS) g_rtFsIsoVolOps = "ISO 9660/UDF", rtFsIsoVol_Close, rtFsIsoVol_QueryInfo, + rtFsIsoVol_QueryInfoEx, RTVFSOBJOPS_VERSION }, RTVFSOPS_VERSION, @@ -6423,6 +6621,12 @@ static int rtFsIsoVolHandlePrimaryVolDesc(PRTFSISOVOL pThis, PCISO9660PRIMARYVOL "Unsupported file structure version: %#x", pVolDesc->bFileStructureVersion); /* + * Take down the location of the primary volume descriptor so we can get + * the volume lable and other info from it later. + */ + pThis->offPrimaryVolDesc = offVolDesc; + + /* * We need the block size ... */ pThis->cbBlock = RT_LE2H_U16(pVolDesc->cbLogicalBlock.le); @@ -6555,6 +6759,12 @@ static int rtFsIsoVolHandleSupplementaryVolDesc(PRTFSISOVOL pThis, PCISO9660SUPV *pbUcs2Level = pVolDesc->abEscapeSequences[2] == ISO9660_JOLIET_ESC_SEQ_2_LEVEL_1 ? 1 : pVolDesc->abEscapeSequences[2] == ISO9660_JOLIET_ESC_SEQ_2_LEVEL_2 ? 2 : 3; Log(("ISO9660: Joliet with UCS-2 level %u\n", *pbUcs2Level)); + + /* + * Take down the location of the secondary volume descriptor so we can get + * the volume lable and other info from it later. + */ + pThis->offSecondaryVolDesc = offVolDesc; } return rc; } @@ -6792,7 +7002,7 @@ static int rtFsIsoVolTryInit(PRTFSISOVOL pThis, RTVFS hVfsSelf, RTVFSFILE hVfsBa /* * If we found a UDF VRS and are interested in UDF, we have more work to do here. */ - if (uUdfLevel > 0 && !(fFlags & RTFSISO9660_F_NO_UDF) ) + if (uUdfLevel > 0 && !(fFlags & RTFSISO9660_F_NO_UDF)) { Log(("rtFsIsoVolTryInit: uUdfLevel=%d\n", uUdfLevel)); rc = rtFsIsoVolHandleUdfDetection(pThis, &uUdfLevel, offUdfBootVolDesc, Buf.ab, sizeof(Buf), pErrInfo); diff --git a/src/VBox/Runtime/common/fs/ntfsvfs.cpp b/src/VBox/Runtime/common/fs/ntfsvfs.cpp index a9a0285d36d..80fb3bba18c 100644 --- a/src/VBox/Runtime/common/fs/ntfsvfs.cpp +++ b/src/VBox/Runtime/common/fs/ntfsvfs.cpp @@ -2601,6 +2601,7 @@ static const RTVFSFILEOPS g_rtFsNtfsFileOps = "NTFS File", rtFsNtfsFile_Close, rtFsNtfsFile_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, @@ -4397,6 +4398,7 @@ static const RTVFSDIROPS g_rtFsNtfsDirOps = "NTFS Dir", rtFsNtfsDir_Close, rtFsNtfsDir_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSDIROPS_VERSION, @@ -4756,6 +4758,7 @@ static const RTVFSOPS g_rtFsNtfsVolOps = /* .pszName = */ "NtfsVol", /* .pfnClose = */ rtFsNtfsVol_Close, /* .pfnQueryInfo = */ rtFsNtfsVol_QueryInfo, + /* .pfnQueryInfoEx = */ NULL, /* .uEndMarker = */ RTVFSOBJOPS_VERSION }, /* .uVersion = */ RTVFSOPS_VERSION, diff --git a/src/VBox/Runtime/common/fs/xfsvfs.cpp b/src/VBox/Runtime/common/fs/xfsvfs.cpp index ec4f08f4cfa..aa963deb6d0 100644 --- a/src/VBox/Runtime/common/fs/xfsvfs.cpp +++ b/src/VBox/Runtime/common/fs/xfsvfs.cpp @@ -1667,6 +1667,7 @@ static const RTVFSFILEOPS g_rtFsXfsFileOps = "XFS File", rtFsXfsFile_Close, rtFsXfsFile_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, @@ -2041,6 +2042,7 @@ static const RTVFSDIROPS g_rtFsXfsDirOps = "XFS Dir", rtFsXfsDir_Close, rtFsXfsDir_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSDIROPS_VERSION, @@ -2222,6 +2224,7 @@ DECL_HIDDEN_CONST(const RTVFSOPS) g_rtFsXfsVolOps = /* .pszName = */ "XfsVol", /* .pfnClose = */ rtFsXfsVol_Close, /* .pfnQueryInfo = */ rtFsXfsVol_QueryInfo, + /* .pfnQueryInfoEx = */ NULL, /* .uEndMarker = */ RTVFSOBJOPS_VERSION }, /* .uVersion = */ RTVFSOPS_VERSION, diff --git a/src/VBox/Runtime/common/vfs/vfsbase.cpp b/src/VBox/Runtime/common/vfs/vfsbase.cpp index 892496b89d1..fded92f273f 100644 --- a/src/VBox/Runtime/common/vfs/vfsbase.cpp +++ b/src/VBox/Runtime/common/vfs/vfsbase.cpp @@ -71,6 +71,7 @@ Assert(*(a_pObjOps)->pszName); \ AssertPtr((a_pObjOps)->pfnClose); \ AssertPtr((a_pObjOps)->pfnQueryInfo); \ + AssertPtrNull((a_pObjOps)->pfnQueryInfoEx); \ Assert((a_pObjOps)->uEndMarker == RTVFSOBJOPS_VERSION); \ } while (0) @@ -2307,6 +2308,31 @@ RTDECL(int) RTVfsQueryRangeState(RTVFS hVfs, uint64_t off, size_t cb, bool *pfUs } +RTDECL(int) RTVfsQueryLabel(RTVFS hVfs, char *pszLabel, size_t cbLabel, size_t *pcbActual) +{ + RTVFSINTERNAL *pThis = hVfs; + AssertPtrReturn(pThis, VERR_INVALID_HANDLE); + AssertReturn(pThis->uMagic == RTVFS_MAGIC, VERR_INVALID_HANDLE); + + if (cbLabel > 0) + AssertPtrReturn(pszLabel, VERR_INVALID_POINTER); + + int rc; + if (pThis->pOps->Obj.pfnQueryInfoEx) + { + size_t cbActualIgn; + if (!pcbActual) + pcbActual = &cbActualIgn; + + RTVfsLockAcquireRead(pThis->Base.hLock); + rc = pThis->pOps->Obj.pfnQueryInfoEx(pThis->Base.pvThis, RTVFSQIEX_VOL_LABEL, pszLabel, cbLabel, pcbActual); + RTVfsLockReleaseRead(pThis->Base.hLock); + } + else + rc = VERR_NOT_SUPPORTED; + return rc; +} + /* diff --git a/src/VBox/Runtime/common/vfs/vfsfss2dir.cpp b/src/VBox/Runtime/common/vfs/vfsfss2dir.cpp index 333ac2ca0d8..bf57a65a725 100644 --- a/src/VBox/Runtime/common/vfs/vfsfss2dir.cpp +++ b/src/VBox/Runtime/common/vfs/vfsfss2dir.cpp @@ -283,6 +283,7 @@ static const RTVFSFSSTREAMOPS g_rtVfsFssToDirOps = "TarFsStreamWriter", rtVfsFssToDir_Close, rtVfsFssToDir_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSFSSTREAMOPS_VERSION, diff --git a/src/VBox/Runtime/common/vfs/vfsmemory.cpp b/src/VBox/Runtime/common/vfs/vfsmemory.cpp index 2a731d0ea57..fef47741ebc 100644 --- a/src/VBox/Runtime/common/vfs/vfsmemory.cpp +++ b/src/VBox/Runtime/common/vfs/vfsmemory.cpp @@ -730,6 +730,7 @@ DECL_HIDDEN_CONST(const RTVFSFILEOPS) g_rtVfsMemFileOps = "MemFile", rtVfsMemFile_Close, rtVfsMemFile_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, diff --git a/src/VBox/Runtime/common/vfs/vfsprogress.cpp b/src/VBox/Runtime/common/vfs/vfsprogress.cpp index db565e1867e..8ebf3e8039a 100644 --- a/src/VBox/Runtime/common/vfs/vfsprogress.cpp +++ b/src/VBox/Runtime/common/vfs/vfsprogress.cpp @@ -307,6 +307,7 @@ DECL_HIDDEN_CONST(const RTVFSIOSTREAMOPS) g_rtVfsProgressIosOps = "I/O Stream Progress", rtVfsProgressFile_Close, rtVfsProgressFile_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, @@ -438,6 +439,7 @@ DECL_HIDDEN_CONST(const RTVFSFILEOPS) g_rtVfsProgressFileOps = "File Progress", rtVfsProgressFile_Close, rtVfsProgressFile_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, diff --git a/src/VBox/Runtime/common/vfs/vfsreadahead.cpp b/src/VBox/Runtime/common/vfs/vfsreadahead.cpp index edd494d0ed1..7a114c8125c 100644 --- a/src/VBox/Runtime/common/vfs/vfsreadahead.cpp +++ b/src/VBox/Runtime/common/vfs/vfsreadahead.cpp @@ -534,6 +534,7 @@ DECL_HIDDEN_CONST(const RTVFSIOSTREAMOPS) g_VfsReadAheadIosOps = "Read ahead I/O stream", rtVfsReadAhead_Close, rtVfsReadAhead_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, @@ -561,6 +562,7 @@ DECL_HIDDEN_CONST(const RTVFSFILEOPS) g_VfsReadAheadFileOps = "Read ahead file", rtVfsReadAhead_Close, rtVfsReadAhead_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, diff --git a/src/VBox/Runtime/common/vfs/vfsstddir.cpp b/src/VBox/Runtime/common/vfs/vfsstddir.cpp index 04492691cc5..201f7119640 100644 --- a/src/VBox/Runtime/common/vfs/vfsstddir.cpp +++ b/src/VBox/Runtime/common/vfs/vfsstddir.cpp @@ -165,6 +165,7 @@ static const RTVFSSYMLINKOPS g_rtVfsStdSymOps = "StdSymlink", rtVfsStdSym_Close, rtVfsStdSym_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSSYMLINKOPS_VERSION, @@ -667,6 +668,7 @@ DECL_HIDDEN_CONST(const RTVFSDIROPS) g_rtVfsStdDirOps = "StdDir", rtVfsStdDir_Close, rtVfsStdDir_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSDIROPS_VERSION, diff --git a/src/VBox/Runtime/common/vfs/vfsstdfile.cpp b/src/VBox/Runtime/common/vfs/vfsstdfile.cpp index 68f6bedc09b..fc564b661a7 100644 --- a/src/VBox/Runtime/common/vfs/vfsstdfile.cpp +++ b/src/VBox/Runtime/common/vfs/vfsstdfile.cpp @@ -450,6 +450,7 @@ DECL_HIDDEN_CONST(const RTVFSFILEOPS) g_rtVfsStdFileOps = "StdFile", rtVfsStdFile_Close, rtVfsStdFile_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, diff --git a/src/VBox/Runtime/common/vfs/vfsstdpipe.cpp b/src/VBox/Runtime/common/vfs/vfsstdpipe.cpp index 1662f5f4f44..09fc4b56606 100644 --- a/src/VBox/Runtime/common/vfs/vfsstdpipe.cpp +++ b/src/VBox/Runtime/common/vfs/vfsstdpipe.cpp @@ -255,6 +255,7 @@ DECL_HIDDEN_CONST(const RTVFSIOSTREAMOPS) g_rtVfsStdPipeOps = "StdFile", rtVfsStdPipe_Close, rtVfsStdPipe_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, diff --git a/src/VBox/Runtime/common/zip/cpiovfs.cpp b/src/VBox/Runtime/common/zip/cpiovfs.cpp index af8d937f361..057314b7ab3 100644 --- a/src/VBox/Runtime/common/zip/cpiovfs.cpp +++ b/src/VBox/Runtime/common/zip/cpiovfs.cpp @@ -441,6 +441,7 @@ static const RTVFSOBJOPS g_rtZipCpioFssBaseObjOps = "CpioFsStream::Obj", rtZipCpioFssBaseObj_Close, rtZipCpioFssBaseObj_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }; @@ -585,6 +586,7 @@ static const RTVFSIOSTREAMOPS g_rtZipCpioFssIosOps = "CpioFsStream::IoStream", rtZipCpioFssIos_Close, rtZipCpioFssIos_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, @@ -671,6 +673,7 @@ static const RTVFSSYMLINKOPS g_rtZipCpioFssSymOps = "CpioFsStream::Symlink", rtZipCpioFssSym_Close, rtZipCpioFssSym_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSSYMLINKOPS_VERSION, @@ -1023,6 +1026,7 @@ static const RTVFSFSSTREAMOPS rtZipCpioFssOps = "CpioFsStream", rtZipCpioFss_Close, rtZipCpioFss_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSFSSTREAMOPS_VERSION, diff --git a/src/VBox/Runtime/common/zip/gzipvfs.cpp b/src/VBox/Runtime/common/zip/gzipvfs.cpp index 8aa01f20c00..3a4caa6be0f 100644 --- a/src/VBox/Runtime/common/zip/gzipvfs.cpp +++ b/src/VBox/Runtime/common/zip/gzipvfs.cpp @@ -668,6 +668,7 @@ static RTVFSIOSTREAMOPS g_rtZipGzipOps = "gzip", rtZipGzip_Close, rtZipGzip_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, diff --git a/src/VBox/Runtime/common/zip/pkzip.cpp b/src/VBox/Runtime/common/zip/pkzip.cpp index d96f87013b3..57d53cc96b9 100644 --- a/src/VBox/Runtime/common/zip/pkzip.cpp +++ b/src/VBox/Runtime/common/zip/pkzip.cpp @@ -164,6 +164,7 @@ static const RTVFSIOSTREAMOPS g_memFssIosOps = "MemFsStream::IoStream", memFssIos_Close, memFssIos_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, diff --git a/src/VBox/Runtime/common/zip/pkzipvfs.cpp b/src/VBox/Runtime/common/zip/pkzipvfs.cpp index a7e49faceb1..8f722384601 100644 --- a/src/VBox/Runtime/common/zip/pkzipvfs.cpp +++ b/src/VBox/Runtime/common/zip/pkzipvfs.cpp @@ -819,6 +819,7 @@ static const RTVFSOBJOPS g_rtZipPkzipFssBaseObjOps = "PkzipFsStream::Obj", rtZipPkzipFssBaseObj_Close, rtZipPkzipFssBaseObj_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }; @@ -1041,6 +1042,7 @@ static const RTVFSIOSTREAMOPS g_rtZipPkzipFssIosOps = "PkzipFsStream::IoStream", rtZipPkzipFssIos_Close, rtZipPkzipFssIos_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, @@ -1233,6 +1235,7 @@ static const RTVFSFSSTREAMOPS rtZipPkzipFssOps = "PkzipFsStream", rtZipPkzipFss_Close, rtZipPkzipFss_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSFSSTREAMOPS_VERSION, diff --git a/src/VBox/Runtime/common/zip/tarvfs.cpp b/src/VBox/Runtime/common/zip/tarvfs.cpp index f72481acf90..3e5aa9ab7a7 100644 --- a/src/VBox/Runtime/common/zip/tarvfs.cpp +++ b/src/VBox/Runtime/common/zip/tarvfs.cpp @@ -830,6 +830,7 @@ static const RTVFSOBJOPS g_rtZipTarFssBaseObjOps = "TarFsStream::Obj", rtZipTarFssBaseObj_Close, rtZipTarFssBaseObj_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }; @@ -974,6 +975,7 @@ static const RTVFSIOSTREAMOPS g_rtZipTarFssIosOps = "TarFsStream::IoStream", rtZipTarFssIos_Close, rtZipTarFssIos_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, @@ -1060,6 +1062,7 @@ static const RTVFSSYMLINKOPS g_rtZipTarFssSymOps = "TarFsStream::Symlink", rtZipTarFssSym_Close, rtZipTarFssSym_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSSYMLINKOPS_VERSION, @@ -1352,6 +1355,7 @@ static const RTVFSFSSTREAMOPS rtZipTarFssOps = "TarFsStream", rtZipTarFss_Close, rtZipTarFss_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSFSSTREAMOPS_VERSION, diff --git a/src/VBox/Runtime/common/zip/tarvfswriter.cpp b/src/VBox/Runtime/common/zip/tarvfswriter.cpp index f87170710a1..51d0a6c03cf 100644 --- a/src/VBox/Runtime/common/zip/tarvfswriter.cpp +++ b/src/VBox/Runtime/common/zip/tarvfswriter.cpp @@ -782,6 +782,7 @@ DECL_HIDDEN_CONST(const RTVFSIOSTREAMOPS) g_rtZipTarWriterIoStrmOps = "TAR push I/O Stream", rtZipTarWriterPush_Close, rtZipTarWriterPush_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, @@ -809,6 +810,7 @@ DECL_HIDDEN_CONST(const RTVFSFILEOPS) g_rtZipTarWriterFileOps = "TAR push file", rtZipTarWriterPush_Close, rtZipTarWriterPush_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, @@ -2055,6 +2057,7 @@ static const RTVFSFSSTREAMOPS g_rtZipTarFssOps = "TarFsStreamWriter", rtZipTarFssWriter_Close, rtZipTarFssWriter_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSFSSTREAMOPS_VERSION, diff --git a/src/VBox/Runtime/common/zip/xarvfs.cpp b/src/VBox/Runtime/common/zip/xarvfs.cpp index 77f73b1da77..93bc9a7e525 100644 --- a/src/VBox/Runtime/common/zip/xarvfs.cpp +++ b/src/VBox/Runtime/common/zip/xarvfs.cpp @@ -811,6 +811,7 @@ static const RTVFSOBJOPS g_rtZipXarFssBaseObjOps = "XarFsStream::Obj", rtZipXarFssBaseObj_Close, rtZipXarFssBaseObj_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }; @@ -1016,6 +1017,7 @@ static const RTVFSIOSTREAMOPS g_rtZipXarFssIosOps = "XarFsStream::IoStream", rtZipXarFssIos_Close, rtZipXarFssIos_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, @@ -1145,6 +1147,7 @@ static const RTVFSFILEOPS g_rtZipXarFssFileOps = "XarFsStream::File", rtZipXarFssFile_Close, rtZipXarFssIos_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, @@ -1333,6 +1336,7 @@ static const RTVFSIOSTREAMOPS g_rtZipXarFssDecompIosOps = "XarFsStream::DecompIoStream", rtZipXarFssDecompIos_Close, rtZipXarFssDecompIos_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, @@ -1426,6 +1430,7 @@ static const RTVFSSYMLINKOPS g_rtZipXarFssSymOps = "XarFsStream::Symlink", rtZipXarFssSym_Close, rtZipXarFssSym_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSSYMLINKOPS_VERSION, @@ -1798,6 +1803,7 @@ static const RTVFSFSSTREAMOPS rtZipXarFssOps = "XarFsStream", rtZipXarFss_Close, rtZipXarFss_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSFSSTREAMOPS_VERSION, diff --git a/src/VBox/Storage/VDIfVfs.cpp b/src/VBox/Storage/VDIfVfs.cpp index 555c2ef23be..c3a3dff0ad2 100644 --- a/src/VBox/Storage/VDIfVfs.cpp +++ b/src/VBox/Storage/VDIfVfs.cpp @@ -181,6 +181,7 @@ DECL_HIDDEN_CONST(const RTVFSIOSTREAMOPS) g_vdIfVfsIosOps = "VDIfIos", vdIfVfsIos_Close, vdIfVfsIos_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, @@ -339,6 +340,7 @@ DECL_HIDDEN_CONST(const RTVFSFILEOPS) g_vdIfVfsFileOps = "VDIfFile", vdIfVfsIos_Close, vdIfVfsIos_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, diff --git a/src/VBox/Storage/VDVfs.cpp b/src/VBox/Storage/VDVfs.cpp index 69149a62491..ab1801bb6e5 100644 --- a/src/VBox/Storage/VDVfs.cpp +++ b/src/VBox/Storage/VDVfs.cpp @@ -581,6 +581,7 @@ DECL_HIDDEN_CONST(const RTVFSFILEOPS) g_vdVfsStdFileOps = "VDFile", vdVfsFile_Close, vdVfsFile_QueryInfo, + NULL, RTVFSOBJOPS_VERSION }, RTVFSIOSTREAMOPS_VERSION, |