Changeset 76126 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Dec 10, 2018 2:11:31 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/os2/VBoxSF/VBoxSF.cpp
r76121 r76126 1697 1697 if (RT_SUCCESS(vrc)) 1698 1698 rc = NO_ERROR; 1699 else if (vrc == VERR_FILE_NOT_FOUND)1699 else 1700 1700 rc = vboxSfOs2ConvertStatusToOs2(vrc, ERROR_ACCESS_DENIED); 1701 1701 … … 1782 1782 * @returns OS/2 status code. 1783 1783 * @param pFolder The folder. 1784 * @param p FolderPath The path within the folder.1784 * @param pReq Open/create request buffer with path. 1785 1785 * @param fAttribs New file attributes. 1786 1786 * @param pTimestamps New timestamps. May be NULL. 1787 1787 */ 1788 static APIRET vboxSfOs2SetPathInfoWorker(PVBOXSFFOLDER pFolder, PSHFLSTRING pFolderPath, ULONG fAttribs, PFILESTATUS pTimestamps)1788 static APIRET vboxSfOs2SetPathInfoWorker(PVBOXSFFOLDER pFolder, VBOXSFCREATEREQ *pReq, ULONG fAttribs, PFILESTATUS pTimestamps) 1789 1789 1790 1790 { … … 1793 1793 */ 1794 1794 APIRET rc; 1795 SHFLCREATEPARMS *pParams = (SHFLCREATEPARMS *)VbglR0PhysHeapAlloc(sizeof(*pParams)); 1796 if (pParams) 1797 { 1798 RT_ZERO(*pParams); 1799 pParams->CreateFlags = SHFL_CF_ACT_OPEN_IF_EXISTS | SHFL_CF_ACT_FAIL_IF_NEW 1800 | SHFL_CF_ACCESS_ATTR_READWRITE | SHFL_CF_ACCESS_DENYNONE | SHFL_CF_ACCESS_NONE; 1801 1802 int vrc = VbglR0SfCreate(&g_SfClient, &pFolder->hHostFolder, pFolderPath, pParams); 1803 LogFlow(("vboxSfOs2SetPathInfoWorker: VbglR0SfCreate -> %Rrc Result=%d Handle=%#RX64 fMode=%#x\n", 1804 vrc, pParams->Result, pParams->Handle, pParams->Info.Attr.fMode)); 1805 if ( vrc == VERR_IS_A_DIRECTORY 1806 || ( RT_SUCCESS(vrc) 1807 && pParams->Handle == SHFL_HANDLE_NIL 1808 && RTFS_IS_DIRECTORY(pParams->Info.Attr.fMode))) 1809 { 1810 RT_ZERO(*pParams); 1811 pParams->CreateFlags = SHFL_CF_DIRECTORY | SHFL_CF_ACT_OPEN_IF_EXISTS | SHFL_CF_ACT_FAIL_IF_NEW 1812 | SHFL_CF_ACCESS_ATTR_READWRITE | SHFL_CF_ACCESS_DENYNONE | SHFL_CF_ACCESS_NONE; 1813 vrc = VbglR0SfCreate(&g_SfClient, &pFolder->hHostFolder, pFolderPath, pParams); 1814 LogFlow(("vboxSfOs2SetPathInfoWorker: VbglR0SfCreate#2 -> %Rrc Result=%d Handle=%#RX64 fMode=%#x\n", 1815 vrc, pParams->Result, pParams->Handle, pParams->Info.Attr.fMode)); 1816 } 1817 if (RT_SUCCESS(vrc)) 1818 { 1819 switch (pParams->Result) 1820 { 1821 case SHFL_FILE_EXISTS: 1822 if (pParams->Handle != SHFL_HANDLE_NIL) 1823 { 1824 /* 1825 * Join up with FS32_FILEINFO to do the actual setting. 1826 */ 1827 rc = vboxSfOs2SetInfoCommonWorker(pFolder, pParams->Handle, fAttribs, pTimestamps, &pParams->Info); 1828 1829 vrc = VbglR0SfClose(&g_SfClient, &pFolder->hHostFolder, pParams->Handle); 1830 AssertRC(vrc); 1831 } 1832 else 1833 { 1834 LogRel(("vboxSfOs2SetPathInfoWorker: No handle! fMode=%#x\n", pParams->Info.Attr.fMode)); 1835 rc = ERROR_SYS_INTERNAL; 1836 } 1837 break; 1838 1839 case SHFL_PATH_NOT_FOUND: 1840 rc = ERROR_PATH_NOT_FOUND; 1841 break; 1842 1843 default: 1844 case SHFL_FILE_NOT_FOUND: 1845 rc = ERROR_FILE_NOT_FOUND; 1846 break; 1847 } 1848 } 1849 else 1850 rc = vboxSfOs2ConvertStatusToOs2(vrc, ERROR_FILE_NOT_FOUND); 1851 VbglR0PhysHeapFree(pParams); 1795 pReq->CreateParms.CreateFlags = SHFL_CF_ACT_OPEN_IF_EXISTS | SHFL_CF_ACT_FAIL_IF_NEW 1796 | SHFL_CF_ACCESS_ATTR_READWRITE | SHFL_CF_ACCESS_DENYNONE | SHFL_CF_ACCESS_NONE; 1797 1798 int vrc = vboxSfOs2HostReqCreate(pFolder, pReq); 1799 LogFlow(("vboxSfOs2SetPathInfoWorker: vboxSfOs2HostReqCreate -> %Rrc Result=%d Handle=%#RX64 fMode=%#x\n", 1800 vrc, pReq->CreateParms.Result, pReq->CreateParms.Handle, pReq->CreateParms.Info.Attr.fMode)); 1801 if ( vrc == VERR_IS_A_DIRECTORY 1802 || ( RT_SUCCESS(vrc) 1803 && pReq->CreateParms.Handle == SHFL_HANDLE_NIL 1804 && RTFS_IS_DIRECTORY(pReq->CreateParms.Info.Attr.fMode))) 1805 { 1806 RT_ZERO(pReq->CreateParms); 1807 pReq->CreateParms.CreateFlags = SHFL_CF_DIRECTORY | SHFL_CF_ACT_OPEN_IF_EXISTS | SHFL_CF_ACT_FAIL_IF_NEW 1808 | SHFL_CF_ACCESS_ATTR_READWRITE | SHFL_CF_ACCESS_DENYNONE | SHFL_CF_ACCESS_NONE; 1809 vrc = vboxSfOs2HostReqCreate(pFolder, pReq); 1810 LogFlow(("vboxSfOs2SetPathInfoWorker: vboxSfOs2HostReqCreate#2 -> %Rrc Result=%d Handle=%#RX64 fMode=%#x\n", 1811 vrc, pReq->CreateParms.Result, pReq->CreateParms.Handle, pReq->CreateParms.Info.Attr.fMode)); 1812 } 1813 if (RT_SUCCESS(vrc)) 1814 { 1815 switch (pReq->CreateParms.Result) 1816 { 1817 case SHFL_FILE_EXISTS: 1818 if (pReq->CreateParms.Handle != SHFL_HANDLE_NIL) 1819 { 1820 /* 1821 * Join up with FS32_FILEINFO to do the actual setting. 1822 */ 1823 uint64_t const uHandle = pReq->CreateParms.Handle; 1824 ASMCompilerBarrier(); /* paranoia */ 1825 1826 rc = vboxSfOs2SetInfoCommonWorker(pFolder, pReq->CreateParms.Handle, fAttribs, pTimestamps, 1827 &pReq->CreateParms.Info); 1828 1829 AssertCompile(sizeof(VBOXSFCLOSEREQ) < sizeof(*pReq)); 1830 vrc = vboxSfOs2HostReqClose(pFolder, (VBOXSFCLOSEREQ *)pReq, uHandle); 1831 AssertRC(vrc); 1832 } 1833 else 1834 { 1835 LogRel(("vboxSfOs2SetPathInfoWorker: No handle! fMode=%#x\n", pReq->CreateParms.Info.Attr.fMode)); 1836 rc = ERROR_SYS_INTERNAL; 1837 } 1838 break; 1839 1840 case SHFL_PATH_NOT_FOUND: 1841 rc = ERROR_PATH_NOT_FOUND; 1842 break; 1843 1844 default: 1845 case SHFL_FILE_NOT_FOUND: 1846 rc = ERROR_FILE_NOT_FOUND; 1847 break; 1848 } 1852 1849 } 1853 1850 else 1854 rc = ERROR_NOT_ENOUGH_MEMORY;1851 rc = vboxSfOs2ConvertStatusToOs2(vrc, ERROR_FILE_NOT_FOUND); 1855 1852 return rc; 1856 1853 } … … 1868 1865 || fFlags == FA_SET) 1869 1866 { 1870 PVBOXSFFOLDER pFolder; 1871 PSHFLSTRING pStrFolderPath; 1872 rc = vboxSfOs2ResolvePath(pszName, pCdFsd, offCurDirEnd, &pFolder, &pStrFolderPath); 1873 LogRel(("FS32_FILEATTRIBUTE: vboxSfOs2ResolvePath: -> %u pFolder=%p\n", rc, pFolder)); 1867 /* Both setting and querying needs to make a create request. */ 1868 PVBOXSFFOLDER pFolder; 1869 VBOXSFCREATEREQ *pReq; 1870 rc = vboxSfOs2ResolvePathEx(pszName, pCdFsd, offCurDirEnd, RT_UOFFSETOF(VBOXSFCREATEREQ, StrPath), 1871 &pFolder, (void **)&pReq); 1874 1872 if (rc == NO_ERROR) 1875 1873 { … … 1879 1877 * Query it. 1880 1878 */ 1881 SHFLCREATEPARMS *pParams = (SHFLCREATEPARMS *)VbglR0PhysHeapAlloc(sizeof(*pParams)); 1882 if (pParams) 1879 pReq->CreateParms.CreateFlags = SHFL_CF_LOOKUP; 1880 1881 int vrc = vboxSfOs2HostReqCreate(pFolder, pReq); 1882 LogFlow(("FS32_FILEATTRIBUTE: vboxSfOs2HostReqCreate -> %Rrc Result=%d fMode=%#x\n", 1883 vrc, pReq->CreateParms.Result, pReq->CreateParms.Info.Attr.fMode)); 1884 if (RT_SUCCESS(vrc)) 1883 1885 { 1884 RT_ZERO(*pParams); 1885 pParams->CreateFlags = SHFL_CF_LOOKUP; 1886 1887 int vrc = VbglR0SfCreate(&g_SfClient, &pFolder->hHostFolder, pStrFolderPath, pParams); 1888 LogFlow(("FS32_FILEATTRIBUTE: VbglR0SfCreate -> %Rrc Result=%d fMode=%#x\n", vrc, pParams->Result, pParams->Info.Attr.fMode)); 1889 if (RT_SUCCESS(vrc)) 1886 switch (pReq->CreateParms.Result) 1890 1887 { 1891 switch (pParams->Result) 1892 { 1893 case SHFL_FILE_EXISTS: 1894 *pfAttr = (uint16_t)((pParams->Info.Attr.fMode & RTFS_DOS_MASK_OS2) >> RTFS_DOS_SHIFT); 1895 rc = NO_ERROR; 1896 break; 1897 1898 case SHFL_PATH_NOT_FOUND: 1899 rc = ERROR_PATH_NOT_FOUND; 1900 break; 1901 1902 default: 1903 case SHFL_FILE_NOT_FOUND: 1904 rc = ERROR_FILE_NOT_FOUND; 1905 break; 1906 } 1888 case SHFL_FILE_EXISTS: 1889 *pfAttr = (uint16_t)((pReq->CreateParms.Info.Attr.fMode & RTFS_DOS_MASK_OS2) >> RTFS_DOS_SHIFT); 1890 rc = NO_ERROR; 1891 break; 1892 1893 case SHFL_PATH_NOT_FOUND: 1894 rc = ERROR_PATH_NOT_FOUND; 1895 break; 1896 1897 default: 1898 case SHFL_FILE_NOT_FOUND: 1899 rc = ERROR_FILE_NOT_FOUND; 1900 break; 1907 1901 } 1908 else1909 rc = vboxSfOs2ConvertStatusToOs2(vrc, ERROR_FILE_NOT_FOUND);1910 VbglR0PhysHeapFree(pParams);1911 1902 } 1912 1903 else 1913 rc = ERROR_NOT_ENOUGH_MEMORY;1904 rc = vboxSfOs2ConvertStatusToOs2(vrc, ERROR_FILE_NOT_FOUND); 1914 1905 } 1915 1906 else … … 1918 1909 * Set the info. Join paths with FS32_PATHINFO. 1919 1910 */ 1920 rc = vboxSfOs2SetPathInfoWorker(pFolder, pStrFolderPath, *pfAttr, NULL); 1921 } 1922 vboxSfOs2ReleasePathAndFolder(pStrFolderPath, pFolder); 1911 rc = vboxSfOs2SetPathInfoWorker(pFolder, pReq, *pfAttr, NULL); 1912 } 1913 VbglR0PhysHeapFree(pReq); 1914 vboxSfOs2ReleaseFolder(pFolder); 1923 1915 } 1924 1916 } … … 2116 2108 * @returns OS/2 status code 2117 2109 * @param pFolder The folder. 2118 * @param p StrFolderPath The path within the folder.2110 * @param pReq Open/create request buffer with folder path. 2119 2111 * @param pszPath The original path for figuring the drive letter or 2120 2112 * UNC part of the path. … … 2122 2114 * @param cbData The maximum amount of data we can return. 2123 2115 */ 2124 static int vboxSfOs2QueryCorrectCase(PVBOXSFFOLDER pFolder, PSHFLSTRING pStrFolderPath, const char *pszPath,2116 static int vboxSfOs2QueryCorrectCase(PVBOXSFFOLDER pFolder, VBOXSFCREATEREQ *pReq, const char *pszPath, 2125 2117 PBYTE pbData, ULONG cbData) 2126 2118 { 2127 2119 /** @todo do case correction. Can do step-by-step dir info... but slow */ 2128 RT_NOREF(pFolder, p StrFolderPath, pszPath, pbData, cbData);2120 RT_NOREF(pFolder, pReq, pszPath, pbData, cbData); 2129 2121 return ERROR_NOT_SUPPORTED; 2130 2122 } … … 2182 2174 * @returns OS/2 status code 2183 2175 * @param pFolder The folder. 2184 * @param p StrFolderPath The path within the folder.2176 * @param pReq Open/create request buffer with folder path. 2185 2177 * @param uLevel The information level. 2186 2178 * @param pbData Where to return the data (user address). 2187 2179 * @param cbData The amount of data to produce. 2188 2180 */ 2189 static APIRET vboxSfOs2QueryPathInfo(PVBOXSFFOLDER pFolder, PSHFLSTRING pStrFolderPath, ULONG uLevel, PBYTE pbData, ULONG cbData)2181 static APIRET vboxSfOs2QueryPathInfo(PVBOXSFFOLDER pFolder, VBOXSFCREATEREQ *pReq, ULONG uLevel, PBYTE pbData, ULONG cbData) 2190 2182 { 2191 2183 APIRET rc; 2192 SHFLCREATEPARMS *pParams = (SHFLCREATEPARMS *)VbglR0PhysHeapAlloc(sizeof(*pParams)); 2193 if (pParams) 2194 { 2195 RT_ZERO(*pParams); 2196 pParams->CreateFlags = SHFL_CF_LOOKUP; 2197 2198 int vrc = VbglR0SfCreate(&g_SfClient, &pFolder->hHostFolder, pStrFolderPath, pParams); 2199 LogFlow(("FS32_PATHINFO: VbglR0SfCreate -> %Rrc Result=%d fMode=%#x\n", vrc, pParams->Result, pParams->Info.Attr.fMode)); 2200 if (RT_SUCCESS(vrc)) 2201 { 2202 switch (pParams->Result) 2203 { 2204 case SHFL_FILE_EXISTS: 2205 switch (uLevel) 2206 { 2207 /* 2208 * Produce the desired file stat data. 2209 */ 2210 case FI_LVL_STANDARD: 2211 case FI_LVL_STANDARD_EASIZE: 2212 case FI_LVL_STANDARD_64: 2213 case FI_LVL_STANDARD_EASIZE_64: 2214 rc = vboxSfOs2FileStatusFromObjInfo(pbData, cbData, uLevel, &pParams->Info); 2215 break; 2216 2217 /* 2218 * We don't do EAs and we "just" need to return no-EAs. 2219 * However, that's not as easy as you might think. 2220 */ 2221 case FI_LVL_EAS_FROM_LIST: 2222 case FI_LVL_EAS_FULL: 2223 case FI_LVL_EAS_FULL_5: 2224 case FI_LVL_EAS_FULL_8: 2225 rc = vboxSfOs2MakeEmptyEaList((PEAOP)pbData, uLevel); 2226 break; 2227 2228 default: 2229 AssertFailed(); 2230 rc = ERROR_GEN_FAILURE; 2231 break; 2232 } 2233 break; 2234 2235 case SHFL_PATH_NOT_FOUND: 2236 rc = ERROR_PATH_NOT_FOUND; 2237 break; 2238 2239 default: 2240 case SHFL_FILE_NOT_FOUND: 2241 rc = ERROR_FILE_NOT_FOUND; 2242 break; 2243 } 2244 } 2245 else 2246 rc = vboxSfOs2ConvertStatusToOs2(vrc, ERROR_FILE_NOT_FOUND); 2247 VbglR0PhysHeapFree(pParams); 2184 pReq->CreateParms.CreateFlags = SHFL_CF_LOOKUP; 2185 2186 int vrc = vboxSfOs2HostReqCreate(pFolder, pReq); 2187 LogFlow(("FS32_PATHINFO: vboxSfOs2HostReqCreate -> %Rrc Result=%d fMode=%#x\n", 2188 vrc, pReq->CreateParms.Result, pReq->CreateParms.Info.Attr.fMode)); 2189 if (RT_SUCCESS(vrc)) 2190 { 2191 switch (pReq->CreateParms.Result) 2192 { 2193 case SHFL_FILE_EXISTS: 2194 switch (uLevel) 2195 { 2196 /* 2197 * Produce the desired file stat data. 2198 */ 2199 case FI_LVL_STANDARD: 2200 case FI_LVL_STANDARD_EASIZE: 2201 case FI_LVL_STANDARD_64: 2202 case FI_LVL_STANDARD_EASIZE_64: 2203 rc = vboxSfOs2FileStatusFromObjInfo(pbData, cbData, uLevel, &pReq->CreateParms.Info); 2204 break; 2205 2206 /* 2207 * We don't do EAs and we "just" need to return no-EAs. 2208 * However, that's not as easy as you might think. 2209 */ 2210 case FI_LVL_EAS_FROM_LIST: 2211 case FI_LVL_EAS_FULL: 2212 case FI_LVL_EAS_FULL_5: 2213 case FI_LVL_EAS_FULL_8: 2214 rc = vboxSfOs2MakeEmptyEaList((PEAOP)pbData, uLevel); 2215 break; 2216 2217 default: 2218 AssertFailed(); 2219 rc = ERROR_GEN_FAILURE; 2220 break; 2221 } 2222 break; 2223 2224 case SHFL_PATH_NOT_FOUND: 2225 rc = ERROR_PATH_NOT_FOUND; 2226 break; 2227 2228 default: 2229 case SHFL_FILE_NOT_FOUND: 2230 rc = ERROR_FILE_NOT_FOUND; 2231 break; 2232 } 2248 2233 } 2249 2234 else 2250 rc = ERROR_NOT_ENOUGH_MEMORY;2235 rc = vboxSfOs2ConvertStatusToOs2(vrc, ERROR_FILE_NOT_FOUND); 2251 2236 return rc; 2252 2237 } … … 2316 2301 * Resolve the path to a folder and folder path. 2317 2302 */ 2318 PVBOXSFFOLDER pFolder;2319 PSHFLSTRING pStrFolderPath;2320 APIRET rc = vboxSfOs2ResolvePath(pszPath, pCdFsd, offCurDirEnd, &pFolder, &pStrFolderPath);2321 LogFlow(("FS32_PATHINFO: vboxSfOs2ResolvePath: -> %u pFolder=%p\n", rc, pFolder));2303 PVBOXSFFOLDER pFolder; 2304 VBOXSFCREATEREQ *pReq; 2305 int rc = vboxSfOs2ResolvePathEx(pszPath, pCdFsd, offCurDirEnd, RT_UOFFSETOF(VBOXSFCREATEREQ, StrPath), 2306 &pFolder, (void **)&pReq); 2322 2307 if (rc == NO_ERROR) 2323 2308 { … … 2329 2314 if ( uLevel != FI_LVL_VERIFY_PATH 2330 2315 && uLevel != FI_LVL_CASE_CORRECT_PATH) 2331 rc = vboxSfOs2QueryPathInfo(pFolder, p StrFolderPath, uLevel, pbData, cbMinData);2316 rc = vboxSfOs2QueryPathInfo(pFolder, pReq, uLevel, pbData, cbMinData); 2332 2317 else if (uLevel == FI_LVL_VERIFY_PATH) 2333 2318 rc = NO_ERROR; /* vboxSfOs2ResolvePath should've taken care of this already */ 2334 2319 else 2335 rc = vboxSfOs2QueryCorrectCase(pFolder, p StrFolderPath, pszPath, pbData, cbData);2320 rc = vboxSfOs2QueryCorrectCase(pFolder, pReq, pszPath, pbData, cbData); 2336 2321 } 2337 2322 /* … … 2350 2335 rc = KernCopyIn(pDataCopy, pbData, cbMinData); 2351 2336 if (rc == NO_ERROR) 2352 rc = vboxSfOs2SetPathInfoWorker(pFolder, p StrFolderPath,2337 rc = vboxSfOs2SetPathInfoWorker(pFolder, pReq, 2353 2338 uLevel == FI_LVL_STANDARD 2354 2339 ? (ULONG)pDataCopy->attrFile … … 2370 2355 rc = ERROR_INVALID_PARAMETER; 2371 2356 } 2372 vboxSfOs2ReleasePathAndFolder(pStrFolderPath, pFolder); 2357 VbglR0PhysHeapFree(pReq); 2358 vboxSfOs2ReleaseFolder(pFolder); 2373 2359 } 2374 2360 RT_NOREF_PV(pCdFsi);
Note:
See TracChangeset
for help on using the changeset viewer.