Changeset 33409 in vbox for trunk/src/VBox/HostServices/SharedFolders
- Timestamp:
- Oct 25, 2010 10:08:21 AM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 66998
- Location:
- trunk/src/VBox/HostServices/SharedFolders
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedFolders/service.cpp
r31052 r33409 780 780 } 781 781 782 /* Read symlink destination */ 783 case SHFL_FN_READLINK: 784 { 785 Log(("svcCall: SHFL_FN_READLINK\n")); 786 787 /* Verify parameter count and types. */ 788 if (cParms != SHFL_CPARMS_READLINK) 789 { 790 rc = VERR_INVALID_PARAMETER; 791 } 792 else 793 if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */ 794 || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR /* path */ 795 || paParms[2].type != VBOX_HGCM_SVC_PARM_PTR /* buffer */ 796 ) 797 { 798 rc = VERR_INVALID_PARAMETER; 799 } 800 else 801 { 802 /* Fetch parameters. */ 803 SHFLROOT root = (SHFLROOT)paParms[0].u.uint32; 804 SHFLSTRING *pPath = (SHFLSTRING *)paParms[1].u.pointer.addr; 805 uint32_t cbPath = paParms[1].u.pointer.size; 806 uint8_t *pBuffer = (uint8_t *)paParms[2].u.pointer.addr; 807 uint32_t cbBuffer = paParms[2].u.pointer.size; 808 809 /* Verify parameters values. */ 810 if (!ShflStringIsValidOrNull(pPath, paParms[1].u.pointer.size)) 811 { 812 rc = VERR_INVALID_PARAMETER; 813 } 814 else 815 { 816 /* Execute the function. */ 817 rc = vbsfReadLink (pClient, root, pPath, cbPath, pBuffer, cbBuffer); 818 819 if (RT_SUCCESS(rc)) 820 { 821 /* Update parameters.*/ 822 ; /* none */ 823 } 824 } 825 } 826 827 break; 828 } 829 782 830 /* Legacy interface */ 783 831 case SHFL_FN_MAP_FOLDER_OLD: … … 1113 1161 break; 1114 1162 } 1163 1164 case SHFL_FN_SYMLINK: 1165 { 1166 Log(("svnCall: SHFL_FN_SYMLINK\n")); 1167 /* Verify parameter count and types. */ 1168 if (cParms != SHFL_CPARMS_SYMLINK) 1169 { 1170 rc = VERR_INVALID_PARAMETER; 1171 } 1172 else 1173 if ( paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT /* root */ 1174 || paParms[1].type != VBOX_HGCM_SVC_PARM_PTR /* newPath */ 1175 || paParms[2].type != VBOX_HGCM_SVC_PARM_PTR /* oldPath */ 1176 || paParms[3].type != VBOX_HGCM_SVC_PARM_PTR /* info */ 1177 ) 1178 { 1179 rc = VERR_INVALID_PARAMETER; 1180 } 1181 else 1182 { 1183 /* Fetch parameters. */ 1184 SHFLROOT root = (SHFLROOT)paParms[0].u.uint32; 1185 SHFLSTRING *pNewPath = (SHFLSTRING *)paParms[1].u.pointer.addr; 1186 SHFLSTRING *pOldPath = (SHFLSTRING *)paParms[2].u.pointer.addr; 1187 RTFSOBJINFO *pInfo = (RTFSOBJINFO *)paParms[3].u.pointer.addr; 1188 uint32_t cbInfo = paParms[3].u.pointer.size; 1189 1190 /* Verify parameters values. */ 1191 if ( !ShflStringIsValid(pNewPath, paParms[1].u.pointer.size) 1192 || !ShflStringIsValid(pOldPath, paParms[2].u.pointer.size) 1193 || (cbInfo != sizeof(RTFSOBJINFO)) 1194 ) 1195 { 1196 rc = VERR_INVALID_PARAMETER; 1197 } 1198 else 1199 { 1200 /* Execute the function. */ 1201 rc = vbsfSymlink (pClient, root, pNewPath, pOldPath, pInfo); 1202 if (RT_SUCCESS(rc)) 1203 { 1204 /* Update parameters.*/ 1205 ; /* none */ 1206 } 1207 } 1208 } 1209 } 1210 break; 1211 1212 #if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) 1213 case SHFL_FN_SET_SYMLINKS: 1214 { 1215 pClient->fu32Flags |= SHFL_CF_SYMLINKS; 1216 rc = VINF_SUCCESS; 1217 break; 1218 } 1219 #endif 1115 1220 1116 1221 default: -
trunk/src/VBox/HostServices/SharedFolders/shfl.h
r31052 r33409 40 40 #define SHFL_CF_UTF8 (0x00000004) 41 41 42 /** Client both supports and wants to use symlinks. */ 43 #define SHFL_CF_SYMLINKS (0x00000008) 44 42 45 /** @} */ 43 46 -
trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp
r32689 r33409 37 37 #define LogFlow Log 38 38 39 #define SHFL_RT_LINK(pClient) ((pClient)->fu32Flags & SHFL_CF_SYMLINKS ? RTPATH_F_ON_LINK : RTPATH_F_FOLLOW_LINK) 40 39 41 /** 40 42 * @todo find a better solution for supporting the execute bit for non-windows … … 100 102 } 101 103 102 static int vbsfCorrectCasing( char *pszFullPath, char *pszStartComponent)104 static int vbsfCorrectCasing(SHFLCLIENTDATA *pClient, char *pszFullPath, char *pszStartComponent) 103 105 { 104 106 PRTDIRENTRYEX pDirEntry = NULL; … … 139 141 size_t cbDirEntrySize = cbDirEntry; 140 142 141 rc = RTDirReadEx(hSearch, pDirEntry, &cbDirEntrySize, RTFSOBJATTRADD_NOTHING, RTPATH_F_FOLLOW_LINK);143 rc = RTDirReadEx(hSearch, pDirEntry, &cbDirEntrySize, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 142 144 if (rc == VERR_NO_MORE_FILES) 143 145 break; … … 494 496 495 497 /** @todo don't check when creating files or directories; waste of time */ 496 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, RTPATH_F_FOLLOW_LINK);498 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 497 499 if (rc == VERR_FILE_NOT_FOUND || rc == VERR_PATH_NOT_FOUND) 498 500 { … … 508 510 { 509 511 *src = 0; 510 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, RTPATH_F_FOLLOW_LINK);512 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 511 513 *src = RTPATH_DELIMITER; 512 514 if (rc == VINF_SUCCESS) … … 544 546 fEndOfString = false; 545 547 *end = 0; 546 rc = RTPathQueryInfoEx(src, &info, RTFSOBJATTRADD_NOTHING, RTPATH_F_FOLLOW_LINK);548 rc = RTPathQueryInfoEx(src, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 547 549 Assert(rc == VINF_SUCCESS || rc == VERR_FILE_NOT_FOUND || rc == VERR_PATH_NOT_FOUND); 548 550 } … … 556 558 { 557 559 /* path component is invalid; try to correct the casing */ 558 rc = vbsfCorrectCasing(p szFullPath, src);560 rc = vbsfCorrectCasing(pClient, pszFullPath, src); 559 561 if (RT_FAILURE(rc)) 560 562 { … … 826 828 * 827 829 * @returns IPRT status code 830 * @param pClient Data structure describing the client accessing the shared folder 828 831 * @param pszPath Path to the file or folder on the host. 829 832 * @param pParms->CreateFlags Creation or open parameters, see include/VBox/shflsvc.h … … 836 839 * @retval pParms->Info On success the parameters of the file opened or created 837 840 */ 838 static int vbsfOpenFile ( const char *pszPath, SHFLCREATEPARMS *pParms)841 static int vbsfOpenFile (SHFLCLIENTDATA *pClient, const char *pszPath, SHFLCREATEPARMS *pParms) 839 842 { 840 843 LogFlow(("vbsfOpenFile: pszPath = %s, pParms = %p\n", pszPath, pParms)); … … 884 887 885 888 /** @todo Possible race left here. */ 886 if (RT_SUCCESS(RTPathQueryInfoEx(pszPath, &info, RTFSOBJATTRADD_NOTHING, RTPATH_F_FOLLOW_LINK)))889 if (RT_SUCCESS(RTPathQueryInfoEx(pszPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)))) 887 890 { 888 891 #ifdef RT_OS_WINDOWS … … 1152 1155 * @retval pParms->Info On success, information returned about the file 1153 1156 */ 1154 static int vbsfLookupFile( char *pszPath, SHFLCREATEPARMS *pParms)1157 static int vbsfLookupFile(SHFLCLIENTDATA *pClient, char *pszPath, SHFLCREATEPARMS *pParms) 1155 1158 { 1156 1159 RTFSOBJINFO info; 1157 1160 int rc; 1158 1161 1159 rc = RTPathQueryInfoEx(pszPath, &info, RTFSOBJATTRADD_NOTHING, RTPATH_F_FOLLOW_LINK);1162 rc = RTPathQueryInfoEx(pszPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 1160 1163 LogFlow(("SHFL_CF_LOOKUP\n")); 1161 1164 /* Client just wants to know if the object exists. */ … … 1242 1245 if (BIT_FLAG(pParms->CreateFlags, SHFL_CF_LOOKUP)) 1243 1246 { 1244 rc = vbsfLookupFile(p szFullPath, pParms);1247 rc = vbsfLookupFile(pClient, pszFullPath, pParms); 1245 1248 } 1246 1249 else … … 1249 1252 RTFSOBJINFO info; 1250 1253 1251 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, RTPATH_F_FOLLOW_LINK);1254 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 1252 1255 LogFlow(("RTPathQueryInfoEx returned %Rrc\n", rc)); 1253 1256 … … 1308 1311 else 1309 1312 { 1310 rc = vbsfOpenFile (p szFullPath, pParms);1313 rc = vbsfOpenFile (pClient, pszFullPath, pParms); 1311 1314 } 1312 1315 } … … 1528 1531 pDirEntry = pDirEntryOrg; 1529 1532 1530 rc = RTDirReadEx(DirHandle, pDirEntry, &cbDirEntrySize, RTFSOBJATTRADD_NOTHING, RTPATH_F_FOLLOW_LINK);1533 rc = RTDirReadEx(DirHandle, pDirEntry, &cbDirEntrySize, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 1531 1534 if (rc == VERR_NO_MORE_FILES) 1532 1535 { … … 1647 1650 if (pDirEntry) 1648 1651 RTMemFree(pDirEntry); 1652 1653 return rc; 1654 } 1655 1656 int vbsfReadLink(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pPath, uint32_t cbPath, uint8_t *pBuffer, uint32_t cbBuffer) 1657 { 1658 int rc = VINF_SUCCESS; 1659 1660 if (pPath == 0 || pBuffer == 0) 1661 { 1662 AssertFailed(); 1663 return VERR_INVALID_PARAMETER; 1664 } 1665 1666 /* Build a host full path for the given path, handle file name case issues 1667 * (if the guest expects case-insensitive paths but the host is 1668 * case-sensitive) and convert ucs2 to utf8 if necessary. 1669 */ 1670 char *pszFullPath = NULL; 1671 uint32_t cbFullPathRoot = 0; 1672 1673 rc = vbsfBuildFullPath (pClient, root, pPath, cbPath, &pszFullPath, &cbFullPathRoot); 1674 1675 if (RT_SUCCESS (rc)) 1676 { 1677 rc = RTReadLink(pszFullPath, (char *) pBuffer, cbBuffer); 1678 1679 /* free the path string */ 1680 vbsfFreeFullPath(pszFullPath); 1681 } 1649 1682 1650 1683 return rc; … … 2107 2140 } 2108 2141 2142 int vbsfSymlink(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pNewPath, SHFLSTRING *pOldPath, RTFSOBJINFO *pInfo) 2143 { 2144 int rc = VINF_SUCCESS; 2145 2146 char *pszFullNewPath = NULL; 2147 char *pszOldPath = NULL; 2148 2149 /* XXX: no support for UCS2 at the moment. */ 2150 if (!BIT_FLAG(pClient->fu32Flags, SHFL_CF_UTF8)) 2151 return VERR_NOT_IMPLEMENTED; 2152 2153 rc = vbsfBuildFullPath (pClient, root, pNewPath, pNewPath->u16Size, &pszFullNewPath, NULL); 2154 if (rc != VINF_SUCCESS) 2155 return rc; 2156 2157 rc = RTSymlink(pszFullNewPath, (const char *)pOldPath->String.utf8); 2158 if (RT_SUCCESS (rc)) 2159 rc = RTPathQueryInfoEx(pszFullNewPath, pInfo, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 2160 2161 vbsfFreeFullPath(pszFullNewPath); 2162 2163 return rc; 2164 } 2165 2109 2166 /* 2110 2167 * Clean up our mess by freeing all handles that are still valid. -
trunk/src/VBox/HostServices/SharedFolders/vbsf.h
r28800 r33409 38 38 int vbsfDisconnect(SHFLCLIENTDATA *pClient); 39 39 int vbsfQueryFileInfo(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLHANDLE Handle, uint32_t flags, uint32_t *pcbBuffer, uint8_t *pBuffer); 40 int vbsfReadLink(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pPath, uint32_t cbPath, uint8_t *pBuffer, uint32_t cbBuffer); 41 int vbsfSymlink(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pNewPath, SHFLSTRING *pOldPath, RTFSOBJINFO *pInfo); 40 42 41 43 #endif /* __VBSF__H */
Note:
See TracChangeset
for help on using the changeset viewer.