diff options
author | Jacek Antonelli | 2008-08-15 23:45:50 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:50 -0500 |
commit | 2a4dea528f670b9bb1f77ef27a8a1dd16603d114 (patch) | |
tree | 95c68e362703c9099d571ecbdc6142b1cda1e005 /linden/indra/llvfs/llvfs.cpp | |
parent | Second Life viewer sources 1.20.6 (diff) | |
download | meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.zip meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.gz meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.bz2 meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.xz |
Second Life viewer sources 1.20.7
Diffstat (limited to 'linden/indra/llvfs/llvfs.cpp')
-rw-r--r-- | linden/indra/llvfs/llvfs.cpp | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/linden/indra/llvfs/llvfs.cpp b/linden/indra/llvfs/llvfs.cpp index e0957db..7903e83 100644 --- a/linden/indra/llvfs/llvfs.cpp +++ b/linden/indra/llvfs/llvfs.cpp | |||
@@ -248,7 +248,7 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r | |||
248 | mDataFilename = new char[strlen(data_filename) + 1]; /* Flawfinder: ignore */ | 248 | mDataFilename = new char[strlen(data_filename) + 1]; /* Flawfinder: ignore */ |
249 | if (mIndexFilename == NULL || mDataFilename == NULL) | 249 | if (mIndexFilename == NULL || mDataFilename == NULL) |
250 | { | 250 | { |
251 | llerrs << "Memory Allocation Failure" << llendl; | 251 | LL_ERRS("VFS") << "Memory Allocation Failure" << LL_ENDL; |
252 | return; | 252 | return; |
253 | } | 253 | } |
254 | strcpy(mIndexFilename, index_filename); /* Flawfinder: ignore */ | 254 | strcpy(mIndexFilename, index_filename); /* Flawfinder: ignore */ |
@@ -261,7 +261,7 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r | |||
261 | 261 | ||
262 | if (mReadOnly) | 262 | if (mReadOnly) |
263 | { | 263 | { |
264 | llwarns << "Can't find " << mDataFilename << " to open read-only VFS" << llendl; | 264 | LL_WARNS("VFS") << "Can't find " << mDataFilename << " to open read-only VFS" << LL_ENDL; |
265 | mValid = VFSVALID_BAD_CANNOT_OPEN_READONLY; | 265 | mValid = VFSVALID_BAD_CANNOT_OPEN_READONLY; |
266 | return; | 266 | return; |
267 | } | 267 | } |
@@ -274,18 +274,18 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r | |||
274 | } | 274 | } |
275 | else | 275 | else |
276 | { | 276 | { |
277 | llwarns << "Can't open VFS data file " << mDataFilename << " attempting to use alternate" << llendl; | 277 | LL_WARNS("VFS") << "Can't open VFS data file " << mDataFilename << " attempting to use alternate" << LL_ENDL; |
278 | 278 | ||
279 | char *temp_index = new char[strlen(mIndexFilename) + 10]; /* Flawfinder: ignore */ | 279 | char *temp_index = new char[strlen(mIndexFilename) + 10]; /* Flawfinder: ignore */ |
280 | if (!temp_index) | 280 | if (!temp_index) |
281 | { | 281 | { |
282 | llerrs << "Out of the memory in LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL read_only, const U32 presize, const BOOL remove_after_crash)" << llendl; | 282 | LL_ERRS("VFS") << "Out of the memory in LLVFS::LLVFS()" << LL_ENDL; |
283 | return; | 283 | return; |
284 | } | 284 | } |
285 | char *temp_data = new char[strlen(mDataFilename) + 10]; /* Flawfinder: ignore */ | 285 | char *temp_data = new char[strlen(mDataFilename) + 10]; /* Flawfinder: ignore */ |
286 | if (!temp_data) | 286 | if (!temp_data) |
287 | { | 287 | { |
288 | llerrs << "Out of the memory in LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL read_only, const U32 presize, const BOOL remove_after_crash)" << llendl; | 288 | LL_ERRS("VFS") << "Out of the memory in LLVFS::LLVFS()" << LL_ENDL; |
289 | return; | 289 | return; |
290 | } | 290 | } |
291 | 291 | ||
@@ -310,7 +310,7 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r | |||
310 | 310 | ||
311 | if (! mDataFP) | 311 | if (! mDataFP) |
312 | { | 312 | { |
313 | llwarns << "Couldn't open vfs data file after trying many alternates" << llendl; | 313 | LL_WARNS("VFS") << "Couldn't open vfs data file after trying many alternates" << LL_ENDL; |
314 | mValid = VFSVALID_BAD_CANNOT_CREATE; | 314 | mValid = VFSVALID_BAD_CANNOT_CREATE; |
315 | delete[] temp_index; | 315 | delete[] temp_index; |
316 | delete[] temp_data; | 316 | delete[] temp_data; |
@@ -338,7 +338,7 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r | |||
338 | char* marker = new char[strlen(mDataFilename) + strlen(".open") + 1]; /* Flawfinder: ignore */ | 338 | char* marker = new char[strlen(mDataFilename) + strlen(".open") + 1]; /* Flawfinder: ignore */ |
339 | if (!marker ) | 339 | if (!marker ) |
340 | { | 340 | { |
341 | llerrs << "Out of memory in LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL read_only, const U32 presize, const BOOL remove_after_crash)" << llendl; | 341 | LL_ERRS("VFS") << "Out of memory in LLVFS::LLVFS()" << LL_ENDL; |
342 | return; | 342 | return; |
343 | } | 343 | } |
344 | sprintf(marker, "%s.open", mDataFilename); /* Flawfinder: ignore */ | 344 | sprintf(marker, "%s.open", mDataFilename); /* Flawfinder: ignore */ |
@@ -348,7 +348,7 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r | |||
348 | unlockAndClose(mDataFP); | 348 | unlockAndClose(mDataFP); |
349 | mDataFP = NULL; | 349 | mDataFP = NULL; |
350 | 350 | ||
351 | llwarns << "VFS: File left open on last run, removing old VFS file " << mDataFilename << llendl; | 351 | LL_WARNS("VFS") << "VFS: File left open on last run, removing old VFS file " << mDataFilename << LL_ENDL; |
352 | LLFile::remove(mIndexFilename); | 352 | LLFile::remove(mIndexFilename); |
353 | LLFile::remove(mDataFilename); | 353 | LLFile::remove(mDataFilename); |
354 | LLFile::remove(marker); | 354 | LLFile::remove(marker); |
@@ -356,7 +356,7 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r | |||
356 | mDataFP = openAndLock(mDataFilename, "w+b", FALSE); | 356 | mDataFP = openAndLock(mDataFilename, "w+b", FALSE); |
357 | if (!mDataFP) | 357 | if (!mDataFP) |
358 | { | 358 | { |
359 | llwarns << "Can't open VFS data file in crash recovery" << llendl; | 359 | LL_WARNS("VFS") << "Can't open VFS data file in crash recovery" << LL_ENDL; |
360 | mValid = VFSVALID_BAD_CANNOT_CREATE; | 360 | mValid = VFSVALID_BAD_CANNOT_CREATE; |
361 | return; | 361 | return; |
362 | } | 362 | } |
@@ -414,9 +414,9 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r | |||
414 | if (block->mLength && block->mSize > 0) | 414 | if (block->mLength && block->mSize > 0) |
415 | { | 415 | { |
416 | // this is corrupt, not empty | 416 | // this is corrupt, not empty |
417 | llwarns << "VFS corruption: " << block->mFileID << " (" << block->mFileType << ") at index " << block->mIndexLocation << " DS: " << data_size << llendl; | 417 | LL_WARNS("VFS") << "VFS corruption: " << block->mFileID << " (" << block->mFileType << ") at index " << block->mIndexLocation << " DS: " << data_size << LL_ENDL; |
418 | llwarns << "Length: " << block->mLength << "\tLocation: " << block->mLocation << "\tSize: " << block->mSize << llendl; | 418 | LL_WARNS("VFS") << "Length: " << block->mLength << "\tLocation: " << block->mLocation << "\tSize: " << block->mSize << LL_ENDL; |
419 | llwarns << "File has bad data - VFS removed" << llendl; | 419 | LL_WARNS("VFS") << "File has bad data - VFS removed" << LL_ENDL; |
420 | 420 | ||
421 | delete[] buffer; | 421 | delete[] buffer; |
422 | delete block; | 422 | delete block; |
@@ -481,13 +481,13 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r | |||
481 | if (cur_file_block->mLocation == last_file_block->mLocation | 481 | if (cur_file_block->mLocation == last_file_block->mLocation |
482 | && cur_file_block->mLength == last_file_block->mLength) | 482 | && cur_file_block->mLength == last_file_block->mLength) |
483 | { | 483 | { |
484 | llwarns << "VFS: removing duplicate entry" | 484 | LL_WARNS("VFS") << "VFS: removing duplicate entry" |
485 | << " at " << cur_file_block->mLocation | 485 | << " at " << cur_file_block->mLocation |
486 | << " length " << cur_file_block->mLength | 486 | << " length " << cur_file_block->mLength |
487 | << " size " << cur_file_block->mSize | 487 | << " size " << cur_file_block->mSize |
488 | << " ID " << cur_file_block->mFileID | 488 | << " ID " << cur_file_block->mFileID |
489 | << " type " << cur_file_block->mFileType | 489 | << " type " << cur_file_block->mFileType |
490 | << llendl; | 490 | << LL_ENDL; |
491 | 491 | ||
492 | // Duplicate entries. Nuke them both for safety. | 492 | // Duplicate entries. Nuke them both for safety. |
493 | mFileBlocks.erase(*cur_file_block); // remove ID/type entry | 493 | mFileBlocks.erase(*cur_file_block); // remove ID/type entry |
@@ -528,12 +528,12 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r | |||
528 | mDataFP = NULL; | 528 | mDataFP = NULL; |
529 | LLFile::remove( mDataFilename ); | 529 | LLFile::remove( mDataFilename ); |
530 | 530 | ||
531 | llwarns << "VFS: overlapping entries" | 531 | LL_WARNS("VFS") << "VFS: overlapping entries" |
532 | << " at " << cur_file_block->mLocation | 532 | << " at " << cur_file_block->mLocation |
533 | << " length " << cur_file_block->mLength | 533 | << " length " << cur_file_block->mLength |
534 | << " ID " << cur_file_block->mFileID | 534 | << " ID " << cur_file_block->mFileID |
535 | << " type " << cur_file_block->mFileType | 535 | << " type " << cur_file_block->mFileType |
536 | << llendl; | 536 | << LL_ENDL; |
537 | mValid = VFSVALID_BAD_CORRUPT; | 537 | mValid = VFSVALID_BAD_CORRUPT; |
538 | return; | 538 | return; |
539 | } | 539 | } |
@@ -563,7 +563,7 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r | |||
563 | { | 563 | { |
564 | if (mReadOnly) | 564 | if (mReadOnly) |
565 | { | 565 | { |
566 | llwarns << "Can't find " << mIndexFilename << " to open read-only VFS" << llendl; | 566 | LL_WARNS("VFS") << "Can't find " << mIndexFilename << " to open read-only VFS" << LL_ENDL; |
567 | mValid = VFSVALID_BAD_CANNOT_OPEN_READONLY; | 567 | mValid = VFSVALID_BAD_CANNOT_OPEN_READONLY; |
568 | return; | 568 | return; |
569 | } | 569 | } |
@@ -572,7 +572,7 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r | |||
572 | mIndexFP = openAndLock(mIndexFilename, "w+b", FALSE); | 572 | mIndexFP = openAndLock(mIndexFilename, "w+b", FALSE); |
573 | if (!mIndexFP) | 573 | if (!mIndexFP) |
574 | { | 574 | { |
575 | llwarns << "Couldn't open an index file for the VFS, probably a sharing violation!" << llendl; | 575 | LL_WARNS("VFS") << "Couldn't open an index file for the VFS, probably a sharing violation!" << LL_ENDL; |
576 | 576 | ||
577 | unlockAndClose( mDataFP ); | 577 | unlockAndClose( mDataFP ); |
578 | mDataFP = NULL; | 578 | mDataFP = NULL; |
@@ -593,11 +593,11 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r | |||
593 | char* marker = new char[strlen(mDataFilename) + strlen(".open") + 1]; | 593 | char* marker = new char[strlen(mDataFilename) + strlen(".open") + 1]; |
594 | if (!marker) | 594 | if (!marker) |
595 | { | 595 | { |
596 | llerrs << "Out of memory in LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL read_only, const U32 presize, const BOOL remove_after_crash)" << llendl; | 596 | LL_ERRS("VFS") << "Out of memory in LLVFS::LLVFS()" << LL_ENDL; |
597 | return; | 597 | return; |
598 | } | 598 | } |
599 | sprintf(marker, "%s.open", mDataFilename); /* Flawfinder: ignore */ | 599 | sprintf(marker, "%s.open", mDataFilename); /* Flawfinder: ignore */ |
600 | FILE* marker_fp = LLFile::fopen(marker, "w"); /* Flawfinder: ignore */ | 600 | LLFILE* marker_fp = LLFile::fopen(marker, "w"); /* Flawfinder: ignore */ |
601 | if (marker_fp) | 601 | if (marker_fp) |
602 | { | 602 | { |
603 | fclose(marker_fp); | 603 | fclose(marker_fp); |
@@ -607,7 +607,8 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r | |||
607 | marker = NULL; | 607 | marker = NULL; |
608 | } | 608 | } |
609 | 609 | ||
610 | llinfos << "VFS: Using index file " << mIndexFilename << " and data file " << mDataFilename << llendl; | 610 | LL_WARNS("VFS") << "Using index file " << mIndexFilename << LL_ENDL; |
611 | LL_WARNS("VFS") << "Using data file " << mDataFilename << LL_ENDL; | ||
611 | 612 | ||
612 | mValid = VFSVALID_OK; | 613 | mValid = VFSVALID_OK; |
613 | } | 614 | } |
@@ -616,7 +617,7 @@ LLVFS::~LLVFS() | |||
616 | { | 617 | { |
617 | if (mDataMutex->isLocked()) | 618 | if (mDataMutex->isLocked()) |
618 | { | 619 | { |
619 | llerrs << "LLVFS destroyed with mutex locked" << llendl; | 620 | LL_ERRS("VFS") << "LLVFS destroyed with mutex locked" << LL_ENDL; |
620 | } | 621 | } |
621 | 622 | ||
622 | unlockAndClose(mIndexFP); | 623 | unlockAndClose(mIndexFP); |
@@ -642,7 +643,7 @@ LLVFS::~LLVFS() | |||
642 | char* marker_file = new char[strlen(mDataFilename) + strlen(".open") + 1]; | 643 | char* marker_file = new char[strlen(mDataFilename) + strlen(".open") + 1]; |
643 | if (marker_file == NULL) | 644 | if (marker_file == NULL) |
644 | { | 645 | { |
645 | llerrs << "Memory Allocation Failure" << llendl; | 646 | LL_ERRS("VFS") << "Memory Allocation Failure" << LL_ENDL; |
646 | return; | 647 | return; |
647 | } | 648 | } |
648 | sprintf(marker_file, "%s.open", mDataFilename); /* Flawfinder: ignore */ | 649 | sprintf(marker_file, "%s.open", mDataFilename); /* Flawfinder: ignore */ |
@@ -2134,7 +2135,7 @@ void LLVFS::dumpFiles() | |||
2134 | //============================================================================ | 2135 | //============================================================================ |
2135 | 2136 | ||
2136 | // static | 2137 | // static |
2137 | FILE *LLVFS::openAndLock(const char *filename, const char *mode, BOOL read_lock) | 2138 | LLFILE *LLVFS::openAndLock(const char *filename, const char *mode, BOOL read_lock) |
2138 | { | 2139 | { |
2139 | #if LL_WINDOWS | 2140 | #if LL_WINDOWS |
2140 | 2141 | ||
@@ -2142,7 +2143,7 @@ FILE *LLVFS::openAndLock(const char *filename, const char *mode, BOOL read_lock) | |||
2142 | 2143 | ||
2143 | #else | 2144 | #else |
2144 | 2145 | ||
2145 | FILE *fp; | 2146 | LLFILE *fp; |
2146 | int fd; | 2147 | int fd; |
2147 | 2148 | ||
2148 | // first test the lock in a non-destructive way | 2149 | // first test the lock in a non-destructive way |
@@ -2192,7 +2193,7 @@ FILE *LLVFS::openAndLock(const char *filename, const char *mode, BOOL read_lock) | |||
2192 | } | 2193 | } |
2193 | 2194 | ||
2194 | // static | 2195 | // static |
2195 | void LLVFS::unlockAndClose(FILE *fp) | 2196 | void LLVFS::unlockAndClose(LLFILE *fp) |
2196 | { | 2197 | { |
2197 | if (fp) | 2198 | if (fp) |
2198 | { | 2199 | { |