Changeset 2704 in kBuild for trunk/src/lib/nt/ntstat.c
- Timestamp:
- Nov 21, 2013 1:26:52 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/nt/ntstat.c
r2703 r2704 133 133 134 134 /* File type. */ 135 if (fAttribs & FILE_ATTRIBUTE_REPARSE_POINT) 135 if ( (fAttribs & FILE_ATTRIBUTE_REPARSE_POINT) 136 && hFile != INVALID_HANDLE_VALUE) 136 137 { 137 138 MY_FILE_ATTRIBUTE_TAG_INFORMATION TagInfo; … … 357 358 //fprintf(stderr, "stat: %s -> %u\n", pszPath, GetLastError()); 358 359 359 /* On things like pagefile.sys we may get sharing violation. */ 360 if (errno == ETXTBSY) 361 { 362 /** @todo Fall back on the parent directory enum if we run into a sharing 363 * violation. */ 360 /* 361 * On things like pagefile.sys we may get sharing violation. We fall 362 * back on directory enumeration for dealing with that. 363 */ 364 if ( errno == ETXTBSY 365 && strchr(pszPath, '*') == NULL /* Serious paranoia... */ 366 && strchr(pszPath, '?') == NULL) 367 { 368 MY_UNICODE_STRING NameUniStr; 369 hFile = birdOpenParentDir(pszPath, 370 FILE_READ_DATA | SYNCHRONIZE, 371 FILE_ATTRIBUTE_NORMAL, 372 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 373 FILE_OPEN, 374 FILE_DIRECTORY_FILE | FILE_OPEN_FOR_BACKUP_INTENT | FILE_SYNCHRONOUS_IO_NONALERT, 375 OBJ_CASE_INSENSITIVE, 376 &NameUniStr); 377 if (hFile != INVALID_HANDLE_VALUE) 378 { 379 MY_FILE_ID_FULL_DIR_INFORMATION *pBuf; 380 ULONG cbBuf = sizeof(*pBuf) + NameUniStr.MaximumLength + 1024; 381 MY_IO_STATUS_BLOCK Ios; 382 MY_NTSTATUS rcNt; 383 384 pBuf = (MY_FILE_ID_FULL_DIR_INFORMATION *)alloca(cbBuf); 385 Ios.u.Status = -1; 386 Ios.Information = -1; 387 rcNt = g_pfnNtQueryDirectoryFile(hFile, NULL, NULL, NULL, &Ios, pBuf, cbBuf, 388 MyFileIdFullDirectoryInformation, FALSE, &NameUniStr, TRUE); 389 if (MY_NT_SUCCESS(rcNt)) 390 rcNt = Ios.u.Status; 391 if (MY_NT_SUCCESS(rcNt)) 392 { 393 /* 394 * Convert the data. 395 */ 396 pStat->st_mode = birdFileInfoToMode(INVALID_HANDLE_VALUE, pBuf->FileAttributes, pszPath, 397 NULL, &pStat->st_dirsymlink); 398 pStat->st_padding0[0] = 0; 399 pStat->st_padding0[1] = 0; 400 pStat->st_size = pBuf->EndOfFile.QuadPart; 401 birdNtTimeToTimeSpec(pBuf->CreationTime.QuadPart, &pStat->st_birthtim); 402 birdNtTimeToTimeSpec(pBuf->ChangeTime.QuadPart, &pStat->st_ctim); 403 birdNtTimeToTimeSpec(pBuf->LastWriteTime.QuadPart, &pStat->st_mtim); 404 birdNtTimeToTimeSpec(pBuf->LastAccessTime.QuadPart, &pStat->st_atim); 405 pStat->st_ino = pBuf->FileId.QuadPart; 406 pStat->st_nlink = 1; 407 pStat->st_rdev = 0; 408 pStat->st_uid = 0; 409 pStat->st_gid = 0; 410 pStat->st_padding1[0] = 0; 411 pStat->st_padding1[1] = 0; 412 pStat->st_padding1[2] = 0; 413 pStat->st_blksize = 65536; 414 pStat->st_blocks = (pBuf->AllocationSize.QuadPart + BIRD_STAT_BLOCK_SIZE - 1) 415 / BIRD_STAT_BLOCK_SIZE; 416 417 /* Get the serial number, reusing the buffer from above. */ 418 rcNt = g_pfnNtQueryVolumeInformationFile(hFile, &Ios, pBuf, cbBuf, MyFileFsVolumeInformation); 419 if (MY_NT_SUCCESS(rcNt)) 420 rcNt = Ios.u.Status; 421 if (MY_NT_SUCCESS(rcNt)) 422 { 423 MY_FILE_FS_VOLUME_INFORMATION const *pVolInfo = (MY_FILE_FS_VOLUME_INFORMATION const *)pBuf; 424 pStat->st_dev = pVolInfo->VolumeSerialNumber 425 | (pVolInfo->VolumeCreationTime.QuadPart << 32); 426 rc = 0; 427 } 428 else 429 { 430 pStat->st_dev = 0; 431 rc = birdSetErrnoFromNt(rcNt); 432 } 433 } 434 435 birdFreeNtPath(&NameUniStr); 436 birdCloseFile(hFile); 437 438 if (MY_NT_SUCCESS(rcNt)) 439 return 0; 440 birdSetErrnoFromNt(rcNt); 441 } 364 442 } 365 443 rc = -1;
Note:
See TracChangeset
for help on using the changeset viewer.