Skip to content

Commit

Permalink
update error code handle
Browse files Browse the repository at this point in the history
  • Loading branch information
XUranus committed Dec 1, 2023
1 parent e94a7be commit 79d0d2c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/task/VolumeBlockReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,9 @@ bool VolumeBlockReader::ReadBlock(uint8_t* buffer, uint32_t& nBytesToRead)
void VolumeBlockReader::HandleReadError(ErrCodeType errorCode)
{
m_failed = true;
ErrCodeType error = m_dataReader->Error();
m_errorCode = error;
m_errorCode = errorCode;
#ifdef __linux__
if (error == EACCES || error == EPERM) {
if (errorCode == EACCES || errorCode == EPERM) {
m_errorCode = (m_sourceType == SourceType::COPYFILE) ?
VOLUMEPROTECT_ERR_COPY_ACCESS_DENIED : VOLUMEPROTECT_ERR_VOLUME_ACCESS_DENIED;
}
Expand Down
11 changes: 5 additions & 6 deletions src/task/VolumeBlockWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "VolumeProtector.h"
#include "native/RawIO.h"
#include "VolumeBlockWriter.h"
#include <asm-generic/errno-base.h>

using namespace volumeprotect;
using namespace volumeprotect::task;
Expand Down Expand Up @@ -171,7 +170,8 @@ void VolumeBlockWriter::MainThread()
}
if (m_status == TaskStatus::SUCCEED && m_sharedContext->counter->blockesWriteFailed != 0) {
m_status = TaskStatus::FAILED;
ERRLOG("%llu blockes failed to write, set writer status to fail");
ERRLOG("%llu blockes failed to write, set writer status to fail",
m_sharedContext->counter->blockesWriteFailed.load());
}
INFOLOG("writer read terminated with status %s", GetStatusString().c_str());
return;
Expand All @@ -180,13 +180,12 @@ void VolumeBlockWriter::MainThread()
void VolumeBlockWriter::HandleWriteError(ErrCodeType errorCode)
{
m_failed = true;
ErrCodeType error = m_dataWriter->Error();
m_errorCode = error;
m_errorCode = errorCode;
#ifdef __linux__
if (error == EACCES || error == EPERM) {
if (errorCode == EACCES || errorCode == EPERM) {
m_errorCode = (m_targetType == TargetType::COPYFILE) ?
VOLUMEPROTECT_ERR_COPY_ACCESS_DENIED : VOLUMEPROTECT_ERR_VOLUME_ACCESS_DENIED;
} else if (m_targetType == TargetType::COPYFILE && error == ENOSPC) {
} else if (m_targetType == TargetType::COPYFILE && errorCode == ENOSPC) {
m_errorCode = VOLUMEPROTECT_ERR_NO_SPACE;
}
#endif
Expand Down

0 comments on commit 79d0d2c

Please sign in to comment.