diff options
-rw-r--r-- | include/llfio/v2.0/detail/impl/posix/map_handle.ipp | 7 | ||||
-rw-r--r-- | include/llfio/v2.0/map_handle.hpp | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/include/llfio/v2.0/detail/impl/posix/map_handle.ipp b/include/llfio/v2.0/detail/impl/posix/map_handle.ipp index 4f3aeabf..bf676d4a 100644 --- a/include/llfio/v2.0/detail/impl/posix/map_handle.ipp +++ b/include/llfio/v2.0/detail/impl/posix/map_handle.ipp @@ -439,14 +439,17 @@ result<map_handle::size_type> map_handle::truncate(size_type newsize, bool permi extent_type length = _length; if(_section != nullptr) { - OUTCOME_TRY(auto &&length_, _section->length()); // length of the backing file - length = length_; + OUTCOME_TRY(length, _section->length()); // length of the backing file } auto _newsize = utils::round_up_to_page_size(newsize, _pagesize); if(_newsize == _reservation) { return success(); } + if(_section == nullptr) + { + length = _newsize; // newsize, but rounded up + } // If wiping the map ... if(newsize == 0) { diff --git a/include/llfio/v2.0/map_handle.hpp b/include/llfio/v2.0/map_handle.hpp index 299010de..69241720 100644 --- a/include/llfio/v2.0/map_handle.hpp +++ b/include/llfio/v2.0/map_handle.hpp @@ -659,7 +659,7 @@ public: \errors Any of the values POSIX `mremap()`, `mmap(addr)` or `VirtualAlloc(addr)` can return. */ LLFIO_MAKE_FREE_FUNCTION - LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<size_type> truncate(size_type newsize, bool permit_relocation = false) noexcept; + LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<size_type> truncate(size_type newsize, bool permit_relocation) noexcept; /*! Ask the system to commit the system resources to make the memory represented by the buffer available with the given permissions. addr and length should be page |