From subversion at boxbackup.org Wed Apr 9 23:14:47 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:14:47 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3306 - box/trunk/lib/backupstore Message-ID: <201404092214.s39MElj4057628@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:14:46 +0100 (Wed, 09 Apr 2014) New Revision: 3306 Modified: box/trunk/lib/backupstore/BackupStoreContext.cpp Log: Don't pass AttributesModTime as the hash of the new directory's attributes. An incorrect comment led me to believe that this parameter was the new directory's AttributesModTime, but actually it was its hash. Modified: box/trunk/lib/backupstore/BackupStoreContext.cpp =================================================================== --- box/trunk/lib/backupstore/BackupStoreContext.cpp 2014-03-02 09:01:01 UTC (rev 3305) +++ box/trunk/lib/backupstore/BackupStoreContext.cpp 2014-04-09 22:14:46 UTC (rev 3306) @@ -1109,7 +1109,7 @@ { dir.AddEntry(rFilename, ModificationTime, id, dirSize, BackupStoreDirectory::Entry::Flags_Dir, - AttributesModTime); + 0 /* attributes hash */); SaveDirectory(dir, InDirectory); // Increment reference count on the new directory to one From subversion at boxbackup.org Wed Apr 9 23:14:51 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:14:51 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3307 - in box/trunk: infrastructure/m4 lib/common Message-ID: <201404092214.s39MEptV057644@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:14:51 +0100 (Wed, 09 Apr 2014) New Revision: 3307 Modified: box/trunk/infrastructure/m4/boxbackup_tests.m4 box/trunk/lib/common/FileModificationTime.cpp Log: Support microsecond timestamps for files on Linux. Modified: box/trunk/infrastructure/m4/boxbackup_tests.m4 =================================================================== --- box/trunk/infrastructure/m4/boxbackup_tests.m4 2014-04-09 22:14:46 UTC (rev 3306) +++ box/trunk/infrastructure/m4/boxbackup_tests.m4 2014-04-09 22:14:51 UTC (rev 3307) @@ -186,7 +186,8 @@ AC_TYPE_SIZE_T AC_CHECK_MEMBERS([struct stat.st_flags]) -AC_CHECK_MEMBERS([struct stat.st_mtimespec]) +AC_CHECK_MEMBERS([struct stat.st_atim]) +AC_CHECK_MEMBERS([struct stat.st_atimespec]) AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec]) AC_CHECK_MEMBERS([struct stat.st_atimensec]) AC_CHECK_MEMBERS([struct sockaddr_in.sin_len],,, [[ Modified: box/trunk/lib/common/FileModificationTime.cpp =================================================================== --- box/trunk/lib/common/FileModificationTime.cpp 2014-04-09 22:14:46 UTC (rev 3306) +++ box/trunk/lib/common/FileModificationTime.cpp 2014-04-09 22:14:51 UTC (rev 3307) @@ -18,11 +18,14 @@ box_time_t FileModificationTime(const EMU_STRUCT_STAT &st) { -#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC - box_time_t datamodified = ((int64_t)st.st_mtime) * (MICRO_SEC_IN_SEC_LL); -#else +#if defined HAVE_STRUCT_STAT_ST_ATIM + box_time_t datamodified = (((int64_t)st.st_mtim.tv_nsec) / NANO_SEC_IN_USEC_LL) + + (((int64_t)st.st_mtim.tv_sec) * (MICRO_SEC_IN_SEC_LL)); +#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC box_time_t datamodified = (((int64_t)st.st_mtimespec.tv_nsec) / NANO_SEC_IN_USEC_LL) + (((int64_t)st.st_mtimespec.tv_sec) * (MICRO_SEC_IN_SEC_LL)); +#else + box_time_t datamodified = ((int64_t)st.st_mtime) * (MICRO_SEC_IN_SEC_LL); #endif return datamodified; @@ -31,7 +34,10 @@ box_time_t FileAttrModificationTime(const EMU_STRUCT_STAT &st) { box_time_t statusmodified = -#ifdef HAVE_STRUCT_STAT_ST_MTIMESPEC +#if defined HAVE_STRUCT_STAT_ST_ATIM + (((int64_t)st.st_ctim.tv_nsec) / (NANO_SEC_IN_USEC_LL)) + + (((int64_t)st.st_ctim.tv_sec) * (MICRO_SEC_IN_SEC_LL)); +#elif defined HAVE_STRUCT_STAT_ST_ATIMESPEC (((int64_t)st.st_ctimespec.tv_nsec) / (NANO_SEC_IN_USEC_LL)) + (((int64_t)st.st_ctimespec.tv_sec) * (MICRO_SEC_IN_SEC_LL)); #elif defined HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC From subversion at boxbackup.org Wed Apr 9 23:14:54 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:14:54 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3308 - box/trunk/lib/server Message-ID: <201404092214.s39MEsxQ057660@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:14:54 +0100 (Wed, 09 Apr 2014) New Revision: 3308 Modified: box/trunk/lib/server/makeprotocol.pl.in Log: Add a static GetMessage() to BackupProtocolError. Allows retrieving the error message for a given code, when we no longer have the protocol object handy. Conflicts: lib/server/makeprotocol.pl.in Modified: box/trunk/lib/server/makeprotocol.pl.in =================================================================== --- box/trunk/lib/server/makeprotocol.pl.in 2014-04-09 22:14:51 UTC (rev 3307) +++ box/trunk/lib/server/makeprotocol.pl.in 2014-04-09 22:14:54 UTC (rev 3308) @@ -323,8 +323,13 @@ if(obj_is_type($cmd,'IsError')) { - print H "\tbool IsError(int &rTypeOut, int &rSubTypeOut) const;\n"; - print H "\tstd::string GetMessage() const;\n"; + $error_message = $cmd; + my ($mem_type,$mem_subtype) = split /,/,obj_get_type_params($cmd,'IsError'); + print H <<__E; + bool IsError(int &rTypeOut, int &rSubTypeOut) const; + std::string GetMessage() const { return GetMessage(m$mem_subtype); }; + static std::string GetMessage(int subtype); +__E } my $has_stream = obj_is_type($cmd, 'StreamWithCommand'); @@ -496,9 +501,9 @@ rSubTypeOut = m$mem_subtype; return true; } -std::string $cmd_class\::GetMessage() const +std::string $cmd_class\::GetMessage(int subtype) { - switch(m$mem_subtype) + switch(subtype) { __E foreach my $const (@{$cmd_constants{$cmd}}) @@ -513,7 +518,7 @@ print CPP <<__E; default: std::ostringstream out; - out << "Unknown subtype " << m$mem_subtype; + out << "Unknown subtype " << subtype; return out.str(); } } @@ -669,6 +674,7 @@ if(rReply.GetType() == expectedType) { // Correct response, do nothing + SetLastError(Protocol::NoError, Protocol::NoError); } else { From subversion at boxbackup.org Wed Apr 9 23:14:57 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:14:57 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3309 - box/trunk/lib/backupstore Message-ID: <201404092214.s39MEvBi057676@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:14:57 +0100 (Wed, 09 Apr 2014) New Revision: 3309 Modified: box/trunk/lib/backupstore/BackupStoreContext.cpp box/trunk/lib/backupstore/BackupStoreContext.h Log: Don't require passing the object ID into BackupStoreContext::SaveDirectory. Passing the wrong object ID would just result in an assertion being thrown (in debug builds) or silently doing the wrong thing (in release builds). I can't see any useful use for this extra parameter, since we can get the container ID from the directory anyway. Modified: box/trunk/lib/backupstore/BackupStoreContext.cpp =================================================================== --- box/trunk/lib/backupstore/BackupStoreContext.cpp 2014-04-09 22:14:54 UTC (rev 3308) +++ box/trunk/lib/backupstore/BackupStoreContext.cpp 2014-04-09 22:14:57 UTC (rev 3309) @@ -697,7 +697,7 @@ } // Write the directory back to disc - SaveDirectory(dir, InDirectory); + SaveDirectory(dir); // Commit the old version's new patched version, now that the directory safely reflects // the state of the files on disc. @@ -832,7 +832,7 @@ if(madeChanges) { // Save the directory back - SaveDirectory(dir, InDirectory); + SaveDirectory(dir); SaveStoreInfo(false); } } @@ -910,7 +910,7 @@ if(madeChanges) { // Save the directory back - SaveDirectory(dir, InDirectory); + SaveDirectory(dir); // Modify the store info, and write mapStoreInfo->ChangeBlocksInDeletedFiles(blocksDel); @@ -953,12 +953,12 @@ // -------------------------------------------------------------------------- // // Function -// Name: BackupStoreContext::SaveDirectory(BackupStoreDirectory &, int64_t) +// Name: BackupStoreContext::SaveDirectory(BackupStoreDirectory &) // Purpose: Save directory back to disc, update time in cache // Created: 2003/09/04 // // -------------------------------------------------------------------------- -void BackupStoreContext::SaveDirectory(BackupStoreDirectory &rDir, int64_t ObjectID) +void BackupStoreContext::SaveDirectory(BackupStoreDirectory &rDir) { if(mapStoreInfo.get() == 0) { @@ -965,10 +965,7 @@ THROW_EXCEPTION(BackupStoreException, StoreInfoNotLoaded) } - if(rDir.GetObjectID() != ObjectID) - { - THROW_EXCEPTION(BackupStoreException, Internal) - } + int64_t ObjectID = rDir.GetObjectID(); try { @@ -1110,7 +1107,7 @@ dir.AddEntry(rFilename, ModificationTime, id, dirSize, BackupStoreDirectory::Entry::Flags_Dir, 0 /* attributes hash */); - SaveDirectory(dir, InDirectory); + SaveDirectory(dir); // Increment reference count on the new directory to one mapRefCount->AddReference(id); @@ -1196,7 +1193,7 @@ } // Save it - SaveDirectory(parentDir, InDirectory); + SaveDirectory(parentDir); // Done break; @@ -1312,7 +1309,7 @@ // Save the directory if(changesMade) { - SaveDirectory(dir, ObjectID); + SaveDirectory(dir); } } } @@ -1353,7 +1350,7 @@ dir.SetAttributes(Attributes, AttributesModTime); // Save back - SaveDirectory(dir, Directory); + SaveDirectory(dir); } catch(...) { @@ -1414,7 +1411,7 @@ } // Save back - SaveDirectory(dir, InDirectory); + SaveDirectory(dir); } catch(...) { @@ -1675,7 +1672,7 @@ } // Save the directory back - SaveDirectory(dir, MoveFromDirectory); + SaveDirectory(dir); } catch(...) { @@ -1769,7 +1766,7 @@ } // Save back - SaveDirectory(to, MoveToDirectory); + SaveDirectory(to); } // Thirdly... remove them from the first directory -- but if it fails, attempt to delete them from the to directory @@ -1785,7 +1782,7 @@ } // Save back - SaveDirectory(from, MoveFromDirectory); + SaveDirectory(from); } catch(...) { @@ -1801,7 +1798,7 @@ } // Save back - SaveDirectory(to, MoveToDirectory); + SaveDirectory(to); // Throw the error throw; @@ -1817,7 +1814,7 @@ change.SetContainerID(MoveToDirectory); // Save it back - SaveDirectory(change, *i); + SaveDirectory(change); } } catch(...) Modified: box/trunk/lib/backupstore/BackupStoreContext.h =================================================================== --- box/trunk/lib/backupstore/BackupStoreContext.h 2014-04-09 22:14:54 UTC (rev 3308) +++ box/trunk/lib/backupstore/BackupStoreContext.h 2014-04-09 22:14:57 UTC (rev 3309) @@ -171,7 +171,7 @@ private: void MakeObjectFilename(int64_t ObjectID, std::string &rOutput, bool EnsureDirectoryExists = false); BackupStoreDirectory &GetDirectoryInternal(int64_t ObjectID); - void SaveDirectory(BackupStoreDirectory &rDir, int64_t ObjectID); + void SaveDirectory(BackupStoreDirectory &rDir); void RemoveDirectoryFromCache(int64_t ObjectID); void ClearDirectoryCache(); void DeleteDirectoryRecurse(int64_t ObjectID, bool Undelete); From subversion at boxbackup.org Wed Apr 9 23:15:01 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:15:01 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3310 - box/trunk/lib/backupstore Message-ID: <201404092215.s39MF1jb057694@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:15:01 +0100 (Wed, 09 Apr 2014) New Revision: 3310 Modified: box/trunk/lib/backupstore/BackupProtocol.h Log: Fix a (currently cosmetic) bug in BackupProtocolLocal2 account ID. It was hardcoded to 0x01234567 due to a copy and paste error. Modified: box/trunk/lib/backupstore/BackupProtocol.h =================================================================== --- box/trunk/lib/backupstore/BackupProtocol.h 2014-04-09 22:14:57 UTC (rev 3309) +++ box/trunk/lib/backupstore/BackupProtocol.h 2014-04-09 22:15:01 UTC (rev 3310) @@ -40,7 +40,7 @@ { mContext.SetClientHasAccount(AccountRootDir, DiscSetNumber); QueryVersion(BACKUP_STORE_SERVER_VERSION); - QueryLogin(0x01234567, + QueryLogin(AccountNumber, ReadOnly ? BackupProtocolLogin::Flags_ReadOnly : 0); } virtual ~BackupProtocolLocal2() { } From subversion at boxbackup.org Wed Apr 9 23:15:04 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:15:04 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3311 - box/trunk/lib/backupstore Message-ID: <201404092215.s39MF4RI057710@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:15:04 +0100 (Wed, 09 Apr 2014) New Revision: 3311 Modified: box/trunk/lib/backupstore/StoreTestUtils.cpp box/trunk/lib/backupstore/StoreTestUtils.h Log: Add a utility to check account for errors, expecting that there are some. Returns the number of errors found and fixed. Modified: box/trunk/lib/backupstore/StoreTestUtils.cpp =================================================================== --- box/trunk/lib/backupstore/StoreTestUtils.cpp 2014-04-09 22:15:01 UTC (rev 3310) +++ box/trunk/lib/backupstore/StoreTestUtils.cpp 2014-04-09 22:15:04 UTC (rev 3311) @@ -202,25 +202,26 @@ Dirs == usage->GetBlocksInDirectories()); } +int check_account_for_errors(Log::Level log_level) +{ + Logging::Guard guard(log_level); + Logging::Tagger tag("check fix", true); + Logging::ShowTagOnConsole show; + std::string errs; + std::auto_ptr config( + Configuration::LoadAndVerify("testfiles/bbstored.conf", + &BackupConfigFileVerify, errs)); + BackupStoreAccountsControl control(*config); + int errors_fixed = control.CheckAccount(0x01234567, + true, // FixErrors + false); // Quiet + return errors_fixed; +} + bool check_account(Log::Level log_level) { - int errors_fixed; - - { - Logging::Guard guard(log_level); - Logging::Tagger tag("check fix", true); - Logging::ShowTagOnConsole show; - std::string errs; - std::auto_ptr config( - Configuration::LoadAndVerify("testfiles/bbstored.conf", - &BackupConfigFileVerify, errs)); - BackupStoreAccountsControl control(*config); - errors_fixed = control.CheckAccount(0x01234567, - true, // FixErrors - false); // Quiet - } - TEST_EQUAL_LINE(0, errors_fixed, "store errors found and fixed"); - + int errors_fixed = check_account_for_errors(log_level); + TEST_EQUAL(0, errors_fixed); return (errors_fixed == 0); } Modified: box/trunk/lib/backupstore/StoreTestUtils.h =================================================================== --- box/trunk/lib/backupstore/StoreTestUtils.h 2014-04-09 22:15:01 UTC (rev 3310) +++ box/trunk/lib/backupstore/StoreTestUtils.h 2014-04-09 22:15:04 UTC (rev 3311) @@ -51,6 +51,9 @@ bool check_num_blocks(BackupProtocolCallable& Client, int Current, int Old, int Deleted, int Dirs, int Total); +//! Checks an account for errors, returning the number of errors found and fixed. +int check_account_for_errors(Log::Level log_level = Log::WARNING); + //! Checks an account for errors, returning true if it's OK, for use in assertions. bool check_account(Log::Level log_level = Log::WARNING); From subversion at boxbackup.org Wed Apr 9 23:15:08 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:15:08 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3312 - in box/trunk: lib/backupstore test/backupstore Message-ID: <201404092215.s39MF8xA057727@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:15:08 +0100 (Wed, 09 Apr 2014) New Revision: 3312 Modified: box/trunk/lib/backupstore/BackupProtocol.h box/trunk/test/backupstore/testbackupstore.cpp Log: Add a Reopen method to BackupProtocolLocal2 for convenience. Modified: box/trunk/lib/backupstore/BackupProtocol.h =================================================================== --- box/trunk/lib/backupstore/BackupProtocol.h 2014-04-09 22:15:04 UTC (rev 3311) +++ box/trunk/lib/backupstore/BackupProtocol.h 2014-04-09 22:15:08 UTC (rev 3312) @@ -26,6 +26,8 @@ { private: BackupStoreContext mContext; + int32_t mAccountNumber; + bool mReadOnly; public: BackupProtocolLocal2(int32_t AccountNumber, @@ -36,7 +38,9 @@ // touch the Context, because it's not initialised yet! : BackupProtocolLocal(mContext), mContext(AccountNumber, (HousekeepingInterface *)NULL, - ConnectionDetails) + ConnectionDetails), + mAccountNumber(AccountNumber), + mReadOnly(ReadOnly) { mContext.SetClientHasAccount(AccountRootDir, DiscSetNumber); QueryVersion(BACKUP_STORE_SERVER_VERSION); @@ -52,6 +56,13 @@ mContext.ReleaseWriteLock(); return finished; } + + void Reopen() + { + QueryVersion(BACKUP_STORE_SERVER_VERSION); + QueryLogin(mAccountNumber, + mReadOnly ? BackupProtocolLogin::Flags_ReadOnly : 0); + } }; #endif // BACKUPPROTOCOL__H Modified: box/trunk/test/backupstore/testbackupstore.cpp =================================================================== --- box/trunk/test/backupstore/testbackupstore.cpp 2014-04-09 22:15:04 UTC (rev 3311) +++ box/trunk/test/backupstore/testbackupstore.cpp 2014-04-09 22:15:08 UTC (rev 3312) @@ -991,8 +991,7 @@ // Housekeeping should not change anything just yet protocol.QueryFinished(); TEST_THAT(run_housekeeping_and_check_account()); - protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION); - protocol.QueryLogin(0x01234567, 0); + protocol.Reopen(); TEST_THAT(check_num_files(1, 2, 0, 1)); TEST_THAT(check_num_blocks(protocol, file1_blocks, patch1_blocks + patch2_blocks, 0, @@ -1027,8 +1026,7 @@ // Housekeeping should not change anything just yet protocol.QueryFinished(); TEST_THAT(run_housekeeping_and_check_account()); - protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION); - protocol.QueryLogin(0x01234567, 0); + protocol.Reopen(); TEST_THAT(check_num_files(1, 3, 0, 1)); TEST_THAT(check_num_blocks(protocol, replaced_blocks, // current @@ -1044,8 +1042,7 @@ "14B", // replaced_blocks + file1_blocks + root_dir_blocks "2000B")); TEST_THAT(run_housekeeping_and_check_account()); - protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION); - protocol.QueryLogin(0x01234567, 0); + protocol.Reopen(); TEST_THAT(check_num_files(1, 1, 0, 1)); TEST_THAT(check_num_blocks(protocol, replaced_blocks, // current @@ -1072,8 +1069,7 @@ protocol.QueryFinished(); TEST_THAT(change_account_limits("0B", "2000B")); TEST_THAT(run_housekeeping_and_check_account()); - protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION); - protocol.QueryLogin(0x01234567, 0); + protocol.Reopen(); TEST_THAT(check_num_files(0, 0, 0, 1)); TEST_THAT(check_num_blocks(protocol, 0, 0, 0, root_dir_blocks, root_dir_blocks)); From subversion at boxbackup.org Wed Apr 9 23:15:11 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:15:11 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3313 - box/trunk/test/backupstore Message-ID: <201404092215.s39MFBuK057743@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:15:11 +0100 (Wed, 09 Apr 2014) New Revision: 3313 Modified: box/trunk/test/backupstore/testbackupstore.cpp Log: Replace magic numbers with named constants for readability. Modified: box/trunk/test/backupstore/testbackupstore.cpp =================================================================== --- box/trunk/test/backupstore/testbackupstore.cpp 2014-04-09 22:15:08 UTC (rev 3312) +++ box/trunk/test/backupstore/testbackupstore.cpp 2014-04-09 22:15:11 UTC (rev 3313) @@ -515,6 +515,9 @@ set_refcount(objectId, 1); } +const box_time_t FAKE_MODIFICATION_TIME = 0xfeedfacedeadbeefLL; +const box_time_t FAKE_ATTR_MODIFICATION_TIME = 0xdeadbeefcafebabeLL; + int64_t create_test_data_subdirs(BackupProtocolCallable &protocol, int64_t indir, const char *name, int depth, BackupStoreRefCountDatabase* pRefCount) @@ -527,7 +530,7 @@ int attrS = 0; std::auto_ptr attr(new MemBlockStream(&attrS, sizeof(attrS))); std::auto_ptr dirCreate(protocol.QueryCreateDirectory( - indir, 9837429842987984LL, dirname, attr)); + indir, FAKE_ATTR_MODIFICATION_TIME, dirname, attr)); subdirid = dirCreate->GetObjectID(); } @@ -1114,7 +1117,7 @@ std::auto_ptr dirCreate(protocol.QueryCreateDirectory( BACKUPSTORE_ROOT_DIRECTORY_ID, - 9837429842987984LL, dirname, attr)); + FAKE_ATTR_MODIFICATION_TIME, dirname, attr)); int64_t subdirid = dirCreate->GetObjectID(); set_refcount(subdirid, 1); @@ -1492,7 +1495,8 @@ // Attributes TEST_THAT(dir.HasAttributes()); - TEST_EQUAL(9837429842987984LL, dir.GetAttributesModTime()); + TEST_EQUAL(FAKE_ATTR_MODIFICATION_TIME, + dir.GetAttributesModTime()); StreamableMemBlock attr(attr1, sizeof(attr1)); TEST_THAT(dir.GetAttributes() == attr); } @@ -1640,10 +1644,8 @@ // Attributes std::auto_ptr attr(new MemBlockStream(attr1, sizeof(attr1))); - std::auto_ptr dirCreate(apProtocol->QueryCreateDirectory( - subdirid, - 9837429842987984LL, nd, attr)); - subsubdirid = dirCreate->GetObjectID(); + subsubdirid = apProtocol->QueryCreateDirectory(subdirid, + FAKE_ATTR_MODIFICATION_TIME, nd, attr)->GetObjectID(); BackupStoreFilenameClear file2("file2"); std::auto_ptr upload( @@ -2334,7 +2336,7 @@ BackupStoreFilenameClear fnxd("exceed-limit-dir"); TEST_CHECK_THROWS(protocol.QueryCreateDirectory( BackupProtocolListDirectory::RootDirectory, - 9837429842987984LL, fnxd, attr), + FAKE_ATTR_MODIFICATION_TIME, fnxd, attr), ConnectionException, Conn_Protocol_UnexpectedReply); // Finish the connection. TODO FIXME reinstate this. From subversion at boxbackup.org Wed Apr 9 23:15:15 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:15:15 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3314 - in box/trunk/lib: backupstore common Message-ID: <201404092215.s39MFFPl057759@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:15:14 +0100 (Wed, 09 Apr 2014) New Revision: 3314 Modified: box/trunk/lib/backupstore/StoreTestUtils.h box/trunk/lib/common/Test.h Log: Add some test helper _OR macros to execute commands when conditions fail. This is useful to return from a test if an assertion/check fails, instead of throwing an exception. Also add logging of the actual error code received (with name) to TEST_COMMAND_RETURNS_ERROR(_OR). Modified: box/trunk/lib/backupstore/StoreTestUtils.h =================================================================== --- box/trunk/lib/backupstore/StoreTestUtils.h 2014-04-09 22:15:11 UTC (rev 3313) +++ box/trunk/lib/backupstore/StoreTestUtils.h 2014-04-09 22:15:14 UTC (rev 3314) @@ -10,6 +10,8 @@ #ifndef STORETESTUTILS__H #define STORETESTUTILS__H +#include "Test.h" + class BackupProtocolCallable; class BackupProtocolClient; class SocketStreamTLS; @@ -78,10 +80,31 @@ //! Deletes the standard test account, for testing behaviour with no account. bool delete_account(); -#define TEST_COMMAND_RETURNS_ERROR(command, error) \ - TEST_CHECK_THROWS(command, ConnectionException, \ - Conn_Protocol_UnexpectedReply); \ - TEST_EQUAL(BackupProtocolError::error, protocol.GetLastErrorType()); +#define TEST_COMMAND_RETURNS_ERROR_OR(protocol, command, error, or_statements) \ + { \ + TEST_CHECK_THROWS_OR(protocol . command, ConnectionException, \ + Conn_Protocol_UnexpectedReply, or_statements); \ + int type, subtype; \ + protocol.GetLastError(type, subtype); \ + if (type == BackupProtocolError::ErrorType) \ + { \ + TEST_EQUAL_LINE(BackupProtocolError::error, subtype, \ + "command returned error: " << \ + BackupProtocolError::GetMessage(subtype)); \ + if (subtype != BackupProtocolError::error) \ + { \ + or_statements; \ + } \ + } \ + else \ + { \ + TEST_FAIL_WITH_MESSAGE("command returned success"); \ + or_statements; \ + } \ + } +#define TEST_COMMAND_RETURNS_ERROR(protocol, command, error) \ + TEST_COMMAND_RETURNS_ERROR_OR(protocol, command, error,) + #endif // STORETESTUTILS__H Modified: box/trunk/lib/common/Test.h =================================================================== --- box/trunk/lib/common/Test.h 2014-04-09 22:15:11 UTC (rev 3313) +++ box/trunk/lib/common/Test.h 2014-04-09 22:15:14 UTC (rev 3314) @@ -49,19 +49,20 @@ #define TEST_ABORT_WITH_MESSAGE(msg) {TEST_FAIL_WITH_MESSAGE(msg); return 1;} -#define TEST_THAT(condition) {if(!(condition)) TEST_FAIL_WITH_MESSAGE("Condition [" #condition "] failed")} +#define TEST_THAT_OR(condition, or_command) \ + if(!(condition)) \ + { \ + TEST_FAIL_WITH_MESSAGE("Condition [" #condition "] failed"); \ + or_command; \ + } +#define TEST_THAT(condition) TEST_THAT_OR(condition,) #define TEST_THAT_ABORTONFAIL(condition) {if(!(condition)) TEST_ABORT_WITH_MESSAGE("Condition [" #condition "] failed")} #define TEST_THAT_THROWONFAIL(condition) \ - { \ - if(!(condition)) \ - { \ - THROW_EXCEPTION_MESSAGE(CommonException, \ - AssertFailed, "Condition [" #condition "] failed"); \ - } \ - } + TEST_THAT_OR(condition, THROW_EXCEPTION_MESSAGE(CommonException, \ + AssertFailed, "Condition [" #condition "] failed")); // NOTE: The 0- bit is to allow this to work with stuff which has negative constants for flags (eg ConnectionException) -#define TEST_CHECK_THROWS(statement, excepttype, subtype) \ +#define TEST_CHECK_THROWS_OR(statement, excepttype, subtype, or_command) \ { \ bool didthrow = false; \ HideExceptionMessageGuard hide; \ @@ -86,12 +87,15 @@ } \ if(!didthrow) \ { \ - TEST_FAIL_WITH_MESSAGE("Didn't throw exception " #excepttype "(" #subtype ")") \ + TEST_FAIL_WITH_MESSAGE("Didn't throw exception " #excepttype "(" #subtype ")"); \ + or_command; \ } \ } +#define TEST_CHECK_THROWS(statement, excepttype, subtype) \ + TEST_CHECK_THROWS_OR(statement, excepttype, subtype,) // utility macro for comparing two strings in a line -#define TEST_EQUAL(_expected, _found) \ +#define TEST_EQUAL_OR(_expected, _found, or_command) \ { \ std::ostringstream _oss1; \ _oss1 << _expected; \ @@ -110,8 +114,11 @@ _oss3 << #_found << " != " << #_expected; \ \ TEST_FAIL_WITH_MESSAGE(_oss3.str().c_str()); \ + or_command; \ } \ } +#define TEST_EQUAL(_expected, _found) \ + TEST_EQUAL_OR(_expected, _found,) // utility macro for comparing two strings in a line #define TEST_EQUAL_LINE(_expected, _found, _line) \ From subversion at boxbackup.org Wed Apr 9 23:15:19 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:15:19 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3315 - in box/trunk: lib/backupstore test/backupstore Message-ID: <201404092215.s39MFJu8057775@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:15:19 +0100 (Wed, 09 Apr 2014) New Revision: 3315 Modified: box/trunk/lib/backupstore/BackupStoreCheck.cpp box/trunk/lib/backupstore/BackupStoreContext.cpp box/trunk/lib/backupstore/HousekeepStoreAccount.cpp box/trunk/lib/backupstore/HousekeepStoreAccount.h box/trunk/test/backupstore/testbackupstore.cpp Log: Directories' entries in parent directory should track current size. When entries are added to a directory by a command (BackupStoreContext), and when entries are removed from a directory (by housekeeping), update the parent directory's entry for us if our size has changed. Make BackupStoreCheck check for, report and fix errors when directory entries are directories and the size is wrong (as well as files). Conflicts: test/backupstore/testbackupstore.cpp Fix directories loaded without size being set, leading to warnings later. We can't check that the old size in the parent entry matched the old real size of the directory, unless we set the old real size in the directory. And we don't need to pass the old directory size to HousekeepStoreAccount::DeleteFile, because we can get it from the directory itself. Modified: box/trunk/lib/backupstore/BackupStoreCheck.cpp =================================================================== --- box/trunk/lib/backupstore/BackupStoreCheck.cpp 2014-04-09 22:15:14 UTC (rev 3314) +++ box/trunk/lib/backupstore/BackupStoreCheck.cpp 2014-04-09 22:15:19 UTC (rev 3315) @@ -871,7 +871,6 @@ ASSERT(piBlock != 0); uint8_t iflags = GetFlags(piBlock, IndexInDirBlock); - bool badEntry = false; // Is the type the same? if(((iflags & Flags_IsDir) == Flags_IsDir) != rEntry.IsDir()) @@ -882,11 +881,12 @@ " references object " << BOX_FORMAT_OBJECTID(rEntry.GetObjectID()) << " which has a different type than expected."); - badEntry = true; ++mNumberErrorsFound; + return false; // remove this entry } + // Check that the entry is not already contained. - else if(iflags & Flags_IsContained) + if(iflags & Flags_IsContained) { BOX_ERROR("Directory ID " << BOX_FORMAT_OBJECTID(DirectoryID) << @@ -893,62 +893,55 @@ " references object " << BOX_FORMAT_OBJECTID(rEntry.GetObjectID()) << " which is already contained."); - badEntry = true; ++mNumberErrorsFound; + return false; // remove this entry } - else + + // Not already contained by another directory. + // Don't set the flag until later, after we finish repairing + // the directory and removing all bad entries. + + // Check that the container ID of the object is correct + if(piBlock->mContainer[IndexInDirBlock] != DirectoryID) { - // Not already contained by another directory. - // Don't set the flag until later, after we finish repairing - // the directory and removing all bad entries. - - // Check that the container ID of the object is correct - if(piBlock->mContainer[IndexInDirBlock] != DirectoryID) + // Needs fixing... + if(iflags & Flags_IsDir) { - // Needs fixing... - if(iflags & Flags_IsDir) - { - // Add to will fix later list - BOX_ERROR("Directory ID " << - BOX_FORMAT_OBJECTID(rEntry.GetObjectID()) - << " has wrong container ID."); - mDirsWithWrongContainerID.push_back(rEntry.GetObjectID()); - ++mNumberErrorsFound; - } - else - { - // This is OK for files, they might move - BOX_INFO("File ID " << - BOX_FORMAT_OBJECTID(rEntry.GetObjectID()) - << " has different container ID, " - "probably moved"); - } - - // Fix entry for now - piBlock->mContainer[IndexInDirBlock] = DirectoryID; + // Add to will fix later list + BOX_ERROR("Directory ID " << + BOX_FORMAT_OBJECTID(rEntry.GetObjectID()) + << " has wrong container ID."); + mDirsWithWrongContainerID.push_back(rEntry.GetObjectID()); + ++mNumberErrorsFound; } + else + { + // This is OK for files, they might move + BOX_INFO("File ID " << + BOX_FORMAT_OBJECTID(rEntry.GetObjectID()) + << " has different container ID, " + "probably moved"); + } + + // Fix entry for now + piBlock->mContainer[IndexInDirBlock] = DirectoryID; } - - // Check the object size, if it's OK and a file - if(!badEntry && !rEntry.IsDir()) + + // Check the object size + if(rEntry.GetSizeInBlocks() != piBlock->mObjectSizeInBlocks[IndexInDirBlock]) { - if(rEntry.GetSizeInBlocks() != piBlock->mObjectSizeInBlocks[IndexInDirBlock]) - { - // Wrong size, correct it. - rEntry.SetSizeInBlocks(piBlock->mObjectSizeInBlocks[IndexInDirBlock]); + // Wrong size, correct it. + BOX_ERROR("Directory " << BOX_FORMAT_OBJECTID(DirectoryID) << + " entry for " << BOX_FORMAT_OBJECTID(rEntry.GetObjectID()) << + " has wrong size " << rEntry.GetSizeInBlocks() << + ", should be " << piBlock->mObjectSizeInBlocks[IndexInDirBlock]); - // Mark as changed - rIsModified = true; - ++mNumberErrorsFound; + rEntry.SetSizeInBlocks(piBlock->mObjectSizeInBlocks[IndexInDirBlock]); - // Tell user - BOX_ERROR("Directory ID " << - BOX_FORMAT_OBJECTID(DirectoryID) << - " has wrong size for object " << - BOX_FORMAT_OBJECTID(rEntry.GetObjectID())); - } + // Mark as changed + rIsModified = true; + ++mNumberErrorsFound; } - return !badEntry; + return true; // don't delete this entry } - Modified: box/trunk/lib/backupstore/BackupStoreContext.cpp =================================================================== --- box/trunk/lib/backupstore/BackupStoreContext.cpp 2014-04-09 22:15:14 UTC (rev 3314) +++ box/trunk/lib/backupstore/BackupStoreContext.cpp 2014-04-09 22:15:19 UTC (rev 3315) @@ -972,6 +972,8 @@ // Write to disc, adjust size in store info std::string dirfn; MakeObjectFilename(ObjectID, dirfn); + int64_t old_dir_size = rDir.GetUserInfo1_SizeInBlocks(); + { RaidFileWrite writeDir(mStoreDiscSet, dirfn); writeDir.Open(true /* allow overwriting */); @@ -994,6 +996,7 @@ // Update size stored in directory rDir.SetUserInfo1_SizeInBlocks(dirSize); } + // Refresh revision ID in cache { int64_t revid = 0; @@ -1003,6 +1006,22 @@ } rDir.SetRevisionID(revid); } + + // Update the directory entry in the grandparent, to ensure + // that it reflects the current size of the parent directory. + int64_t new_dir_size = rDir.GetUserInfo1_SizeInBlocks(); + if(new_dir_size != old_dir_size && + rDir.GetObjectID() != BACKUPSTORE_ROOT_DIRECTORY_ID) + { + BackupStoreDirectory& parent( + GetDirectoryInternal(rDir.GetContainerID())); + BackupStoreDirectory::Entry* en = + parent.FindEntryByID(rDir.GetObjectID()); + ASSERT(en); + ASSERT(en->GetSizeInBlocks() == old_dir_size); + en->SetSizeInBlocks(new_dir_size); + SaveDirectory(parent); + } } catch(...) { @@ -1608,7 +1627,9 @@ // Created: 12/11/03 // // -------------------------------------------------------------------------- -void BackupStoreContext::MoveObject(int64_t ObjectID, int64_t MoveFromDirectory, int64_t MoveToDirectory, const BackupStoreFilename &rNewFilename, bool MoveAllWithSameName, bool AllowMoveOverDeletedObject) +void BackupStoreContext::MoveObject(int64_t ObjectID, int64_t MoveFromDirectory, + int64_t MoveToDirectory, const BackupStoreFilename &rNewFilename, + bool MoveAllWithSameName, bool AllowMoveOverDeletedObject) { if(mReadOnly) { @@ -1683,8 +1704,9 @@ return; } - // Got to be careful how this is written, as we can't guarentte that if we have two - // directories open, the first won't be deleted as the second is opened. (cache) + // Got to be careful how this is written, as we can't guarantee that + // if we have two directories open, the first won't be deleted as the + // second is opened. (cache) // List of entries to move std::vector moving; Modified: box/trunk/lib/backupstore/HousekeepStoreAccount.cpp =================================================================== --- box/trunk/lib/backupstore/HousekeepStoreAccount.cpp 2014-04-09 22:15:14 UTC (rev 3314) +++ box/trunk/lib/backupstore/HousekeepStoreAccount.cpp 2014-04-09 22:15:19 UTC (rev 3315) @@ -368,6 +368,7 @@ BackupStoreDirectory dir; BufferedStream buf(*dirStream); dir.ReadFromStream(buf, IOStream::TimeOutInfinite); + dir.SetUserInfo1_SizeInBlocks(originalDirSizeInBlocks); dirStream->Close(); // Is it empty? @@ -409,8 +410,8 @@ && (en->IsDeleted() || en->IsOld())) { // Delete this immediately. - DeleteFile(ObjectID, en->GetObjectID(), dir, objectFilename, - originalDirSizeInBlocks, rBackupStoreInfo); + DeleteFile(ObjectID, en->GetObjectID(), dir, + objectFilename, rBackupStoreInfo); // flag as having done something deletedSomething = true; @@ -643,19 +644,17 @@ // Get the filename std::string dirFilename; BackupStoreDirectory dir; - int64_t dirSizeInBlocksOrig = 0; { MakeObjectFilename(i->mInDirectory, dirFilename); std::auto_ptr dirStream(RaidFileRead::Open(mStoreDiscSet, dirFilename)); - dirSizeInBlocksOrig = dirStream->GetDiscUsageInBlocks(); dir.ReadFromStream(*dirStream, IOStream::TimeOutInfinite); + dir.SetUserInfo1_SizeInBlocks(dirStream->GetDiscUsageInBlocks()); } // Delete the file BackupStoreRefCountDatabase::refcount_t refs = DeleteFile(i->mInDirectory, i->mObjectID, dir, - dirFilename, dirSizeInBlocksOrig, - rBackupStoreInfo); + dirFilename, rBackupStoreInfo); if(refs == 0) { BOX_INFO("Housekeeping removed " << @@ -702,7 +701,7 @@ BackupStoreRefCountDatabase::refcount_t HousekeepStoreAccount::DeleteFile( int64_t InDirectory, int64_t ObjectID, BackupStoreDirectory &rDirectory, - const std::string &rDirectoryFilename, int64_t OriginalDirSizeInBlocks, + const std::string &rDirectoryFilename, BackupStoreInfo& rBackupStoreInfo) { // Find the entry inside the directory @@ -727,6 +726,7 @@ BOX_FORMAT_OBJECTID(InDirectory) << ", " "indicates logic error/corruption? Run " "bbstoreaccounts check fix"); + mErrorCount++; return refs; } @@ -859,7 +859,6 @@ // Save directory back to disc // BLOCK - int64_t dirRevisedSize = 0; { RaidFileWrite writeDir(mStoreDiscSet, rDirectoryFilename, mapNewRefs->GetRefCount(InDirectory)); @@ -867,18 +866,18 @@ rDirectory.WriteToStream(writeDir); // Get the disc usage (must do this before commiting it) - dirRevisedSize = writeDir.GetDiscUsageInBlocks(); + int64_t new_size = writeDir.GetDiscUsageInBlocks(); // Commit directory writeDir.Commit(BACKUP_STORE_CONVERT_TO_RAID_IMMEDIATELY); // Adjust block counts if the directory itself changed in size - if(dirRevisedSize > 0) - { - int64_t adjust = dirRevisedSize - OriginalDirSizeInBlocks; - mBlocksUsedDelta += adjust; - mBlocksInDirectoriesDelta += adjust; - } + int64_t original_size = rDirectory.GetUserInfo1_SizeInBlocks(); + int64_t adjust = new_size - original_size; + mBlocksUsedDelta += adjust; + mBlocksInDirectoriesDelta += adjust; + + UpdateDirectorySize(rDirectory, new_size); } // Commit any new adjusted entry @@ -926,7 +925,76 @@ return 0; } +// -------------------------------------------------------------------------- +// +// Function +// Name: HousekeepStoreAccount::UpdateDirectorySize( +// BackupStoreDirectory& rDirectory, +// IOStream::pos_type new_size_in_blocks) +// Purpose: Update the directory size, modifying the parent +// directory's entry for this directory if necessary. +// Created: 05/03/14 +// +// -------------------------------------------------------------------------- +void HousekeepStoreAccount::UpdateDirectorySize( + BackupStoreDirectory& rDirectory, + IOStream::pos_type new_size_in_blocks) +{ +#ifndef NDEBUG + { + std::string dirFilename; + MakeObjectFilename(rDirectory.GetObjectID(), dirFilename); + std::auto_ptr dirStream( + RaidFileRead::Open(mStoreDiscSet, dirFilename)); + ASSERT(new_size_in_blocks == dirStream->GetDiscUsageInBlocks()); + } +#endif + + IOStream::pos_type old_size_in_blocks = + rDirectory.GetUserInfo1_SizeInBlocks(); + + if(new_size_in_blocks == old_size_in_blocks) + { + return; + } + + rDirectory.SetUserInfo1_SizeInBlocks(new_size_in_blocks); + + if (rDirectory.GetObjectID() == BACKUPSTORE_ROOT_DIRECTORY_ID) + { + return; + } + + std::string parentFilename; + MakeObjectFilename(rDirectory.GetContainerID(), parentFilename); + std::auto_ptr parentStream( + RaidFileRead::Open(mStoreDiscSet, parentFilename)); + BackupStoreDirectory parent(*parentStream); + BackupStoreDirectory::Entry* en = + parent.FindEntryByID(rDirectory.GetObjectID()); + ASSERT(en); + + if (en->GetSizeInBlocks() != old_size_in_blocks) + { + BOX_WARNING("Directory " << + BOX_FORMAT_OBJECTID(rDirectory.GetObjectID()) << + " entry in directory " << + BOX_FORMAT_OBJECTID(rDirectory.GetContainerID()) << + " had incorrect size " << en->GetSizeInBlocks() << + ", should have been " << old_size_in_blocks); + mErrorCount++; + } + + en->SetSizeInBlocks(new_size_in_blocks); + + RaidFileWrite writeDir(mStoreDiscSet, parentFilename, + mapNewRefs->GetRefCount(rDirectory.GetContainerID())); + writeDir.Open(true /* allow overwriting */); + parent.WriteToStream(writeDir); + writeDir.Commit(BACKUP_STORE_CONVERT_TO_RAID_IMMEDIATELY); +} + // -------------------------------------------------------------------------- // // Function @@ -1022,11 +1090,13 @@ containingDirStream->GetDiscUsageInBlocks(); containingDir.ReadFromStream(*containingDirStream, IOStream::TimeOutInfinite); + containingDir.SetUserInfo1_SizeInBlocks(containingDirSizeInBlocksOrig); } // Find the entry BackupStoreDirectory::Entry *pdirentry = containingDir.FindEntryByID(dir.GetObjectID()); + // TODO FIXME invert test and reduce indentation if((pdirentry != 0) && pdirentry->IsDeleted()) { // Should be deleted @@ -1049,6 +1119,7 @@ // Commit directory writeDir.Commit(BACKUP_STORE_CONVERT_TO_RAID_IMMEDIATELY); + UpdateDirectorySize(containingDir, dirSize); // adjust usage counts for this directory if(dirSize > 0) Modified: box/trunk/lib/backupstore/HousekeepStoreAccount.h =================================================================== --- box/trunk/lib/backupstore/HousekeepStoreAccount.h 2014-04-09 22:15:14 UTC (rev 3314) +++ box/trunk/lib/backupstore/HousekeepStoreAccount.h 2014-04-09 22:15:19 UTC (rev 3315) @@ -56,10 +56,10 @@ int64_t ObjectID, BackupStoreDirectory &rDirectory, const std::string &rDirectoryFilename, - int64_t OriginalDirSizeInBlocks, BackupStoreInfo& rBackupStoreInfo); + void UpdateDirectorySize(BackupStoreDirectory &rDirectory, + IOStream::pos_type new_size_in_blocks); -private: typedef struct { int64_t mObjectID; Modified: box/trunk/test/backupstore/testbackupstore.cpp =================================================================== --- box/trunk/test/backupstore/testbackupstore.cpp 2014-04-09 22:15:14 UTC (rev 3314) +++ box/trunk/test/backupstore/testbackupstore.cpp 2014-04-09 22:15:19 UTC (rev 3315) @@ -775,6 +775,11 @@ return (result == 0); } +int64_t create_directory(BackupProtocolCallable& protocol, + int64_t parent_dir_id = BACKUPSTORE_ROOT_DIRECTORY_ID); +int64_t create_file(BackupProtocolCallable& protocol, int64_t subdirid, + const std::string& remote_filename = ""); + bool test_server_housekeeping() { SETUP(); @@ -1079,7 +1084,7 @@ // Used to not consume the stream std::auto_ptr upload(new ZeroStream(1000)); - TEST_COMMAND_RETURNS_ERROR(protocol.QueryStoreFile( + TEST_COMMAND_RETURNS_ERROR(protocol, QueryStoreFile( BACKUPSTORE_ROOT_DIRECTORY_ID, 0, 0, /* use for attr hash too */ @@ -1108,7 +1113,7 @@ return true; } -int64_t create_directory(BackupProtocolCallable& protocol) +int64_t create_directory(BackupProtocolCallable& protocol, int64_t parent_dir_id) { // Create a directory BackupStoreFilenameClear dirname("lovely_directory"); @@ -1116,8 +1121,7 @@ std::auto_ptr attr(new MemBlockStream(attr1, sizeof(attr1))); std::auto_ptr dirCreate(protocol.QueryCreateDirectory( - BACKUPSTORE_ROOT_DIRECTORY_ID, - FAKE_ATTR_MODIFICATION_TIME, dirname, attr)); + parent_dir_id, FAKE_ATTR_MODIFICATION_TIME, dirname, attr)); int64_t subdirid = dirCreate->GetObjectID(); set_refcount(subdirid, 1); @@ -1124,14 +1128,26 @@ return subdirid; } -int64_t create_file(BackupProtocolCallable& protocol, int64_t subdirid) +int64_t create_file(BackupProtocolCallable& protocol, int64_t subdirid, + const std::string& remote_filename) { // Stick a file in it write_test_file(0); + + BackupStoreFilenameClear remote_filename_encoded; + if (remote_filename.empty()) + { + remote_filename_encoded = uploads[0].name; + } + else + { + remote_filename_encoded = remote_filename; + } + std::string filename("testfiles/test0"); int64_t modtime; std::auto_ptr upload(BackupStoreFile::EncodeFile(filename, - subdirid, uploads[0].name, &modtime)); + subdirid, remote_filename_encoded, &modtime)); std::auto_ptr stored(protocol.QueryStoreFile( subdirid, @@ -1138,7 +1154,7 @@ modtime, modtime, /* use for attr hash too */ 0, /* diff from ID */ - uploads[0].name, + remote_filename_encoded, upload)); int64_t subdirfileid = stored->GetObjectID(); @@ -1770,7 +1786,7 @@ TEST_THAT(en != 0); if(en) { - TEST_THAT(en->GetObjectID() == dirtodelete); + TEST_EQUAL(dirtodelete, en->GetObjectID()); BackupStoreFilenameClear n("test_delete"); TEST_THAT(en->GetName() == n); } @@ -1785,10 +1801,185 @@ #endif apProtocol->QueryFinished(); } + + tearDown(); + return true; +} + +int get_object_size(BackupProtocolCallable& protocol, int64_t ObjectID, + int64_t ContainerID) +{ + // Get the root directory cached in the read-only connection + protocol.QueryListDirectory(ContainerID, 0, // FlagsMustBeSet + BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, + false /* no attributes */); + + BackupStoreDirectory dir(protocol.ReceiveStream()); + BackupStoreDirectory::Entry *en = dir.FindEntryByID(ObjectID); + TEST_THAT(en != 0); + if (!en) return -1; + + TEST_EQUAL(ObjectID, en->GetObjectID()); + return en->GetSizeInBlocks(); +} + +bool test_directory_parent_entry_tracks_directory_size() +{ + SETUP(); + + BackupProtocolLocal2 protocol(0x01234567, "test", "backup/01234567/", + 0, false); + BackupProtocolLocal2 protocolReadOnly(0x01234567, "test", + "backup/01234567/", 0, true); // read only + int64_t subdirid = create_directory(protocol); + + // Get the root directory cached in the read-only connection, and + // test that the initial size is correct. + int old_size = get_raid_file(subdirid)->GetDiscUsageInBlocks(); + TEST_THAT(old_size > 0); + TEST_EQUAL(old_size, get_object_size(protocolReadOnly, subdirid, + BACKUPSTORE_ROOT_DIRECTORY_ID)); + + // TODO FIXME Sleep to ensure that file timestamp changes (win32?) + + // Start adding files until the size on disk increases. This is + // guaranteed to happen eventually :) + int new_size = old_size; + int64_t last_added_file_id = 0; + std::string last_added_filename; + + for (int i = 0; new_size == old_size; i++) + { + std::ostringstream name; + name << "testfile_" << i; + last_added_filename = name.str(); + last_added_file_id = create_file(protocol, subdirid, name.str()); + new_size = get_raid_file(subdirid)->GetDiscUsageInBlocks(); + } + + // Check that the root directory entry has been updated + TEST_EQUAL(new_size, get_object_size(protocolReadOnly, subdirid, + BACKUPSTORE_ROOT_DIRECTORY_ID)); + + // Now delete an entry, and check that the size is reduced + protocol.QueryDeleteFile(subdirid, + BackupStoreFilenameClear(last_added_filename)); + + // Reduce the limits, to remove it permanently from the store + protocol.QueryFinished(); + protocolReadOnly.QueryFinished(); + TEST_THAT(change_account_limits("0B", "20000B")); + TEST_THAT(run_housekeeping_and_check_account()); + set_refcount(last_added_file_id, 0); + protocol.Reopen(); + protocolReadOnly.Reopen(); + + TEST_EQUAL(old_size, get_raid_file(subdirid)->GetDiscUsageInBlocks()); + + // Check that the entry in the root directory was updated too + TEST_EQUAL(old_size, get_object_size(protocolReadOnly, subdirid, + BACKUPSTORE_ROOT_DIRECTORY_ID)); + + // Push the limits back up + protocol.QueryFinished(); + protocolReadOnly.QueryFinished(); + TEST_THAT(change_account_limits("1000B", "20000B")); + TEST_THAT(run_housekeeping_and_check_account()); + protocol.Reopen(); + protocolReadOnly.Reopen(); + + // Add a directory, this should push the object size back up + int64_t dir2id = create_directory(protocol, subdirid); + TEST_EQUAL(new_size, get_raid_file(subdirid)->GetDiscUsageInBlocks()); + TEST_EQUAL(new_size, get_object_size(protocolReadOnly, subdirid, + BACKUPSTORE_ROOT_DIRECTORY_ID)); + + // Delete it again, which should reduce the object size again + protocol.QueryDeleteDirectory(dir2id); + + // Reduce the limits, to remove it permanently from the store + protocol.QueryFinished(); + protocolReadOnly.QueryFinished(); + TEST_THAT(change_account_limits("0B", "20000B")); + TEST_THAT(run_housekeeping_and_check_account()); + set_refcount(last_added_file_id, 0); + protocol.Reopen(); + protocolReadOnly.Reopen(); + + // Check that the entry in the root directory was updated + TEST_EQUAL(old_size, get_raid_file(subdirid)->GetDiscUsageInBlocks()); + TEST_EQUAL(old_size, get_object_size(protocolReadOnly, subdirid, + BACKUPSTORE_ROOT_DIRECTORY_ID)); + + // Check that bbstoreaccounts check fix will detect and repair when + // a directory's parent entry has the wrong size for the directory. + + protocol.QueryFinished(); + + std::auto_ptr root_read(get_raid_file(BACKUPSTORE_ROOT_DIRECTORY_ID)); + BackupStoreDirectory root(static_cast >(root_read)); + BackupStoreDirectory::Entry *en = root.FindEntryByID(subdirid); + TEST_THAT(en != 0); + if (!en) return false; + en->SetSizeInBlocks(1234); + + std::string rfn; + StoreStructure::MakeObjectFilename(BACKUPSTORE_ROOT_DIRECTORY_ID, + "backup/01234567/" /* mStoreRoot */, 0 /* mStoreDiscSet */, + rfn, false); // EnsureDirectoryExists + RaidFileWrite rfw(0, rfn); + rfw.Open(true); // AllowOverwrite + root.WriteToStream(rfw); + rfw.Commit(/* ConvertToRaidNow */ true); + + TEST_EQUAL(1234, get_object_size(protocolReadOnly, subdirid, + BACKUPSTORE_ROOT_DIRECTORY_ID)); + TEST_EQUAL(1, check_account_for_errors()); + TEST_EQUAL(old_size, get_object_size(protocolReadOnly, subdirid, + BACKUPSTORE_ROOT_DIRECTORY_ID)); + + protocolReadOnly.QueryFinished(); + tearDown(); return true; } +bool test_cannot_open_multiple_writable_connections() +{ + SETUP(); + TEST_THAT_THROWONFAIL(StartServer()); + + // First try a local protocol. This works even on Windows. + BackupProtocolLocal2 protocolWritable(0x01234567, "test", + "backup/01234567/", 0, false); // Not read-only + + // Set the client store marker + protocolWritable.QuerySetClientStoreMarker(0x8732523ab23aLL); + + // First try a local protocol. This works even on Windows. + BackupProtocolLocal2 protocolWritable2(0x01234567, "test", + "backup/01234567/", 0, false); // Not read-only + assert_writable_connection_fails(protocolWritable2); + + BackupProtocolLocal2 protocolReadOnly(0x01234567, "test", + "backup/01234567/", 0, true); // Read-only + TEST_EQUAL(0x8732523ab23aLL, + assert_readonly_connection_succeeds(protocolReadOnly)); + + // Try network connections too. + TLSContext context; + + BackupProtocolClient protocolWritable3(open_conn("localhost", context)); + assert_writable_connection_fails(protocolWritable3); + + BackupProtocolClient protocolReadOnly2(open_conn("localhost", context)); + TEST_EQUAL(0x8732523ab23aLL, + assert_readonly_connection_succeeds(protocolReadOnly2)); + + tearDown(); + return true; +} + bool test_encoding() { // Now test encoded files @@ -2740,6 +2931,7 @@ TEST_THAT(test_bbstoreaccounts_create()); TEST_THAT(test_bbstoreaccounts_delete()); TEST_THAT(test_backupstore_directory()); + TEST_THAT(test_directory_parent_entry_tracks_directory_size()); TEST_THAT(test_encoding()); TEST_THAT(test_symlinks()); TEST_THAT(test_store_info()); From subversion at boxbackup.org Wed Apr 9 23:15:28 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:15:28 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3317 - box/trunk/lib/common Message-ID: <201404092215.s39MFSF7057808@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:15:28 +0100 (Wed, 09 Apr 2014) New Revision: 3317 Modified: box/trunk/lib/common/Logging.h Log: Add a guard that can temporarily add a Logger to the logging system. This is very useful with the forthcoming Capture logger. Modified: box/trunk/lib/common/Logging.h =================================================================== --- box/trunk/lib/common/Logging.h 2014-04-09 22:15:25 UTC (rev 3316) +++ box/trunk/lib/common/Logging.h 2014-04-09 22:15:28 UTC (rev 3317) @@ -377,6 +377,23 @@ } } }; + + class TempLoggerGuard + { + private: + Logger* mpLogger; + + public: + TempLoggerGuard(Logger* pLogger) + : mpLogger(pLogger) + { + Logging::Add(mpLogger); + } + ~TempLoggerGuard() + { + Logging::Remove(mpLogger); + } + }; }; class FileLogger : public Logger From subversion at boxbackup.org Wed Apr 9 23:15:25 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:15:25 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3316 - in box/trunk: bin/bbackupquery infrastructure lib/backupstore lib/common test/backupstore test/bbackupd Message-ID: <201404092215.s39MFPh2057791@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:15:25 +0100 (Wed, 09 Apr 2014) New Revision: 3316 Modified: box/trunk/bin/bbackupquery/BackupQueries.cpp box/trunk/bin/bbackupquery/bbackupquery.cpp box/trunk/infrastructure/buildenv-testmain-template.cpp box/trunk/lib/backupstore/BackupCommands.cpp box/trunk/lib/backupstore/StoreTestUtils.cpp box/trunk/lib/common/Box.h box/trunk/lib/common/Logging.cpp box/trunk/lib/common/Logging.h box/trunk/lib/common/Test.cpp box/trunk/test/backupstore/testbackupstore.cpp box/trunk/test/bbackupd/testbbackupd.cpp Log: Remove the global logging level. It's incompatible with having a logger that logs everything, regardless of the global log level. Modified: box/trunk/bin/bbackupquery/BackupQueries.cpp =================================================================== --- box/trunk/bin/bbackupquery/BackupQueries.cpp 2014-04-09 22:15:19 UTC (rev 3315) +++ box/trunk/bin/bbackupquery/BackupQueries.cpp 2014-04-09 22:15:25 UTC (rev 3316) @@ -1967,11 +1967,9 @@ // At TRACE level, we print a line for each file and // directory, so we don't need dots. - bool printDots = ! Logging::IsEnabled(Log::TRACE); - result = BackupClientRestore(mrConnection, dirID, storeDirEncoded.c_str(), localName.c_str(), - printDots /* print progress dots */, restoreDeleted, + true /* print progress dots */, restoreDeleted, false /* don't undelete after restore! */, opts['r'] /* resume? */, opts['f'] /* force continue after errors */); Modified: box/trunk/bin/bbackupquery/bbackupquery.cpp =================================================================== --- box/trunk/bin/bbackupquery/bbackupquery.cpp 2014-04-09 22:15:19 UTC (rev 3315) +++ box/trunk/bin/bbackupquery/bbackupquery.cpp 2014-04-09 22:15:25 UTC (rev 3316) @@ -221,9 +221,9 @@ Logging::SetProgramName("bbackupquery"); #ifdef BOX_RELEASE_BUILD - int masterLevel = Log::NOTICE; // need an int to do math with + int consoleLogLevel = Log::NOTICE; // need an int to do math with #else - int masterLevel = Log::INFO; // need an int to do math with + int consoleLogLevel = Log::INFO; // need an int to do math with #endif #ifdef WIN32 @@ -253,7 +253,7 @@ { case 'q': { - if(masterLevel == Log::NOTHING) + if(consoleLogLevel == Log::NOTHING) { BOX_FATAL("Too many '-q': " "Cannot reduce logging " @@ -260,13 +260,13 @@ "level any more"); return 2; } - masterLevel--; + consoleLogLevel--; } break; case 'v': { - if(masterLevel == Log::EVERYTHING) + if(consoleLogLevel == Log::EVERYTHING) { BOX_FATAL("Too many '-v': " "Cannot increase logging " @@ -273,20 +273,20 @@ "level any more"); return 2; } - masterLevel++; + consoleLogLevel++; } break; case 'V': { - masterLevel = Log::EVERYTHING; + consoleLogLevel = Log::EVERYTHING; } break; case 'W': { - masterLevel = Logging::GetNamedLevel(optarg); - if (masterLevel == Log::INVALID) + consoleLogLevel = Logging::GetNamedLevel(optarg); + if (consoleLogLevel == Log::INVALID) { BOX_FATAL("Invalid logging level"); return 2; @@ -351,7 +351,7 @@ argc -= optind; argv += optind; - Logging::SetGlobalLevel((Log::Level)masterLevel); + Logging::GetConsole().Filter((Log::Level)consoleLogLevel); std::auto_ptr fileLogger; if (fileLogLevel != Log::INVALID) @@ -359,20 +359,8 @@ fileLogger.reset(new FileLogger(fileLogFile, fileLogLevel)); } - bool quiet = false; - if (masterLevel < Log::NOTICE) - { - // Quiet mode - quiet = true; - } + BOX_NOTICE(BANNER_TEXT("Backup Query Tool")); - // Print banner? - if(!quiet) - { - const char *banner = BANNER_TEXT("Backup Query Tool"); - BOX_NOTICE(banner); - } - #ifdef WIN32 if (unicodeConsole) { @@ -399,7 +387,7 @@ #endif // WIN32 // Read in the configuration file - if(!quiet) BOX_INFO("Using configuration file " << configFilename); + BOX_INFO("Using configuration file " << configFilename); std::string errs; std::auto_ptr config( @@ -428,7 +416,7 @@ BackupClientCryptoKeys_Setup(conf.GetKeyValue("KeysFile").c_str()); // 2. Connect to server - if(!quiet) BOX_INFO("Connecting to store..."); + BOX_INFO("Connecting to store..."); SocketStreamTLS *socket = new SocketStreamTLS; std::auto_ptr apSocket(socket); socket->Open(tlsContext, Socket::TypeINET, @@ -436,7 +424,7 @@ conf.GetKeyValueInt("StorePort")); // 3. Make a protocol, and handshake - if(!quiet) BOX_INFO("Handshake with store..."); + BOX_INFO("Handshake with store..."); std::auto_ptr apConnection(new BackupProtocolClient(apSocket)); BackupProtocolClient& connection(*(apConnection.get())); @@ -449,7 +437,7 @@ } // 4. Log in to server - if(!quiet) BOX_INFO("Login to store..."); + BOX_INFO("Login to store..."); // Check the version of the server { std::auto_ptr serverVersion(connection.QueryVersion(BACKUP_STORE_SERVER_VERSION)); @@ -463,7 +451,8 @@ (readWrite)?0:(BackupProtocolLogin::Flags_ReadOnly)); // 5. Tell user. - if(!quiet) printf("Login complete.\n\nType \"help\" for a list of commands.\n\n"); + BOX_INFO("Login complete."); + BOX_INFO("Type \"help\" for a list of commands."); // Set up a context for our work BackupQueries context(connection, conf, readWrite); @@ -572,9 +561,9 @@ } // Done... stop nicely - if(!quiet) BOX_INFO("Logging off..."); + BOX_INFO("Logging off..."); connection.QueryFinished(); - if(!quiet) BOX_INFO("Session finished."); + BOX_INFO("Session finished."); // Return code returnCode = context.GetReturnCode(); Modified: box/trunk/infrastructure/buildenv-testmain-template.cpp =================================================================== --- box/trunk/infrastructure/buildenv-testmain-template.cpp 2014-04-09 22:15:19 UTC (rev 3315) +++ box/trunk/infrastructure/buildenv-testmain-template.cpp 2014-04-09 22:15:25 UTC (rev 3316) @@ -372,7 +372,7 @@ } } - Logging::SetGlobalLevel((Log::Level)logLevel); + Logging::FilterSyslog(Log::NOTHING); Logging::FilterConsole((Log::Level)logLevel); argc -= optind - 1; Modified: box/trunk/lib/backupstore/BackupCommands.cpp =================================================================== --- box/trunk/lib/backupstore/BackupCommands.cpp 2014-04-09 22:15:19 UTC (rev 3315) +++ box/trunk/lib/backupstore/BackupCommands.cpp 2014-04-09 22:15:25 UTC (rev 3316) @@ -298,7 +298,7 @@ // Check the object exists if(!rContext.ObjectExists(mObjectID)) { - return std::auto_ptr(new BackupProtocolSuccess(NoObject)); + return PROTOCOL_ERROR(Err_DoesNotExist); } // Open the object Modified: box/trunk/lib/backupstore/StoreTestUtils.cpp =================================================================== --- box/trunk/lib/backupstore/StoreTestUtils.cpp 2014-04-09 22:15:19 UTC (rev 3315) +++ box/trunk/lib/backupstore/StoreTestUtils.cpp 2014-04-09 22:15:25 UTC (rev 3316) @@ -34,7 +34,8 @@ Configuration::LoadAndVerify ("testfiles/bbstored.conf", &BackupConfigFileVerify, errs)); BackupStoreAccountsControl control(*config); - Logging::Guard guard(Log::WARNING); + + Logger::LevelGuard guard(Logging::GetConsole(), Log::WARNING); int result = control.CreateAccount(0x01234567, 0, soft, hard); TEST_EQUAL(0, result); return (result == 0); @@ -47,7 +48,7 @@ Configuration::LoadAndVerify ("testfiles/bbstored.conf", &BackupConfigFileVerify, errs)); BackupStoreAccountsControl control(*config); - Logging::Guard guard(Log::WARNING); + Logger::LevelGuard guard(Logging::GetConsole(), Log::WARNING); TEST_THAT_THROWONFAIL(control.DeleteAccount(0x01234567, false) == 0); return true; } @@ -204,7 +205,7 @@ int check_account_for_errors(Log::Level log_level) { - Logging::Guard guard(log_level); + Logger::LevelGuard guard(Logging::GetConsole(), log_level); Logging::Tagger tag("check fix", true); Logging::ShowTagOnConsole show; std::string errs; Modified: box/trunk/lib/common/Box.h =================================================================== --- box/trunk/lib/common/Box.h 2014-04-09 22:15:19 UTC (rev 3315) +++ box/trunk/lib/common/Box.h 2014-04-09 22:15:25 UTC (rev 3316) @@ -116,16 +116,8 @@ { \ if((!HideExceptionMessageGuard::ExceptionsHidden() \ && !HideSpecificExceptionGuard::IsHidden( \ - type::ExceptionType, type::subtype)) \ - || Logging::Guard::IsGuardingFrom(Log::EVERYTHING)) \ + type::ExceptionType, type::subtype))) \ { \ - std::auto_ptr guard; \ - \ - if(Logging::Guard::IsGuardingFrom(Log::EVERYTHING)) \ - { \ - guard.reset(new Logging::Guard(Log::EVERYTHING)); \ - } \ - \ OPTIONAL_DO_BACKTRACE \ BOX_WARNING("Exception thrown: " \ #type "(" #subtype ") " \ @@ -140,16 +132,8 @@ _box_throw_line << message; \ if((!HideExceptionMessageGuard::ExceptionsHidden() \ && !HideSpecificExceptionGuard::IsHidden( \ - type::ExceptionType, type::subtype)) \ - || Logging::Guard::IsGuardingFrom(Log::EVERYTHING)) \ + type::ExceptionType, type::subtype))) \ { \ - std::auto_ptr guard; \ - \ - if(Logging::Guard::IsGuardingFrom(Log::EVERYTHING)) \ - { \ - guard.reset(new Logging::Guard(Log::EVERYTHING)); \ - } \ - \ OPTIONAL_DO_BACKTRACE \ BOX_WARNING("Exception thrown: " \ #type "(" #subtype ") (" << \ Modified: box/trunk/lib/common/Logging.cpp =================================================================== --- box/trunk/lib/common/Logging.cpp 2014-04-09 22:15:19 UTC (rev 3315) +++ box/trunk/lib/common/Logging.cpp 2014-04-09 22:15:25 UTC (rev 3316) @@ -42,7 +42,6 @@ std::string Logging::sContext; Console* Logging::spConsole = NULL; Syslog* Logging::spSyslog = NULL; -Log::Level Logging::sGlobalLevel = Log::EVERYTHING; Logging Logging::sGlobalLogging; //automatic initialisation std::string Logging::sProgramName; @@ -49,9 +48,6 @@ HideSpecificExceptionGuard::SuppressedExceptions_t HideSpecificExceptionGuard::sSuppressedExceptions; -int Logging::Guard::sGuardCount = 0; -Log::Level Logging::Guard::sOriginalLevel = Log::INVALID; - Logging::Logging() { ASSERT(!spConsole); @@ -142,11 +138,6 @@ void Logging::Log(Log::Level level, const std::string& rFile, int line, const std::string& rMessage) { - if (level > sGlobalLevel) - { - return; - } - std::string newMessage; if (sContextSet) @@ -175,11 +166,6 @@ return; } - if (level > sGlobalLevel) - { - return; - } - std::string newMessage; if (sContextSet) @@ -255,8 +241,7 @@ bool Logger::IsEnabled(Log::Level level) { - return Logging::IsEnabled(level) && - (int)mCurrentLevel >= (int)level; + return (int)mCurrentLevel >= (int)level; } bool Console::sShowTime = false; Modified: box/trunk/lib/common/Logging.h =================================================================== --- box/trunk/lib/common/Logging.h 2014-04-09 22:15:19 UTC (rev 3315) +++ box/trunk/lib/common/Logging.h 2014-04-09 22:15:25 UTC (rev 3316) @@ -39,9 +39,7 @@ #define BOX_WARNING(stuff) BOX_LOG(Log::WARNING, stuff) #define BOX_NOTICE(stuff) BOX_LOG(Log::NOTICE, stuff) #define BOX_INFO(stuff) BOX_LOG(Log::INFO, stuff) -#define BOX_TRACE(stuff) \ - if (Logging::IsEnabled(Log::TRACE)) \ - { BOX_LOG(Log::TRACE, stuff) } +#define BOX_TRACE(stuff) BOX_LOG(Log::TRACE, stuff) #define BOX_SYS_ERRNO_MESSAGE(error_number, stuff) \ stuff << ": " << std::strerror(error_number) << \ @@ -201,7 +199,7 @@ virtual void SetProgramName(const std::string& rProgramName) = 0; - class Guard + class LevelGuard { private: Logger& mLogger; @@ -208,12 +206,16 @@ Log::Level mOldLevel; public: - Guard(Logger& Logger) + LevelGuard(Logger& Logger, Log::Level newLevel = Log::INVALID) : mLogger(Logger) { mOldLevel = Logger.GetLevel(); + if (newLevel != Log::INVALID) + { + Logger.Filter(newLevel); + } } - ~Guard() + ~LevelGuard() { mLogger.Filter(mOldLevel); } @@ -298,7 +300,6 @@ static bool sContextSet; static Console* spConsole; static Syslog* spSyslog; - static Log::Level sGlobalLevel; static Logging sGlobalLogging; static std::string sProgramName; @@ -317,13 +318,7 @@ int line, const std::string& rMessage); static void SetContext(std::string context); static void ClearContext(); - static void SetGlobalLevel(Log::Level level) { sGlobalLevel = level; } - static Log::Level GetGlobalLevel() { return sGlobalLevel; } static Log::Level GetNamedLevel(const std::string& rName); - static bool IsEnabled(Log::Level level) - { - return (int)sGlobalLevel >= (int)level; - } static void SetProgramName(const std::string& rProgramName); static std::string GetProgramName() { return sProgramName; } static void SetFacility(int facility); @@ -330,39 +325,6 @@ static Console& GetConsole() { return *spConsole; } static Syslog& GetSyslog() { return *spSyslog; } - class Guard - { - private: - Log::Level mOldLevel; - static int sGuardCount; - static Log::Level sOriginalLevel; - - public: - Guard(Log::Level newLevel) - { - mOldLevel = Logging::GetGlobalLevel(); - if(sGuardCount == 0) - { - sOriginalLevel = mOldLevel; - } - sGuardCount++; - Logging::SetGlobalLevel(newLevel); - } - ~Guard() - { - sGuardCount--; - Logging::SetGlobalLevel(mOldLevel); - } - - static bool IsActive() { return (sGuardCount > 0); } - static Log::Level GetOriginalLevel() { return sOriginalLevel; } - static bool IsGuardingFrom(Log::Level originalLevel) - { - return IsActive() && - (int)sOriginalLevel >= (int)originalLevel; - } - }; - class ShowTagOnConsole { private: Modified: box/trunk/lib/common/Test.cpp =================================================================== --- box/trunk/lib/common/Test.cpp 2014-04-09 22:15:19 UTC (rev 3315) +++ box/trunk/lib/common/Test.cpp 2014-04-09 22:15:25 UTC (rev 3316) @@ -230,14 +230,7 @@ #endif // time for it to start up - if (Logging::GetGlobalLevel() >= Log::TRACE) - { - BOX_TRACE("Waiting for server to start"); - } - else - { - ::fprintf(stdout, "Waiting for server to start: "); - } + BOX_TRACE("Waiting for server to start"); for (int i = 0; i < 15; i++) { @@ -251,12 +244,6 @@ break; } - if (Logging::GetGlobalLevel() < Log::TRACE) - { - ::fprintf(stdout, "."); - ::fflush(stdout); - } - ::sleep(1); } @@ -265,15 +252,6 @@ if (pidIfKnown && !ServerIsAlive(pidIfKnown)) { - if (Logging::GetGlobalLevel() >= Log::TRACE) - { - BOX_ERROR("server died!"); - } - else - { - ::fprintf(stdout, " server died!\n"); - } - TEST_FAIL_WITH_MESSAGE("Server died!"); return -1; } @@ -280,27 +258,11 @@ if (!TestFileNotEmpty(pidFile)) { - if (Logging::GetGlobalLevel() >= Log::TRACE) - { - BOX_ERROR("timed out!"); - } - else - { - ::fprintf(stdout, " timed out!\n"); - } - TEST_FAIL_WITH_MESSAGE("Server didn't save PID file"); return -1; } - if (Logging::GetGlobalLevel() >= Log::TRACE) - { - BOX_TRACE("Server started"); - } - else - { - ::fprintf(stdout, " done.\n"); - } + BOX_TRACE("Server started"); // wait a second for the pid to be written to the file ::sleep(1); @@ -419,35 +381,14 @@ // Wait a given number of seconds for something to complete void wait_for_operation(int seconds, const char* message) { - if (Logging::GetGlobalLevel() >= Log::TRACE) - { - BOX_TRACE("Waiting " << seconds << " seconds for " << message); - } - else - { - printf("Waiting for %s: ", message); - fflush(stdout); - } + BOX_TRACE("Waiting " << seconds << " seconds for " << message); for(int l = 0; l < seconds; ++l) { sleep(1); - if (Logging::GetGlobalLevel() < Log::TRACE) - { - printf("."); - fflush(stdout); - } } - if (Logging::GetGlobalLevel() >= Log::TRACE) - { - BOX_TRACE("Finished waiting for " << message); - } - else - { - printf(" done.\n"); - fflush(stdout); - } + BOX_TRACE("Finished waiting for " << message); } void safe_sleep(int seconds) Modified: box/trunk/test/backupstore/testbackupstore.cpp =================================================================== --- box/trunk/test/backupstore/testbackupstore.cpp 2014-04-09 22:15:19 UTC (rev 3315) +++ box/trunk/test/backupstore/testbackupstore.cpp 2014-04-09 22:15:25 UTC (rev 3316) @@ -1104,6 +1104,11 @@ ConnectionException, Conn_Protocol_UnexpectedReply); } + // Try retrieving an object that doesn't exist. That used to return + // BackupProtocolSuccess(NoObject) for no apparent reason. + TEST_COMMAND_RETURNS_ERROR(protocol, QueryGetObject(store1objid + 1), + Err_DoesNotExist); + // Close the protocol, so we can housekeep the account protocol.QueryFinished(); TEST_THAT(run_housekeeping_and_check_account()); Modified: box/trunk/test/bbackupd/testbbackupd.cpp =================================================================== --- box/trunk/test/bbackupd/testbbackupd.cpp 2014-04-09 22:15:19 UTC (rev 3315) +++ box/trunk/test/bbackupd/testbbackupd.cpp 2014-04-09 22:15:25 UTC (rev 3316) @@ -324,7 +324,7 @@ BackupClientFileAttributes t3; { - Logging::Guard guard(Log::ERROR); + Logger::LevelGuard(Logging::GetConsole(), Log::ERROR); TEST_CHECK_THROWS(t3.ReadAttributes("doesn't exist"), CommonException, OSFileError); } @@ -345,7 +345,7 @@ #ifndef WIN32 { - Logging::Guard guard(Log::ERROR); + Logger::LevelGuard(Logging::GetConsole(), Log::ERROR); TEST_CHECK_THROWS(t1.WriteAttributes("testfiles/test1_nXX"), CommonException, OSFileError); TEST_CHECK_THROWS(t3.WriteAttributes("doesn't exist"), @@ -879,7 +879,7 @@ context, 0 /* read-write */); { - Logging::Guard guard(Log::ERROR); + Logger::LevelGuard(Logging::GetConsole(), Log::ERROR); TEST_CHECK_THROWS(ReadDirectory(*client, 0x12345678), ConnectionException, Conn_Protocol_UnexpectedReply); @@ -1713,11 +1713,6 @@ // in fork child TEST_THAT(setsid() != -1); - if (!Logging::IsEnabled(Log::TRACE)) - { - Logging::SetGlobalLevel(Log::NOTHING); - } - // BackupStoreDaemon must be destroyed before exit(), // to avoid memory leaks being reported. { @@ -1742,15 +1737,14 @@ ::signal(SIGPIPE, SIG_IGN); { - Log::Level newLevel = Logging::GetGlobalLevel(); + Console& console(Logging::GetConsole()); + Logger::LevelGuard guard(console); - if (!Logging::IsEnabled(Log::TRACE)) + if (console.GetLevel() < Log::TRACE) { - newLevel = Log::NOTHING; + console.Filter(Log::NOTHING); } - Logging::Guard guard(newLevel); - BackupDaemon bbackupd; bbackupd.Configure("testfiles/bbackupd.conf"); bbackupd.InitCrypto(); @@ -3424,7 +3418,8 @@ fflush(stdout); { - Logging::Guard guard(Log::FATAL); + Logger::LevelGuard(Logging::GetConsole(), + Log::FATAL); TEST_THAT(BackupClientRestore(*client, restoredirid, "Test1", "testfiles/no-such-path/subdir", From subversion at boxbackup.org Wed Apr 9 23:15:32 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:15:32 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3318 - box/trunk/lib/common Message-ID: <201404092215.s39MFWis057824@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:15:31 +0100 (Wed, 09 Apr 2014) New Revision: 3318 Modified: box/trunk/lib/common/Logging.h Log: Add a capturing logger. Useful in testing whether code logs the expected messages or not. Modified: box/trunk/lib/common/Logging.h =================================================================== --- box/trunk/lib/common/Logging.h 2014-04-09 22:15:28 UTC (rev 3317) +++ box/trunk/lib/common/Logging.h 2014-04-09 22:15:31 UTC (rev 3318) @@ -284,6 +284,58 @@ // -------------------------------------------------------------------------- // // Class +// Name: Capture +// Purpose: Keeps log messages for analysis in tests. +// Created: 2014/03/08 +// +// -------------------------------------------------------------------------- + +class Capture : public Logger +{ + public: + struct Message + { + Log::Level level; + std::string file; + int line; + std::string message; + }; + + private: + std::vector mMessages; + + public: + virtual ~Capture() { } + + virtual bool Log(Log::Level level, const std::string& rFile, + int line, std::string& rMessage) + { + Message message; + message.level = level; + message.file = rFile; + message.line = line; + message.message = rMessage; + mMessages.push_back(message); + return true; + } + virtual const char* GetType() { return "Capture"; } + virtual void SetProgramName(const std::string& rProgramName) { } + const std::vector& GetMessages() const { return mMessages; } + std::string GetString() const + { + std::ostringstream oss; + for (std::vector::const_iterator i = mMessages.begin(); + i != mMessages.end(); i++) + { + oss << i->message << "\n"; + } + return oss.str(); + } +}; + +// -------------------------------------------------------------------------- +// +// Class // Name: Logging // Purpose: Static logging helper, keeps track of enabled loggers // and distributes log messages to them. From subversion at boxbackup.org Wed Apr 9 23:15:36 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:15:36 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3319 - in box/trunk: bin/bbackupquery lib/backupstore test/bbackupd Message-ID: <201404092215.s39MFatK057840@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:15:36 +0100 (Wed, 09 Apr 2014) New Revision: 3319 Modified: box/trunk/bin/bbackupquery/BackupQueries.cpp box/trunk/lib/backupstore/backupprotocol.txt box/trunk/test/bbackupd/testbbackupd.cpp Log: Remove NoObject reply, and adapt BackupQueries accordingly. Modified: box/trunk/bin/bbackupquery/BackupQueries.cpp =================================================================== --- box/trunk/bin/bbackupquery/BackupQueries.cpp 2014-04-09 22:15:31 UTC (rev 3318) +++ box/trunk/bin/bbackupquery/BackupQueries.cpp 2014-04-09 22:15:36 UTC (rev 3319) @@ -875,21 +875,27 @@ { // Request object std::auto_ptr getobj(mrConnection.QueryGetObject(id)); - if(getobj->GetObjectID() != BackupProtocolGetObject::NoObject) - { - // Stream that object out to the file - std::auto_ptr objectStream(mrConnection.ReceiveStream()); - objectStream->CopyStreamTo(out); + + // Stream that object out to the file + std::auto_ptr objectStream(mrConnection.ReceiveStream()); + objectStream->CopyStreamTo(out); - BOX_INFO("Object ID " << BOX_FORMAT_OBJECTID(id) << - " fetched successfully."); - } - else + BOX_INFO("Object ID " << BOX_FORMAT_OBJECTID(id) << + " fetched successfully."); + } + catch(ConnectionException &e) + { + if(mrConnection.GetLastErrorType() == BackupProtocolError::Err_DoesNotExist) { BOX_ERROR("Object ID " << BOX_FORMAT_OBJECTID(id) << " does not exist on store."); ::unlink(args[1].c_str()); } + else + { + BOX_ERROR("Error occured fetching object."); + ::unlink(args[1].c_str()); + } } catch(...) { Modified: box/trunk/lib/backupstore/backupprotocol.txt =================================================================== --- box/trunk/lib/backupstore/backupprotocol.txt 2014-04-09 22:15:31 UTC (rev 3318) +++ box/trunk/lib/backupstore/backupprotocol.txt 2014-04-09 22:15:36 UTC (rev 3319) @@ -77,8 +77,7 @@ GetObject 10 Command(Success) int64 ObjectID - CONSTANT NoObject 0 - # reply has stream following, if ObjectID != NoObject + # reply has stream following (if successful) MoveObject 11 Command(Success) Modified: box/trunk/test/bbackupd/testbbackupd.cpp =================================================================== --- box/trunk/test/bbackupd/testbbackupd.cpp 2014-04-09 22:15:31 UTC (rev 3318) +++ box/trunk/test/bbackupd/testbbackupd.cpp 2014-04-09 22:15:36 UTC (rev 3319) @@ -888,6 +888,34 @@ client->QueryFinished(); } + printf("\n==== Testing that GetObject on nonexistent file outputs the " + "correct error message\n"); + { + std::auto_ptr connection = ConnectAndLogin( + context, 0 /* read-write */); + std::string errs; + std::auto_ptr config( + Configuration::LoadAndVerify + ("testfiles/bbackupd.conf", &BackupDaemonConfigVerify, errs)); + BackupQueries query(*connection, *config, false); // read-only + std::vector args; + args.push_back("2"); // object ID + args.push_back("testfiles/2.obj"); // output file + bool opts[256]; + + Capture capture; + Logging::TempLoggerGuard guard(&capture); + query.CommandGetObject(args, opts); + std::vector messages = capture.GetMessages(); + TEST_THAT(!messages.empty()); + if (!messages.empty()) + { + std::string last_message = messages.back().message; + TEST_EQUAL("Object ID 0x2 does not exist on store.", + last_message); + } + } + // unpack the files for the initial test TEST_THAT(::system("rm -rf testfiles/TestDir1") == 0); TEST_THAT(::mkdir("testfiles/TestDir1", 0777) == 0); From subversion at boxbackup.org Wed Apr 9 23:15:39 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:15:39 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3320 - box/trunk/bin/bbackupctl Message-ID: <201404092215.s39MFdxf057856@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:15:39 +0100 (Wed, 09 Apr 2014) New Revision: 3320 Modified: box/trunk/bin/bbackupctl/bbackupctl.cpp Log: Add a status command to bbackupctl. Allows polling the daemon to see if it's running, without telling it to actually do anything. Modified: box/trunk/bin/bbackupctl/bbackupctl.cpp =================================================================== --- box/trunk/bin/bbackupctl/bbackupctl.cpp 2014-04-09 22:15:36 UTC (rev 3319) +++ box/trunk/bin/bbackupctl/bbackupctl.cpp 2014-04-09 22:15:39 UTC (rev 3320) @@ -38,6 +38,7 @@ WaitForSyncStart, WaitForSyncEnd, SyncAndWaitForEnd, + NoCommand, }; void PrintUsageAndExit() @@ -44,6 +45,7 @@ { printf("Usage: bbackupctl [-q] [-c config_file] \n" "Commands are:\n" + " status -- report daemon status without changing anything\n" " sync -- start a synchronisation (backup) run now\n" " force-sync -- force the start of a synchronisation run, " "even if SyncAllowScript says no\n" @@ -230,6 +232,11 @@ { command = SyncAndWaitForEnd; } + else if (commandName == "status") + { + BOX_NOTICE("state " << currentState); + command = NoCommand; + } switch (command) { @@ -269,10 +276,18 @@ { // Normal case, just send the command given // plus a quit command. - std::string cmd = commandName; - cmd += "\nquit\n"; + std::string cmd = commandName + "\n"; connection.Write(cmd.c_str(), cmd.size()); } + // fall through + + case NoCommand: + { + // Normal case, just send the command given + // plus a quit command. + std::string cmd = "quit\n"; + connection.Write(cmd.c_str(), cmd.size()); + } } // Read the response @@ -280,7 +295,7 @@ bool syncIsRunning = false; bool finished = false; - while(!finished && !getLine.IsEOF() && getLine.GetLine(line)) + while(command != NoCommand && !finished && !getLine.IsEOF() && getLine.GetLine(line)) { switch (command) { From subversion at boxbackup.org Wed Apr 9 23:15:42 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:15:42 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3321 - box/trunk/lib/common Message-ID: <201404092215.s39MFglj057872@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:15:42 +0100 (Wed, 09 Apr 2014) New Revision: 3321 Modified: box/trunk/lib/common/Guards.h Log: Improve error messages when FileHandleGuard fails to open a file. Use the standard macros to report file error messages in the standard format, including a filename and message in the exception. Modified: box/trunk/lib/common/Guards.h =================================================================== --- box/trunk/lib/common/Guards.h 2014-04-09 22:15:39 UTC (rev 3320) +++ box/trunk/lib/common/Guards.h 2014-04-09 22:15:42 UTC (rev 3321) @@ -37,9 +37,8 @@ { if(mOSFileHandle < 0) { - BOX_LOG_SYS_ERROR("FileHandleGuard: failed to open " - "file '" << rFilename << "'"); - THROW_EXCEPTION(CommonException, OSFileOpenError) + THROW_SYS_FILE_ERROR("Failed to open file", rFilename, + CommonException, OSFileOpenError); } } From subversion at boxbackup.org Wed Apr 9 23:15:45 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:15:45 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3322 - box/trunk/lib/common Message-ID: <201404092215.s39MFjsr057888@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:15:45 +0100 (Wed, 09 Apr 2014) New Revision: 3322 Modified: box/trunk/lib/common/MainHelper.h Log: Improve error message when fatal exception aborts a command-line tool. Report the exception message details if it's a BoxException, so it's more user friendly. Modified: box/trunk/lib/common/MainHelper.h =================================================================== --- box/trunk/lib/common/MainHelper.h 2014-04-09 22:15:42 UTC (rev 3321) +++ box/trunk/lib/common/MainHelper.h 2014-04-09 22:15:45 UTC (rev 3322) @@ -19,18 +19,21 @@ #include "BoxException.h" #include "Logging.h" -#define MAINHELPER_START \ - if(argc == 2 && ::strcmp(argv[1], "--version") == 0) \ - { printf(BOX_VERSION "\n"); return 0; } \ +#define MAINHELPER_START \ + if(argc == 2 && ::strcmp(argv[1], "--version") == 0) \ + { printf(BOX_VERSION "\n"); return 0; } \ MEMLEAKFINDER_INIT \ - MEMLEAKFINDER_START \ + MEMLEAKFINDER_START \ try { -#define MAINHELPER_END \ - } catch(std::exception &e) { \ +#define MAINHELPER_END \ + } catch(BoxException &e) { \ + BOX_FATAL(e.what() << ": " << e.GetMessage()); \ + return 1; \ + } catch(std::exception &e) { \ BOX_FATAL(e.what()); \ - return 1; \ - } catch(...) { \ + return 1; \ + } catch(...) { \ BOX_FATAL("UNKNOWN"); \ return 1; \ } From subversion at boxbackup.org Wed Apr 9 23:15:49 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:15:49 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3323 - in box/trunk/lib: common server Message-ID: <201404092215.s39MFndB057905@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:15:49 +0100 (Wed, 09 Apr 2014) New Revision: 3323 Modified: box/trunk/lib/common/Logging.cpp box/trunk/lib/common/Logging.h box/trunk/lib/server/Daemon.cpp box/trunk/lib/server/Daemon.h Log: Refactor logging option processing out of Daemon class. Allows command-line tools to reuse the same option processing. Modified: box/trunk/lib/common/Logging.cpp =================================================================== --- box/trunk/lib/common/Logging.cpp 2014-04-09 22:15:45 UTC (rev 3322) +++ box/trunk/lib/common/Logging.cpp 2014-04-09 22:15:49 UTC (rev 3323) @@ -554,3 +554,151 @@ return false; } +// -------------------------------------------------------------------------- +// +// Function +// Name: Logging::OptionParser::GetOptionString() +// Purpose: Returns the valid Getopt command-line options +// that Logging::OptionParser::ProcessOption will handle. +// Created: 2014/04/09 +// +// -------------------------------------------------------------------------- +std::string Logging::OptionParser::GetOptionString() +{ + return "PqQt:TUvVW:"; +} + +// -------------------------------------------------------------------------- +// +// Function +// Name: Logging::OptionParser::ProcessOption(signed int option) +// Purpose: Processes the supplied option (equivalent to the +// return code from getopt()). Return zero if the +// option was handled successfully, or nonzero to +// abort the program with that return value. +// Created: 2007/09/18 +// +// -------------------------------------------------------------------------- +int Logging::OptionParser::ProcessOption(signed int option) +{ + switch(option) + { + case 'P': + { + Console::SetShowPID(true); + } + break; + + case 'q': + { + if(mCurrentLevel == Log::NOTHING) + { + BOX_FATAL("Too many '-q': " + "Cannot reduce logging " + "level any more"); + return 2; + } + mCurrentLevel--; + } + break; + + case 'Q': + { + mCurrentLevel = Log::NOTHING; + } + break; + + case 't': + { + Logging::SetProgramName(optarg); + Console::SetShowTag(true); + } + break; + + case 'T': + { + Console::SetShowTime(true); + } + break; + + case 'U': + { + Console::SetShowTime(true); + Console::SetShowTimeMicros(true); + } + break; + + case 'v': + { + if(mCurrentLevel == Log::EVERYTHING) + { + BOX_FATAL("Too many '-v': " + "Cannot increase logging " + "level any more"); + return 2; + } + mCurrentLevel++; + } + break; + + case 'V': + { + mCurrentLevel = Log::EVERYTHING; + } + break; + + case 'W': + { + mCurrentLevel = Logging::GetNamedLevel(optarg); + if (mCurrentLevel == Log::INVALID) + { + BOX_FATAL("Invalid logging level: " << optarg); + return 2; + } + } + break; + + case '?': + { + BOX_FATAL("Unknown option on command line: " + << "'" << (char)optopt << "'"); + return 2; + } + break; + + default: + { + BOX_FATAL("Unknown error in getopt: returned " + << "'" << option << "'"); + return 1; + } + } + + // If we didn't explicitly return an error code above, then the option + // was fine, so return 0 to continue processing. + return 0; +} + +// -------------------------------------------------------------------------- +// +// Function +// Name: Logging::OptionParser::GetUsageString() +// Purpose: Returns a string suitable for displaying as part +// of a program's command-line usage help message, +// describing the logging options. +// Created: 2014/04/09 +// +// -------------------------------------------------------------------------- +std::string Logging::OptionParser::GetUsageString() +{ + return + " -P Show process ID (PID) in console output\n" + " -q Run more quietly, reduce verbosity level by one, can repeat\n" + " -Q Run at minimum verbosity, log nothing to console and system\n" + " -t Tag console output with specified marker\n" + " -T Timestamp console output\n" + " -U Timestamp console output with microseconds\n" + " -v Run more verbosely, increase verbosity level by one, can repeat\n" + " -V Run at maximum verbosity, log everything to console and system\n" + " -W Set verbosity to error/warning/notice/info/trace/everything\n"; +} Modified: box/trunk/lib/common/Logging.h =================================================================== --- box/trunk/lib/common/Logging.h 2014-04-09 22:15:45 UTC (rev 3322) +++ box/trunk/lib/common/Logging.h 2014-04-09 22:15:49 UTC (rev 3323) @@ -446,6 +446,37 @@ Logging::Remove(mpLogger); } }; + + // -------------------------------------------------------------------------- + // + // Class + // Name: Logging::OptionParser + // Purpose: Process command-line options + // Created: 2014/04/09 + // + // -------------------------------------------------------------------------- + class OptionParser + { + public: + OptionParser(Log::Level InitialLevel = + #ifdef BOX_RELEASE_BUILD + Log::NOTICE + #else + Log::INFO + #endif + ) + : mCurrentLevel(InitialLevel) + { } + + static std::string GetOptionString(); + int ProcessOption(signed int option); + static std::string GetUsageString(); + int mCurrentLevel; // need an int to do math with + Log::Level GetCurrentLevel() + { + return (Log::Level) mCurrentLevel; + } + }; }; class FileLogger : public Logger Modified: box/trunk/lib/server/Daemon.cpp =================================================================== --- box/trunk/lib/server/Daemon.cpp 2014-04-09 22:15:45 UTC (rev 3322) +++ box/trunk/lib/server/Daemon.cpp 2014-04-09 22:15:49 UTC (rev 3323) @@ -106,11 +106,11 @@ // -------------------------------------------------------------------------- std::string Daemon::GetOptionString() { - return "c:" + return std::string("c:" #ifndef WIN32 "DF" #endif - "hkKo:O:PqQt:TUvVW:"; + "hkKo:O:") + Logging::OptionParser::GetOptionString(); } void Daemon::Usage() @@ -132,17 +132,8 @@ " -k Keep console open after fork, keep writing log messages to it\n" " -K Stop writing log messages to console while daemon is running\n" " -o Log to a file, defaults to maximum verbosity\n" - " -O Set file log verbosity to error/warning/notice/info/trace/everything\n" - " -P Show process ID (PID) in console output\n" - " -q Run more quietly, reduce verbosity level by one, can repeat\n" - " -Q Run at minimum verbosity, log nothing to console and system\n" - " -t Tag console output with specified marker\n" - " -T Timestamp console output\n" - " -U Timestamp console output with microseconds\n" - " -v Run more verbosely, increase verbosity level by one, can repeat\n" - " -V Run at maximum verbosity, log everything to console and system\n" - " -W Set verbosity to error/warning/notice/info/trace/everything\n" - ; + " -O Set file log verbosity to error/warning/notice/info/trace/everything\n" << + Logging::OptionParser::GetUsageString(); } // -------------------------------------------------------------------------- @@ -218,94 +209,9 @@ } break; - case 'P': - { - Console::SetShowPID(true); - } - break; - - case 'q': - { - if(mLogLevel == Log::NOTHING) - { - BOX_FATAL("Too many '-q': " - "Cannot reduce logging " - "level any more"); - return 2; - } - mLogLevel--; - } - break; - - case 'Q': - { - mLogLevel = Log::NOTHING; - } - break; - - case 't': - { - Logging::SetProgramName(optarg); - Console::SetShowTag(true); - } - break; - - case 'T': - { - Console::SetShowTime(true); - } - break; - - case 'U': - { - Console::SetShowTime(true); - Console::SetShowTimeMicros(true); - } - break; - - case 'v': - { - if(mLogLevel == Log::EVERYTHING) - { - BOX_FATAL("Too many '-v': " - "Cannot increase logging " - "level any more"); - return 2; - } - mLogLevel++; - } - break; - - case 'V': - { - mLogLevel = Log::EVERYTHING; - } - break; - - case 'W': - { - mLogLevel = Logging::GetNamedLevel(optarg); - if (mLogLevel == Log::INVALID) - { - BOX_FATAL("Invalid logging level: " << optarg); - return 2; - } - } - break; - - case '?': - { - BOX_FATAL("Unknown option on command line: " - << "'" << (char)optopt << "'"); - return 2; - } - break; - default: { - BOX_FATAL("Unknown error in getopt: returned " - << "'" << option << "'"); - return 1; + return mLogLevel.ProcessOption(option); } } @@ -351,12 +257,6 @@ int Daemon::ProcessOptions(int argc, const char *argv[]) { - #ifdef BOX_RELEASE_BUILD - mLogLevel = Log::NOTICE; - #else - mLogLevel = Log::INFO; - #endif - if (argc == 2 && strcmp(argv[1], "/?") == 0) { Usage(); @@ -406,8 +306,8 @@ return 2; } - Logging::FilterConsole((Log::Level)mLogLevel); - Logging::FilterSyslog ((Log::Level)mLogLevel); + Logging::FilterConsole(mLogLevel.GetCurrentLevel()); + Logging::FilterSyslog (mLogLevel.GetCurrentLevel()); if (mLogFileLevel != Log::INVALID) { Modified: box/trunk/lib/server/Daemon.h =================================================================== --- box/trunk/lib/server/Daemon.h 2014-04-09 22:15:45 UTC (rev 3322) +++ box/trunk/lib/server/Daemon.h 2014-04-09 22:15:49 UTC (rev 3323) @@ -99,7 +99,7 @@ bool mRunInForeground; bool mKeepConsoleOpenAfterFork; bool mHaveConfigFile; - int mLogLevel; // need an int to do math with + Logging::OptionParser mLogLevel; std::string mLogFile; Log::Level mLogFileLevel; std::auto_ptr mapLogFileLogger; From subversion at boxbackup.org Wed Apr 9 23:15:52 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:15:52 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3324 - in box/trunk/bin: bbackupctl bbackupquery Message-ID: <201404092215.s39MFqIe057921@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:15:52 +0100 (Wed, 09 Apr 2014) New Revision: 3324 Modified: box/trunk/bin/bbackupctl/bbackupctl.cpp box/trunk/bin/bbackupquery/bbackupquery.cpp Log: Use shared code for logging options in bbackupctl and bbackupquery. Enables all standard logging options and reduces code duplication. Modified: box/trunk/bin/bbackupctl/bbackupctl.cpp =================================================================== --- box/trunk/bin/bbackupctl/bbackupctl.cpp 2014-04-09 22:15:49 UTC (rev 3323) +++ box/trunk/bin/bbackupctl/bbackupctl.cpp 2014-04-09 22:15:52 UTC (rev 3324) @@ -11,13 +11,12 @@ #include #include +#include #ifdef HAVE_UNISTD_H #include #endif -#include - #include "box_getopt.h" #include "MainHelper.h" #include "BoxPortsAndFiles.h" @@ -41,9 +40,14 @@ NoCommand, }; -void PrintUsageAndExit() +void PrintUsageAndExit(int ret) { - printf("Usage: bbackupctl [-q] [-c config_file] \n" + std::cout << + "Usage: bbackupctl [options] \n" + "\n" + "Options:\n" << + Logging::OptionParser::GetUsageString() << + "\n" "Commands are:\n" " status -- report daemon status without changing anything\n" " sync -- start a synchronisation (backup) run now\n" @@ -54,8 +58,8 @@ " wait-for-sync -- wait until the next sync starts, then exit\n" " wait-for-end -- wait until the next sync finishes, then exit\n" " sync-and-wait -- start sync, wait until it finishes, then exit\n" - ); - exit(1); + ; + exit(ret); } int main(int argc, const char *argv[]) @@ -72,28 +76,27 @@ // Filename for configuration file? std::string configFilename = BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE; - // Quiet? - bool quiet = false; - // See if there's another entry on the command line int c; - while((c = getopt(argc, (char * const *)argv, "qc:l:")) != -1) + std::string options("c:"); + options += Logging::OptionParser::GetOptionString(); + Logging::OptionParser LogLevel; + + while((c = getopt(argc, (char * const *)argv, options.c_str())) != -1) { switch(c) { - case 'q': - // Quiet mode - quiet = true; - break; - case 'c': // store argument configFilename = optarg; break; - case '?': default: - PrintUsageAndExit(); + int ret = LogLevel.ProcessOption(c); + if(ret != 0) + { + PrintUsageAndExit(ret); + } } } // Adjust arguments @@ -103,11 +106,13 @@ // Check there's a command if(argc != 1) { - PrintUsageAndExit(); + PrintUsageAndExit(2); } + Logging::FilterConsole(LogLevel.GetCurrentLevel()); + // Read in the configuration file - if(!quiet) BOX_NOTICE("Using configuration file " << configFilename); + BOX_INFO("Using configuration file " << configFilename); std::string errs; std::auto_ptr config( @@ -191,16 +196,13 @@ return 1; } // Print summary? - if(!quiet) - { - BOX_INFO("Daemon configuration summary:\n" - " AutomaticBackup = " << - (autoBackup?"true":"false") << "\n" - " UpdateStoreInterval = " << updateStoreInterval << - " seconds\n" - " MinimumFileAge = " << minimumFileAge << " seconds\n" - " MaxUploadWait = " << maxUploadWait << " seconds"); - } + BOX_TRACE("Daemon configuration summary:\n" + " AutomaticBackup = " << + (autoBackup?"true":"false") << "\n" + " UpdateStoreInterval = " << updateStoreInterval << + " seconds\n" + " MinimumFileAge = " << minimumFileAge << " seconds\n" + " MaxUploadWait = " << maxUploadWait << " seconds"); std::string stateLine; if(!getLine.GetLine(stateLine) || getLine.IsEOF()) @@ -318,7 +320,7 @@ { if(line == "start-sync") { - if (!quiet) BOX_INFO("Sync started..."); + BOX_TRACE("Sync started..."); syncIsRunning = true; } else if(line == "finish-sync") @@ -325,7 +327,7 @@ { if (syncIsRunning) { - if (!quiet) BOX_INFO("Sync finished."); + BOX_TRACE("Sync finished."); // Send a quit command to finish nicely connection.Write("quit\n", 5); @@ -334,7 +336,7 @@ } else { - if (!quiet) BOX_INFO("Previous sync finished."); + BOX_TRACE("Previous sync finished."); } // daemon must still be busy } @@ -346,12 +348,9 @@ // Is this an OK or error line? if(line == "ok") { - if(!quiet) - { - BOX_INFO("Control command " - "sent: " << - commandName); - } + BOX_TRACE("Control command " + "sent: " << + commandName); finished = true; } else if(line == "error") Modified: box/trunk/bin/bbackupquery/bbackupquery.cpp =================================================================== --- box/trunk/bin/bbackupquery/bbackupquery.cpp 2014-04-09 22:15:49 UTC (rev 3323) +++ box/trunk/bin/bbackupquery/bbackupquery.cpp 2014-04-09 22:15:52 UTC (rev 3324) @@ -66,11 +66,6 @@ "Usage: bbackupquery [options] [command]...\n" "\n" "Options:\n" - " -q Run more quietly, reduce verbosity level by one, can repeat\n" - " -Q Run at minimum verbosity, log nothing\n" - " -v Run more verbosely, increase verbosity level by one, can repeat\n" - " -V Run at maximum verbosity, log everything\n" - " -W Set verbosity to error/warning/notice/info/trace/everything\n" " -w Read/write mode, allow changes to store\n" #ifdef WIN32 " -u Enable Unicode console, requires font change to Lucida Console\n" @@ -80,11 +75,13 @@ #endif " -c Use the specified configuration file. If -c is omitted, the last\n" " argument is the configuration file, or else the default \n" - " [" << BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE << - "]\n" + " [" << BOX_GET_DEFAULT_BBACKUPD_CONFIG_FILE << "]\n" " -o Write logging output to specified file as well as console\n" " -O Set file verbosity to error/warning/notice/info/trace/everything\n" " -l Write protocol debugging logs to specified file\n" + << + Logging::OptionParser::GetUsageString() + << "\n" "Parameters: as many commands as you like. If commands are multiple words,\n" "remember to enclose the command in quotes. Remember to use the quit command\n" @@ -220,12 +217,6 @@ Logging::SetProgramName("bbackupquery"); - #ifdef BOX_RELEASE_BUILD - int consoleLogLevel = Log::NOTICE; // need an int to do math with - #else - int consoleLogLevel = Log::INFO; // need an int to do math with - #endif - #ifdef WIN32 #define WIN32_OPTIONS "u" bool unicodeConsole = false; @@ -240,7 +231,9 @@ #define READLINE_OPTIONS #endif - const char* validOpts = "qvVwc:l:o:O:W:" WIN32_OPTIONS READLINE_OPTIONS; + std::string options("wc:l:o:O:" WIN32_OPTIONS READLINE_OPTIONS); + options += Logging::OptionParser::GetOptionString(); + Logging::OptionParser LogLevel; std::string fileLogFile; Log::Level fileLogLevel = Log::INVALID; @@ -247,53 +240,10 @@ // See if there's another entry on the command line int c; - while((c = getopt(argc, (char * const *)argv, validOpts)) != -1) + while((c = getopt(argc, (char * const *)argv, options.c_str())) != -1) { switch(c) { - case 'q': - { - if(consoleLogLevel == Log::NOTHING) - { - BOX_FATAL("Too many '-q': " - "Cannot reduce logging " - "level any more"); - return 2; - } - consoleLogLevel--; - } - break; - - case 'v': - { - if(consoleLogLevel == Log::EVERYTHING) - { - BOX_FATAL("Too many '-v': " - "Cannot increase logging " - "level any more"); - return 2; - } - consoleLogLevel++; - } - break; - - case 'V': - { - consoleLogLevel = Log::EVERYTHING; - } - break; - - case 'W': - { - consoleLogLevel = Logging::GetNamedLevel(optarg); - if (consoleLogLevel == Log::INVALID) - { - BOX_FATAL("Invalid logging level"); - return 2; - } - } - break; - case 'w': // Read/write mode readWrite = true; @@ -342,9 +292,12 @@ break; #endif - case '?': default: - PrintUsageAndExit(); + int ret = LogLevel.ProcessOption(c); + if (ret != 0) + { + PrintUsageAndExit(); + } } } // Adjust arguments @@ -351,7 +304,7 @@ argc -= optind; argv += optind; - Logging::GetConsole().Filter((Log::Level)consoleLogLevel); + Logging::GetConsole().Filter(LogLevel.GetCurrentLevel()); std::auto_ptr fileLogger; if (fileLogLevel != Log::INVALID) From subversion at boxbackup.org Wed Apr 9 23:15:57 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Wed, 9 Apr 2014 23:15:57 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3325 - in box/trunk: bin/bbackupd bin/bbackupquery lib/backupstore Message-ID: <201404092215.s39MFvTg057937@wm.boxbackup.org> Author: chris Date: 2014-04-09 23:15:57 +0100 (Wed, 09 Apr 2014) New Revision: 3325 Modified: box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp box/trunk/bin/bbackupd/BackupClientDirectoryRecord.h box/trunk/bin/bbackupd/BackupDaemon.cpp box/trunk/bin/bbackupd/BackupDaemon.h box/trunk/bin/bbackupquery/BackupQueries.h box/trunk/lib/backupstore/BackupStoreException.txt box/trunk/lib/backupstore/BackupStoreFile.cpp box/trunk/lib/backupstore/BackupStoreFile.h box/trunk/lib/backupstore/BackupStoreFileDiff.cpp box/trunk/lib/backupstore/BackupStoreFileEncodeStream.cpp box/trunk/lib/backupstore/BackupStoreFileEncodeStream.h Log: Poll command socket regularly during file uploads. Makes the daemon responsive to polling and commands, even during a file upload operation. Modified: box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp =================================================================== --- box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp 2014-04-09 22:15:52 UTC (rev 3324) +++ box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp 2014-04-09 22:15:57 UTC (rev 3325) @@ -1707,7 +1707,8 @@ connection.GetTimeout(), &rContext, // DiffTimer implementation 0 /* not interested in the modification time */, - &isCompletelyDifferent); + &isCompletelyDifferent, + rParams.mpBackgroundTask); if(isCompletelyDifferent) { @@ -1727,7 +1728,8 @@ apStreamToUpload = BackupStoreFile::EncodeFile( rFilename, mObjectID, /* containing directory */ rStoreFilename, NULL, &rParams, - &(rParams.mrRunStatusProvider)); + &(rParams.mrRunStatusProvider), + rParams.mpBackgroundTask); } rContext.SetNiceMode(true); @@ -1842,7 +1844,8 @@ RunStatusProvider &rRunStatusProvider, SysadminNotifier &rSysadminNotifier, ProgressNotifier &rProgressNotifier, - BackupClientContext &rContext) + BackupClientContext &rContext, + BackgroundTask *pBackgroundTask) : mSyncPeriodStart(0), mSyncPeriodEnd(0), mMaxUploadWait(0), @@ -1856,7 +1859,8 @@ mReadErrorsOnFilesystemObjects(false), mMaxUploadRate(0), mUploadAfterThisTimeInTheFuture(99999999999999999LL), - mHaveLoggedWarningAboutFutureFileTimes(false) + mHaveLoggedWarningAboutFutureFileTimes(false), + mpBackgroundTask(pBackgroundTask) { } Modified: box/trunk/bin/bbackupd/BackupClientDirectoryRecord.h =================================================================== --- box/trunk/bin/bbackupd/BackupClientDirectoryRecord.h 2014-04-09 22:15:52 UTC (rev 3324) +++ box/trunk/bin/bbackupd/BackupClientDirectoryRecord.h 2014-04-09 22:15:57 UTC (rev 3325) @@ -14,6 +14,7 @@ #include #include +#include "BackgroundTask.h" #include "BackupClientFileAttributes.h" #include "BackupDaemonInterface.h" #include "BackupStoreDirectory.h" @@ -76,7 +77,8 @@ RunStatusProvider &rRunStatusProvider, SysadminNotifier &rSysadminNotifier, ProgressNotifier &rProgressNotifier, - BackupClientContext &rContext); + BackupClientContext &rContext, + BackgroundTask *pBackgroundTask); ~SyncParams(); private: // No copying @@ -91,6 +93,7 @@ box_time_t mMaxFileTimeInFuture; int32_t mFileTrackingSizeThreshold; int32_t mDiffingUploadSizeThreshold; + BackgroundTask *mpBackgroundTask; RunStatusProvider &mrRunStatusProvider; SysadminNotifier &mrSysadminNotifier; ProgressNotifier &mrProgressNotifier; Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp =================================================================== --- box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-09 22:15:52 UTC (rev 3324) +++ box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-09 22:15:57 UTC (rev 3325) @@ -202,7 +202,8 @@ mpProgressNotifier(this), mpLocationResolver(this), mpRunStatusProvider(this), - mpSysadminNotifier(this) + mpSysadminNotifier(this), + mapCommandSocketPollTimer(NULL) #ifdef WIN32 , mInstallService(false), mRemoveService(false), @@ -442,6 +443,9 @@ // initialise global timer mechanism Timers::Init(); + mapCommandSocketPollTimer.reset(new Timer(COMMAND_SOCKET_POLL_INTERVAL, + "CommandSocketPollTimer")); + #ifndef WIN32 // Ignore SIGPIPE so that if a command connection is broken, // the daemon doesn't terminate. @@ -926,7 +930,7 @@ // Set up the sync parameters BackupClientDirectoryRecord::SyncParams params(*mpRunStatusProvider, - *mpSysadminNotifier, *mpProgressNotifier, clientContext); + *mpSysadminNotifier, *mpProgressNotifier, clientContext, this); params.mSyncPeriodStart = syncPeriodStart; params.mSyncPeriodEnd = syncPeriodEndExtended; // use potentially extended end time @@ -1844,6 +1848,51 @@ // -------------------------------------------------------------------------- // // Function +// Name: BackupDaemon::RunBackgroundTask() +// Purpose: Checks for connections or commands on the command +// socket and handles them with minimal delay. Polled +// during lengthy operations such as file uploads. +// Created: 07/04/14 +// +// -------------------------------------------------------------------------- +bool BackupDaemon::RunBackgroundTask(State state, uint64_t progress, + uint64_t maximum) +{ + BOX_TRACE("BackupDaemon::RunBackgroundTask: state = " << state << + ", progress = " << progress << "/" << maximum); + + if(mapCommandSocketPollTimer->HasExpired()) + { + mapCommandSocketPollTimer->Reset(COMMAND_SOCKET_POLL_INTERVAL); + } + else + { + // Do no more work right now + return true; + } + + if(mapCommandSocketInfo.get()) + { + BOX_TRACE("BackupDaemon::RunBackgroundTask: polling command socket"); + + bool sync_flag_out, sync_is_forced_out; + + WaitOnCommandSocket(0, // RequiredDelay + sync_flag_out, sync_is_forced_out); + + if(sync_flag_out) + { + BOX_WARNING("Ignoring request to sync while " + "already syncing."); + } + } + + return true; +} + +// -------------------------------------------------------------------------- +// +// Function // Name: BackupDaemon::WaitOnCommandSocket(box_time_t, bool &, bool &) // Purpose: Waits on a the command socket for a time of UP TO the required time // but may be much less, and handles a command if necessary. Modified: box/trunk/bin/bbackupd/BackupDaemon.h =================================================================== --- box/trunk/bin/bbackupd/BackupDaemon.h 2014-04-09 22:15:52 UTC (rev 3324) +++ box/trunk/bin/bbackupd/BackupDaemon.h 2014-04-09 22:15:57 UTC (rev 3325) @@ -25,6 +25,7 @@ #include "TLSContext.h" #include "autogen_BackupProtocol.h" +#include "autogen_BackupStoreException.h" #ifdef WIN32 #include "WinNamedPipeListener.h" @@ -38,6 +39,8 @@ # include #endif +#define COMMAND_SOCKET_POLL_INTERVAL 1000 + class BackupClientDirectoryRecord; class BackupClientContext; class Configuration; @@ -55,7 +58,7 @@ // // -------------------------------------------------------------------------- class BackupDaemon : public Daemon, ProgressNotifier, LocationResolver, -RunStatusProvider, SysadminNotifier +RunStatusProvider, SysadminNotifier, BackgroundTask { public: BackupDaemon(); @@ -232,6 +235,8 @@ void SetLocationResolver (LocationResolver* p) { mpLocationResolver = p; } void SetRunStatusProvider(RunStatusProvider* p) { mpRunStatusProvider = p; } void SetSysadminNotifier (SysadminNotifier* p) { mpSysadminNotifier = p; } + virtual bool RunBackgroundTask(State state, uint64_t progress, + uint64_t maximum); private: ProgressNotifier* mpProgressNotifier; @@ -238,6 +243,7 @@ LocationResolver* mpLocationResolver; RunStatusProvider* mpRunStatusProvider; SysadminNotifier* mpSysadminNotifier; + std::auto_ptr mapCommandSocketPollTimer; /* ProgressNotifier implementation */ public: @@ -250,7 +256,13 @@ if (mLogAllFileAccess) { BOX_INFO("Scanning directory: " << rLocalPath); - } + } + + if (!RunBackgroundTask(BackgroundTask::Scanning_Dirs, 0, 0)) + { + THROW_EXCEPTION(BackupStoreException, + CancelledByBackgroundTask); + } } virtual void NotifyDirStatFailed( const BackupClientDirectoryRecord* pDirRecord, Modified: box/trunk/bin/bbackupquery/BackupQueries.h =================================================================== --- box/trunk/bin/bbackupquery/BackupQueries.h 2014-04-09 22:15:52 UTC (rev 3324) +++ box/trunk/bin/bbackupquery/BackupQueries.h 2014-04-09 22:15:57 UTC (rev 3325) @@ -272,6 +272,7 @@ virtual void NotifyDirComparing(const std::string& rLocalPath, const std::string& rRemotePath) { + BOX_INFO("Comparing directory: " << rLocalPath); } virtual void NotifyDirCompared( @@ -303,6 +304,7 @@ virtual void NotifyFileComparing(const std::string& rLocalPath, const std::string& rRemotePath) { + BOX_TRACE("Comparing file: " << rLocalPath); } virtual void NotifyFileCompared(const std::string& rLocalPath, Modified: box/trunk/lib/backupstore/BackupStoreException.txt =================================================================== --- box/trunk/lib/backupstore/BackupStoreException.txt 2014-04-09 22:15:52 UTC (rev 3324) +++ box/trunk/lib/backupstore/BackupStoreException.txt 2014-04-09 22:15:57 UTC (rev 3325) @@ -71,3 +71,4 @@ UnknownObjectRefCountRequested 68 A reference count was requested for an object whose reference count is not known. MultiplyReferencedObject 69 Attempted to modify an object with multiple references, should be uncloned first CorruptReferenceCountDatabase 70 The account's refcount database is corrupt and must be rebuilt by housekeeping. +CancelledByBackgroundTask 71 The current task was cancelled on request by the background task. Modified: box/trunk/lib/backupstore/BackupStoreFile.cpp =================================================================== --- box/trunk/lib/backupstore/BackupStoreFile.cpp 2014-04-09 22:15:52 UTC (rev 3324) +++ box/trunk/lib/backupstore/BackupStoreFile.cpp 2014-04-09 22:15:57 UTC (rev 3325) @@ -78,7 +78,8 @@ const BackupStoreFilename &rStoreFilename, int64_t *pModificationTime, ReadLoggingStream::Logger* pLogger, - RunStatusProvider* pRunStatusProvider) + RunStatusProvider* pRunStatusProvider, + BackgroundTask* pBackgroundTask) { // Create the stream std::auto_ptr stream( @@ -86,7 +87,8 @@ // Do the initial setup stream->Setup(Filename, 0 /* no recipe, just encode */, ContainerID, - rStoreFilename, pModificationTime, pLogger, pRunStatusProvider); + rStoreFilename, pModificationTime, pLogger, pRunStatusProvider, + pBackgroundTask); // Return the stream for the caller return stream; Modified: box/trunk/lib/backupstore/BackupStoreFile.h =================================================================== --- box/trunk/lib/backupstore/BackupStoreFile.h 2014-04-09 22:15:52 UTC (rev 3324) +++ box/trunk/lib/backupstore/BackupStoreFile.h 2014-04-09 22:15:57 UTC (rev 3325) @@ -27,6 +27,7 @@ int64_t mTotalFileStreamSize; } BackupStoreFileStats; +class BackgroundTask; class RunStatusProvider; // Uncomment to disable backwards compatibility @@ -128,7 +129,8 @@ int64_t ContainerID, const BackupStoreFilename &rStoreFilename, int64_t *pModificationTime = 0, ReadLoggingStream::Logger* pLogger = NULL, - RunStatusProvider* pRunStatusProvider = NULL + RunStatusProvider* pRunStatusProvider = NULL, + BackgroundTask* pBackgroundTask = NULL ); static std::auto_ptr EncodeFileDiff ( @@ -138,7 +140,8 @@ int Timeout, DiffTimer *pDiffTimer, int64_t *pModificationTime = 0, - bool *pIsCompletelyDifferent = 0 + bool *pIsCompletelyDifferent = 0, + BackgroundTask* pBackgroundTask = NULL ); // Shortcut interface static int64_t QueryStoreFileDiff(BackupProtocolCallable& protocol, Modified: box/trunk/lib/backupstore/BackupStoreFileDiff.cpp =================================================================== --- box/trunk/lib/backupstore/BackupStoreFileDiff.cpp 2014-04-09 22:15:52 UTC (rev 3324) +++ box/trunk/lib/backupstore/BackupStoreFileDiff.cpp 2014-04-09 22:15:57 UTC (rev 3325) @@ -128,7 +128,8 @@ const std::string& Filename, int64_t ContainerID, const BackupStoreFilename &rStoreFilename, int64_t DiffFromObjectID, IOStream &rDiffFromBlockIndex, int Timeout, DiffTimer *pDiffTimer, - int64_t *pModificationTime, bool *pIsCompletelyDifferent) + int64_t *pModificationTime, bool *pIsCompletelyDifferent, + BackgroundTask* pBackgroundTask) { // Is it a symlink? { @@ -144,7 +145,11 @@ { *pIsCompletelyDifferent = true; } - return EncodeFile(Filename, ContainerID, rStoreFilename, pModificationTime); + return EncodeFile(Filename, ContainerID, rStoreFilename, + pModificationTime, + NULL, // ReadLoggingStream::Logger + NULL, // RunStatusProvider + pBackgroundTask); // BackgroundTask } } @@ -162,7 +167,11 @@ { *pIsCompletelyDifferent = true; } - return EncodeFile(Filename, ContainerID, rStoreFilename, pModificationTime); + return EncodeFile(Filename, ContainerID, rStoreFilename, + pModificationTime, + NULL, // ReadLoggingStream::Logger + NULL, // RunStatusProvider + pBackgroundTask); // BackgroundTask } // Pointer to recipe we're going to create @@ -210,7 +219,11 @@ new BackupStoreFileEncodeStream); // Do the initial setup - stream->Setup(Filename, precipe, ContainerID, rStoreFilename, pModificationTime); + stream->Setup(Filename, precipe, ContainerID, rStoreFilename, + pModificationTime, + NULL, // ReadLoggingStream::Logger + NULL, // RunStatusProvider + pBackgroundTask); precipe = 0; // Stream has taken ownership of this // Tell user about completely different status? Modified: box/trunk/lib/backupstore/BackupStoreFileEncodeStream.cpp =================================================================== --- box/trunk/lib/backupstore/BackupStoreFileEncodeStream.cpp 2014-04-09 22:15:52 UTC (rev 3324) +++ box/trunk/lib/backupstore/BackupStoreFileEncodeStream.cpp 2014-04-09 22:15:57 UTC (rev 3325) @@ -11,6 +11,7 @@ #include +#include "BackgroundTask.h" #include "BackupClientFileAttributes.h" #include "BackupStoreConstants.h" #include "BackupStoreException.h" @@ -40,25 +41,28 @@ // // -------------------------------------------------------------------------- BackupStoreFileEncodeStream::BackupStoreFileEncodeStream() - : mpRecipe(0), - mpFile(0), - mpLogging(0), - mpRunStatusProvider(NULL), - mStatus(Status_Header), - mSendData(true), - mTotalBlocks(0), - mAbsoluteBlockNumber(-1), - mInstructionNumber(-1), - mNumBlocks(0), - mCurrentBlock(-1), - mCurrentBlockEncodedSize(0), - mPositionInCurrentBlock(0), - mBlockSize(BACKUP_FILE_MIN_BLOCK_SIZE), - mLastBlockSize(0), - mTotalBytesSent(0), - mpRawBuffer(0), - mAllocatedBufferSize(0), - mEntryIVBase(0) +: mpRecipe(0), + mpFile(0), + mpLogging(0), + mpRunStatusProvider(NULL), + mpBackgroundTask(NULL), + mStatus(Status_Header), + mSendData(true), + mTotalBlocks(0), + mBytesToUpload(0), + mBytesUploaded(0), + mAbsoluteBlockNumber(-1), + mInstructionNumber(-1), + mNumBlocks(0), + mCurrentBlock(-1), + mCurrentBlockEncodedSize(0), + mPositionInCurrentBlock(0), + mBlockSize(BACKUP_FILE_MIN_BLOCK_SIZE), + mLastBlockSize(0), + mTotalBytesSent(0), + mpRawBuffer(0), + mAllocatedBufferSize(0), + mEntryIVBase(0) { } @@ -115,7 +119,8 @@ BackupStoreFileEncodeStream::Recipe *pRecipe, int64_t ContainerID, const BackupStoreFilename &rStoreFilename, int64_t *pModificationTime, ReadLoggingStream::Logger* pLogger, - RunStatusProvider* pRunStatusProvider) + RunStatusProvider* pRunStatusProvider, + BackgroundTask* pBackgroundTask) { // Pointer to a blank recipe which we might create BackupStoreFileEncodeStream::Recipe *pblankRecipe = 0; @@ -162,6 +167,7 @@ CalculateBlockSizes((*pRecipe)[inst].mSpaceBefore, numBlocks, blockSize, lastBlockSize); // Add to accumlated total mTotalBlocks += numBlocks; + mBytesToUpload += (*pRecipe)[inst].mSpaceBefore; // Update maximum clear size if(blockSize > maxBlockClearSize) maxBlockClearSize = blockSize; if(lastBlockSize > maxBlockClearSize) maxBlockClearSize = lastBlockSize; @@ -278,6 +284,7 @@ } mpRunStatusProvider = pRunStatusProvider; + mpBackgroundTask = pBackgroundTask; } @@ -341,6 +348,19 @@ THROW_EXCEPTION(BackupStoreException, SignalReceived); } + if(mpBackgroundTask) + { + BackgroundTask::State state = (mpRecipe->at(0).mBlocks == 0) + ? BackgroundTask::Uploading_Full + : BackgroundTask::Uploading_Patch; + if(!mpBackgroundTask->RunBackgroundTask(state, mBytesUploaded, + mBytesToUpload)) + { + THROW_EXCEPTION(BackupStoreException, + CancelledByBackgroundTask); + } + } + int bytesToRead = NBytes; uint8_t *buffer = (uint8_t*)pBuffer; @@ -575,6 +595,8 @@ // Encode it mCurrentBlockEncodedSize = BackupStoreFile::EncodeChunk(mpRawBuffer, blockRawSize, mEncodedBuffer); + + mBytesUploaded += blockRawSize; //TRACE2("Encode: Encoded size of block %d is %d\n", (int32_t)mCurrentBlock, (int32_t)mCurrentBlockEncodedSize); Modified: box/trunk/lib/backupstore/BackupStoreFileEncodeStream.h =================================================================== --- box/trunk/lib/backupstore/BackupStoreFileEncodeStream.h 2014-04-09 22:15:52 UTC (rev 3324) +++ box/trunk/lib/backupstore/BackupStoreFileEncodeStream.h 2014-04-09 22:15:57 UTC (rev 3325) @@ -79,7 +79,8 @@ const BackupStoreFilename &rStoreFilename, int64_t *pModificationTime, ReadLoggingStream::Logger* pLogger = NULL, - RunStatusProvider* pRunStatusProvider = NULL); + RunStatusProvider* pRunStatusProvider = NULL, + BackgroundTask* pBackgroundTask = NULL); virtual int Read(void *pBuffer, int NBytes, int Timeout); virtual void Write(const void *pBuffer, int NBytes); @@ -109,14 +110,18 @@ CollectInBufferStream mData; // buffer for header and index entries IOStream *mpLogging; RunStatusProvider* mpRunStatusProvider; + BackgroundTask* mpBackgroundTask; int mStatus; bool mSendData; // true if there's file data to send (ie not a symlink) int64_t mTotalBlocks; // Total number of blocks in the file + int64_t mBytesToUpload; // Total number of clear bytes to encode and upload + int64_t mBytesUploaded; // Total number of clear bytes already encoded + // excluding reused blocks already on the server. int64_t mAbsoluteBlockNumber; // The absolute block number currently being output // Instruction number int64_t mInstructionNumber; // All the below are within the current instruction - int64_t mNumBlocks; // number of blocks. Last one will be a different size to the rest in most cases + int64_t mNumBlocks; // number of blocks. Last one will be a different size to the rest in most cases int64_t mCurrentBlock; int32_t mCurrentBlockEncodedSize; int32_t mPositionInCurrentBlock; // for reading out From subversion at boxbackup.org Sat Apr 12 12:47:13 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Sat, 12 Apr 2014 12:47:13 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3326 - box/trunk/lib/backupstore Message-ID: <201404121147.s3CBlDER078668@wm.boxbackup.org> Author: chris Date: 2014-04-12 12:47:12 +0100 (Sat, 12 Apr 2014) New Revision: 3326 Added: box/trunk/lib/backupstore/BackgroundTask.h Log: Add missing BackgroundTask header Added: box/trunk/lib/backupstore/BackgroundTask.h =================================================================== --- box/trunk/lib/backupstore/BackgroundTask.h (rev 0) +++ box/trunk/lib/backupstore/BackgroundTask.h 2014-04-12 11:47:12 UTC (rev 3326) @@ -0,0 +1,39 @@ +// -------------------------------------------------------------------------- +// +// File +// Name: BackgroundTask.h +// Purpose: Declares the BackgroundTask interface. +// Created: 2014/04/07 +// +// -------------------------------------------------------------------------- + +#ifndef BACKGROUNDTASK__H +#define BACKGROUNDTASK__H + +// -------------------------------------------------------------------------- +// +// Class +// Name: BackgroundTask +// Purpose: Provides a RunBackgroundTask() method which allows +// background tasks such as polling the command socket +// to happen while a file is being uploaded. If it +// returns false, the current task should be aborted. +// Created: 2014/04/07 +// +// -------------------------------------------------------------------------- +class BackgroundTask +{ + public: + enum State { + Unknown = 0, + Scanning_Dirs, + Searching_Blocks, + Uploading_Full, + Uploading_Patch, + }; + virtual ~BackgroundTask() { } + virtual bool RunBackgroundTask(State state, uint64_t progress, + uint64_t maximum) = 0; +}; + +#endif // BACKGROUNDTASK__H From subversion at boxbackup.org Sat Apr 12 12:54:03 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Sat, 12 Apr 2014 12:54:03 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3327 - box/trunk/bin/bbackupd Message-ID: <201404121154.s3CBs34C078706@wm.boxbackup.org> Author: chris Date: 2014-04-12 12:54:03 +0100 (Sat, 12 Apr 2014) New Revision: 3327 Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp Log: Initialise sync flags in WaitOnCommandSocket. Otherwise all callers need to initialise them, or get false positives. Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp =================================================================== --- box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-12 11:47:12 UTC (rev 3326) +++ box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-12 11:54:03 UTC (rev 3327) @@ -1901,6 +1901,9 @@ // -------------------------------------------------------------------------- void BackupDaemon::WaitOnCommandSocket(box_time_t RequiredDelay, bool &DoSyncFlagOut, bool &SyncIsForcedOut) { + DoSyncFlagOut = false; + SyncIsForcedOut = false; + ASSERT(mapCommandSocketInfo.get()); if(!mapCommandSocketInfo.get()) { From subversion at boxbackup.org Sat Apr 12 23:03:42 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Sat, 12 Apr 2014 23:03:42 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3328 - box/trunk/lib/server Message-ID: <201404122203.s3CM3gOV081650@wm.boxbackup.org> Author: chris Date: 2014-04-12 23:03:41 +0100 (Sat, 12 Apr 2014) New Revision: 3328 Modified: box/trunk/lib/server/SocketStream.cpp Log: Fix compilation on Debian 7 (Wheezy) by including bsd/unistd.h. If libedit is installed then -ledit will be detected and added to the link line, which makes the test for getpeereid pass. Then SocketStream.cpp tries to use it, but that won't work unless we include bsd/unistd.h where the prototype is declared. Modified: box/trunk/lib/server/SocketStream.cpp =================================================================== --- box/trunk/lib/server/SocketStream.cpp 2014-04-12 11:54:03 UTC (rev 3327) +++ box/trunk/lib/server/SocketStream.cpp 2014-04-12 22:03:41 UTC (rev 3328) @@ -25,6 +25,10 @@ #include #endif +#ifdef HAVE_BSD_UNISTD_H + #include +#endif + #include "SocketStream.h" #include "ServerException.h" #include "CommonException.h" From subversion at boxbackup.org Thu Apr 17 17:47:02 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Thu, 17 Apr 2014 17:47:02 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3329 - box/trunk/bin/bbackupd Message-ID: <201404171647.s3HGl2IY019620@wm.boxbackup.org> Author: chris Date: 2014-04-17 17:47:01 +0100 (Thu, 17 Apr 2014) New Revision: 3329 Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp Log: Fix BackgroundTask timer being destroyed after timer system cleaned up. Caused an assertion failure and crash. Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp =================================================================== --- box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-12 22:03:41 UTC (rev 3328) +++ box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-17 16:47:01 UTC (rev 3329) @@ -477,25 +477,23 @@ } catch(...) { - if(mapCommandSocketInfo.get()) + try { - try - { - mapCommandSocketInfo.reset(); - } - catch(std::exception &e) - { - BOX_WARNING("Internal error while " - "closing command socket after " - "another exception: " << e.what()); - } - catch(...) - { - BOX_WARNING("Error closing command socket " - "after exception, ignored."); - } + mapCommandSocketInfo.reset(); } + catch(std::exception &e) + { + BOX_WARNING("Internal error while closing command " + "socket after another exception, ignored: " << + e.what()); + } + catch(...) + { + BOX_WARNING("Error closing command socket after " + "exception, ignored."); + } + mapCommandSocketPollTimer.reset(); Timers::Cleanup(); throw; @@ -503,6 +501,7 @@ // Clean up mapCommandSocketInfo.reset(); + mapCommandSocketPollTimer.reset(); Timers::Cleanup(); } From subversion at boxbackup.org Thu Apr 17 17:47:37 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Thu, 17 Apr 2014 17:47:37 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3330 - box/trunk/docs/api-notes Message-ID: <201404171647.s3HGlbKA019638@wm.boxbackup.org> Author: chris Date: 2014-04-17 17:47:37 +0100 (Thu, 17 Apr 2014) New Revision: 3330 Modified: box/trunk/docs/api-notes/win32_build_on_cygwin_using_mingw.txt Log: More updates to Win32 build instructions. Modified: box/trunk/docs/api-notes/win32_build_on_cygwin_using_mingw.txt =================================================================== --- box/trunk/docs/api-notes/win32_build_on_cygwin_using_mingw.txt 2014-04-17 16:47:01 UTC (rev 3329) +++ box/trunk/docs/api-notes/win32_build_on_cygwin_using_mingw.txt 2014-04-17 16:47:37 UTC (rev 3330) @@ -45,16 +45,16 @@ == OpenSSL == -Download OpenSSL from [http://www.openssl.org/source/openssl-1.0.0e.tar.gz] +Download OpenSSL from [http://www.openssl.org/source/openssl-1.0.1f.tar.gz] Open a Cygwin shell, go to the base directory, and unpack OpenSSL: - tar xzvf openssl-1.0.0e.tar.gz + tar xzvf openssl-1.0.1f.tar.gz Configure OpenSSL for MinGW compilation, and build and install it: - cd openssl-1.0.0e - ./Configure --prefix=/usr/x86_64-w64-mingw32/ mingw64 --cross-compile-prefix=x86_64-w64-mingw32- + cd openssl-1.0.1f + ./Configure --prefix=/usr/x86_64-w64-mingw32 mingw64 --cross-compile-prefix=x86_64-w64-mingw32- make make install_sw @@ -63,16 +63,14 @@ This step is only required to support regular expressions in including/excluding files from backups. However, this is a very useful feature. Download PCRE from -[http://prdownloads.sourceforge.net/pcre/pcre-8.12.tar.bz2?download]. +[http://prdownloads.sourceforge.net/pcre/pcre-8.34.tar.bz2?download]. Open a Cygwin shell, go to the base directory, and unpack, build and install PCRE: - tar xjvf pcre-8.12.tar.bz2 - cd pcre-8.12 - export CFLAGS="-mno-cygwin" - export CXXFLAGS="-mno-cygwin" - ./configure --prefix=/usr/i686-pc-mingw32 --disable-shared + tar xjvf pcre-8.34.tar.bz2 + cd pcre-8.34 + ./configure --prefix=/usr/x86_64-w64-mingw32 --disable-shared --target=x86_64-w64-mingw32 make make install From subversion at boxbackup.org Thu Apr 17 21:56:57 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Thu, 17 Apr 2014 21:56:57 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3331 - box/trunk/bin/bbackupd Message-ID: <201404172056.s3HKuvR2021509@wm.boxbackup.org> Author: chris Date: 2014-04-17 21:56:57 +0100 (Thu, 17 Apr 2014) New Revision: 3331 Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp Log: Rewrite backup idle/poll loop for clarity. Add helpful debugging messages about why the decision was taken to sleep or start a backup, and how long the system will wait until the next backup. Flatten the code to avoid the double loop. Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp =================================================================== --- box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-17 16:47:37 UTC (rev 3330) +++ box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-17 20:56:57 UTC (rev 3331) @@ -567,80 +567,105 @@ bool doSync = false; bool mDoSyncForcedByCommand = false; - // Is a delay necessary? - box_time_t currentTime; + box_time_t currentTime = GetCurrentBoxTime(); - do + // Check whether we should be stopping, and if so, + // don't hang around waiting on the command socket. + if(StopRun()) { - // Check whether we should be stopping, - // and don't run a sync if so. - if(StopRun()) break; - - currentTime = GetCurrentBoxTime(); + BOX_INFO("Skipping command socket polling " + "due to shutdown request"); + break; + } - // Pause a while, but no more than - // MAX_SLEEP_TIME seconds (use the conditional - // because times are unsigned) - box_time_t requiredDelay = - (mNextSyncTime < currentTime) - ? (0) - : (mNextSyncTime - currentTime); + // Is a delay necessary? + currentTime = GetCurrentBoxTime(); + box_time_t requiredDelay = (mNextSyncTime < currentTime) + ? (0) : (mNextSyncTime - currentTime); - // If there isn't automatic backup happening, - // set a long delay. And limit delays at the - // same time. - if(!automaticBackup && !mDoSyncForcedByPreviousSyncError) - { - requiredDelay = SecondsToBoxTime(MAX_SLEEP_TIME); - } - else if(requiredDelay > SecondsToBoxTime(MAX_SLEEP_TIME)) - { - requiredDelay = SecondsToBoxTime(MAX_SLEEP_TIME); - } + if (mDoSyncForcedByPreviousSyncError) + { + BOX_INFO("Last backup was not successful, " + "next one starting at " << + FormatTime(mNextSyncTime, false)); + } + else if (automaticBackup) + { + BOX_INFO("Automatic backups are enabled, " + "next one starting at " << + FormatTime(mNextSyncTime, false)); + } + else + { + BOX_INFO("No automatic backups, waiting for " + "bbackupctl snapshot command"); + requiredDelay = SecondsToBoxTime(MAX_SLEEP_TIME); + } - // Only delay if necessary - if(requiredDelay > 0) - { - // Sleep somehow. There are choices - // on how this should be done, - // depending on the state of the - // control connection - if(mapCommandSocketInfo.get() != 0) - { - // A command socket exists, - // so sleep by waiting on it - WaitOnCommandSocket(requiredDelay, - doSync, mDoSyncForcedByCommand); - } - else - { - // No command socket or - // connection, just do a - // normal sleep - time_t sleepSeconds = - BoxTimeToSeconds(requiredDelay); - ::sleep((sleepSeconds <= 0) - ? 1 : sleepSeconds); - } - } - - if ((automaticBackup || mDoSyncForcedByPreviousSyncError) - && currentTime >= mNextSyncTime) - { - doSync = true; - } + if(requiredDelay > SecondsToBoxTime(MAX_SLEEP_TIME)) + { + requiredDelay = SecondsToBoxTime(MAX_SLEEP_TIME); } - while(!doSync && !StopRun()); - // Time of sync start, and if it's time for another sync - // (and we're doing automatic syncs), set the flag - mCurrentSyncStartTime = GetCurrentBoxTime(); - if((automaticBackup || mDoSyncForcedByPreviousSyncError) && - mCurrentSyncStartTime >= mNextSyncTime) + // Only delay if necessary + if(requiredDelay == 0) { - doSync = true; + // No sleep necessary, so don't listen on the command + // socket at all right now. } - + else if(mapCommandSocketInfo.get() != 0) + { + // A command socket exists, so sleep by waiting for a + // connection or command on it. + WaitOnCommandSocket(requiredDelay, doSync, + mDoSyncForcedByCommand); + } + else + { + // No command socket or connection, just do a normal + // sleep. + time_t sleepSeconds = + BoxTimeToSeconds(requiredDelay); + ::sleep((sleepSeconds <= 0) + ? 1 : sleepSeconds); + } + + if(StopRun()) + { + BOX_INFO("Stopping idle loop due to shutdown request"); + break; + } + else if(doSync) + { + BOX_INFO("Starting a backup immediately due to " + "bbackupctl sync command"); + } + else if(currentTime < mNextSyncTime) + { + BOX_TRACE("Sleeping again because next sync time " + "has not arrived"); + continue; + } + else if(mDoSyncForcedByPreviousSyncError) + { + BOX_INFO("Last backup was not successful, next one " + "starting now"); + } + else if(automaticBackup) + { + BOX_INFO("Automatic backups are enabled, next one " + "starting now"); + } + else + { + BOX_TRACE("Sleeping again because automatic backups " + "are not enabled"); + continue; + } + + // If we pass this point, or exit the loop, we should have + // logged something at INFO level or higher to explain why. + // Use a script to see if sync is allowed now? if(!mDoSyncForcedByCommand && doSync && !StopRun()) { @@ -650,21 +675,20 @@ // Script has asked for a delay mNextSyncTime = GetCurrentBoxTime() + SecondsToBoxTime(d); - doSync = false; + BOX_INFO("Impending backup stopped by " + "SyncAllowScript, next attempt " + "scheduled for " << + FormatTime(mNextSyncTime, false)); + continue; } } - // Ready to sync? (but only if we're not supposed - // to be stopping) - if(doSync && !StopRun()) - { - RunSyncNowWithExceptionHandling(); - } + RunSyncNowWithExceptionHandling(); // Set state SetState(storageLimitExceeded?State_StorageLimitExceeded:State_Idle); - - } while(!StopRun()); + } + while(!StopRun()); // Make sure we have a clean start next time round (if restart) DeleteAllLocations(); From subversion at boxbackup.org Thu Apr 17 21:57:11 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Thu, 17 Apr 2014 21:57:11 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3332 - box/trunk/bin/bbackupd Message-ID: <201404172057.s3HKvBS6021525@wm.boxbackup.org> Author: chris Date: 2014-04-17 21:57:11 +0100 (Thu, 17 Apr 2014) New Revision: 3332 Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp Log: Don't consider inode database errors enough reason to run the next backup immediately after the end of the current one. Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp =================================================================== --- box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-17 20:56:57 UTC (rev 3331) +++ box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-17 20:57:11 UTC (rev 3332) @@ -729,13 +729,13 @@ // do not retry immediately without a good reason mDoSyncForcedByPreviousSyncError = false; - + + // Is it a berkely db failure? + bool isBerkelyDbFailure = false; + // Notify system administrator about the final state of the backup if(errorOccurred) { - // Is it a berkely db failure? - bool isBerkelyDbFailure = false; - if (errorCode == BackupStoreException::ExceptionType && errorSubCode == BackupStoreException::BerkelyDBFailure) { @@ -806,7 +806,7 @@ // If we were retrying after an error, and this backup succeeded, // then now would be a good time to stop :-) - mDoSyncForcedByPreviousSyncError = errorOccurred; + mDoSyncForcedByPreviousSyncError = errorOccurred && !isBerkelyDbFailure; OnBackupFinish(); } From subversion at boxbackup.org Thu Apr 17 21:57:15 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Thu, 17 Apr 2014 21:57:15 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3333 - box/trunk/bin/bbackupd Message-ID: <201404172057.s3HKvFbI021542@wm.boxbackup.org> Author: chris Date: 2014-04-17 21:57:15 +0100 (Thu, 17 Apr 2014) New Revision: 3333 Modified: box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp Log: Fix warnings about member variables being initialised in a different order. Modified: box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp =================================================================== --- box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp 2014-04-17 20:57:11 UTC (rev 3332) +++ box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp 2014-04-17 20:57:15 UTC (rev 3333) @@ -1859,8 +1859,8 @@ mReadErrorsOnFilesystemObjects(false), mMaxUploadRate(0), mUploadAfterThisTimeInTheFuture(99999999999999999LL), - mHaveLoggedWarningAboutFutureFileTimes(false), - mpBackgroundTask(pBackgroundTask) + mpBackgroundTask(pBackgroundTask), + mHaveLoggedWarningAboutFutureFileTimes(false) { } From subversion at boxbackup.org Thu Apr 17 21:57:26 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Thu, 17 Apr 2014 21:57:26 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3334 - box/trunk/bin/bbackupd Message-ID: <201404172057.s3HKvQuE021558@wm.boxbackup.org> Author: chris Date: 2014-04-17 21:57:25 +0100 (Thu, 17 Apr 2014) New Revision: 3334 Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp Log: Rewrap some lines to reduce unnecessary wrapping. Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp =================================================================== --- box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-17 20:57:15 UTC (rev 3333) +++ box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-17 20:57:25 UTC (rev 3334) @@ -826,8 +826,7 @@ // Delete the serialised store object file, // so that we don't try to reload it after a // partially completed backup - if(mDeleteStoreObjectInfoFile && - !DeleteStoreObjectInfo()) + if(mDeleteStoreObjectInfoFile && !DeleteStoreObjectInfo()) { BOX_ERROR("Failed to delete the StoreObjectInfoFile, " "backup cannot continue safely."); @@ -914,18 +913,15 @@ // than minimumFileAge after the last sync. Deal with it by // moving back syncPeriodStart, which should not do any // damage. - syncPeriodStart = syncPeriodEnd - - SecondsToBoxTime(1); + syncPeriodStart = syncPeriodEnd - SecondsToBoxTime(1); } if(syncPeriodStart >= syncPeriodEnd) { - BOX_ERROR("Invalid (negative) sync period: " - "perhaps your clock is going " - "backwards (" << syncPeriodStart << - " to " << syncPeriodEnd << ")"); - THROW_EXCEPTION(ClientException, - ClockWentBackwards); + BOX_ERROR("Invalid (negative) sync period: perhaps your clock " + "is going backwards? (" << syncPeriodStart << " to " << + syncPeriodEnd << ")"); + THROW_EXCEPTION(ClientException, ClockWentBackwards); } // Check logic From subversion at boxbackup.org Thu Apr 17 21:57:33 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Thu, 17 Apr 2014 21:57:33 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3335 - box/trunk/bin/bbackupd Message-ID: <201404172057.s3HKvXmc021575@wm.boxbackup.org> Author: chris Date: 2014-04-17 21:57:33 +0100 (Thu, 17 Apr 2014) New Revision: 3335 Modified: box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp Log: Call RunBackgroundTask while scanning directories as well. Enables bbackupd to be stopped, reloaded or status queried while scanning a large directory. Modified: box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp =================================================================== --- box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp 2014-04-17 20:57:25 UTC (rev 3334) +++ box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp 2014-04-17 20:57:33 UTC (rev 3335) @@ -303,10 +303,19 @@ struct dirent *en = 0; EMU_STRUCT_STAT file_st; std::string filename; + int num_entries_found = 0; + while((en = ::readdir(dirHandle)) != 0) { + num_entries_found++; rParams.mrContext.DoKeepAlive(); - + if(rParams.mpBackgroundTask) + { + rParams.mpBackgroundTask->RunBackgroundTask( + BackgroundTask::Scanning_Dirs, + num_entries_found, 0); + } + // Don't need to use // LinuxWorkaround_FinishDirentStruct(en, // rLocalPath.c_str()); From subversion at boxbackup.org Fri Apr 18 09:47:38 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Fri, 18 Apr 2014 09:47:38 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3336 - in box/trunk: . bin/bbackupctl Message-ID: <201404180847.s3I8lc7t026131@wm.boxbackup.org> Author: chris Date: 2014-04-18 09:47:38 +0100 (Fri, 18 Apr 2014) New Revision: 3336 Modified: box/trunk/bin/bbackupctl/bbackupctl.cpp box/trunk/modules.txt Log: Make bbackupctl status display the human-readable daemon state name. Modified: box/trunk/bin/bbackupctl/bbackupctl.cpp =================================================================== --- box/trunk/bin/bbackupctl/bbackupctl.cpp 2014-04-17 20:57:33 UTC (rev 3335) +++ box/trunk/bin/bbackupctl/bbackupctl.cpp 2014-04-18 08:47:38 UTC (rev 3336) @@ -19,6 +19,7 @@ #include "box_getopt.h" #include "MainHelper.h" +#include "BackupDaemon.h" #include "BoxPortsAndFiles.h" #include "BackupDaemonConfigVerify.h" #include "Socket.h" @@ -236,7 +237,21 @@ } else if (commandName == "status") { - BOX_NOTICE("state " << currentState); + std::string stateName; + + #define STATE(x) case BackupDaemon::State_ ## x: stateName = #x; break; + switch (currentState) + { + STATE(Initialising); + STATE(Idle); + STATE(Connected); + STATE(Error); + STATE(StorageLimitExceeded); + default: + stateName = "unknown"; + break; + } + BOX_NOTICE("state " << currentState << " " << stateName); command = NoCommand; } Modified: box/trunk/modules.txt =================================================================== --- box/trunk/modules.txt 2014-04-17 20:57:33 UTC (rev 3335) +++ box/trunk/modules.txt 2014-04-18 08:47:38 UTC (rev 3336) @@ -33,7 +33,7 @@ bin/bbstoreaccounts lib/raidfile lib/backupstore bin/bbackupd lib/server lib/backupclient qdbm bin/bbackupquery lib/server lib/backupclient -bin/bbackupctl lib/server lib/backupclient +bin/bbackupctl bin/bbackupd test/backupstore bin/bbstored bin/bbstoreaccounts lib/server lib/backupstore lib/backupclient lib/raidfile test/backupstorefix bin/bbstored bin/bbstoreaccounts lib/backupstore lib/raidfile bin/bbackupquery bin/bbackupd bin/bbackupctl From subversion at boxbackup.org Fri Apr 18 09:56:02 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Fri, 18 Apr 2014 09:56:02 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3337 - box/trunk/bin/bbackupd Message-ID: <201404180856.s3I8u21Q026188@wm.boxbackup.org> Author: chris Date: 2014-04-18 09:56:01 +0100 (Fri, 18 Apr 2014) New Revision: 3337 Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp Log: Simplify the sync start logic some more, log when force-sync overrides script. Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp =================================================================== --- box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-18 08:47:38 UTC (rev 3336) +++ box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-18 08:56:01 UTC (rev 3337) @@ -667,8 +667,13 @@ // logged something at INFO level or higher to explain why. // Use a script to see if sync is allowed now? - if(!mDoSyncForcedByCommand && doSync && !StopRun()) + if(mDoSyncForcedByCommand) { + BOX_INFO("Skipping SyncAllowScript due to bbackupctl " + "force-sync command"); + } + else + { int d = UseScriptToSeeIfSyncAllowed(); if(d > 0) { From subversion at boxbackup.org Fri Apr 18 10:27:52 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Fri, 18 Apr 2014 10:27:52 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3338 - box/trunk/bin/bbackupd Message-ID: <201404180927.s3I9Rq0w026351@wm.boxbackup.org> Author: chris Date: 2014-04-18 10:27:52 +0100 (Fri, 18 Apr 2014) New Revision: 3338 Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp Log: Stop the CommandSocketPollTimer at end of each backup. Otherwise it interrupts us needlessly while we're sleeping waiting for the next backup. Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp =================================================================== --- box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-18 08:56:01 UTC (rev 3337) +++ box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-18 09:27:52 UTC (rev 3338) @@ -202,8 +202,7 @@ mpProgressNotifier(this), mpLocationResolver(this), mpRunStatusProvider(this), - mpSysadminNotifier(this), - mapCommandSocketPollTimer(NULL) + mpSysadminNotifier(this) #ifdef WIN32 , mInstallService(false), mRemoveService(false), @@ -443,9 +442,6 @@ // initialise global timer mechanism Timers::Init(); - mapCommandSocketPollTimer.reset(new Timer(COMMAND_SOCKET_POLL_INTERVAL, - "CommandSocketPollTimer")); - #ifndef WIN32 // Ignore SIGPIPE so that if a command connection is broken, // the daemon doesn't terminate. @@ -493,7 +489,6 @@ "exception, ignored."); } - mapCommandSocketPollTimer.reset(); Timers::Cleanup(); throw; @@ -501,7 +496,6 @@ // Clean up mapCommandSocketInfo.reset(); - mapCommandSocketPollTimer.reset(); Timers::Cleanup(); } @@ -1680,6 +1674,10 @@ // Notify administrator NotifySysadmin(SysadminNotifier::BackupStart); + // Setup timer for polling the command socket + mapCommandSocketPollTimer.reset(new Timer(COMMAND_SOCKET_POLL_INTERVAL, + "CommandSocketPollTimer")); + // Set state and log start SetState(State_Connected); BOX_NOTICE("Beginning scan of local files"); @@ -1708,6 +1706,10 @@ // Notify administrator NotifySysadmin(SysadminNotifier::BackupFinish); + // Stop the timer for polling the command socket, + // to prevent needless alarms while sleeping. + mapCommandSocketPollTimer.reset(); + // Tell anything connected to the command socket SendSyncStartOrFinish(false /* finish */); From subversion at boxbackup.org Fri Apr 18 10:28:04 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Fri, 18 Apr 2014 10:28:04 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3339 - box/trunk/bin/bbackupd Message-ID: <201404180928.s3I9S4MM026368@wm.boxbackup.org> Author: chris Date: 2014-04-18 10:28:04 +0100 (Fri, 18 Apr 2014) New Revision: 3339 Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp Log: Rewrap long lines (whitespace only). Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp =================================================================== --- box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-18 09:27:52 UTC (rev 3338) +++ box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-18 09:28:04 UTC (rev 3339) @@ -540,10 +540,10 @@ // When the last sync started (only updated if the store was not full when the sync ended) mLastSyncTime = 0; - // -------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------- - mDeleteStoreObjectInfoFile = DeserializeStoreObjectInfo( - mLastSyncTime, mNextSyncTime); + mDeleteStoreObjectInfoFile = DeserializeStoreObjectInfo(mLastSyncTime, + mNextSyncTime); // -------------------------------------------------------------------------------------------- @@ -1098,8 +1098,7 @@ // delete the file next time we start a backup mDeleteStoreObjectInfoFile = - SerializeStoreObjectInfo(mLastSyncTime, - mNextSyncTime); + SerializeStoreObjectInfo(mLastSyncTime, mNextSyncTime); // -------------------------------------------------------------------------------------------- } From subversion at boxbackup.org Fri Apr 18 10:28:10 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Fri, 18 Apr 2014 10:28:10 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3340 - box/trunk/bin/bbackupd Message-ID: <201404180928.s3I9SApU026384@wm.boxbackup.org> Author: chris Date: 2014-04-18 10:28:09 +0100 (Fri, 18 Apr 2014) New Revision: 3340 Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp Log: Eliminate duplicate call to GetCurrentBoxTime(). Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp =================================================================== --- box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-18 09:28:04 UTC (rev 3339) +++ box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-18 09:28:09 UTC (rev 3340) @@ -561,8 +561,6 @@ bool doSync = false; bool mDoSyncForcedByCommand = false; - box_time_t currentTime = GetCurrentBoxTime(); - // Check whether we should be stopping, and if so, // don't hang around waiting on the command socket. if(StopRun()) @@ -573,7 +571,7 @@ } // Is a delay necessary? - currentTime = GetCurrentBoxTime(); + box_time_t currentTime = GetCurrentBoxTime(); box_time_t requiredDelay = (mNextSyncTime < currentTime) ? (0) : (mNextSyncTime - currentTime); From subversion at boxbackup.org Fri Apr 18 10:28:14 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Fri, 18 Apr 2014 10:28:14 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3341 - box/trunk/bin/bbackupd Message-ID: <201404180928.s3I9SEPT026400@wm.boxbackup.org> Author: chris Date: 2014-04-18 10:28:14 +0100 (Fri, 18 Apr 2014) New Revision: 3341 Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp Log: Restore correct initialisation of mCurrentSyncStartTime. Was accidentally removed by the refactoring of the backup idle loop. Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp =================================================================== --- box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-18 09:28:09 UTC (rev 3340) +++ box/trunk/bin/bbackupd/BackupDaemon.cpp 2014-04-18 09:28:14 UTC (rev 3341) @@ -680,6 +680,7 @@ } } + mCurrentSyncStartTime = GetCurrentBoxTime(); RunSyncNowWithExceptionHandling(); // Set state From subversion at boxbackup.org Fri Apr 18 23:25:42 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Fri, 18 Apr 2014 23:25:42 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3342 - box/trunk/lib/server Message-ID: <201404182225.s3IMPgM8030194@wm.boxbackup.org> Author: chris Date: 2014-04-18 23:25:41 +0100 (Fri, 18 Apr 2014) New Revision: 3342 Modified: box/trunk/lib/server/makeprotocol.pl.in Log: Add debugging code for when SendStream() fails during client command. Will hopefully help to debug Brendon Baumgartner's issue with backups not completing and repeating over and over, due to this error: > Apr 18 11:14:09 hosting bbackupd[18990]: WARNING: Exception thrown: > ServerException(Protocol_BadUsage) (Sending a stream with a definite > size of zero is not allowed in the protocol) at Protocol.cpp:703 Modified: box/trunk/lib/server/makeprotocol.pl.in =================================================================== --- box/trunk/lib/server/makeprotocol.pl.in 2014-04-18 09:28:14 UTC (rev 3341) +++ box/trunk/lib/server/makeprotocol.pl.in 2014-04-18 22:25:41 UTC (rev 3342) @@ -1105,8 +1105,6 @@ my $has_stream = obj_is_type($cmd,'StreamWithCommand'); my $argextra = $has_stream?', std::auto_ptr apDataStream':''; my $send_stream_extra = ''; - my $send_stream_method = $writing_client ? "SendStream" - : "SendStreamAfterCommand"; print CPP <<__E; std::auto_ptr<$reply_class> $server_or_client_class\::Query(const $request_class &rQuery$argextra) @@ -1119,7 +1117,15 @@ { $send_stream_extra = <<__E; // Send stream after the command - SendStream(*apDataStream); + try + { + SendStream(*apDataStream); + } + catch (BoxException &e) + { + BOX_WARNING("Failed to send stream after command: " << + rQuery.ToString() << ": " << e.what()); + } __E } From subversion at boxbackup.org Sat Apr 19 00:13:30 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Sat, 19 Apr 2014 00:13:30 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3343 - box/trunk Message-ID: <201404182313.s3INDUrI030441@wm.boxbackup.org> Author: chris Date: 2014-04-19 00:13:30 +0100 (Sat, 19 Apr 2014) New Revision: 3343 Modified: box/trunk/config.guess box/trunk/config.sub Log: Update configure scripts to latest version. Was having problems compiling on MinGW x86_64, with the scripts failing to properly detect the platform and recommending upgrading them. It may not have fixed the problem, but doesn't seem like a bad idea. Modified: box/trunk/config.guess =================================================================== --- box/trunk/config.guess 2014-04-18 22:25:41 UTC (rev 3342) +++ box/trunk/config.guess 2014-04-18 23:13:30 UTC (rev 3343) @@ -1,13 +1,12 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +# Copyright 1992-2014 Free Software Foundation, Inc. -timestamp='2004-03-03' +timestamp='2014-03-23' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -16,25 +15,23 @@ # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# Originally written by Per Bothner . -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). # -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. +# Originally written by Per Bothner. # -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# +# Please send patches with a ChangeLog entry to config-patches at gnu.org. + me=`echo "$0" | sed -e 's,.*/,,'` usage="\ @@ -53,8 +50,7 @@ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -Free Software Foundation, Inc. +Copyright 1992-2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -66,11 +62,11 @@ while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; + echo "$timestamp" ; exit ;; --version | -v ) - echo "$version" ; exit 0 ;; + echo "$version" ; exit ;; --help | --h* | -h ) - echo "$usage"; exit 0 ;; + echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. @@ -104,7 +100,7 @@ trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; @@ -123,7 +119,7 @@ ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ;' +esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi at noc.rutgers.edu 1994-08-24) @@ -136,12 +132,33 @@ UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown +case "${UNAME_SYSTEM}" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + eval $set_cc_for_build + cat <<-EOF > $dummy.c + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + ;; +esac + # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward @@ -158,6 +175,7 @@ arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched @@ -166,7 +184,7 @@ arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null + | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? @@ -176,7 +194,7 @@ fi ;; *) - os=netbsd + os=netbsd ;; esac # The OS release @@ -196,64 +214,27 @@ # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" - exit 0 ;; - amd64:OpenBSD:*:*) - echo x86_64-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - arc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - cats:OpenBSD:*:*) - echo arm-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - macppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvmeppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - pegasos:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - pmax:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mipseb-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sun3:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - wgrisc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; + exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + exit ;; *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} - exit 0 ;; + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; macppc:MirBSD:*:*) - echo powerppc-unknown-mirbsd${UNAME_RELEASE} - exit 0 ;; + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} - exit 0 ;; + exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) @@ -260,7 +241,7 @@ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on @@ -306,40 +287,46 @@ # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit 0 ;; - Alpha*:OpenVMS:*:*) - echo alpha-hp-vms - exit 0 ;; + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix - exit 0 ;; + exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 - exit 0 ;; + exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 - exit 0;; + exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos - exit 0 ;; + exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos - exit 0 ;; + exit ;; *:OS/390:*:*) echo i370-ibm-openedition - exit 0 ;; + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; *:OS400:*:*) - echo powerpc-ibm-os400 - exit 0 ;; + echo powerpc-ibm-os400 + exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} - exit 0;; + exit ;; + arm*:riscos:*:*|arm*:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp - exit 0;; + exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee at wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then @@ -347,32 +334,51 @@ else echo pyramid-pyramid-bsd fi - exit 0 ;; + exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 - exit 0 ;; + exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 - exit 0 ;; - DRS?6000:UNIX_SV:4.2*:7*) + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7 && exit 0 ;; + sparc) echo sparc-icl-nx7; exit ;; esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; - i86pc:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval $set_cc_for_build + SUN_ARCH="i386" + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH="x86_64" + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) @@ -381,10 +387,10 @@ esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit 0 ;; + exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} - exit 0 ;; + exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 @@ -396,10 +402,10 @@ echo sparc-sun-sunos${UNAME_RELEASE} ;; esac - exit 0 ;; + exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} - exit 0 ;; + exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor @@ -409,41 +415,41 @@ # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; + exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit 0 ;; + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit 0 ;; + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit 0 ;; + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} - exit 0 ;; + exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} - exit 0 ;; + exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 - exit 0 ;; + exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} - exit 0 ;; + exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} - exit 0 ;; + exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} - exit 0 ;; + exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c @@ -467,35 +473,36 @@ exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c \ - && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && exit 0 + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} - exit 0 ;; + exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax - exit 0 ;; + exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax - exit 0 ;; + exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax - exit 0 ;; + exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix - exit 0 ;; + exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 - exit 0 ;; + exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 - exit 0 ;; + exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 - exit 0 ;; + exit ;; AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ @@ -508,29 +515,29 @@ else echo i586-dg-dgux${UNAME_RELEASE} fi - exit 0 ;; + exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 - exit 0 ;; + exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 - exit 0 ;; + exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 - exit 0 ;; + exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd - exit 0 ;; + exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit 0 ;; + exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix - exit 0 ;; + exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` @@ -538,7 +545,7 @@ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit 0 ;; + exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build @@ -553,15 +560,19 @@ exit(0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 - echo rs6000-ibm-aix3.2.5 + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi - exit 0 ;; - *:AIX:*:[45]) + exit ;; + *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 @@ -574,28 +585,28 @@ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit 0 ;; + exit ;; *:AIX:*:*) echo rs6000-ibm-aix - exit 0 ;; + exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 - exit 0 ;; + exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit 0 ;; # report: romp-ibm BSD 4.3 + exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx - exit 0 ;; + exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 - exit 0 ;; + exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd - exit 0 ;; + exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 - exit 0 ;; + exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in @@ -604,52 +615,52 @@ 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac + esac ;; + esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + sed 's/^ //' << EOF >$dummy.c - #define _HPUX_SOURCE - #include - #include + #define _HPUX_SOURCE + #include + #include - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa @@ -657,9 +668,19 @@ esac if [ ${HP_ARCH} = "hppa2.0w" ] then - # avoid double evaluation of $set_cc_for_build - test -n "$CC_FOR_BUILD" || eval $set_cc_for_build - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ then HP_ARCH="hppa2.0w" else @@ -667,11 +688,11 @@ fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit 0 ;; + exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} - exit 0 ;; + exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c @@ -699,24 +720,25 @@ exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 - exit 0 ;; + exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd - exit 0 ;; + exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd - exit 0 ;; + exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix - exit 0 ;; + exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf - exit 0 ;; + exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf - exit 0 ;; + exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk @@ -723,313 +745,320 @@ else echo ${UNAME_MACHINE}-unknown-osf1 fi - exit 0 ;; + exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites - exit 0 ;; + exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd - exit 0 ;; + exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit 0 ;; + exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd - exit 0 ;; + exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd - exit 0 ;; + exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd - exit 0 ;; + exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' - exit 0 ;; + exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + exit ;; *:UNICOS/mp:*:*) - echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit 0 ;; + exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; + exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; + exit ;; *:FreeBSD:*:*) - # Determine whether the default compiler uses glibc. - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #if __GLIBC__ >= 2 - LIBC=gnu - #else - LIBC= - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - # GNU/KFreeBSD systems have a "k" prefix to indicate we are using - # FreeBSD's kernel, but not the complete OS. - case ${LIBC} in gnu) kernel_only='k' ;; esac - echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} - exit 0 ;; + UNAME_PROCESSOR=`/usr/bin/uname -p` + case ${UNAME_PROCESSOR} in + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin - exit 0 ;; - i*:MINGW*:*) + exit ;; + *:MINGW64*:*) + echo ${UNAME_MACHINE}-pc-mingw64 + exit ;; + *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 - exit 0 ;; + exit ;; + *:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 - exit 0 ;; - x86:Interix*:[34]*) - echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' - exit 0 ;; + exit ;; + *:Interix*:*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + authenticamd | genuineintel | EM64T) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + IA64) + echo ia64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks - exit 0 ;; + exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix - exit 0 ;; + exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin - exit 0 ;; + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin - exit 0 ;; + exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + exit ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit 0 ;; + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu - exit 0 ;; + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix - exit 0 ;; + exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC="gnulibc1" ; fi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; arm*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + else + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + fi + fi + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; cris:Linux:*:*) - echo cris-axis-linux-gnu - exit 0 ;; + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + crisv32:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + frv:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + hexagon:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:Linux:*:*) + echo ${UNAME_MACHINE}-pc-linux-${LIBC} + exit ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; - mips:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU - #undef mips - #undef mipsel + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mipsel + CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips + CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; - mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips64 - #undef mips64el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mips64el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips64 - #else - CPU= - #endif - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 - ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit 0 ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu - exit 0 ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit 0 ;; + openrisc*:Linux:*:*) + echo or1k-unknown-linux-${LIBC} + exit ;; + or32:Linux:*:* | or1k*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-${LIBC} + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-${LIBC} + exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; + PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; + PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; + *) echo hppa-unknown-linux-${LIBC} ;; esac - exit 0 ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu - exit 0 ;; + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-${LIBC} + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-${LIBC} + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-${LIBC} + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-${LIBC} + exit ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux - exit 0 ;; + echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-${LIBC} + exit ;; x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu - exit 0 ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - # Set LC_ALL=C to ensure ld outputs messages in English. - ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit 0 ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit 0 ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit 0 ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #ifdef __ELF__ - # ifdef __GLIBC__ - # if __GLIBC__ >= 2 - LIBC=gnu - # else - LIBC=gnulibc1 - # endif - # else - LIBC=gnulibc1 - # endif - #else - #ifdef __INTEL_COMPILER - LIBC=gnu - #else - LIBC=gnuaout - #endif - #endif - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 - test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 - ;; + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 - exit 0 ;; + exit ;; i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. + # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit 0 ;; + exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx - exit 0 ;; + exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop - exit 0 ;; + exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos - exit 0 ;; - i*86:syllable:*:*) + exit ;; + i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable - exit 0 ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit 0 ;; + exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then @@ -1037,8 +1066,9 @@ else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi - exit 0 ;; - i*86:*:5:[78]*) + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; @@ -1045,7 +1075,7 @@ *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit 0 ;; + exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 @@ -1082,54 +1115,64 @@ else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi - exit 0 ;; + exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv - exit 0 ;; + exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv - exit 0 ;; + exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix - exit 0 ;; - M68*:*:R3V[567]*:*) - test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0) + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4 && exit 0 ;; + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 - exit 0 ;; + exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} - exit 0 ;; + exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 - exit 0 ;; + exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 - exit 0 ;; + exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` @@ -1137,68 +1180,109 @@ else echo ns32k-sni-sysv fi - exit 0 ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit 0 ;; + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 - exit 0 ;; + exit ;; *:*:*:FTX*) # From seanf at swdc.stratus.com. echo i860-stratus-sysv4 - exit 0 ;; + exit ;; + i*86:VOS:*:*) + # From Paul.Green at stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; *:VOS:*:*) # From Paul.Green at stratus.com. echo hppa1.1-stratus-vos - exit 0 ;; + exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} - exit 0 ;; + exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 - exit 0 ;; + exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv${UNAME_RELEASE} else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv${UNAME_RELEASE} fi - exit 0 ;; + exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos - exit 0 ;; + exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos - exit 0 ;; + exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos - exit 0 ;; + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} - exit 0 ;; + exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} - exit 0 ;; + exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} - exit 0 ;; + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; + exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; + exit ;; *:Darwin:*:*) - case `uname -p` in - *86) UNAME_PROCESSOR=i686 ;; - powerpc) UNAME_PROCESSOR=powerpc ;; - esac + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + eval $set_cc_for_build + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # Avoid executing cc on OS X 10.9, as it ships with a stub + # that puts up a graphical alert prompting to install + # developer tools. Any system running Mac OS X 10.7 or + # later (Darwin 11 and later) is required to have a 64-bit + # processor. This is not true of the ARM version of Darwin + # that Apple uses in portable devices. + UNAME_PROCESSOR=x86_64 + fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit 0 ;; + exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then @@ -1206,22 +1290,28 @@ UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit 0 ;; + exit ;; *:QNX:*:4*) echo i386-pc-qnx - exit 0 ;; + exit ;; + NEO-?:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk${UNAME_RELEASE} + exit ;; + NSE-*:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} - exit 0 ;; + exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux - exit 0 ;; + exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv - exit 0 ;; + exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit 0 ;; + exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 @@ -1232,183 +1322,55 @@ UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 - exit 0 ;; + exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 - exit 0 ;; + exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex - exit 0 ;; + exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 - exit 0 ;; + exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 - exit 0 ;; + exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 - exit 0 ;; + exit ;; *:ITS:*:*) echo pdp10-unknown-its - exit 0 ;; + exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} - exit 0 ;; + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-unknown-esx + exit ;; esac -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit 0 ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit 0 ;; - c34*) - echo c34-convex-bsd - exit 0 ;; - c38*) - echo c38-convex-bsd - exit 0 ;; - c4*) - echo c4-convex-bsd - exit 0 ;; - esac -fi - cat >&2 <. +# # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. + +# Please send patches with a ChangeLog entry to config-patches at gnu.org. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. @@ -37,6 +32,9 @@ # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. @@ -70,8 +68,7 @@ version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -Free Software Foundation, Inc. +Copyright 1992-2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -83,11 +80,11 @@ while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; + echo "$timestamp" ; exit ;; --version | -v ) - echo "$version" ; exit 0 ;; + echo "$version" ; exit ;; --help | --h* | -h ) - echo "$usage"; exit 0 ;; + echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. @@ -99,7 +96,7 @@ *local*) # First pass through any local machine types. echo $1 - exit 0;; + exit ;; * ) break ;; @@ -118,11 +115,18 @@ # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ - kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | \ + kopensolaris*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] @@ -145,10 +149,13 @@ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis) + -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; + -bluegene*) + os=-cnk + ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 @@ -163,13 +170,17 @@ os=-chorusos basic_machine=$1 ;; - -chorusrdb) - os=-chorusrdb + -chorusrdb) + os=-chorusrdb basic_machine=$1 - ;; + ;; -hiux*) os=-hiuxwe2 ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` @@ -186,6 +197,10 @@ # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` @@ -203,6 +218,12 @@ -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; -lynx*) os=-lynxos ;; @@ -227,25 +248,39 @@ # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ + | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ - | c4x | clipper \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | be32 | be64 \ + | bfin \ + | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ - | fr30 | frv \ + | epiphany \ + | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ - | m32r | m68000 | m68k | m88k | mcore \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ - | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ @@ -252,33 +287,68 @@ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ + | moxie \ + | mt \ | msp430 \ + | nds32 | nds32le | nds32be \ + | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ - | openrisc | or32 \ + | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ - | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | rl78 | rx \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ - | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ - | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ - | v850 | v850e \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ - | x86 | xscale | xstormy16 | xtensa \ - | z8k) + | x86 | xc16x | xstormy16 | xtensa \ + | z8k | z80) basic_machine=$basic_machine-unknown ;; - m6811 | m68hc11 | m6812 | m68hc12) - # Motorola 68HC11/12. + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; + ms1) + basic_machine=mt-unknown + ;; + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. @@ -293,32 +363,42 @@ # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ + | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* \ - | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ - | clipper-* | cydra-* \ + | avr-* | avr32-* \ + | be32-* | be64-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ - | m32r-* \ + | k1om-* \ + | le32-* | le64-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | mcore-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ + | mips64octeon-* | mips64octeonel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ - | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ @@ -325,28 +405,43 @@ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ | msp430-* \ - | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \ + | nds32-* | nds32le-* | nds32be-* \ + | nios-* | nios2-* | nios2eb-* | nios2el-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ - | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ - | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ | tron-* \ - | v850-* | v850e-* | vax-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ | we32k-* \ - | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ - | xtensa-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ + | xstormy16-* | xtensa*-* \ | ymp-* \ - | z8k-*) + | z8k-* | z80-*) ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) @@ -363,7 +458,7 @@ basic_machine=a29k-amd os=-udi ;; - abacus) + abacus) basic_machine=abacus-unknown ;; adobe68k) @@ -409,6 +504,10 @@ basic_machine=m68k-apollo os=-bsd ;; + aros) + basic_machine=i386-pc + os=-aros + ;; aux) basic_machine=m68k-apple os=-aux @@ -417,10 +516,35 @@ basic_machine=ns32k-sequent os=-dynix ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; c90) basic_machine=c90-cray os=-unicos ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; convex-c1) basic_machine=c1-convex os=-bsd @@ -445,13 +569,20 @@ basic_machine=j90-cray os=-unicos ;; - cr16c) - basic_machine=cr16c-unknown + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16 | cr16-*) + basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; @@ -481,6 +612,14 @@ basic_machine=m88k-motorola os=-sysv3 ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx @@ -592,7 +731,6 @@ i370-ibm* | ibm*) basic_machine=i370-ibm ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 @@ -631,6 +769,14 @@ basic_machine=m68k-isi os=-sysv ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; m88k-omron*) basic_machine=m88k-omron ;; @@ -642,10 +788,21 @@ basic_machine=ns32k-utek os=-sysv ;; + microblaze*) + basic_machine=microblaze-xilinx + ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 + ;; mingw32) - basic_machine=i386-pc + basic_machine=i686-pc os=-mingw32 ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; miniframe) basic_machine=m68000-convergent ;; @@ -659,10 +816,6 @@ mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; - mmix*) - basic_machine=mmix-knuth - os=-mmixware - ;; monitor) basic_machine=m68k-rom68k os=-coff @@ -675,10 +828,21 @@ basic_machine=i386-pc os=-msdos ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + msys) + basic_machine=i686-pc + os=-msys + ;; mvs) basic_machine=i370-ibm os=-mvs ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; ncr3000) basic_machine=i486-ncr os=-sysv4 @@ -743,10 +907,12 @@ np1) basic_machine=np1-gould ;; - nv1) - basic_machine=nv1-cray - os=-unicosmp + neo-tandem) + basic_machine=neo-tandem ;; + nse-tandem) + basic_machine=nse-tandem + ;; nsr-tandem) basic_machine=nsr-tandem ;; @@ -754,9 +920,8 @@ basic_machine=hppa1.1-oki os=-proelf ;; - or32 | or32-*) + openrisc | openrisc-*) basic_machine=or32-unknown - os=-coff ;; os400) basic_machine=powerpc-ibm @@ -778,6 +943,14 @@ basic_machine=i860-intel os=-osf ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; pbd) basic_machine=sparc-tti ;; @@ -787,6 +960,12 @@ pc532 | pc532-*) basic_machine=ns32k-pc532 ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; @@ -816,9 +995,10 @@ ;; power) basic_machine=power-ibm ;; - ppc) basic_machine=powerpc-unknown + ppc | ppcbe) basic_machine=powerpc-unknown ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown @@ -843,6 +1023,14 @@ basic_machine=i586-unknown os=-pw32 ;; + rdos | rdos64) + basic_machine=x86_64-pc + os=-rdos + ;; + rdos32) + basic_machine=i386-pc + os=-rdos + ;; rom68k) basic_machine=m68k-rom68k os=-coff @@ -869,6 +1057,10 @@ sb1el) basic_machine=mipsisa64sb1el-unknown ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; sei) basic_machine=mips-sei os=-seiux @@ -880,6 +1072,9 @@ basic_machine=sh-hitachi os=-hms ;; + sh5el) + basic_machine=sh5le-unknown + ;; sh64) basic_machine=sh64-unknown ;; @@ -901,6 +1096,9 @@ basic_machine=i860-stratus os=-sysv4 ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; sun2) basic_machine=m68000-sun ;; @@ -957,18 +1155,10 @@ basic_machine=t90-cray os=-unicos ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff + tile*) + basic_machine=$basic_machine-unknown + os=-linux-gnu ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff - ;; tx39) basic_machine=mipstx39-unknown ;; @@ -1029,9 +1219,16 @@ basic_machine=hppa1.1-winbond os=-proelf ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; xps | xps100) basic_machine=xps100-honeywell ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ;; ymp) basic_machine=ymp-cray os=-unicos @@ -1040,6 +1237,10 @@ basic_machine=z8k-unknown os=-sim ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; none) basic_machine=none-none os=-none @@ -1059,6 +1260,9 @@ romp) basic_machine=romp-ibm ;; + mmix) + basic_machine=mmix-knuth + ;; rs6000) basic_machine=rs6000-ibm ;; @@ -1075,13 +1279,10 @@ we32k) basic_machine=we32k-att ;; - sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; - sh64) - basic_machine=sh64-unknown - ;; - sparc | sparcv9 | sparcv9b) + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) @@ -1125,9 +1326,12 @@ if [ x"$os" != x"" ] then case $os in - # First match some system type aliases - # that might get confused with valid system types. + # First match some system type aliases + # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; @@ -1148,26 +1352,31 @@ # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ + | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -chorusos* | -chorusrdb* | -cegcc* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-musl* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*) + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1185,7 +1394,7 @@ os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) @@ -1206,7 +1415,7 @@ -opened*) os=-openedition ;; - -os400*) + -os400*) os=-os400 ;; -wince*) @@ -1255,7 +1464,7 @@ -sinix*) os=-sysv4 ;; - -tpf*) + -tpf*) os=-tpf ;; -triton*) @@ -1291,9 +1500,14 @@ -aros*) os=-aros ;; - -kaos*) - os=-kaos + -zvmoe) + os=-zvmoe ;; + -dicos*) + os=-dicos + ;; + -nacl*) + ;; -none) ;; *) @@ -1316,6 +1530,12 @@ # system, and we'll never get to this point. case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; *-acorn) os=-riscix1.2 ;; @@ -1325,9 +1545,24 @@ arm*-semi) os=-aout ;; - c4x-* | tic4x-*) - os=-coff - ;; + c4x-* | tic4x-*) + os=-coff + ;; + c8051-*) + os=-elf + ;; + hexagon-*) + os=-elf + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff + ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 @@ -1346,13 +1581,13 @@ ;; m68000-sun) os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 ;; m68*-cisco) os=-aout ;; + mep-*) + os=-elf + ;; mips*-cisco) os=-elf ;; @@ -1371,9 +1606,15 @@ *-be) os=-beos ;; + *-haiku) + os=-haiku + ;; *-ibm) os=-aix ;; + *-knuth) + os=-mmixware + ;; *-wec) os=-proelf ;; @@ -1476,7 +1717,7 @@ -sunos*) vendor=sun ;; - -aix*) + -cnk*|-aix*) vendor=ibm ;; -beos*) @@ -1539,7 +1780,7 @@ esac echo $basic_machine$os -exit 0 +exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) From subversion at boxbackup.org Fri Apr 25 10:31:24 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Fri, 25 Apr 2014 10:31:24 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3344 - box/trunk/lib/server Message-ID: <201404250931.s3P9VOln085895@wm.boxbackup.org> Author: chris Date: 2014-04-25 10:31:23 +0100 (Fri, 25 Apr 2014) New Revision: 3344 Modified: box/trunk/lib/server/makeprotocol.pl.in Log: Don't just eat the exception, rethrow it after logging details. Modified: box/trunk/lib/server/makeprotocol.pl.in =================================================================== --- box/trunk/lib/server/makeprotocol.pl.in 2014-04-18 23:13:30 UTC (rev 3343) +++ box/trunk/lib/server/makeprotocol.pl.in 2014-04-25 09:31:23 UTC (rev 3344) @@ -1125,6 +1125,7 @@ { BOX_WARNING("Failed to send stream after command: " << rQuery.ToString() << ": " << e.what()); + throw; } __E } From subversion at boxbackup.org Sat Apr 26 19:48:47 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Sat, 26 Apr 2014 19:48:47 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3345 - box/trunk/bin/bbackupd Message-ID: <201404261848.s3QImlpU097124@wm.boxbackup.org> Author: chris Date: 2014-04-26 19:48:46 +0100 (Sat, 26 Apr 2014) New Revision: 3345 Modified: box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp Log: Fix crash uploading empty attributes when directory disappears during scan. Thanks to Brendon Baumgartner for the report on the mailing list, and for helping to diagnose the problem. Modified: box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp =================================================================== --- box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp 2014-04-25 09:31:23 UTC (rev 3344) +++ box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp 2014-04-26 18:48:46 UTC (rev 3345) @@ -1335,6 +1335,19 @@ en = 0; } + // Zero pointer in rEntriesLeftOver, if we have a pointer to zero + if(en != 0) + { + for(unsigned int l = 0; l < rEntriesLeftOver.size(); ++l) + { + if(rEntriesLeftOver[l] == en) + { + rEntriesLeftOver[l] = 0; + break; + } + } + } + // Flag for having created directory, so can optimise the // recursive call not to read it again, because we know // it's empty. @@ -1350,7 +1363,7 @@ // In the list, just use this pointer psubDirRecord = e->second; } - else + else { // Note: if we have exceeded our storage limit, then // we should not upload any more data, nor create any @@ -1366,19 +1379,25 @@ // No. Exists on the server, and we know about it from the listing. subDirObjectID = en->GetObjectID(); } - else if(rContext.StorageLimitExceeded()) + else if(rContext.StorageLimitExceeded()) // know we've got a connection if we get this far, // as dir will have been modified. { doCreateDirectoryRecord = false; - } + } else { // Yes, creation required! // It is known that the it doesn't exist: - // if pDirOnStore == 0, then the directory has had an initial sync, and hasn't been modified. - // so it has definately been created already. - // if en == 0 but pDirOnStore != 0, well... obviously it doesn't exist. + // + // if en == 0 and pDirOnStore == 0, then the + // directory has had an initial sync, and + // hasn't been modified (Really? then why + // are we here? TODO FIXME) + // so it has definately been created already + // (so why create it again?) + // + // if en == 0 but pDirOnStore != 0, well... obviously it doesn't exist. // Get attributes box_time_t attrModTime = 0; @@ -1396,11 +1415,14 @@ } catch (BoxException &e) { + // We used to try to recover from this, + // but we'd need an attributes block to + // upload to the server, so we have to + // skip creating the directory instead. BOX_WARNING("Failed to read attributes " - "of directory, cannot check " - "for rename, assuming new: '" - << nonVssDirPath << "'"); - failedToReadAttributes = true; + "of directory, ignoring it " + "for now: " << nonVssDirPath); + continue; } // Check to see if the directory been renamed @@ -1438,9 +1460,9 @@ // Get connection BackupProtocolClient &connection(rContext.GetConnection()); - + // Don't do a check for storage limit exceeded here, because if we get to this - // stage, a connection will have been opened, and the status known, so the check + // stage, a connection will have been opened, and the status known, so the check // in the else if(...) above will be correct. // Build attribute stream for sending @@ -1452,10 +1474,10 @@ connection.QueryMoveObject(renameObjectID, renameInDirectory, mObjectID /* move to this directory */, - BackupProtocolMoveObject::Flags_MoveAllWithSameName | + BackupProtocolMoveObject::Flags_MoveAllWithSameName | BackupProtocolMoveObject::Flags_AllowMoveOverDeletedObject, storeFilename); - + // Put the latest attributes on it connection.QueryChangeDirAttributes(renameObjectID, attrModTime, attrStream); @@ -1490,7 +1512,7 @@ } if (doCreateDirectoryRecord) - { + { // New an object for this psubDirRecord = new BackupClientDirectoryRecord(subDirObjectID, *d); @@ -1507,9 +1529,9 @@ } } } - + ASSERT(psubDirRecord != 0 || rContext.StorageLimitExceeded()); - + if(psubDirRecord) { // Sync this sub directory too @@ -1517,21 +1539,8 @@ rRemotePath + "/" + *d, rBackupLocation, haveJustCreatedDirOnServer); } + } - // Zero pointer in rEntriesLeftOver, if we have a pointer to zero - if(en != 0) - { - for(unsigned int l = 0; l < rEntriesLeftOver.size(); ++l) - { - if(rEntriesLeftOver[l] == en) - { - rEntriesLeftOver[l] = 0; - break; - } - } - } - } - // Delete everything which is on the store, but not on disc for(unsigned int l = 0; l < rEntriesLeftOver.size(); ++l) { From subversion at boxbackup.org Tue Apr 29 20:22:38 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Tue, 29 Apr 2014 20:22:38 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3346 - box/trunk/lib/backupstore Message-ID: <201404291922.s3TJMcJF022501@wm.boxbackup.org> Author: chris Date: 2014-04-29 20:22:37 +0100 (Tue, 29 Apr 2014) New Revision: 3346 Modified: box/trunk/lib/backupstore/BackupStoreCheck2.cpp Log: Add a comment explaining why we can't move detached dirs back into place. Modified: box/trunk/lib/backupstore/BackupStoreCheck2.cpp =================================================================== --- box/trunk/lib/backupstore/BackupStoreCheck2.cpp 2014-04-26 18:48:46 UTC (rev 3345) +++ box/trunk/lib/backupstore/BackupStoreCheck2.cpp 2014-04-29 19:22:37 UTC (rev 3346) @@ -149,6 +149,8 @@ if((flags & Flags_IsDir) == Flags_IsDir) { // Directory. Just put into lost and found. + // (It doesn't contain its filename, so we + // can't recreate the entry in the parent) putIntoDirectoryID = GetLostAndFoundDirID(); } else From subversion at boxbackup.org Tue Apr 29 20:22:46 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Tue, 29 Apr 2014 20:22:46 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3347 - in box/trunk: lib/backupstore test/backupstore Message-ID: <201404291922.s3TJMkqT022518@wm.boxbackup.org> Author: chris Date: 2014-04-29 20:22:46 +0100 (Tue, 29 Apr 2014) New Revision: 3347 Modified: box/trunk/lib/backupstore/BackupStoreContext.cpp box/trunk/test/backupstore/testbackupstore.cpp Log: Fix error when modifying a directory with missing entry in parent. This is hopefully the cause of the segfaults reported by Brendon Baumgartner. Modified: box/trunk/lib/backupstore/BackupStoreContext.cpp =================================================================== --- box/trunk/lib/backupstore/BackupStoreContext.cpp 2014-04-29 19:22:37 UTC (rev 3346) +++ box/trunk/lib/backupstore/BackupStoreContext.cpp 2014-04-29 19:22:46 UTC (rev 3347) @@ -1017,10 +1017,20 @@ GetDirectoryInternal(rDir.GetContainerID())); BackupStoreDirectory::Entry* en = parent.FindEntryByID(rDir.GetObjectID()); - ASSERT(en); - ASSERT(en->GetSizeInBlocks() == old_dir_size); - en->SetSizeInBlocks(new_dir_size); - SaveDirectory(parent); + if(!en) + { + BOX_ERROR("Missing entry for directory " << + BOX_FORMAT_OBJECTID(rDir.GetObjectID()) << + " in directory " << + BOX_FORMAT_OBJECTID(rDir.GetContainerID()) << + " while trying to update dir size in parent"); + } + else + { + ASSERT(en->GetSizeInBlocks() == old_dir_size); + en->SetSizeInBlocks(new_dir_size); + SaveDirectory(parent); + } } } catch(...) Modified: box/trunk/test/backupstore/testbackupstore.cpp =================================================================== --- box/trunk/test/backupstore/testbackupstore.cpp 2014-04-29 19:22:37 UTC (rev 3346) +++ box/trunk/test/backupstore/testbackupstore.cpp 2014-04-29 19:22:46 UTC (rev 3347) @@ -1828,6 +1828,19 @@ return en->GetSizeInBlocks(); } +bool write_dir(BackupStoreDirectory& dir) +{ + std::string rfn; + StoreStructure::MakeObjectFilename(dir.GetObjectID(), + "backup/01234567/" /* mStoreRoot */, 0 /* mStoreDiscSet */, + rfn, false); // EnsureDirectoryExists + RaidFileWrite rfw(0, rfn); + rfw.Open(true); // AllowOverwrite + dir.WriteToStream(rfw); + rfw.Commit(/* ConvertToRaidNow */ true); + return true; +} + bool test_directory_parent_entry_tracks_directory_size() { SETUP(); @@ -1894,7 +1907,45 @@ protocol.Reopen(); protocolReadOnly.Reopen(); - // Add a directory, this should push the object size back up + // Now modify the root directory to remove its entry for this one + std::auto_ptr root_read(get_raid_file(BACKUPSTORE_ROOT_DIRECTORY_ID)); + BackupStoreDirectory root(static_cast >(root_read)); + BackupStoreDirectory::Entry *en = root.FindEntryByID(subdirid); + TEST_THAT_OR(en, return false); + BackupStoreDirectory::Entry enCopy(*en); + root.DeleteEntry(subdirid); + TEST_THAT(write_dir(root)); + + // Add a directory, this should try to push the object size back up, + // which will try to modify the subdir's entry in its parent, which + // no longer exists, which should just log an error instead of + // aborting/segfaulting. + create_directory(protocol, subdirid); + + // Repair the error ourselves, as bbstoreaccounts can't. + protocol.QueryFinished(); + enCopy.SetSizeInBlocks(get_raid_file(subdirid)->GetDiscUsageInBlocks()); + root.AddEntry(enCopy); + TEST_THAT(write_dir(root)); + + // We also have to remove the entry for lovely_directory created by + // create_directory(), because otherwise we can't create it again. + // (Perhaps it should not have been committed because we failed to + // update the parent, but currently it is.) + std::auto_ptr subdir_read(get_raid_file(subdirid)); + BackupStoreDirectory subdir(static_cast >(subdir_read)); + { + BackupStoreDirectory::Iterator i(subdir); + en = i.FindMatchingClearName( + BackupStoreFilenameClear("lovely_directory")); + } + TEST_THAT_OR(en, return false); + protocol.Reopen(); + protocol.QueryDeleteDirectory(en->GetObjectID()); + set_refcount(en->GetObjectID(), 0); + + // This should have fixed the error, so we should be able to add the + // entry now. This should push the object size back up. int64_t dir2id = create_directory(protocol, subdirid); TEST_EQUAL(new_size, get_raid_file(subdirid)->GetDiscUsageInBlocks()); TEST_EQUAL(new_size, get_object_size(protocolReadOnly, subdirid, @@ -1903,12 +1954,12 @@ // Delete it again, which should reduce the object size again protocol.QueryDeleteDirectory(dir2id); - // Reduce the limits, to remove it permanently from the store + // Reduce the limits, to remove it permanently from the store protocol.QueryFinished(); protocolReadOnly.QueryFinished(); TEST_THAT(change_account_limits("0B", "20000B")); TEST_THAT(run_housekeeping_and_check_account()); - set_refcount(last_added_file_id, 0); + set_refcount(dir2id, 0); protocol.Reopen(); protocolReadOnly.Reopen(); @@ -1922,22 +1973,13 @@ protocol.QueryFinished(); - std::auto_ptr root_read(get_raid_file(BACKUPSTORE_ROOT_DIRECTORY_ID)); - BackupStoreDirectory root(static_cast >(root_read)); - BackupStoreDirectory::Entry *en = root.FindEntryByID(subdirid); - TEST_THAT(en != 0); - if (!en) return false; + root_read = get_raid_file(BACKUPSTORE_ROOT_DIRECTORY_ID); + root.ReadFromStream(*root_read, IOStream::TimeOutInfinite); + en = root.FindEntryByID(subdirid); + TEST_THAT_OR(en != 0, return false); en->SetSizeInBlocks(1234); + TEST_THAT(write_dir(root)); - std::string rfn; - StoreStructure::MakeObjectFilename(BACKUPSTORE_ROOT_DIRECTORY_ID, - "backup/01234567/" /* mStoreRoot */, 0 /* mStoreDiscSet */, - rfn, false); // EnsureDirectoryExists - RaidFileWrite rfw(0, rfn); - rfw.Open(true); // AllowOverwrite - root.WriteToStream(rfw); - rfw.Commit(/* ConvertToRaidNow */ true); - TEST_EQUAL(1234, get_object_size(protocolReadOnly, subdirid, BACKUPSTORE_ROOT_DIRECTORY_ID)); TEST_EQUAL(1, check_account_for_errors()); From subversion at boxbackup.org Tue Apr 29 20:22:54 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Tue, 29 Apr 2014 20:22:54 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3348 - in box/trunk/lib: backupstore common raidfile Message-ID: <201404291922.s3TJMsTm022534@wm.boxbackup.org> Author: chris Date: 2014-04-29 20:22:54 +0100 (Tue, 29 Apr 2014) New Revision: 3348 Modified: box/trunk/lib/backupstore/BackupStoreDirectory.cpp box/trunk/lib/common/BufferedStream.h box/trunk/lib/common/FileStream.h box/trunk/lib/common/IOStream.cpp box/trunk/lib/common/IOStream.h box/trunk/lib/raidfile/RaidFileRead.cpp box/trunk/lib/raidfile/RaidFileRead.h Log: Add a ToString method to IOStream and some subclasses. Useful to help debug problems such as invalid file headers when the source of the stream might not be too obvious. Modified: box/trunk/lib/backupstore/BackupStoreDirectory.cpp =================================================================== --- box/trunk/lib/backupstore/BackupStoreDirectory.cpp 2014-04-29 19:22:46 UTC (rev 3347) +++ box/trunk/lib/backupstore/BackupStoreDirectory.cpp 2014-04-29 19:22:54 UTC (rev 3348) @@ -133,11 +133,11 @@ if(OBJECTMAGIC_DIR_MAGIC_VALUE != ntohl(hdr.mMagicValue)) { THROW_EXCEPTION_MESSAGE(BackupStoreException, BadDirectoryFormat, - "Wrong magic number in directory object " << - BOX_FORMAT_OBJECTID(mObjectID) << ": expected " << + "Wrong magic number for directory: expected " << BOX_FORMAT_HEX32(OBJECTMAGIC_DIR_MAGIC_VALUE) << " but found " << - BOX_FORMAT_HEX32(ntohl(hdr.mMagicValue))); + BOX_FORMAT_HEX32(ntohl(hdr.mMagicValue)) << " in " << + rStream.ToString()); } // Get data Modified: box/trunk/lib/common/BufferedStream.h =================================================================== --- box/trunk/lib/common/BufferedStream.h 2014-04-29 19:22:46 UTC (rev 3347) +++ box/trunk/lib/common/BufferedStream.h 2014-04-29 19:22:54 UTC (rev 3348) @@ -33,6 +33,10 @@ virtual bool StreamDataLeft(); virtual bool StreamClosed(); + virtual std::string ToString() const + { + return std::string("Buffered ") + mrSource.ToString(); + } private: BufferedStream(const BufferedStream &rToCopy) : mrSource(rToCopy.mrSource) { /* do not call */ } Modified: box/trunk/lib/common/FileStream.h =================================================================== --- box/trunk/lib/common/FileStream.h 2014-04-29 19:22:46 UTC (rev 3347) +++ box/trunk/lib/common/FileStream.h 2014-04-29 19:22:54 UTC (rev 3348) @@ -49,6 +49,10 @@ virtual bool StreamClosed(); bool CompareWith(IOStream& rOther, int Timeout = IOStream::TimeOutInfinite); + std::string ToString() const + { + return std::string("local file ") + mFileName; + } private: tOSFileHandle mOSFileHandle; Modified: box/trunk/lib/common/IOStream.cpp =================================================================== --- box/trunk/lib/common/IOStream.cpp 2014-04-29 19:22:46 UTC (rev 3347) +++ box/trunk/lib/common/IOStream.cpp 2014-04-29 19:22:54 UTC (rev 3348) @@ -245,7 +245,30 @@ } } +// -------------------------------------------------------------------------- +// +// Function +// Name: IOStream::Write +// Purpose: Convenience method for writing a null-terminated +// C string to a protocol buffer. +// +// -------------------------------------------------------------------------- void IOStream::Write(const char *pBuffer) { Write(pBuffer, strlen(pBuffer)); } + +// -------------------------------------------------------------------------- +// +// Function +// Name: IOStream::ToString() +// Purpose: Returns a string which describes this stream. Useful +// when reporting exceptions about a stream of unknown +// origin, for example in BackupStoreDirectory(). +// Created: 2014/04/28 +// +// -------------------------------------------------------------------------- +std::string IOStream::ToString() const +{ + return "unknown IOStream"; +} Modified: box/trunk/lib/common/IOStream.h =================================================================== --- box/trunk/lib/common/IOStream.h 2014-04-29 19:22:46 UTC (rev 3347) +++ box/trunk/lib/common/IOStream.h 2014-04-29 19:22:54 UTC (rev 3348) @@ -65,6 +65,7 @@ void Flush(int Timeout = IOStream::TimeOutInfinite); static int ConvertSeekTypeToOSWhence(int SeekType); + virtual std::string ToString() const; }; Modified: box/trunk/lib/raidfile/RaidFileRead.cpp =================================================================== --- box/trunk/lib/raidfile/RaidFileRead.cpp 2014-04-29 19:22:46 UTC (rev 3347) +++ box/trunk/lib/raidfile/RaidFileRead.cpp 2014-04-29 19:22:54 UTC (rev 3348) @@ -1767,6 +1767,7 @@ return RaidFileUtil::DiscUsageInBlocks(GetFileSize(), rdiscSet); } - - - +std::string RaidFileRead::ToString() const +{ + return std::string("RaidFile ") + mFilename; +} Modified: box/trunk/lib/raidfile/RaidFileRead.h =================================================================== --- box/trunk/lib/raidfile/RaidFileRead.h 2014-04-29 19:22:46 UTC (rev 3347) +++ box/trunk/lib/raidfile/RaidFileRead.h 2014-04-29 19:22:54 UTC (rev 3348) @@ -61,6 +61,7 @@ virtual pos_type BytesLeftToRead(); pos_type GetDiscUsageInBlocks(); + std::string ToString() const; typedef int64_t FileSizeType; From subversion at boxbackup.org Tue Apr 29 20:23:02 2014 From: subversion at boxbackup.org (subversion at boxbackup.org) Date: Tue, 29 Apr 2014 20:23:02 +0100 (BST) Subject: [Box Backup-commit] COMMIT r3349 - in box/trunk: lib/backupstore lib/common test/backupstore Message-ID: <201404291923.s3TJN2wQ022551@wm.boxbackup.org> Author: chris Date: 2014-04-29 20:23:02 +0100 (Tue, 29 Apr 2014) New Revision: 3349 Modified: box/trunk/lib/backupstore/BackupStoreContext.cpp box/trunk/lib/backupstore/BackupStoreDirectory.h box/trunk/lib/common/IOStream.h box/trunk/test/backupstore/testbackupstore.cpp Log: Whitespace fixes. Modified: box/trunk/lib/backupstore/BackupStoreContext.cpp =================================================================== --- box/trunk/lib/backupstore/BackupStoreContext.cpp 2014-04-29 19:22:54 UTC (rev 3348) +++ box/trunk/lib/backupstore/BackupStoreContext.cpp 2014-04-29 19:23:02 UTC (rev 3349) @@ -1121,7 +1121,7 @@ } // Commit the file - dirFile.Commit(BACKUP_STORE_CONVERT_TO_RAID_IMMEDIATELY); + dirFile.Commit(BACKUP_STORE_CONVERT_TO_RAID_IMMEDIATELY); // Make sure the size of the directory is added to the usage counts in the info ASSERT(dirSize > 0); @@ -1151,7 +1151,7 @@ RemoveDirectoryFromCache(InDirectory); // Don't worry about the incremented number in the store info - throw; + throw; } // Save the store info (may not be postponed) Modified: box/trunk/lib/backupstore/BackupStoreDirectory.h =================================================================== --- box/trunk/lib/backupstore/BackupStoreDirectory.h 2014-04-29 19:22:54 UTC (rev 3348) +++ box/trunk/lib/backupstore/BackupStoreDirectory.h 2014-04-29 19:23:02 UTC (rev 3349) @@ -139,7 +139,7 @@ void WriteToStreamDependencyInfo(IOStream &rStream) const; private: - BackupStoreFilename mName; + BackupStoreFilename mName; box_time_t mModificationTime; int64_t mObjectID; int64_t mSizeInBlocks; Modified: box/trunk/lib/common/IOStream.h =================================================================== --- box/trunk/lib/common/IOStream.h 2014-04-29 19:22:54 UTC (rev 3348) +++ box/trunk/lib/common/IOStream.h 2014-04-29 19:23:02 UTC (rev 3349) @@ -58,12 +58,12 @@ virtual bool StreamDataLeft() = 0; // Has the stream been closed (writing not possible) virtual bool StreamClosed() = 0; - + // Utility functions bool ReadFullBuffer(void *pBuffer, int NBytes, int *pNBytesRead, int Timeout = IOStream::TimeOutInfinite); bool CopyStreamTo(IOStream &rCopyTo, int Timeout = IOStream::TimeOutInfinite, int BufferSize = 1024); void Flush(int Timeout = IOStream::TimeOutInfinite); - + static int ConvertSeekTypeToOSWhence(int SeekType); virtual std::string ToString() const; }; Modified: box/trunk/test/backupstore/testbackupstore.cpp =================================================================== --- box/trunk/test/backupstore/testbackupstore.cpp 2014-04-29 19:22:54 UTC (rev 3348) +++ box/trunk/test/backupstore/testbackupstore.cpp 2014-04-29 19:23:02 UTC (rev 3349) @@ -1849,7 +1849,7 @@ 0, false); BackupProtocolLocal2 protocolReadOnly(0x01234567, "test", "backup/01234567/", 0, true); // read only - + int64_t subdirid = create_directory(protocol); // Get the root directory cached in the read-only connection, and @@ -1876,7 +1876,7 @@ new_size = get_raid_file(subdirid)->GetDiscUsageInBlocks(); } - // Check that the root directory entry has been updated + // Check that the root directory entry has been updated TEST_EQUAL(new_size, get_object_size(protocolReadOnly, subdirid, BACKUPSTORE_ROOT_DIRECTORY_ID)); @@ -1884,7 +1884,7 @@ protocol.QueryDeleteFile(subdirid, BackupStoreFilenameClear(last_added_filename)); - // Reduce the limits, to remove it permanently from the store + // Reduce the limits, to remove it permanently from the store protocol.QueryFinished(); protocolReadOnly.QueryFinished(); TEST_THAT(change_account_limits("0B", "20000B")); @@ -1987,7 +1987,7 @@ BACKUPSTORE_ROOT_DIRECTORY_ID)); protocolReadOnly.QueryFinished(); - tearDown(); + tearDown(); return true; } @@ -2269,7 +2269,7 @@ TEST_THAT(delfiles[1] == 4); } - tearDown(); + tearDown(); return true; } @@ -2532,7 +2532,7 @@ // will investigate. delete_account(); - tearDown(); + tearDown(); return true; } @@ -2616,7 +2616,6 @@ TEST_THAT(StopServer()); } - return 0; }