Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/llfio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2018-07-24 22:29:21 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2018-07-24 22:29:21 +0300
commit964d174c1c44d4810789b198bbf07271cebbe8c8 (patch)
treedc3d0ebb672e919caa2f9d2b8fb5654d230ae604 /include/llfio/v2.0/detail/impl/windows/directory_handle.ipp
parent084b3eb8aaae639e9a63e97245386fd78b8d8413 (diff)
i/o buffers now work as if they were span<byte>.
Implemented many of the missing functions in path_view. Implemented symlink_handle for Windows.
Diffstat (limited to 'include/llfio/v2.0/detail/impl/windows/directory_handle.ipp')
-rw-r--r--include/llfio/v2.0/detail/impl/windows/directory_handle.ipp46
1 files changed, 2 insertions, 44 deletions
diff --git a/include/llfio/v2.0/detail/impl/windows/directory_handle.ipp b/include/llfio/v2.0/detail/impl/windows/directory_handle.ipp
index abdd5a1e..158bbc7f 100644
--- a/include/llfio/v2.0/detail/impl/windows/directory_handle.ipp
+++ b/include/llfio/v2.0/detail/impl/windows/directory_handle.ipp
@@ -138,50 +138,8 @@ result<directory_handle> directory_handle::directory(const path_handle &base, pa
result<directory_handle> directory_handle::clone(mode mode_, caching caching_, deadline /* unused */) const noexcept
{
LLFIO_LOG_FUNCTION_CALL(this);
- // Fast path
- if(mode_ == mode::unchanged && caching_ == caching::unchanged)
- {
- result<directory_handle> ret(directory_handle(native_handle_type(), _devid, _inode, _caching, _flags));
- ret.value()._v.behaviour = _v.behaviour;
- if(DuplicateHandle(GetCurrentProcess(), _v.h, GetCurrentProcess(), &ret.value()._v.h, 0, 0, DUPLICATE_SAME_ACCESS) == 0)
- {
- return win32_error();
- }
- return ret;
- }
- // Slow path
- windows_nt_kernel::init();
- using namespace windows_nt_kernel;
- result<directory_handle> ret(directory_handle(native_handle_type(), _devid, _inode, caching_, _flags));
- native_handle_type &nativeh = ret.value()._v;
- nativeh.behaviour |= native_handle_type::disposition::directory;
- DWORD fileshare = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
- OUTCOME_TRY(access, access_mask_from_handle_mode(nativeh, mode_, _flags));
- OUTCOME_TRYV(attributes_from_handle_caching_and_flags(nativeh, caching_, _flags));
- /* It is super important that we remove the DELETE permission for directories as otherwise relative renames
- will always fail due to an unfortunate design choice by Microsoft.
- */
- access &= ~DELETE;
- OUTCOME_TRY(ntflags, ntflags_from_handle_caching_and_flags(nativeh, caching_, _flags));
- ntflags |= 0x01 /*FILE_DIRECTORY_FILE*/; // required to open a directory
- OBJECT_ATTRIBUTES oa{};
- memset(&oa, 0, sizeof(oa));
- oa.Length = sizeof(OBJECT_ATTRIBUTES);
- // It is entirely undocumented that this is how you clone a file handle with new privs
- UNICODE_STRING _path{};
- memset(&_path, 0, sizeof(_path));
- oa.ObjectName = &_path;
- oa.RootDirectory = _v.h;
- IO_STATUS_BLOCK isb = make_iostatus();
- NTSTATUS ntstat = NtOpenFile(&nativeh.h, access, &oa, &isb, fileshare, ntflags);
- if(STATUS_PENDING == ntstat)
- {
- ntstat = ntwait(nativeh.h, isb, deadline());
- }
- if(ntstat < 0)
- {
- return ntkernel_error(ntstat);
- }
+ result<directory_handle> ret(directory_handle(native_handle_type(), _devid, _inode, _caching, _flags));
+ OUTCOME_TRY(do_clone_handle(ret.value()._v, _v, mode_, caching_, _flags, true));
return ret;
}