Changeset 2115
- Timestamp:
- 28/03/2008 22:18:44 (9 months ago)
- Location:
- box/trunk
- Files:
-
- 16 modified
-
bin/bbackupd/BackupClientContext.cpp (modified) (1 diff)
-
bin/bbackupd/BackupDaemon.cpp (modified) (4 diffs)
-
bin/bbackupd/Win32ServiceFunctions.cpp (modified) (2 diffs)
-
bin/bbackupquery/BackupQueries.cpp (modified) (5 diffs)
-
bin/bbackupquery/bbackupquery.cpp (modified) (1 diff)
-
lib/backupclient/BackupClientRestore.cpp (modified) (4 diffs)
-
lib/common/BoxTime.cpp (modified) (1 diff)
-
lib/common/EventWatchFilesystemObject.cpp (modified) (5 diffs)
-
lib/common/FileStream.cpp (modified) (6 diffs)
-
lib/common/FileStream.h (modified) (1 diff)
-
lib/common/Guards.h (modified) (1 diff)
-
lib/common/Logging.h (modified) (1 diff)
-
lib/server/Daemon.cpp (modified) (6 diffs)
-
lib/server/ServerControl.h (modified) (1 diff)
-
lib/server/SocketListen.h (modified) (13 diffs)
-
lib/server/SocketStream.cpp (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/bin/bbackupd/BackupClientContext.cpp
r1783 r2115 147 147 if (!mpExtendedLogFileHandle) 148 148 { 149 BOX_ ERROR("Failed to open extended log"150 " file: " << strerror(errno));149 BOX_LOG_SYS_ERROR("Failed to open extended " 150 "log file: " << mExtendedLogFile); 151 151 } 152 152 else -
box/trunk/bin/bbackupd/BackupDaemon.cpp
r2109 r2115 1813 1813 #endif // HAVE_STRUCT_STATVFS_F_MNTONNAME 1814 1814 { 1815 BOX_ WARNING("Failed to stat location "1815 BOX_LOG_SYS_WARNING("Failed to stat location " 1816 1816 "path '" << apLoc->mPath << 1817 "' (" << strerror(errno) << 1818 "), skipping location '" << 1817 "', skipping location '" << 1819 1818 apLoc->mName << "'"); 1820 1819 continue; … … 2190 2189 if(::rename(newmap.c_str(), target.c_str()) != 0) 2191 2190 { 2192 BOX_ERROR("failed to rename ID map: " << newmap 2193 << " to " << target << ": " 2194 << strerror(errno)); 2191 BOX_LOG_SYS_ERROR("Failed to rename ID map: " << 2192 newmap << " to " << target); 2195 2193 THROW_EXCEPTION(CommonException, OSFileError) 2196 2194 } … … 3056 3054 if(!FileExists(storeObjectInfoFile.c_str())) 3057 3055 { 3058 // File doesn't exist -- so can't be deleted. But something isn't quite right, so log a message 3059 BOX_WARNING("Store object info file did not exist when it " 3060 "was supposed to. (" << storeObjectInfoFile << ")"); 3056 // File doesn't exist -- so can't be deleted. But something 3057 // isn't quite right, so log a message 3058 BOX_WARNING("StoreObjectInfoFile did not exist when it " 3059 "was supposed to: " << storeObjectInfoFile); 3061 3060 3062 3061 // Return true to stop things going around in a loop … … 3067 3066 if(::unlink(storeObjectInfoFile.c_str()) != 0) 3068 3067 { 3069 BOX_ ERROR("Failed to delete the old store object info file:"3070 << storeObjectInfoFile << ": "<< strerror(errno));3068 BOX_LOG_SYS_ERROR("Failed to delete the old " 3069 "StoreObjectInfoFile: " << storeObjectInfoFile); 3071 3070 return false; 3072 3071 } -
box/trunk/bin/bbackupd/Win32ServiceFunctions.cpp
r1892 r2115 208 208 if (emu_stat(pConfigFileName, &st) != 0) 209 209 { 210 BOX_ ERROR("Failed to open configuration file '" <<211 pConfigFileName << "': " << strerror(errno));210 BOX_LOG_SYS_ERROR("Failed to open configuration file " 211 "'" << pConfigFileName << "'"); 212 212 return 1; 213 213 } … … 222 222 } 223 223 224 SC_HANDLE scm = OpenSCManager(0, 0,SC_MANAGER_CREATE_SERVICE);224 SC_HANDLE scm = OpenSCManager(0, 0, SC_MANAGER_CREATE_SERVICE); 225 225 226 226 if (!scm) -
box/trunk/bin/bbackupquery/BackupQueries.cpp
r1926 r2115 811 811 else 812 812 { 813 BOX_ ERROR("Error changing to directory '" <<814 args[0] << ": " << strerror(errno));813 BOX_LOG_SYS_ERROR("Failed to change to directory " 814 "'" << args[0] << "'"); 815 815 } 816 816 … … 823 823 if(::getcwd(wd, PATH_MAX) == 0) 824 824 { 825 BOX_ERROR("Error getting current directory: " << 826 strerror(errno)); 825 BOX_LOG_SYS_ERROR("Error getting current directory"); 827 826 SetReturnCode(COMMAND_RETURN_ERROR); 828 827 return; … … 1400 1399 else 1401 1400 { 1402 BOX_WARNING("Failed to access local directory '" << 1403 localDirDisplay << ": " << strerror(errno) << 1404 "'."); 1401 BOX_LOG_SYS_WARNING("Failed to access local directory " 1402 "'" << localDirDisplay << "'"); 1405 1403 rParams.mUncheckedFiles ++; 1406 1404 } … … 1450 1448 if(dirhandle == 0) 1451 1449 { 1452 BOX_ WARNING("Failed to open local directory '" <<1453 localDirDisplay << "' : " << strerror(errno));1450 BOX_LOG_SYS_WARNING("Failed to open local directory '" << 1451 localDirDisplay << "'"); 1454 1452 rParams.mUncheckedFiles ++; 1455 1453 return; … … 1519 1517 if(::closedir(dirhandle) != 0) 1520 1518 { 1521 BOX_ ERROR("Failed to close local directory '" <<1522 localDirDisplay << "': " << strerror(errno));1519 BOX_LOG_SYS_ERROR("Failed to close local directory " 1520 "'" << localDirDisplay << "'"); 1523 1521 } 1524 1522 dirhandle = 0; -
box/trunk/bin/bbackupquery/bbackupquery.cpp
r2104 r2115 175 175 if(logFile == 0) 176 176 { 177 BOX_ ERROR("Failed to open log file '" <<178 optarg << "': " << strerror(errno));177 BOX_LOG_SYS_ERROR("Failed to open log file " 178 "'" << optarg << "'"); 179 179 } 180 180 break; -
box/trunk/lib/backupclient/BackupClientRestore.cpp
r1921 r2115 268 268 if(::unlink(rLocalDirectoryName.c_str()) != 0) 269 269 { 270 BOX_ ERROR("Failed to delete file " <<271 rLocalDirectoryName << ": " <<272 strerror(errno));270 BOX_LOG_SYS_ERROR("Failed to delete " 271 "file '" << 272 rLocalDirectoryName << "'"); 273 273 return Restore_UnknownError; 274 274 } 275 275 BOX_TRACE("In restore, directory name " 276 "collision with file " <<277 rLocalDirectoryName );276 "collision with file '" << 277 rLocalDirectoryName << "'"); 278 278 } 279 279 break; … … 379 379 ::mkdir(rLocalDirectoryName.c_str(), S_IRWXU) != 0) 380 380 { 381 BOX_ERROR("Failed to create directory '" << 382 rLocalDirectoryName << "': " << 383 strerror(errno)); 381 BOX_LOG_SYS_ERROR("Failed to create directory '" << 382 rLocalDirectoryName << "'"); 384 383 return Restore_UnknownError; 385 384 } … … 452 451 // Local name 453 452 BackupStoreFilenameClear nm(en->GetName()); 454 std::string localFilename(rLocalDirectoryName + DIRECTORY_SEPARATOR_ASCHAR + nm.GetClearFilename()); 453 std::string localFilename(rLocalDirectoryName + 454 DIRECTORY_SEPARATOR_ASCHAR + 455 nm.GetClearFilename()); 455 456 456 457 // Unlink anything which already exists: … … 460 461 ::unlink(localFilename.c_str()) != 0) 461 462 { 462 BOX_ ERROR("Failed to delete file '" <<463 localFilename << "': " <<464 strerror(errno));463 BOX_LOG_SYS_ERROR("Failed to delete " 464 "file '" << localFilename << 465 "'"); 465 466 return Restore_UnknownError; 466 467 } 467 468 468 469 // Request it from the store 469 rConnection.QueryGetFile(DirectoryID, en->GetObjectID()); 470 rConnection.QueryGetFile(DirectoryID, 471 en->GetObjectID()); 470 472 471 473 // Stream containing encoded file 472 std::auto_ptr<IOStream> objectStream(rConnection.ReceiveStream()); 473 474 // Decode the file -- need to do different things depending on whether 475 // the directory entry has additional attributes 474 std::auto_ptr<IOStream> objectStream( 475 rConnection.ReceiveStream()); 476 477 // Decode the file -- need to do different 478 // things depending on whether the directory 479 // entry has additional attributes 476 480 try 477 481 { -
box/trunk/lib/common/BoxTime.cpp
r1783 r2115 40 40 if (gettimeofday(&tv, NULL) != 0) 41 41 { 42 BOX_ ERROR("Failed to gettimeofday(), dropping"43 " precision: " << strerror(errno));42 BOX_LOG_SYS_ERROR("Failed to gettimeofday(), " 43 "dropping precision"); 44 44 } 45 45 else -
box/trunk/lib/common/EventWatchFilesystemObject.cpp
r1694 r2115 27 27 // 28 28 // Function 29 // Name: EventWatchFilesystemObject::EventWatchFilesystemObject(const char *) 30 // Purpose: Constructor -- opens the file object 31 // Created: 12/3/04 29 // Name: EventWatchFilesystemObject::EventWatchFilesystemObject 30 // (const char *) 31 // Purpose: Constructor -- opens the file object 32 // Created: 12/3/04 32 33 // 33 34 // -------------------------------------------------------------------------- … … 40 41 if(mDescriptor == -1) 41 42 { 42 BOX_ERROR("EventWatchFilesystemObject: " 43 "Failed to open file '" << Filename << "': " << 44 strerror(errno)); 43 BOX_LOG_SYS_ERROR("EventWatchFilesystemObject: " 44 "Failed to open file '" << Filename << "'"); 45 45 THROW_EXCEPTION(CommonException, OSFileOpenError) 46 46 } … … 54 54 // 55 55 // Function 56 // Name: EventWatchFilesystemObject::~EventWatchFilesystemObject()57 // Purpose: Destructor58 // Created: 12/3/0456 // Name: EventWatchFilesystemObject::~EventWatchFilesystemObject() 57 // Purpose: Destructor 58 // Created: 12/3/04 59 59 // 60 60 // -------------------------------------------------------------------------- … … 71 71 // 72 72 // Function 73 // Name: EventWatchFilesystemObject::EventWatchFilesystemObject(const EventWatchFilesystemObject &) 74 // Purpose: Copy constructor 75 // Created: 12/3/04 73 // Name: EventWatchFilesystemObject::EventWatchFilesystemObject 74 // (const EventWatchFilesystemObject &) 75 // Purpose: Copy constructor 76 // Created: 12/3/04 76 77 // 77 78 // -------------------------------------------------------------------------- 78 EventWatchFilesystemObject::EventWatchFilesystemObject(const EventWatchFilesystemObject &rToCopy) 79 EventWatchFilesystemObject::EventWatchFilesystemObject( 80 const EventWatchFilesystemObject &rToCopy) 79 81 : mDescriptor(::dup(rToCopy.mDescriptor)) 80 82 { … … 90 92 // 91 93 // Function 92 // Name: EventWatchFilesystemObject::FillInKEvent(struct kevent &, int)93 // Purpose: For WaitForEvent94 // Created: 12/3/0494 // Name: EventWatchFilesystemObject::FillInKEvent(struct kevent &, int) 95 // Purpose: For WaitForEvent 96 // Created: 12/3/04 95 97 // 96 98 // -------------------------------------------------------------------------- 97 void EventWatchFilesystemObject::FillInKEvent(struct kevent &rEvent, int Flags) const 99 void EventWatchFilesystemObject::FillInKEvent(struct kevent &rEvent, 100 int Flags) const 98 101 { 99 EV_SET(&rEvent, mDescriptor, EVFILT_VNODE, EV_CLEAR, NOTE_DELETE | NOTE_WRITE, 0, (void*)this); 102 EV_SET(&rEvent, mDescriptor, EVFILT_VNODE, EV_CLEAR, 103 NOTE_DELETE | NOTE_WRITE, 0, (void*)this); 100 104 } 101 105 #else 102 void EventWatchFilesystemObject::FillInPoll(int &fd, short &events, int Flags) const 106 void EventWatchFilesystemObject::FillInPoll(int &fd, short &events, 107 int Flags) const 103 108 { 104 109 THROW_EXCEPTION(CommonException, KQueueNotSupportedOnThisPlatform) -
box/trunk/lib/common/FileStream.cpp
r1369 r2115 31 31 : mOSFileHandle(::open(Filename, flags, mode)), 32 32 #endif 33 mIsEOF(false) 33 mIsEOF(false), 34 mFileName(Filename) 34 35 { 35 36 #ifdef WIN32 … … 50 51 } 51 52 } 52 #ifdef WIN3253 this->fileName = Filename;54 #endif55 53 } 56 54 … … 66 64 FileStream::FileStream(tOSFileHandle FileDescriptor) 67 65 : mOSFileHandle(FileDescriptor), 68 mIsEOF(false) 66 mIsEOF(false), 67 mFileName("HANDLE") 69 68 { 70 69 #ifdef WIN32 … … 78 77 THROW_EXCEPTION(CommonException, OSFileOpenError) 79 78 } 80 #ifdef WIN3281 this->fileName = "HANDLE";82 #endif83 79 } 84 80 … … 151 147 ); 152 148 153 if ( valid)149 if(valid) 154 150 { 155 151 r = numBytesRead; 156 152 } 157 else if (GetLastError() == ERROR_BROKEN_PIPE)153 else if(GetLastError() == ERROR_BROKEN_PIPE) 158 154 { 159 155 r = 0; … … 161 157 else 162 158 { 163 BOX_ERROR("Failed to read from file: " << 164 GetErrorMessage(GetLastError())); 159 BOX_LOG_WIN_ERROR("Failed to read from file: " << mFileName); 165 160 r = -1; 166 161 } 167 162 #else 168 163 int r = ::read(mOSFileHandle, pBuffer, NBytes); 169 #endif170 164 if(r == -1) 171 165 { 166 BOX_LOG_SYS_ERROR("Failed to read from file: " << mFileName); 167 } 168 #endif 169 170 if(r == -1) 171 { 172 172 THROW_EXCEPTION(CommonException, OSFileReadError) 173 173 } 174 174 175 if(r == 0) 175 176 { -
box/trunk/lib/common/FileStream.h
r950 r2115 58 58 FileStream(const FileStream &rToCopy) { /* do not call */ } 59 59 60 #ifdef WIN3261 60 // for debugging.. 62 std::string fileName; 63 #endif 61 std::string mFileName; 64 62 }; 65 63 -
box/trunk/lib/common/Guards.h
r1777 r2115 38 38 if(mOSFileHandle < 0) 39 39 { 40 BOX_ ERROR("FileHandleGuard: failed to open file '" <<41 rFilename << "': " << strerror(errno));40 BOX_LOG_SYS_ERROR("FileHandleGuard: failed to open " 41 "file '" << rFilename << "'"); 42 42 THROW_EXCEPTION(CommonException, OSFileOpenError) 43 43 } -
box/trunk/lib/common/Logging.h
r2102 r2115 48 48 if (Logging::IsEnabled(Log::TRACE)) \ 49 49 { BOX_LOG(Log::TRACE, stuff) } 50 51 #define BOX_LOG_SYS_WARNING(stuff) \ 52 BOX_WARNING(stuff << ": " << strerror(errno) << " (" << errno << ")") 53 #define BOX_LOG_SYS_ERROR(stuff) \ 54 BOX_ERROR(stuff << ": " << strerror(errno) << " (" << errno << ")") 55 #define BOX_LOG_SYS_FATAL(stuff) \ 56 BOX_FATAL(stuff << ": " << strerror(errno) << " (" << errno << ")") 57 58 #ifdef WIN32 59 #define BOX_LOG_WIN_ERROR(stuff) \ 60 BOX_ERROR(stuff << ": " << GetErrorMessage(GetLastError())) 61 #define BOX_LOG_WIN_ERROR_NUMBER(stuff, number) \ 62 BOX_ERROR(stuff << ": " << GetErrorMessage(number)) 63 #endif 50 64 51 65 #define BOX_FORMAT_ACCOUNT(accno) \ -
box/trunk/lib/server/Daemon.cpp
r2110 r2115 466 466 if(::setsid() == -1) 467 467 { 468 BOX_ERROR("Failed to setsid(): " << 469 strerror(errno)); 468 BOX_LOG_SYS_ERROR("Failed to setsid()"); 470 469 THROW_EXCEPTION(ServerException, DaemoniseFailed) 471 470 } … … 476 475 case -1: 477 476 // error 477 BOX_LOG_SYS_ERROR("Failed to fork() a child"); 478 478 THROW_EXCEPTION(ServerException, DaemoniseFailed) 479 479 break; … … 498 498 sa.sa_handler = SignalHandler; 499 499 sa.sa_flags = 0; 500 sigemptyset(&sa.sa_mask); // macro 501 if(::sigaction(SIGHUP, &sa, NULL) != 0 || ::sigaction(SIGTERM, &sa, NULL) != 0) 502 { 500 sigemptyset(&sa.sa_mask); // macro 501 if(::sigaction(SIGHUP, &sa, NULL) != 0 || 502 ::sigaction(SIGTERM, &sa, NULL) != 0) 503 { 504 BOX_LOG_SYS_ERROR("Failed to set signal handlers"); 503 505 THROW_EXCEPTION(ServerException, DaemoniseFailed) 504 506 } … … 516 518 if(::write(pidFile, pid, pidsize) != pidsize) 517 519 { 518 BOX_FATAL("can't write pid file"); 520 BOX_LOG_SYS_FATAL("Failed to write PID file: " << 521 pidFileName); 519 522 THROW_EXCEPTION(ServerException, DaemoniseFailed) 520 523 } … … 545 548 if(devnull == -1) 546 549 { 550 BOX_LOG_SYS_ERROR("Failed to open /dev/null"); 547 551 THROW_EXCEPTION(CommonException, OSFileError); 548 552 } … … 891 895 return 0; 892 896 } 897 BOX_LOG_SYS_ERROR("Failed to stat configuration file: " << 898 GetConfigFileName()); 893 899 THROW_EXCEPTION(CommonException, OSFileError) 894 900 } -
box/trunk/lib/server/ServerControl.h
r1999 r2115 143 143 if (!killed) 144 144 { 145 BOX_ERROR("Failed to kill process " << pid << ": " << 146 strerror(errno)); 145 BOX_LOG_SYS_ERROR("Failed to kill process " << pid); 147 146 } 148 147 TEST_THAT(killed); -
box/trunk/lib/server/SocketListen.h
