-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix inability to open directory junctions on Windows using `symlink_h…
…andle` (issue #73).
- Loading branch information
Showing
5 changed files
with
95 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time | ||
#define LLFIO_PREVIOUS_COMMIT_REF 17d8156ac89e3b8c6aa19a14e0dd723bd65e0902 | ||
#define LLFIO_PREVIOUS_COMMIT_DATE "2021-03-09 09:38:56 +00:00" | ||
#define LLFIO_PREVIOUS_COMMIT_UNIQUE 17d8156a | ||
#define LLFIO_PREVIOUS_COMMIT_REF 545a722a055dcc38e7f80520a7a34008bfa9a86f | ||
#define LLFIO_PREVIOUS_COMMIT_DATE "2021-03-15 10:40:32 +00:00" | ||
#define LLFIO_PREVIOUS_COMMIT_UNIQUE 545a722a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* Integration test kernel for issue #73 Windows directory junctions cannot be opened with symlink_handle | ||
(C) 2021 Niall Douglas <http://www.nedproductions.biz/> (2 commits) | ||
File Created: Mar 2021 | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License in the accompanying file | ||
Licence.txt or at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
Distributed under the Boost Software License, Version 1.0. | ||
(See accompanying file Licence.txt or copy at | ||
http://www.boost.org/LICENSE_1_0.txt) | ||
*/ | ||
|
||
#include "../test_kernel_decl.hpp" | ||
|
||
static inline void TestIssue0073() | ||
{ | ||
#ifndef _WIN32 | ||
return; | ||
#endif | ||
namespace llfio = LLFIO_V2_NAMESPACE; | ||
|
||
auto tempdirh = llfio::temp_directory().value(); | ||
auto untempdir = llfio::make_scope_exit([&]() noexcept { (void) llfio::algorithm::reduce(std::move(tempdirh)); }); | ||
std::cout << "NOTE: Test directory can be found at " << tempdirh.current_path().value() << std::endl; | ||
|
||
// Test windows junctions | ||
{ | ||
auto dirh = | ||
llfio::directory_handle::directory(tempdirh, "testjunction", llfio::symlink_handle::mode::write, llfio::symlink_handle::creation::if_needed).value(); | ||
auto h = llfio::symlink_handle::symlink(dirh, {}, llfio::symlink_handle::mode::write).value(); | ||
h.write({llfio::symlink_handle::const_buffers_type("linkcontent", llfio::symlink_handle::symlink_type::win_junction)}).value(); | ||
auto rb = h.read().value(); | ||
BOOST_CHECK(rb.type() == llfio::symlink_handle::symlink_type::win_junction); | ||
BOOST_CHECK(rb.path().path() == "linkcontent"); | ||
h.unlink().value(); | ||
} | ||
|
||
// Test normal symbolic links | ||
{ | ||
auto h_ = llfio::symlink_handle::symlink(tempdirh, "testlink", llfio::symlink_handle::mode::write, llfio::symlink_handle::creation::if_needed); | ||
if(!h_ && h_.error() == llfio::errc::function_not_supported) | ||
{ | ||
std::cout << "NOTE: Failed to create symbolic link, assuming lack of SeCreateSymbolicLinkPrivilege privileges." << std::endl; | ||
return; | ||
} | ||
auto h = std::move(h_).value(); | ||
h.write("linkcontent").value(); | ||
auto rb = h.read().value(); | ||
BOOST_CHECK(rb.type() == llfio::symlink_handle::symlink_type::symbolic); | ||
BOOST_CHECK(rb.path().path() == "linkcontent"); | ||
h.unlink().value(); | ||
} | ||
} | ||
|
||
KERNELTEST_TEST_KERNEL(regression, llfio, issues, 0073, "Tests issue #0073 Windows directory junctions cannot be opened with symlink_handle", TestIssue0073()) |