From 9c21ee70207fec7dad9dfccfc6520631a3d61a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hannappel?= Date: Tue, 20 Apr 2021 13:14:54 +0200 Subject: [PATCH 01/12] add build/test on arm --- .gitlab-ci.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d480a26..8326357 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,6 +14,15 @@ build_a: tags: - kubernetes +build_arm: + stage: build + script: gitlab/build.sh + artifacts: + paths: + - install/ + tags: + - arm + build_noxattr: stage: build script: gitlab/build.sh devtoolset-9 -DUSE_XATTR=OFF @@ -111,6 +120,16 @@ test_a: tags: - kubernetes +test_arm: + stage: test + script: gitlab/test.sh tests/auto /data/tmp /data/tmp + needs: + - build_arm + dependencies: + - build_arm + tags: + - /arm + test_tmp: stage: test script: gitlab/test.sh tests/auto /tmp /tmp -- GitLab From 419ed8fdcc967b9d20ecf3d870c3594bd17debb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hannappel?= Date: Tue, 20 Apr 2021 14:13:46 +0200 Subject: [PATCH 02/12] slightly simplify stop handler, don't assert lock freedom --- CMakeLists.txt | 2 +- src/ewmscp.cpp | 37 +++++++++++++++++-------------------- src/ewmscp.h | 8 +++----- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 502048f..e23d204 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ else() endif() SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STD_FLAG}") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wunused -Woverloaded-virtual -Wshadow -Wextra -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wvla -fstack-protector -fstack-check -Wstack-protector") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wunused -Woverloaded-virtual -Wshadow -Wextra -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wvla -fstack-protector -Wstack-protector") IF (${CMAKE_SIZEOF_VOID_P} EQUAL 4) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FILE_OFFSET_BITS=64") diff --git a/src/ewmscp.cpp b/src/ewmscp.cpp index de2b11b..ab72a53 100644 --- a/src/ewmscp.cpp +++ b/src/ewmscp.cpp @@ -133,51 +133,48 @@ void sigUsrHandler(int sigNum) { } } -defineStatic(stopRequest::instance, nullptr); +defineStatic(stopRequest::handlerId, stopRequest::handlerIdType::unhandled); +defineStatic(stopRequest::reason,"no reason"); +defineStatic(stopRequest::stopRequested, false); void stopRequest::sigHandler(int) { - stopRequest::instance->stopRequested = true; - static_assert(ATOMIC_BOOL_LOCK_FREE == 2, "atomic bool is not always lock free"); // assert that stopRequested is always lock-free + stopRequested = true; + // static_assert(std::atomic_is_lock_free(&stopRequested), "atomic bool is not always lock free"); // assert that stopRequested is always lock-free } -stopRequest::stopRequest(): handlerId(handlerIdType::unhandled), stopRequested(false) {} void stopRequest::instantiate(stopRequest::handlerIdType id) { - if (instance != nullptr) { + if (handlerId != handlerIdType::unhandled) { throw std::logic_error("stop request handler cannot be instatiated twice"); } if (id == handlerIdType::unhandled || id == handlerIdType::undefined) { throw std::logic_error("illegal handler id value"); } - instance = new stopRequest; std::signal(SIGTERM, sigHandler); - instance->handlerId = id; + handlerId = id; } bool stopRequest::Requested() { - if (instance != nullptr) { - return instance->stopRequested; + if (handlerId != handlerIdType::unhandled) { + return stopRequested; } return false; } bool stopRequest::Requested(handlerIdType id) { - if (instance != nullptr) { - return instance->handlerId == id && instance->stopRequested; - } - return false; + return handlerId == id && stopRequested; } void stopRequest::RequestStop(const std::string& aReason) { - if (instance != nullptr) { + if (handlerId != handlerIdType::unhandled) { static std::mutex instanceProtector; std::unique_lock lock(instanceProtector); - stopRequest::instance->stopRequested = true; - stopRequest::instance->reason = aReason; + stopRequested = true; + reason = aReason; } else { errMsg::emit(errMsg::level::crit, errMsg::location(), "stopRequest", "requestStop", "no stop request instance"); } } void stopRequest::ThrowUpReasonably() { - if (instance != nullptr) { - if (instance->stopRequested) { - if (! instance->reason.empty()) { - throw std::runtime_error(instance->reason); + if (handlerId != handlerIdType::unhandled) { + if (stopRequested) { + if (! reason.empty()) { + throw std::runtime_error(reason); } else { throw std::runtime_error("SIGTERM received"); } diff --git a/src/ewmscp.h b/src/ewmscp.h index bd8416a..d53dd3a 100644 --- a/src/ewmscp.h +++ b/src/ewmscp.h @@ -123,12 +123,10 @@ class stopRequest { processLoop }; private: - handlerIdType handlerId; - std::string reason; - static stopRequest* instance; + static handlerIdType handlerId; + static std::string reason; static void sigHandler(int); - std::atomic stopRequested; - stopRequest(); + static std::atomic stopRequested; public: static void instantiate(handlerIdType id); static bool Requested(); -- GitLab From 4799385ff4e8eb3ad6af557a7c83f0c4164bc411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hannappel?= Date: Tue, 20 Apr 2021 15:06:18 +0200 Subject: [PATCH 03/12] arm nees libatomic explicitly --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9dd758d..7af87a2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,7 +33,7 @@ SET(OPTION_CHRONO ${CMAKE_SOURCE_DIR}/OptionParser/src/OptionsChrono.cpp) SET(EWMSCP_INCLUDES) SET(EWMSCP_OPTIONS) -SET(EWMSCP_LIBS "pthread") +SET(EWMSCP_LIBS "pthread" "atomic") SET(EWMSCP_SOURCES ewmscp.cpp copyRequest.cpp block.cpp md5sum.cpp md5.c genericStat.cpp outputHandler.cpp) list(APPEND EWMSCP_SOURCES ${OPTION_SRCS} ${OPTION_CHRONO}) -- GitLab From fc4184989da9aa455e558ea6e089612cde447dfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hannappel?= Date: Tue, 20 Apr 2021 15:31:11 +0200 Subject: [PATCH 04/12] test processor type --- CMakeLists.txt | 2 ++ src/CMakeLists.txt | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e23d204..35cf52f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,8 @@ IF(NOT CMAKE_BUILD_TYPE) ENDIF(NOT CMAKE_BUILD_TYPE) MESSAGE("Selected build type: ${CMAKE_BUILD_TYPE}") +MESSAGE("Building for ${CMAKE_SYSTEM_PROCESSOR} (${CMAKE_SYSTEM},${CMAKE_SYSTEM_NAME}) on ${CMAKE_HOST_SYSTEM_PROCESSOR}") + SET (CPLUSPLUSVERSION "11") CHECK_CXX_COMPILER_FLAG("-std=c++${CPLUSPLUSVERSION}" COMPILER_SUPPORTS_CXXVERSION) if(COMPILER_SUPPORTS_CXXVERSION) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7af87a2..63f1f98 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,7 +33,10 @@ SET(OPTION_CHRONO ${CMAKE_SOURCE_DIR}/OptionParser/src/OptionsChrono.cpp) SET(EWMSCP_INCLUDES) SET(EWMSCP_OPTIONS) -SET(EWMSCP_LIBS "pthread" "atomic") +SET(EWMSCP_LIBS "pthread") +if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm") + list(APPEND EWMSCP_LIBS "atomic") +endif() SET(EWMSCP_SOURCES ewmscp.cpp copyRequest.cpp block.cpp md5sum.cpp md5.c genericStat.cpp outputHandler.cpp) list(APPEND EWMSCP_SOURCES ${OPTION_SRCS} ${OPTION_CHRONO}) -- GitLab From a12b81ff1575c3b04e5663c1be1c591ea269ba9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hannappel?= Date: Tue, 20 Apr 2021 15:33:06 +0200 Subject: [PATCH 05/12] fix arm tyle --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 63f1f98..eb2c7c9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,7 +34,7 @@ SET(OPTION_CHRONO ${CMAKE_SOURCE_DIR}/OptionParser/src/OptionsChrono.cpp) SET(EWMSCP_INCLUDES) SET(EWMSCP_OPTIONS) SET(EWMSCP_LIBS "pthread") -if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm") +if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l") list(APPEND EWMSCP_LIBS "atomic") endif() SET(EWMSCP_SOURCES ewmscp.cpp copyRequest.cpp block.cpp md5sum.cpp md5.c genericStat.cpp outputHandler.cpp) -- GitLab From 9597e759d6cc68daaec3528349a0ef07285ffe7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hannappel?= Date: Tue, 20 Apr 2021 15:46:47 +0200 Subject: [PATCH 06/12] atomic also needed for dirCount on arm --- src/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eb2c7c9..2cd94ac 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -178,7 +178,11 @@ add_executable(createLargeTestFileTree createLargeTestFileTree.cpp) install(TARGETS createLargeTestFileTree DESTINATION bin) add_executable(dirCount dirCount.cpp ${OPTION_SRCS}) -target_link_libraries(dirCount pthread) +if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l") + target_link_libraries(dirCount pthread atomic) +else() + target_link_libraries(dirCount pthread) +endif() install(TARGETS dirCount DESTINATION bin) add_executable(dateTest dateTest.cpp ${OPTION_SRCS} ${OPTION_CHRONO}) -- GitLab From aa00b5b4e6998fa02456876aad9619884d5423e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hannappel?= Date: Tue, 20 Apr 2021 15:56:13 +0200 Subject: [PATCH 07/12] fix SIGTERM handler again, and test pipe for arm --- .gitlab-ci.yml | 2 +- src/ewmscp.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8326357..1433a6d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -128,7 +128,7 @@ test_arm: dependencies: - build_arm tags: - - /arm + - arm test_tmp: stage: test diff --git a/src/ewmscp.cpp b/src/ewmscp.cpp index ab72a53..473212a 100644 --- a/src/ewmscp.cpp +++ b/src/ewmscp.cpp @@ -134,7 +134,7 @@ void sigUsrHandler(int sigNum) { } defineStatic(stopRequest::handlerId, stopRequest::handlerIdType::unhandled); -defineStatic(stopRequest::reason,"no reason"); +defineStaticNoArg(stopRequest::reason); defineStatic(stopRequest::stopRequested, false); void stopRequest::sigHandler(int) { stopRequested = true; -- GitLab From c851f6bea9bfa3df5e7dd5de68769847ba35ba95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hannappel?= Date: Tue, 20 Apr 2021 17:53:53 +0200 Subject: [PATCH 08/12] fix timing of tests when no /bin/time is there, add arm inotify test --- .gitlab-ci.yml | 10 ++++++++++ gitlab/test.sh | 8 +++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1433a6d..4d01e74 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -328,3 +328,13 @@ test_inotify_b: - build_9 tags: - bare-metal + +test_inotify_arm: + stage: test + script: gitlab/test.sh tests/auto.inotify /tmp /tmp + needs: + - build_arm + dependencies: + - build_arm + tags: + - arm diff --git a/gitlab/test.sh b/gitlab/test.sh index 95e79cb..f2d4f9d 100755 --- a/gitlab/test.sh +++ b/gitlab/test.sh @@ -76,14 +76,12 @@ for test in ${tests}; do export dst=$argdstbase/$(basename $cmpdst) result=$(mktemp) if [ -f /bin/time ]; then - timed="/bin/time -a -o ${result} -f" - format=' %E %I %O %M' + timed="/bin/time -a -o ${result} -f %E\t%I\t%O\t%M" elif [ -f /usr/bin/time ]; then - timed="/usr/bin/time -a -o ${result} -f" - format=' %E %M' + timed="/usr/bin/time -a -o ${result} -f %E\t%M" fi - if ${timed} "${format}" ${test} &> ${result}; then + if ${timed} ${test} &> ${result}; then echo -en "${GREEN}success${NORM}" tail -1 ${result} grep -e 'Warning:' -e 'CRIT:' -e 'DEBUG:' $result && warnings=$[ $warnings + $(grep 'Warning:' $result | wc -l) ] -- GitLab From 8a57aa60eb039c1c4a643954612e854df69f46ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hannappel?= Date: Mon, 17 May 2021 16:55:18 +0200 Subject: [PATCH 09/12] overcome format problem by using stringstream --- src/genericStat.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/genericStat.cpp b/src/genericStat.cpp index b69806e..7113ebc 100644 --- a/src/genericStat.cpp +++ b/src/genericStat.cpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include genericStat::genericStat(const struct stat& statBuf, const clock_type::duration& aTimeResolution): device(statBuf.st_dev), @@ -49,8 +51,11 @@ void genericStat::chronoToString(std::string& spec, const clock_type::time_point char buffer[123]; strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S.", &time); spec = buffer; - std::sprintf(buffer, "%06ld", std::chrono::duration_cast(Chrono.time_since_epoch()).count() % 1000000); - spec += buffer; + std::ostringstream buf2; + buf2 << std::setw(6) << std::setfill('0') + << std::chrono::duration_cast(Chrono.time_since_epoch()).count() % 1000000; + // std::sprintf(buffer, "%06ld", std::chrono::duration_cast(Chrono.time_since_epoch()).count() % 1000000); + spec += buf2.str(); } -- GitLab From 785b8c29f621a2e06b46457f1725ec658fa83255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hannappel?= Date: Tue, 18 May 2021 11:30:49 +0200 Subject: [PATCH 10/12] improve inotify-watch dir list and fix inode check on copytest --- src/inotify_watch.cpp | 10 +++++----- tests/auto/simpleCopyBackupModeRemove.bash | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/inotify_watch.cpp b/src/inotify_watch.cpp index 6617781..9d640e2 100644 --- a/src/inotify_watch.cpp +++ b/src/inotify_watch.cpp @@ -59,7 +59,7 @@ #include typedef std::chrono::system_clock clock_type; -std::ostream* errStream = &std::cerr; +std::ostream* errStream(nullptr); options::single errPrefix('\0', "errPrefix", "prefix for error messages"); @@ -297,13 +297,13 @@ class watchedDirType { public: static void dump(std::ostream& out) { - out << "begin list of watched directories (" << getWatchedDirs().size() << "):\n"; + out << errPrefix << "begin list of watched directories (" << getWatchedDirs().size() << "):\n"; for (const auto& item: getWatchedDirs()) { std::string path; item.second->buildPath(path); - out << item.first << ": " << path << "\n"; + out << errPrefix << item.first << ": " << path << "\n"; } - out << "end list of watched directories.\n"; + out << errPrefix << "end list of watched directories.\n"; } @@ -645,7 +645,7 @@ int main(int argc, const char* argv[]) { } parser.fParse(argc, argv); - logstream::provider errStreamBase(errorStream, *errStream << errPrefix); + logstream::provider errStreamBase(errorStream, std::cerr); errStream = &(errStreamBase.getStream()); { diff --git a/tests/auto/simpleCopyBackupModeRemove.bash b/tests/auto/simpleCopyBackupModeRemove.bash index 2f3c03c..8f07b75 100755 --- a/tests/auto/simpleCopyBackupModeRemove.bash +++ b/tests/auto/simpleCopyBackupModeRemove.bash @@ -4,6 +4,7 @@ copy=${cmpdst}/a echo "oldfile" > ${cmpdst}/a copyOldInode=$(stat -c %i $copy) +ln ${copy} ${cmpdst}/inodesaver ewmscp ${stdargs} ${srcargs} ${dstargs} -v --backupMode remove ${src}/a ${dst} fail=$? -- GitLab From 9ea21de3ccd89b3d06dc0f013d02ba9cfe43db0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hannappel?= Date: Tue, 18 May 2021 14:00:21 +0200 Subject: [PATCH 11/12] move from off_t to size_t for more consistent signedness --- src/copyRequest.cpp | 4 ++-- src/genericStat.h | 6 +++--- src/inputHandler.h | 2 +- src/inputHandlerLibssh.cpp | 2 +- src/inputHandlerLibssh.h | 2 +- src/inputHandlerPosixFile.cpp | 18 +++++++++++------- src/inputHandlerPosixFile.h | 8 +++++--- src/sparseMap.cpp | 2 +- 8 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/copyRequest.cpp b/src/copyRequest.cpp index c6c727c..5167430 100644 --- a/src/copyRequest.cpp +++ b/src/copyRequest.cpp @@ -539,8 +539,8 @@ void copyRequest::base::reader(inputHandler::base::reader& input, && nReadThreads > 1 && nBlocks >= nReadThreads) { blockReadRequestQueue readRequests; - for (off_t o = 0; o < readInitialStat->size; o += memoryBlockSize) { - size_t s = readInitialStat->size - o; + for (size_t o = 0; o < readInitialStat->size; o += memoryBlockSize) { + auto s = readInitialStat->size - o; s = std::min(s, memoryBlockSize); readRequests.emplace(s, o); } diff --git a/src/genericStat.h b/src/genericStat.h index 74f1bbf..c1bb16d 100644 --- a/src/genericStat.h +++ b/src/genericStat.h @@ -13,9 +13,9 @@ class genericStat { public: typedef std::chrono::system_clock clock_type; dev_t device; - off_t size; - off_t sizeOnDisk; - blksize_t blksize; + size_t size; + size_t sizeOnDisk; + size_t blksize; clock_type::time_point aTime; clock_type::time_point mTime; clock_type::duration timeResolution; diff --git a/src/inputHandler.h b/src/inputHandler.h index eb5c4ca..e025baf 100644 --- a/src/inputHandler.h +++ b/src/inputHandler.h @@ -109,7 +109,7 @@ namespace inputHandler { /// like the standard seek, to be used only when appending new data to a file /// \throw std::system_error if seek fails /// \throw unimplementedActionError if seek is not implemented (most input handlers) - virtual void seek(std::make_unsigned::type /*pos*/ ///< [in] position from the start of the file + virtual void seek(size_t /*pos*/ ///< [in] position from the start of the file ) { throw unimplementedActionError("seek not implemented"); }; diff --git a/src/inputHandlerLibssh.cpp b/src/inputHandlerLibssh.cpp index 2f6ef6b..9b27264 100644 --- a/src/inputHandlerLibssh.cpp +++ b/src/inputHandlerLibssh.cpp @@ -89,7 +89,7 @@ namespace inputHandler { - void libssh::readerLibssh::seek(std::make_unsigned::type pos) { + void libssh::readerLibssh::seek(size_t pos) { throwcall::sftp::good0(sftp_seek64(file, pos), handler, "can't seek ", path, " to ", pos); } diff --git a/src/inputHandlerLibssh.h b/src/inputHandlerLibssh.h index b5e89bd..24fa904 100644 --- a/src/inputHandlerLibssh.h +++ b/src/inputHandlerLibssh.h @@ -24,7 +24,7 @@ namespace inputHandler { copyRequest::stateType &state, const genericStat& inititalStat); ~readerLibssh() override; - void seek(std::make_unsigned::type pos) override; + void seek(size_t pos) override; bool readBlock(block &b) override; void checkUnchangedness() override; }; diff --git a/src/inputHandlerPosixFile.cpp b/src/inputHandlerPosixFile.cpp index 3863fc4..e715d4e 100644 --- a/src/inputHandlerPosixFile.cpp +++ b/src/inputHandlerPosixFile.cpp @@ -115,13 +115,15 @@ namespace inputHandler { pos < readInitialStat.size; what = what == SEEK_HOLE ? SEEK_DATA : SEEK_HOLE) { timerInst(lseek); - auto next = lseek(fd, pos, what); - if (next == -1 && errno == ENXIO) { // we found a hole at the end of the file + size_t next; + auto result = lseek(fd, pos, what); + if (result == -1 && errno == ENXIO) { // we found a hole at the end of the file next = readInitialStat.size; } else { - throwcall::badval(next, -1, + throwcall::badval(result, -1, "seek ", path, " for ", what == SEEK_HOLE ? "hole" : "data", ", from offset ", pos); + next = result; } if (next != pos) { regions.emplace_back(pos, next, what == SEEK_DATA); @@ -134,7 +136,7 @@ namespace inputHandler { } - void posixFile::readerPosixFile::seek(std::make_unsigned::type pos) { + void posixFile::readerPosixFile::seek(size_t pos) { throwcall::badval(lseek(fd, pos, SEEK_SET), -1, "can't seek ", path, " to ", pos); if (! regions.empty()) { @@ -160,11 +162,13 @@ namespace inputHandler { b.setHoleState(true); b.bump_size(region.size()); timerInst(lseek); - auto nextData = lseek(fd, totalBytesRead, SEEK_DATA); - if (nextData == -1 && errno == ENXIO) { // this is the final hole + size_t nextData; + auto result = lseek(fd, totalBytesRead, SEEK_DATA); + if (result == -1 && errno == ENXIO) { // this is the final hole nextData = region.getEnd(); } else { - throwcall::badval(nextData, -1, "seek in ", path, " to data after ", totalBytesRead); + throwcall::badval(result, -1, "seek in ", path, " to data after ", totalBytesRead); + nextData = result; } totalBytesRead += region.size(); // hole counts as total size... if (nextData != totalBytesRead) { diff --git a/src/inputHandlerPosixFile.h b/src/inputHandlerPosixFile.h index 16b3d74..98130ce 100644 --- a/src/inputHandlerPosixFile.h +++ b/src/inputHandlerPosixFile.h @@ -18,8 +18,10 @@ namespace inputHandler { public: /// class for data or hole regions, needed for sparse file handling class regionType { - std::make_unsigned::type start; - std::make_unsigned::type end; + // std::make_unsigned::type start; + //std::make_unsigned::type end; + size_t start; + size_t end; bool hole; public: regionType(decltype(start) aStart, decltype(end) aEnd, decltype(hole) aHole): @@ -50,7 +52,7 @@ namespace inputHandler { ~readerPosixFile() override; bool parallelizable() const override; bool setupSparseRegions(const std::string& sparseHandling) override; - void seek(std::make_unsigned::type pos) override; + void seek(size_t pos) override; bool readBlock(block &b) override; void readBlockP(block& b, size_t bytesToRead, off_t offset) override; void checkUnchangedness() override; diff --git a/src/sparseMap.cpp b/src/sparseMap.cpp index 8ef48f4..549c695 100644 --- a/src/sparseMap.cpp +++ b/src/sparseMap.cpp @@ -96,7 +96,7 @@ int main(int argc, const char *argv[]) { printRegion(std::cout, pos, next); std::cout << "\n"; if (findZeroes && what.at(toggle).first == SEEK_HOLE) { - off_t zeroBlocksStart = 0; + size_t zeroBlocksStart = 0; bool lastBlockWasData = true; for (auto offset = pos; offset < next;) { auto bytesRead = pread(fd, blkBuf, blockSize, offset); -- GitLab From 806bbdd99ef1cebe10edd50316502603f66352fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hannappel?= Date: Tue, 18 May 2021 14:20:34 +0200 Subject: [PATCH 12/12] suppress abi compatibility warning on arm --- src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2cd94ac..df7b099 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -36,6 +36,7 @@ SET(EWMSCP_OPTIONS) SET(EWMSCP_LIBS "pthread") if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l") list(APPEND EWMSCP_LIBS "atomic") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi") endif() SET(EWMSCP_SOURCES ewmscp.cpp copyRequest.cpp block.cpp md5sum.cpp md5.c genericStat.cpp outputHandler.cpp) list(APPEND EWMSCP_SOURCES ${OPTION_SRCS} ${OPTION_CHRONO}) -- GitLab