diff options
author | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2020-04-21 12:59:37 +0300 |
---|---|---|
committer | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2020-04-21 12:59:37 +0300 |
commit | 4441633ac61b3a43e69888e3217ecbaea9961d9b (patch) | |
tree | ff2b3ed0d48e3d45608a143b6119774e82e1f9a8 | |
parent | 95e5abf9e3b6f9f598729328fb28df7627356b25 (diff) | |
parent | 18e9135e121db97f2893c14894161068a6335033 (diff) |
Merge remote-tracking branch 'remotes/origin/develop' into resumable_io_branch_merge
-rw-r--r-- | Build.md | 8 | ||||
-rw-r--r-- | include/llfio/v2.0/detail/impl/remove_all.ipp | 2 | ||||
-rw-r--r-- | include/llfio/v2.0/detail/impl/windows/import.hpp | 15 | ||||
-rw-r--r-- | include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp | 4 | ||||
-rw-r--r-- | include/llfio/v2.0/detail/impl/windows/stat.ipp | 13 | ||||
-rw-r--r-- | include/llfio/v2.0/detail/impl/windows/statfs.ipp | 63 | ||||
-rw-r--r-- | include/llfio/v2.0/detail/impl/windows/storage_profile.ipp | 9 | ||||
-rw-r--r-- | include/llfio/v2.0/mapped_file_handle.hpp | 2 | ||||
-rw-r--r-- | include/llfio/v2.0/storage_profile.hpp | 2 |
9 files changed, 95 insertions, 23 deletions
@@ -128,4 +128,10 @@ ctest -C Release -R llfio_dl ## Installing libraries from source -It all works as per standard with cmake, a `make install` with the usual options and environment variables. +~~~ +mkdir build +cd build +cmake .. +cmake --build . -- _dl _sl _hl +cmake --build . --target install +~~~ diff --git a/include/llfio/v2.0/detail/impl/remove_all.ipp b/include/llfio/v2.0/detail/impl/remove_all.ipp index 373c8a49..7135552c 100644 --- a/include/llfio/v2.0/detail/impl/remove_all.ipp +++ b/include/llfio/v2.0/detail/impl/remove_all.ipp @@ -53,6 +53,7 @@ namespace algorithm try { LLFIO_LOG_FUNCTION_CALL(nullptr); + log_level_guard logg(log_level::fatal); auto default_callback = [](remove_all_callback_reason reason, remove_all_callback_arg /*unused*/, remove_all_callback_arg /*unused*/) -> result<void> { // Ignore any unremoveable during directory enumeration, we only care about those // which occur after the tree has been removed. @@ -461,6 +462,7 @@ namespace algorithm // Set up the threadpool of workers auto worker = [&] { + log_level_guard logg(log_level::fatal); for(;;) { directory_handle mywork; diff --git a/include/llfio/v2.0/detail/impl/windows/import.hpp b/include/llfio/v2.0/detail/impl/windows/import.hpp index a61707de..b5aacbd1 100644 --- a/include/llfio/v2.0/detail/impl/windows/import.hpp +++ b/include/llfio/v2.0/detail/impl/windows/import.hpp @@ -632,6 +632,14 @@ namespace windows_nt_kernel ULONG BytesPerSector; } FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION; + typedef struct _FILE_FS_SIZE_INFORMATION // NOLINT + { + LARGE_INTEGER TotalAllocationUnits; + LARGE_INTEGER AvailableAllocationUnits; + ULONG SectorsPerAllocationUnit; + ULONG BytesPerSector; + } FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION; + typedef struct _FILE_FS_OBJECTID_INFORMATION // NOLINT { UCHAR ObjectId[16]; @@ -1153,6 +1161,11 @@ namespace windows_nt_kernel } // MAKE SURE you update the early exit check at the top to whatever the last of these is! + +#if !LLFIO_EXPERIMENTAL_STATUS_CODE + // Work around a race caused by fetching one of these for the first time during static deinit + (void) ntkernel_error_category::ntkernel_category(); +#endif } #ifdef _MSC_VER #pragma warning(pop) @@ -1528,7 +1541,7 @@ inline result<DWORD> ntflags_from_handle_caching_and_flags(native_handle_type &n switch(_caching) { case handle::caching::unchanged: - break; // can be called by reopen() + break; // can be called by reopen() case handle::caching::none: ntflags |= 0x00000008 /*FILE_NO_INTERMEDIATE_BUFFERING*/ | 0x00000002 /*FILE_WRITE_THROUGH*/; nativeh.behaviour |= native_handle_type::disposition::aligned_io; diff --git a/include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp b/include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp index 53f24324..3433d8d2 100644 --- a/include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp +++ b/include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp @@ -57,11 +57,11 @@ result<mapped_file_handle::size_type> mapped_file_handle::reserve(size_type rese _reservation = reservation; return _reservation; } - section_handle::flag mapflags = section_handle::flag::read | section_handle::flag::nocommit; + section_handle::flag mapflags = section_handle::flag::read; // Reserve the full reservation in address space if(this->is_writable()) { - mapflags |= section_handle::flag::write; + mapflags |= section_handle::flag::write | section_handle::flag::nocommit; } OUTCOME_TRYV(_mh.close()); OUTCOME_TRY(mh, map_handle::map(_sh, reservation, 0, mapflags)); diff --git a/include/llfio/v2.0/detail/impl/windows/stat.ipp b/include/llfio/v2.0/detail/impl/windows/stat.ipp index f662c458..91e2ce4c 100644 --- a/include/llfio/v2.0/detail/impl/windows/stat.ipp +++ b/include/llfio/v2.0/detail/impl/windows/stat.ipp @@ -126,13 +126,18 @@ LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<size_t> stat_t::fill(const handle &h, sta return win32_error(); } buffer_[len] = 0; - if(memcmp(buffer_, L"\\Device\\HarddiskVolume", 44) != 0) + const bool is_harddisk = (memcmp(buffer_, L"\\Device\\HarddiskVolume", 44) == 0); + const bool is_unc = (memcmp(buffer_, L"\\Device\\Mup", 22) == 0); + if(!is_harddisk && !is_unc) { return errc::illegal_byte_sequence; } - // buffer_ should look like \Device\HarddiskVolumeX, so our number is from +22 onwards - st_dev = _wtoi(buffer_ + 22); - ++ret; + if(is_harddisk) + { + // buffer_ should look like \Device\HarddiskVolumeX, so our number is from +22 onwards + st_dev = _wtoi(buffer_ + 22); + ++ret; + } } if(wanted & want::ino) { diff --git a/include/llfio/v2.0/detail/impl/windows/statfs.ipp b/include/llfio/v2.0/detail/impl/windows/statfs.ipp index 5ca3d9a7..8b23b4e1 100644 --- a/include/llfio/v2.0/detail/impl/windows/statfs.ipp +++ b/include/llfio/v2.0/detail/impl/windows/statfs.ipp @@ -1,5 +1,5 @@ /* Information about the volume storing a file -(C) 2015-2017 Niall Douglas <http://www.nedproductions.biz/> (6 commits) +(C) 2015-2020 Niall Douglas <http://www.nedproductions.biz/> (6 commits) File Created: Dec 2015 @@ -79,7 +79,7 @@ LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<size_t> statfs_t::fill(const handle &h, s { auto *fffsi = reinterpret_cast<FILE_FS_FULL_SIZE_INFORMATION *>(buffer); isb.Status = -1; - ntstat = NtQueryVolumeInformationFile(h.native_handle().h, &isb, fffsi, sizeof(buffer), FileFsFullSizeInformation); + ntstat = NtQueryVolumeInformationFile(h.native_handle().h, &isb, fffsi, sizeof(FILE_FS_FULL_SIZE_INFORMATION), FileFsFullSizeInformation); if(STATUS_PENDING == ntstat) { ntstat = ntwait(h.native_handle().h, isb, deadline()); @@ -113,7 +113,7 @@ LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<size_t> statfs_t::fill(const handle &h, s { auto *ffoi = reinterpret_cast<FILE_FS_OBJECTID_INFORMATION *>(buffer); isb.Status = -1; - ntstat = NtQueryVolumeInformationFile(h.native_handle().h, &isb, ffoi, sizeof(buffer), FileFsObjectIdInformation); + ntstat = NtQueryVolumeInformationFile(h.native_handle().h, &isb, ffoi, sizeof(FILE_FS_OBJECTID_INFORMATION), FileFsObjectIdInformation); if(STATUS_PENDING == ntstat) { ntstat = ntwait(h.native_handle().h, isb, deadline()); @@ -129,7 +129,7 @@ LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<size_t> statfs_t::fill(const handle &h, s { auto *ffssi = reinterpret_cast<FILE_FS_SECTOR_SIZE_INFORMATION *>(buffer); isb.Status = -1; - ntstat = NtQueryVolumeInformationFile(h.native_handle().h, &isb, ffssi, sizeof(buffer), FileFsSectorSizeInformation); + ntstat = NtQueryVolumeInformationFile(h.native_handle().h, &isb, ffssi, sizeof(FILE_FS_SECTOR_SIZE_INFORMATION), FileFsSectorSizeInformation); if(STATUS_PENDING == ntstat) { ntstat = ntwait(h.native_handle().h, isb, deadline()); @@ -165,17 +165,58 @@ LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<size_t> statfs_t::fill(const handle &h, s { continue; // path changed } - len -= pathlen; - // buffer should look like \Device\HarddiskVolumeX - if(memcmp(buffer, L"\\Device\\HarddiskVolume", 44) != 0) + // buffer should look like \Device\HarddiskVolumeX or \Device\Mup\SERVER\SHARE + const bool is_harddisk = (memcmp(buffer, L"\\Device\\HarddiskVolume", 44) == 0); + const bool is_unc = (memcmp(buffer, L"\\Device\\Mup", 22) == 0); + if(!is_harddisk && !is_unc) { return errc::illegal_byte_sequence; } - f_mntfromname.reserve(len + 3); - f_mntfromname.assign("\\!!"); // escape prefix for NT kernel path - for(size_t n = 0; n < len; n++) + if(is_harddisk) + { + len -= pathlen; + f_mntfromname.reserve(len + 3); + f_mntfromname.assign("\\!!"); // escape prefix for NT kernel path + for(size_t n = 0; n < len; n++) + { + f_mntfromname.push_back(static_cast<char>(buffer[n])); + } + } + if(is_unc) { - f_mntfromname.push_back(static_cast<char>(buffer[n])); +#if 1 + len -= pathlen - 1; + f_mntfromname.reserve(len + 3); + f_mntfromname.assign("\\!!"); // escape prefix for NT kernel path + while(buffer[len] != '\\') + { + len++; + } + len++; + while(buffer[len] != '\\') + { + len++; + } + for(size_t n = 0; n < len; n++) + { + f_mntfromname.push_back(static_cast<char>(buffer[n])); + } +#else + f_mntfromname.reserve(pathlen + 1); + f_mntfromname.assign("\\\\?\\UNC"); + int count = 3; + for(size_t n = 0; n < pathlen; n++) + { + if(buffer2[n] == '\\') + { + if(--count == 0) + { + break; + } + } + f_mntfromname.push_back(static_cast<char>(buffer2[n])); + } +#endif } ++ret; wanted &= ~want::mntfromname; diff --git a/include/llfio/v2.0/detail/impl/windows/storage_profile.ipp b/include/llfio/v2.0/detail/impl/windows/storage_profile.ipp index 82bddd3b..b15effbc 100644 --- a/include/llfio/v2.0/detail/impl/windows/storage_profile.ipp +++ b/include/llfio/v2.0/detail/impl/windows/storage_profile.ipp @@ -223,6 +223,11 @@ namespace storage_profile { try { + if(memcmp(_mntfromname.c_str(), "\\!!\\Device\\Mup", 14) == 0 || memcmp(_mntfromname.c_str(), "\\\\", 2) == 0) + { + sp.controller_type.value = "Network"; + return success(); + } alignas(8) wchar_t buffer[32769]; // Firstly open a handle to the volume OUTCOME_TRY(volumeh, file_handle::file({}, _mntfromname, handle::mode::none, handle::creation::open_existing, handle::caching::only_metadata)); @@ -360,7 +365,7 @@ namespace storage_profile { if(ERROR_IO_PENDING == GetLastError()) { - NTSTATUS ntstat = ntwait(volumeh.native_handle().h, ol, deadline()); + NTSTATUS ntstat = ntwait(diskh.native_handle().h, ol, deadline()); if(ntstat != 0) { return ntkernel_error(ntstat); @@ -413,7 +418,7 @@ namespace storage_profile { if(ERROR_IO_PENDING == GetLastError()) { - NTSTATUS ntstat = ntwait(volumeh.native_handle().h, ol, deadline()); + NTSTATUS ntstat = ntwait(diskh.native_handle().h, ol, deadline()); if(ntstat != 0) { return ntkernel_error(ntstat); diff --git a/include/llfio/v2.0/mapped_file_handle.hpp b/include/llfio/v2.0/mapped_file_handle.hpp index b560af83..6286d40c 100644 --- a/include/llfio/v2.0/mapped_file_handle.hpp +++ b/include/llfio/v2.0/mapped_file_handle.hpp @@ -423,7 +423,7 @@ public: the call to `update_map()`, this call is not particularly efficient, and you ought to cache its value where possible. */ - LLFIO_HEADERS_ONLY_VIRTUAL_SPEC result<extent_type> maximum_extent() const noexcept override { return const_cast<mapped_file_handle *>(this)->update_map(); } + LLFIO_HEADERS_ONLY_VIRTUAL_SPEC result<extent_type> maximum_extent() const noexcept override { return (0 == _reservation) ? underlying_file_maximum_extent() : const_cast<mapped_file_handle *>(this)->update_map(); } /*! \brief Resize the current maximum permitted extent of the mapped file to the given extent, avoiding any new allocation of physical storage where supported, and mapping or unmapping any new pages diff --git a/include/llfio/v2.0/storage_profile.hpp b/include/llfio/v2.0/storage_profile.hpp index d93eab49..32c8601d 100644 --- a/include/llfio/v2.0/storage_profile.hpp +++ b/include/llfio/v2.0/storage_profile.hpp @@ -1,5 +1,5 @@ /* A profile of an OS and filing system -(C) 2015-2017 Niall Douglas <http://www.nedproductions.biz/> (7 commits) +(C) 2015-2020 Niall Douglas <http://www.nedproductions.biz/> (7 commits) File Created: Dec 2015 |