Changeset 77047 in vbox
- Timestamp:
- Jan 30, 2019 3:38:53 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/mangling.h
r76585 r77047 809 809 # define RTVfsDirFromRTDir RT_MANGLER(RTVfsDirFromRTDir) 810 810 # define RTVfsDirOpenNormal RT_MANGLER(RTVfsDirOpenNormal) 811 # define RTVfsDirIsStdDir RT_MANGLER(RTVfsDirIsStdDir) 811 812 # define RTDvmCreate RT_MANGLER(RTDvmCreate) 812 813 # define RTDvmCreateFromVfsFile RT_MANGLER(RTDvmCreateFromVfsFile) … … 2575 2576 # define RTVfsDirRemoveDir RT_MANGLER(RTVfsDirRemoveDir) 2576 2577 # define RTVfsDirSetPathMode RT_MANGLER(RTVfsDirSetPathMode) 2578 # define RTVfsDirToPrivate RT_MANGLER(RTVfsDirToPrivate) 2577 2579 # define RTVfsFileFlush RT_MANGLER(RTVfsFileFlush) 2578 2580 # define RTVfsFileFromBuffer RT_MANGLER(RTVfsFileFromBuffer) -
trunk/include/iprt/vfs.h
r76585 r77047 686 686 RTDECL(int) RTVfsDirOpenNormal(const char *pszPath, uint32_t fFlags, PRTVFSDIR phVfsDir); 687 687 688 /** Checks if @a hVfsDir was opened using RTVfsDirOpenNormal() or 689 * RTVfsDirFromRTDir(), either directly or indirectly. */ 690 RTDECL(bool) RTVfsDirIsStdDir(RTVFSDIR hVfsDir); 691 688 692 /** 689 693 * Queries information about a object in or under the given directory. -
trunk/include/iprt/vfslowlevel.h
r76585 r77047 761 761 #define RTVFSDIR_F_NO_VFS_REF RT_BIT_32(0) 762 762 /** @} */ 763 764 /** 765 * Gets the private data of a directory. 766 * 767 * @returns Pointer to the private data. NULL if the handle is invalid in some 768 * way. 769 * @param hVfsDir The directory handle. 770 * @param pDirOps The directory operations. This servers as a 771 * sort of password. 772 */ 773 RTDECL(void *) RTVfsDirToPrivate(RTVFSDIR hVfsDir, PCRTVFSDIROPS pDirOps); 763 774 764 775 -
trunk/src/VBox/Runtime/common/fs/isomakercmd.cpp
r76553 r77047 1704 1704 * @param cDepth Number of recursions. Used to deal with loopy 1705 1705 * directories. 1706 * @param fFilesWithSrcPath Whether to add files using @a pszSrc or to add 1707 * as VFS handles (open first). For saving native 1708 * file descriptors. 1706 1709 */ 1707 1710 static int rtFsIsoMakerCmdAddVfsDirRecursive(PRTFSISOMAKERCMDOPTS pOpts, RTVFSDIR hVfsDir, uint32_t idxDirObj, 1708 char *pszSrc, size_t cchSrc, uint32_t fNamespaces, uint8_t cDepth) 1711 char *pszSrc, size_t cchSrc, uint32_t fNamespaces, uint8_t cDepth, 1712 bool fFilesWithSrcPath) 1709 1713 { 1710 1714 /* … … 1775 1779 { 1776 1780 /* 1777 * Files are added with VFS file sources.1778 * The ASSUMPTION is that we're working with a virtual file system1779 * here and won't be wasting native file descriptors.1781 * Files are either added with VFS handles or paths to the sources, 1782 * depending on what's considered more efficient. We prefer the latter 1783 * if hVfsDir maps to native handle and not a virtual one. 1780 1784 */ 1781 RTVFSFILE hVfsFileSrc; 1782 rc = RTVfsDirOpenFile(hVfsDir, pDirEntry->szName, 1783 RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, &hVfsFileSrc); 1785 if (!fFilesWithSrcPath) 1786 { 1787 RTVFSFILE hVfsFileSrc; 1788 rc = RTVfsDirOpenFile(hVfsDir, pDirEntry->szName, 1789 RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, &hVfsFileSrc); 1790 if (RT_SUCCESS(rc)) 1791 { 1792 rc = RTFsIsoMakerAddUnnamedFileWithVfsFile(pOpts->hIsoMaker, hVfsFileSrc, &idxObj); 1793 RTVfsFileRelease(hVfsFileSrc); 1794 if (RT_FAILURE(rc)) 1795 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error adding file '%s' (VFS recursive, handle): %Rrc", 1796 pszSrc, rc); 1797 } 1798 else 1799 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error opening file '%s' (VFS recursive): %Rrc", pszSrc, rc); 1800 } 1801 else 1802 { 1803 /* Add file with source path: */ 1804 rc = RTFsIsoMakerAddUnnamedFileWithSrcPath(pOpts->hIsoMaker, pszSrc, &idxObj); 1805 if (RT_FAILURE(rc)) 1806 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error adding file '%s' (VFS recursive, path): %Rrc", 1807 pszSrc, rc); 1808 } 1784 1809 if (RT_SUCCESS(rc)) 1785 1810 { 1786 rc = RTFsIsoMakerAddUnnamedFileWithVfsFile(pOpts->hIsoMaker, hVfsFileSrc, &idxObj); 1787 RTVfsFileRelease(hVfsFileSrc); 1788 if (RT_SUCCESS(rc)) 1789 { 1790 pOpts->cItemsAdded++; 1791 rc = RTFsIsoMakerObjSetNameAndParent(pOpts->hIsoMaker, idxObj, idxDirObj, fNamespaces, 1792 pDirEntry->szName); 1793 if (RT_FAILURE(rc)) 1794 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error setting parent & name on file '%s' to '%s': %Rrc", 1795 pszSrc, pDirEntry->szName, rc); 1796 } 1797 else 1798 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error adding file '%s' (VFS recursive): %Rrc", pszSrc, rc); 1811 pOpts->cItemsAdded++; 1812 rc = RTFsIsoMakerObjSetNameAndParent(pOpts->hIsoMaker, idxObj, idxDirObj, fNamespaces, 1813 pDirEntry->szName); 1814 if (RT_FAILURE(rc)) 1815 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error setting parent & name on file '%s' to '%s': %Rrc", 1816 pszSrc, pDirEntry->szName, rc); 1799 1817 } 1800 else1801 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error opening file '%s' (VFS recursive): %Rrc", pszSrc, rc);1802 1818 } 1803 1819 else if (RTFS_IS_DIRECTORY(pDirEntry->Info.Attr.fMode)) … … 1819 1835 /* Recurse into the sub-directory. */ 1820 1836 rc = rtFsIsoMakerCmdAddVfsDirRecursive(pOpts, hVfsSubDirSrc, idxObj, pszSrc, 1821 cchSrc + 1 + pDirEntry->cbName, fNamespaces, cDepth + 1); 1837 cchSrc + 1 + pDirEntry->cbName, fNamespaces, cDepth + 1, 1838 fFilesWithSrcPath); 1822 1839 else 1823 1840 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, … … 1864 1881 * @param pszSrc The source directory name. 1865 1882 * @param pParsed The parsed names. 1883 * @param fFilesWithSrcPath Whether to add files using @a pszSrc 1884 * or to add as VFS handles (open first). For 1885 * saving native file descriptors. 1866 1886 * @param pidxObj Where to return the configuration index for the 1867 1887 * added file. Optional. 1868 1888 */ 1869 1889 static int rtFsIsoMakerCmdAddVfsDirCommon(PRTFSISOMAKERCMDOPTS pOpts, RTVFSDIR hVfsDirSrc, char *pszSrc, 1870 PCRTFSISOMKCMDPARSEDNAMES pParsed, PCRTFSOBJINFO pObjInfo)1890 PCRTFSISOMKCMDPARSEDNAMES pParsed, bool fFilesWithSrcPath, PCRTFSOBJINFO pObjInfo) 1871 1891 { 1872 1892 /* … … 1904 1924 fNamespaces |= pParsed->aNames[i].fNameSpecifiers & RTFSISOMAKERCMDNAME_MAJOR_MASK; 1905 1925 rc = rtFsIsoMakerCmdAddVfsDirRecursive(pOpts, hVfsDirSrc, idxObj, pszSrc, 1906 pParsed->aNames[pParsed->cNamesWithSrc - 1].cchPath, fNamespaces, 0 /*cDepth*/); 1926 pParsed->aNames[pParsed->cNamesWithSrc - 1].cchPath, fNamespaces, 0 /*cDepth*/, 1927 fFilesWithSrcPath); 1907 1928 } 1908 1929 … … 1929 1950 if (RT_SUCCESS(rc)) 1930 1951 { 1931 rc = rtFsIsoMakerCmdAddVfsDirCommon(pOpts, hVfsDirSrc, pszSrc, pParsed, pObjInfo);1952 rc = rtFsIsoMakerCmdAddVfsDirCommon(pOpts, hVfsDirSrc, pszSrc, pParsed, false /*fFilesWithSrcPath*/, pObjInfo); 1932 1953 RTVfsDirRelease(hVfsDirSrc); 1933 1954 } … … 1958 1979 if (RT_SUCCESS(rc)) 1959 1980 { 1960 rc = rtFsIsoMakerCmdAddVfsDirCommon(pOpts, hVfsDirSrc, pszSrc, pParsed, pObjInfo); 1981 rc = rtFsIsoMakerCmdAddVfsDirCommon(pOpts, hVfsDirSrc, pszSrc, pParsed, 1982 RTVfsDirIsStdDir(hVfsDirSrc) /*fFilesWithSrcPath*/, pObjInfo); 1961 1983 RTVfsDirRelease(hVfsDirSrc); 1962 1984 } -
trunk/src/VBox/Runtime/common/vfs/vfsbase.cpp
r76553 r77047 2519 2519 2520 2520 2521 RTDECL(void *) RTVfsDirToPrivate(RTVFSDIR hVfsDir, PCRTVFSDIROPS pDirOps) 2522 { 2523 RTVFSDIRINTERNAL *pThis = hVfsDir; 2524 AssertPtrReturn(pThis, NULL); 2525 AssertReturn(pThis->uMagic == RTVFSDIR_MAGIC, NULL); 2526 if (pThis->pOps != pDirOps) 2527 return NULL; 2528 return pThis->Base.pvThis; 2529 } 2530 2531 2521 2532 #ifdef DEBUG 2522 2533 # undef RTVfsDirRetain -
trunk/src/VBox/Runtime/common/vfs/vfsstddir.cpp
r76553 r77047 753 753 754 754 755 RTDECL(bool) RTVfsDirIsStdDir(RTVFSDIR hVfsDir) 756 { 757 return RTVfsDirToPrivate(hVfsDir, &g_rtVfsStdDirOps) != NULL; 758 } 759 760 755 761 /** 756 762 * @interface_method_impl{RTVFSCHAINELEMENTREG,pfnValidate}
Note:
See TracChangeset
for help on using the changeset viewer.