diff --git a/Include/Aurora/IO/IAsyncTransaction.hpp b/Include/Aurora/IO/IAsyncTransaction.hpp index 5315dd98..c647a0a9 100644 --- a/Include/Aurora/IO/IAsyncTransaction.hpp +++ b/Include/Aurora/IO/IAsyncTransaction.hpp @@ -71,6 +71,8 @@ namespace Aurora::IO */ virtual void Reset() = 0; + virtual void SetBaseOffset(AuUInt64 uBaseOffset) = 0; + AURT_ADD_USR_DATA; }; } \ No newline at end of file diff --git a/Source/IO/FS/Async.Linux.cpp b/Source/IO/FS/Async.Linux.cpp index 98c21503..3f77122a 100644 --- a/Source/IO/FS/Async.Linux.cpp +++ b/Source/IO/FS/Async.Linux.cpp @@ -249,6 +249,11 @@ namespace Aurora::IO::FS return bool(this->loopSource_); } + void LinuxAsyncFileTransaction::SetBaseOffset(AuUInt64 uBaseOffset) + { + this->uBaseOffset = uBaseOffset; + } + bool LinuxAsyncFileTransaction::StartRead(AuUInt64 offset, const AuSPtr &memoryView) { if (HasState()) @@ -296,6 +301,8 @@ namespace Aurora::IO::FS return true; } } + + offset += this->uBaseOffset; if (!UNIX::LinuxOverlappedSubmitRead(fd, offset, this, this->loopSource_.get(), bool(this->handle_->pIPCPipe))) { @@ -351,6 +358,8 @@ namespace Aurora::IO::FS LIOS_Init(AuSharedFromThis()); SetMemory(memoryView); + offset += this->uBaseOffset; + if (!UNIX::LinuxOverlappedSubmitWrite(fd, offset, this, this->loopSource_.get())) { LIOS_SendProcess(0, true, errno); diff --git a/Source/IO/FS/Async.Linux.hpp b/Source/IO/FS/Async.Linux.hpp index 82cd251e..332baed5 100644 --- a/Source/IO/FS/Async.Linux.hpp +++ b/Source/IO/FS/Async.Linux.hpp @@ -77,11 +77,15 @@ namespace Aurora::IO::FS void DispatchCb(); AuSPtr GetFileHandle(); + void SetBaseOffset(AuUInt64 uBaseOffset) override; + virtual void LIOS_Process(AuUInt32 read, bool failure, int err, bool mark) override; private: AuSPtr handle_; - AuUInt32 lastAbstractOffset_ {}, lastFinishedStat_{}; + AuUInt64 lastAbstractOffset_ {}; + AuUInt32 lastFinishedStat_ {}; + AuUInt64 uBaseOffset {}; bool latch_ {}; bool bTxFinished_ {}; AuSPtr sub_; diff --git a/Source/IO/FS/Async.NT.cpp b/Source/IO/FS/Async.NT.cpp index 6b0c3231..3856711d 100644 --- a/Source/IO/FS/Async.NT.cpp +++ b/Source/IO/FS/Async.NT.cpp @@ -345,10 +345,13 @@ namespace Aurora::IO::FS this->bHasFailed = false; this->dwLastAbstractStat = memoryView->length; - this->dwLastAbstractOffset = offset; + this->qwLastAbstractOffset = offset; this->dwLastBytes = 0; this->ResetAIO(); + + offset += this->uBaseOffset; + this->overlap.Offset = AuBitsToLower(offset); this->overlap.OffsetHigh = AuBitsToHigher(offset); @@ -398,9 +401,12 @@ namespace Aurora::IO::FS this->pMemoryHold = memoryView; this->dwLastBytes = 0; this->dwLastAbstractStat = memoryView->length; - this->dwLastAbstractOffset = offset; + this->qwLastAbstractOffset = offset; this->ResetAIO(); + + offset += this->uBaseOffset; + this->overlap.Offset = AuBitsToLower(offset); this->overlap.OffsetHigh = AuBitsToHigher(offset); auto ret = ::WriteFileEx((HANDLE)optWrite.value(), memoryView->ptr, memoryView->length, &this->overlap, FileOperationCompletion); @@ -421,7 +427,7 @@ namespace Aurora::IO::FS if (this->pSub_) { - this->pSub_->OnAsyncFileOpFinished(this->dwLastAbstractOffset, read); + this->pSub_->OnAsyncFileOpFinished(this->qwLastAbstractOffset, read); } } @@ -543,6 +549,11 @@ namespace Aurora::IO::FS this->pSub_ = sub; } + void NtAsyncFileTransaction::SetBaseOffset(AuUInt64 uBaseOffset) + { + this->uBaseOffset = uBaseOffset; + } + bool NtAsyncFileTransaction::Wait(AuUInt32 timeout) { if (this->bLatch) diff --git a/Source/IO/FS/Async.NT.hpp b/Source/IO/FS/Async.NT.hpp index b9a48389..6fea4bec 100644 --- a/Source/IO/FS/Async.NT.hpp +++ b/Source/IO/FS/Async.NT.hpp @@ -54,6 +54,8 @@ namespace Aurora::IO::FS void SetCallback(const AuSPtr &sub) override; + void SetBaseOffset(AuUInt64 uBaseOffset) override; + bool Wait(AuUInt32 timeout) override; AuSPtr NewLoopSource() override; @@ -68,12 +70,13 @@ namespace Aurora::IO::FS OVERLAPPED overlap {}; HANDLE event = INVALID_HANDLE_VALUE; AuSPtr pPin; - AuUInt32 dwLastAbstractStat {}, - dwLastAbstractOffset {}; + AuUInt32 dwLastAbstractStat {}; + AuUInt64 qwLastAbstractOffset {}; bool bLatch {}; AuUInt32 dwLastBytes {}; AuUInt32 dwOsErrorCode {}; bool bHasFailed {}; + AuUInt64 uBaseOffset {}; AuWPtr pNtIpcPipeImpl; AuSPtr pMemoryHold; diff --git a/Source/IO/Net/AuNetStream.Linux.cpp b/Source/IO/Net/AuNetStream.Linux.cpp index 01344626..f740c8da 100644 --- a/Source/IO/Net/AuNetStream.Linux.cpp +++ b/Source/IO/Net/AuNetStream.Linux.cpp @@ -206,6 +206,11 @@ namespace Aurora::IO::Net return false; } + void LinuxAsyncNetworkTransaction::SetBaseOffset(AuUInt64 uBaseOffset) + { + + } + bool LinuxAsyncNetworkTransaction::Complete() { return this->bLatch; diff --git a/Source/IO/Net/AuNetStream.Linux.hpp b/Source/IO/Net/AuNetStream.Linux.hpp index 75d51386..ca49bca5 100644 --- a/Source/IO/Net/AuNetStream.Linux.hpp +++ b/Source/IO/Net/AuNetStream.Linux.hpp @@ -42,6 +42,8 @@ namespace Aurora::IO::Net void Reset() override; + void SetBaseOffset(AuUInt64 uBaseOffset) override; + virtual void LIOS_Process(AuUInt32 read, bool failure, int err, bool mark) override; void MakeSyncable(); diff --git a/Source/IO/Net/AuNetStream.NT.cpp b/Source/IO/Net/AuNetStream.NT.cpp index 3998ab2d..d6765d76 100644 --- a/Source/IO/Net/AuNetStream.NT.cpp +++ b/Source/IO/Net/AuNetStream.NT.cpp @@ -387,6 +387,11 @@ namespace Aurora::IO::Net return this->pWaitable; } + void NtAsyncNetworkTransaction::SetBaseOffset(AuUInt64 uBaseOffset) + { + + } + void NtAsyncNetworkTransaction::Reset() { if (this->dwLastAbstractStat) diff --git a/Source/IO/Net/AuNetStream.NT.hpp b/Source/IO/Net/AuNetStream.NT.hpp index 13a664e8..9b0950b1 100644 --- a/Source/IO/Net/AuNetStream.NT.hpp +++ b/Source/IO/Net/AuNetStream.NT.hpp @@ -39,6 +39,8 @@ namespace Aurora::IO::Net bool Wait(AuUInt32 timeout) override; AuSPtr NewLoopSource() override; + void SetBaseOffset(AuUInt64 uBaseOffset) override; + void Reset(); void MakeSyncable();