Changeset 2708 in kBuild for trunk/src/lib/nt
- Timestamp:
- Nov 21, 2013 10:26:40 AM (11 years ago)
- Location:
- trunk/src/lib/nt
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/nt/ntdir.c
r2702 r2708 92 92 93 93 94 /** 95 * Alternative opendir, with extra stat() info returned by readdir(). 96 */ 97 BirdDir_T *birdDirOpenExtraInfo(const char *pszPath) 98 { 99 return birdDirOpenInternal(pszPath, NULL, 0 /*fMinimalInfo*/); 100 } 101 102 94 103 static int birdDirReadMore(BirdDir_T *pDir) 95 104 { … … 229 238 { 230 239 fSkipEntry = 1; 240 pDir->fHaveData = 0; 231 241 continue; 232 242 } 233 243 234 pEntry->d_ino = 0;235 pEntry->d_s ize = 0;244 memset(&pEntry->d_stat, 0, sizeof(pEntry->d_stat)); 245 pEntry->d_stat.st_mode = S_IFMT; 236 246 pEntry->d_type = DT_UNKNOWN; 237 pEntry->d_dirsymlink = 0;238 247 pEntry->d_reclen = 0; 239 248 pEntry->d_namlen = 0; … … 246 255 } 247 256 248 //case MyFileIdBothDirectoryInformation: 249 //{ 250 // MY_FILE_BOTH_DIR_INFORMATION 251 // 252 //} 257 case MyFileIdFullDirectoryInformation: 258 { 259 MY_FILE_ID_FULL_DIR_INFORMATION *pInfo = (MY_FILE_ID_FULL_DIR_INFORMATION *)&pDir->pabBuf[pDir->offBuf]; 260 if ( pDir->offBuf >= pDir->cbBuf - MIN_SIZEOF_MY_FILE_ID_FULL_DIR_INFORMATION 261 || pInfo->FileNameLength >= pDir->cbBuf 262 || pDir->offBuf + pInfo->FileNameLength + MIN_SIZEOF_MY_FILE_ID_FULL_DIR_INFORMATION > pDir->cbBuf) 263 { 264 fSkipEntry = 1; 265 pDir->fHaveData = 0; 266 continue; 267 } 268 269 pEntry->d_type = DT_UNKNOWN; 270 pEntry->d_reclen = 0; 271 pEntry->d_namlen = 0; 272 if (birdDirCopyNameToEntry(pInfo->FileName, pInfo->FileNameLength, pEntry) != 0) 273 fSkipEntry = 1; 274 birdStatFillFromFileIdFullDirInfo(&pEntry->d_stat, pInfo, pEntry->d_name); 275 pEntry->d_stat.st_dev = pDir->uDev; 276 switch (pEntry->d_stat.st_mode & S_IFMT) 277 { 278 case S_IFREG: pEntry->d_type = DT_REG; break; 279 case S_IFDIR: pEntry->d_type = DT_DIR; break; 280 case S_IFLNK: pEntry->d_type = DT_LNK; break; 281 case S_IFIFO: pEntry->d_type = DT_FIFO; break; 282 case S_IFCHR: pEntry->d_type = DT_CHR; break; 283 default: 284 #ifndef NDEBUG 285 __debugbreak(); 286 #endif 287 pEntry->d_type = DT_UNKNOWN; 288 break; 289 } 290 291 cbMinCur = MIN_SIZEOF_MY_FILE_ID_FULL_DIR_INFORMATION + pInfo->FileNameLength; 292 offNext = pInfo->NextEntryOffset; 293 break; 294 } 253 295 254 296 default: -
trunk/src/lib/nt/ntdir.h
r2702 r2708 37 37 typedef struct dirent 38 38 { 39 /** File ID if available. */ 40 unsigned __int64 d_ino; 41 /** The file size. */ 42 unsigned __int64 d_size; 43 /** The name type. */ 44 unsigned char d_type; 45 /** Qualifies the DT_LNK d_type value. */ 46 unsigned char d_dirsymlink; 39 /** Optional stat information. 40 * Only provided if using birdDirOpenExtraInfo(). */ 41 BirdStat_T d_stat; 47 42 /** The record length. */ 48 43 unsigned __int16 d_reclen; 49 44 /** The name length. */ 50 45 unsigned __int16 d_namlen; 46 /** The name type. */ 47 unsigned char d_type; 51 48 /** The name. */ 52 char d_name[512 - 8 - 8 - 1 - 1 - 2 - 2];49 char d_name[512 - sizeof(BirdStat_T) - 2 - 2 - 1]; 53 50 } BirdDirEntry_T; 51 52 #define d_ino d_stat.st_ino; 54 53 55 54 /** @name d_type values. … … 98 97 99 98 BirdDir_T *birdDirOpen(const char *pszPath); 99 BirdDir_T *birdDirOpenExtraInfo(const char *pszPath); 100 100 BirdDirEntry_T *birdDirRead(BirdDir_T *pDir); 101 101 long birdDirTell(BirdDir_T *pDir); -
trunk/src/lib/nt/ntstat.c
r2707 r2708 184 184 185 185 186 /** 187 * Fills in a stat structure from an MY_FILE_ID_FULL_DIR_INFORMATION entry. 188 * 189 * @param pStat The stat structure. 190 * @param pBuf The MY_FILE_ID_FULL_DIR_INFORMATION entry. 191 * @param pszPath Optionally, the path for X bit checks. 192 */ 193 void birdStatFillFromFileIdFullDirInfo(BirdStat_T *pStat, MY_FILE_ID_FULL_DIR_INFORMATION const *pBuf, const char *pszPath) 194 { 195 pStat->st_mode = birdFileInfoToMode(INVALID_HANDLE_VALUE, pBuf->FileAttributes, pszPath, 196 NULL, &pStat->st_dirsymlink); 197 pStat->st_padding0[0] = 0; 198 pStat->st_padding0[1] = 0; 199 pStat->st_size = pBuf->EndOfFile.QuadPart; 200 birdNtTimeToTimeSpec(pBuf->CreationTime.QuadPart, &pStat->st_birthtim); 201 birdNtTimeToTimeSpec(pBuf->ChangeTime.QuadPart, &pStat->st_ctim); 202 birdNtTimeToTimeSpec(pBuf->LastWriteTime.QuadPart, &pStat->st_mtim); 203 birdNtTimeToTimeSpec(pBuf->LastAccessTime.QuadPart, &pStat->st_atim); 204 pStat->st_ino = pBuf->FileId.QuadPart; 205 pStat->st_nlink = 1; 206 pStat->st_rdev = 0; 207 pStat->st_uid = 0; 208 pStat->st_gid = 0; 209 pStat->st_padding1[0] = 0; 210 pStat->st_padding1[1] = 0; 211 pStat->st_padding1[2] = 0; 212 pStat->st_blksize = 65536; 213 pStat->st_blocks = (pBuf->AllocationSize.QuadPart + BIRD_STAT_BLOCK_SIZE - 1) 214 / BIRD_STAT_BLOCK_SIZE; 215 } 216 217 186 218 int birdStatHandle(HANDLE hFile, BirdStat_T *pStat, const char *pszPath) 187 219 { … … 394 426 * Convert the data. 395 427 */ 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; 428 birdStatFillFromFileIdFullDirInfo(pStat, pBuf, pszPath); 416 429 417 430 /* Get the serial number, reusing the buffer from above. */ -
trunk/src/lib/nt/ntstat.h
r2707 r2708 79 79 int birdStatOnFd(int fd, BirdStat_T *pStat); 80 80 int birdStatModTimeOnly(const char *pszPath, BirdTimeSpec_T *pTimeSpec, int fFollowLink); 81 #ifdef ___nt_ntstuff_h 82 void birdStatFillFromFileIdFullDirInfo(BirdStat_T *pStat, MY_FILE_ID_FULL_DIR_INFORMATION const *pBuf, const char *pszPath); 83 #endif 81 84 82 85 #define STAT_REDEFINED_ALREADY -
trunk/src/lib/nt/ntstuff.h
r2704 r2708 197 197 WCHAR FileName[1]; 198 198 } MY_FILE_ID_FULL_DIR_INFORMATION; 199 /** The sizeof(MY_FILE_NAMES_INFORMATION) without the FileName. */ 200 #define MIN_SIZEOF_MY_FILE_ID_FULL_DIR_INFORMATION ( (size_t)&((MY_FILE_ID_FULL_DIR_INFORMATION *)0)->FileName ) 199 201 200 202
Note:
See TracChangeset
for help on using the changeset viewer.