- Timestamp:
- Oct 25, 2010 4:28:14 PM (14 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/fs.cpp
r30365 r33437 91 91 } 92 92 } 93 94 /* Is it really a symbolic link? */ 95 if (fMode & RTFS_DOS_NT_REPARSE_POINT) 96 fMode = (fMode & ~RTFS_TYPE_MASK) | RTFS_TYPE_SYMLINK; 97 93 98 /* writable? */ 94 99 if (!(fMode & RTFS_DOS_READONLY)) -
trunk/src/VBox/Runtime/r3/win/path-win.cpp
r33337 r33437 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Oracle Corporation7 * Copyright (C) 2006-2010 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 224 224 } 225 225 FindClose(hDir); 226 Data.dwFileAttributes = FindData.dwFileAttributes; 227 Data.ftCreationTime = FindData.ftCreationTime; 228 Data.ftLastAccessTime = FindData.ftLastAccessTime; 229 Data.ftLastWriteTime = FindData.ftLastWriteTime; 230 Data.nFileSizeHigh = FindData.nFileSizeHigh; 231 Data.nFileSizeLow = FindData.nFileSizeLow; 226 227 Data.dwFileAttributes = FindData.dwFileAttributes; 228 Data.ftCreationTime = FindData.ftCreationTime; 229 Data.ftLastAccessTime = FindData.ftLastAccessTime; 230 Data.ftLastWriteTime = FindData.ftLastWriteTime; 231 Data.nFileSizeHigh = FindData.nFileSizeHigh; 232 Data.nFileSizeLow = FindData.nFileSizeLow; 232 233 } 233 234 else … … 238 239 } 239 240 } 240 RTUtf16Free(pwszPath); 241 242 /* 243 * Getting the information for the link target is a bit annoying and 244 * subject to the same access violation mess as above.. :/ 245 */ 246 /** @todo we're too lazy wrt to error paths here... */ 241 247 if ( (fFlags & RTPATH_F_FOLLOW_LINK) 242 248 && (Data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) 243 249 { 244 #ifndef DEBUG_sandervl 245 AssertFailed(); 246 #endif 247 /** @todo Symlinks: RTPathQueryInfoEx is not handling symbolic links 248 * correctly on Windows. (Both GetFileAttributesEx and FileFindFirst 249 * will return info about the symlink.) */ 250 } 250 HANDLE hFinal = CreateFileW(pwszPath, 251 GENERIC_READ, 252 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 253 NULL, 254 OPEN_EXISTING, 255 FILE_FLAG_BACKUP_SEMANTICS, 256 NULL); 257 if (hFinal != INVALID_HANDLE_VALUE) 258 { 259 BY_HANDLE_FILE_INFORMATION FileData; 260 if (GetFileInformationByHandle(hFinal, &FileData)) 261 { 262 Data.dwFileAttributes = FileData.dwFileAttributes; 263 Data.ftCreationTime = FileData.ftCreationTime; 264 Data.ftLastAccessTime = FileData.ftLastAccessTime; 265 Data.ftLastWriteTime = FileData.ftLastWriteTime; 266 Data.nFileSizeHigh = FileData.nFileSizeHigh; 267 Data.nFileSizeLow = FileData.nFileSizeLow; 268 } 269 CloseHandle(hFinal); 270 } 271 else if (GetLastError() != ERROR_SHARING_VIOLATION) 272 { 273 rc = RTErrConvertFromWin32(GetLastError()); 274 RTUtf16Free(pwszPath); 275 return rc; 276 } 277 } 278 279 RTUtf16Free(pwszPath); 251 280 252 281 /* -
trunk/src/VBox/Runtime/r3/win/symlink-win.cpp
r33429 r33437 44 44 45 45 46 /******************************************************************************* 47 * Structures and Typedefs * 48 *******************************************************************************/ 49 typedef struct MY_REPARSE_DATA_BUFFER 50 { 51 ULONG ReparseTag; 52 #define MY_IO_REPARSE_TAG_SYMLINK 0xa000000c 53 #define MY_IO_REPARSE_TAG_MOUNT_POINT 0xa0000003 54 55 USHORT ReparseDataLength; 56 USHORT Reserved; 57 union 58 { 59 struct 60 { 61 USHORT SubstituteNameOffset; 62 USHORT SubstituteNameLength; 63 USHORT PrintNameOffset; 64 USHORT PrintNameLength; 65 ULONG Flags; 66 #define MY_SYMLINK_FLAG_RELATIVE 1 67 WCHAR PathBuffer[1]; 68 } SymbolicLinkReparseBuffer; 69 struct 70 { 71 USHORT SubstituteNameOffset; 72 USHORT SubstituteNameLength; 73 USHORT PrintNameOffset; 74 USHORT PrintNameLength; 75 WCHAR PathBuffer[1]; 76 } MountPointReparseBuffer; 77 struct 78 { 79 UCHAR DataBuffer[1]; 80 } GenericReparseBuffer; 81 }; 82 } MY_REPARSE_DATA_BUFFER; 83 #define MY_FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS) 84 85 46 86 RTDECL(bool) RTSymlinkExists(const char *pszSymlink) 47 87 { … … 68 108 { 69 109 rc = RTPathQueryInfoEx(pszSymlink, &ObjInfo, RTFSOBJATTRADD_NOTHING, RTPATH_F_FOLLOW_LINK); 70 fRc = RT_SUCCESS(rc);110 fRc = !RT_SUCCESS_NP(rc); 71 111 } 72 112 } … … 126 166 size_t cchTarget = strlen(pszTarget); 127 167 size_t cchVolSpecTarget = rtPathVolumeSpecLen(pszTarget); 168 #if 0 /* looks like this isn't needed after all. That makes everything much simper :-) */ 128 169 if ( cchTarget > RT_MIN(cchVolSpecTarget, 1) 129 170 && RTPATH_IS_SLASH(pszTarget[cchTarget - 1])) … … 140 181 } 141 182 } 183 #endif 142 184 143 185 if (enmType == RTSYMLINKTYPE_UNKNOWN) … … 148 190 else if (cchVolSpecTarget) 149 191 { 192 /** @todo this is subject to sharing violations. */ 150 193 DWORD dwAttr = GetFileAttributesW(pwszNativeTarget); 151 194 if ( dwAttr != INVALID_FILE_ATTRIBUTES … … 247 290 NULL, 248 291 OPEN_EXISTING, 249 FILE_FLAG_OPEN_REPARSE_POINT ,292 FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, 250 293 NULL); 251 294 if (hSymlink != INVALID_HANDLE_VALUE) 252 295 { 253 /** @todo what do we do next? FSCTL_GET_REPARSE_POINT? */ 254 rc = VERR_NOT_IMPLEMENTED; 255 296 DWORD cbReturned = 0; 297 union 298 { 299 MY_REPARSE_DATA_BUFFER Buf; 300 uint8_t abBuf[16*_1K + sizeof(WCHAR)]; 301 } u; 302 if (DeviceIoControl(hSymlink, 303 MY_FSCTL_GET_REPARSE_POINT, 304 NULL /*pInBuffer */, 305 0 /*cbInBuffer */, 306 &u.Buf, 307 sizeof(u) - sizeof(WCHAR), 308 &cbReturned, 309 NULL /*pOverlapped*/)) 310 { 311 if (u.Buf.ReparseTag == MY_IO_REPARSE_TAG_SYMLINK) 312 { 313 PWCHAR pwszTarget = &u.Buf.SymbolicLinkReparseBuffer.PathBuffer[0]; 314 pwszTarget += u.Buf.SymbolicLinkReparseBuffer.SubstituteNameOffset / 2; 315 pwszTarget[u.Buf.SymbolicLinkReparseBuffer.SubstituteNameLength / 2] = 0; 316 if ( !(u.Buf.SymbolicLinkReparseBuffer.Flags & MY_SYMLINK_FLAG_RELATIVE) 317 && pwszTarget[0] == '\\' 318 && pwszTarget[1] == '?' 319 && pwszTarget[2] == '?' 320 && pwszTarget[3] == '\\' 321 && pwszTarget[4] != 0 322 ) 323 pwszTarget += 4; 324 rc = RTUtf16ToUtf8(pwszTarget, ppszTarget); 325 } 326 else 327 rc = VERR_NOT_SYMLINK; 328 } 329 else 330 rc = RTErrConvertFromWin32(GetLastError()); 256 331 CloseHandle(hSymlink); 257 332 } -
trunk/src/VBox/Runtime/win/RTErrConvertFromWin32.cpp
r30093 r33437 396 396 //case WSANO_RECOVERY (WSABASEERR+1003) 397 397 //case WSANO_DATA (WSABASEERR+1004) 398 399 400 #ifndef ERROR_NOT_A_REPARSE_POINT 401 # define ERROR_NOT_A_REPARSE_POINT 0x1126 402 #endif 403 case ERROR_NOT_A_REPARSE_POINT: return VERR_NOT_SYMLINK; 404 398 405 } 399 406
Note:
See TracChangeset
for help on using the changeset viewer.