Skip to content

Commit cf92fe0

Browse files
authored
Update to windows-sys 0.52.0. (#338)
* Update to windows-sys 0.52.0. * Fix somoe warnings. * Fix a race condition in `remove_open_dir_by_searching`. When searching for a directory in its parent, ignore `NOENT` errors, which can happen when another process is removing directories in the same parent.
1 parent 3663202 commit cf92fe0

File tree

9 files changed

+46
-25
lines changed

9 files changed

+46
-25
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ rustix = { version = "0.38.0", features = ["fs"] }
4141
nt_version = "0.1.3"
4242

4343
[target.'cfg(windows)'.dependencies.windows-sys]
44-
version = "0.48.0"
44+
version = "0.52.0"
4545
features = [
4646
"Win32_Storage_FileSystem",
4747
"Win32_Foundation",

cap-directories/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ directories-next = "2.0.0"
2020
rustix = { version = "0.38.0" }
2121

2222
[target.'cfg(windows)'.dependencies.windows-sys]
23-
version = "0.48.0"
23+
version = "0.52.0"
2424
features = [
2525
"Win32_Foundation",
2626
]

cap-fs-ext/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ std = ["cap-std"]
3333
#async_std_arf_strings = ["cap-async-std/arf_strings", "async_std_fs_utf8", "arf-strings"]
3434

3535
[target.'cfg(windows)'.dependencies.windows-sys]
36-
version = "0.48.0"
36+
version = "0.52.0"
3737
features = [
3838
"Win32_Storage_FileSystem",
3939
]

cap-primitives/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ rustix = { version = "0.38.0", features = ["fs", "process", "procfs", "termios",
3131
winx = "0.36.0"
3232

3333
[target.'cfg(windows)'.dependencies.windows-sys]
34-
version = "0.48.0"
34+
version = "0.52.0"
3535
features = [
3636
"Win32_Foundation",
3737
"Win32_Security",
3838
"Win32_Storage_FileSystem",
3939
"Win32_System_Kernel",
4040
"Win32_System_WindowsProgramming",
41+
"Win32_System_IO",
42+
"Wdk_Storage_FileSystem",
43+
"Wdk_Foundation",
4144
]

cap-primitives/src/rustix/fs/remove_open_dir_by_searching.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,17 @@ pub(crate) fn remove_open_dir_by_searching(dir: fs::File) -> io::Result<()> {
1010
let mut iter = read_dir_unchecked(&dir, Component::ParentDir.as_ref(), FollowSymlinks::No)?;
1111
while let Some(child) = iter.next() {
1212
let child = child?;
13-
if child.is_same_file(&metadata)? {
13+
14+
// Test if the child we found by iteration matches the directory we're
15+
// looking for. Ignore `NotFound` errors, which can happen if another
16+
// process removes a different directory in the same parent.
17+
let same = match child.is_same_file(&metadata) {
18+
Ok(same) => same,
19+
Err(err) if err.kind() == std::io::ErrorKind::NotFound => false,
20+
Err(err) => Err(err)?,
21+
};
22+
23+
if same {
1424
return child.remove_dir();
1525
}
1626
}

cap-primitives/src/windows/fs/create_file_at_w.rs

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
use std::mem;
44
use std::os::windows::io::HandleOrInvalid;
55
use std::ptr::null_mut;
6+
use windows_sys::Wdk::Foundation::OBJECT_ATTRIBUTES;
7+
use windows_sys::Wdk::Storage::FileSystem::{
8+
NtCreateFile, FILE_CREATE, FILE_DELETE_ON_CLOSE, FILE_NON_DIRECTORY_FILE,
9+
FILE_NO_INTERMEDIATE_BUFFERING, FILE_OPEN, FILE_OPEN_FOR_BACKUP_INTENT, FILE_OPEN_IF,
10+
FILE_OPEN_REPARSE_POINT, FILE_OVERWRITE, FILE_OVERWRITE_IF, FILE_RANDOM_ACCESS,
11+
FILE_SEQUENTIAL_ONLY, FILE_SYNCHRONOUS_IO_NONALERT, FILE_WRITE_THROUGH,
12+
};
613
use windows_sys::Win32::Foundation::{
714
RtlNtStatusToDosError, SetLastError, ERROR_ALREADY_EXISTS, ERROR_FILE_EXISTS,
815
ERROR_INVALID_NAME, ERROR_INVALID_PARAMETER, ERROR_NOT_SUPPORTED, GENERIC_ALL, GENERIC_READ,
@@ -14,29 +21,26 @@ use windows_sys::Win32::Security::{
1421
SECURITY_STATIC_TRACKING,
1522
};
1623
use windows_sys::Win32::Storage::FileSystem::{
17-
NtCreateFile, CREATE_ALWAYS, CREATE_NEW, DELETE, FILE_ATTRIBUTE_ARCHIVE,
18-
FILE_ATTRIBUTE_COMPRESSED, FILE_ATTRIBUTE_DEVICE, FILE_ATTRIBUTE_DIRECTORY, FILE_ATTRIBUTE_EA,
19-
FILE_ATTRIBUTE_ENCRYPTED, FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_INTEGRITY_STREAM,
20-
FILE_ATTRIBUTE_NORMAL, FILE_ATTRIBUTE_NOT_CONTENT_INDEXED, FILE_ATTRIBUTE_NO_SCRUB_DATA,
21-
FILE_ATTRIBUTE_OFFLINE, FILE_ATTRIBUTE_PINNED, FILE_ATTRIBUTE_READONLY,
22-
FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS, FILE_ATTRIBUTE_RECALL_ON_OPEN,
23-
FILE_ATTRIBUTE_REPARSE_POINT, FILE_ATTRIBUTE_SPARSE_FILE, FILE_ATTRIBUTE_SYSTEM,
24-
FILE_ATTRIBUTE_TEMPORARY, FILE_ATTRIBUTE_UNPINNED, FILE_ATTRIBUTE_VIRTUAL, FILE_CREATE,
25-
FILE_CREATION_DISPOSITION, FILE_FLAGS_AND_ATTRIBUTES, FILE_FLAG_BACKUP_SEMANTICS,
26-
FILE_FLAG_DELETE_ON_CLOSE, FILE_FLAG_NO_BUFFERING, FILE_FLAG_OPEN_NO_RECALL,
27-
FILE_FLAG_OPEN_REPARSE_POINT, FILE_FLAG_OVERLAPPED, FILE_FLAG_POSIX_SEMANTICS,
28-
FILE_FLAG_RANDOM_ACCESS, FILE_FLAG_SEQUENTIAL_SCAN, FILE_FLAG_SESSION_AWARE,
29-
FILE_FLAG_WRITE_THROUGH, FILE_OPEN, FILE_OPEN_IF, FILE_OVERWRITE, FILE_OVERWRITE_IF,
30-
FILE_READ_ATTRIBUTES, FILE_SHARE_MODE, OPEN_ALWAYS, OPEN_EXISTING, SECURITY_CONTEXT_TRACKING,
31-
SECURITY_EFFECTIVE_ONLY, SECURITY_SQOS_PRESENT, SYNCHRONIZE, TRUNCATE_EXISTING,
24+
CREATE_ALWAYS, CREATE_NEW, DELETE, FILE_ATTRIBUTE_ARCHIVE, FILE_ATTRIBUTE_COMPRESSED,
25+
FILE_ATTRIBUTE_DEVICE, FILE_ATTRIBUTE_DIRECTORY, FILE_ATTRIBUTE_EA, FILE_ATTRIBUTE_ENCRYPTED,
26+
FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_INTEGRITY_STREAM, FILE_ATTRIBUTE_NORMAL,
27+
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED, FILE_ATTRIBUTE_NO_SCRUB_DATA, FILE_ATTRIBUTE_OFFLINE,
28+
FILE_ATTRIBUTE_PINNED, FILE_ATTRIBUTE_READONLY, FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS,
29+
FILE_ATTRIBUTE_RECALL_ON_OPEN, FILE_ATTRIBUTE_REPARSE_POINT, FILE_ATTRIBUTE_SPARSE_FILE,
30+
FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_TEMPORARY, FILE_ATTRIBUTE_UNPINNED,
31+
FILE_ATTRIBUTE_VIRTUAL, FILE_CREATION_DISPOSITION, FILE_FLAGS_AND_ATTRIBUTES,
32+
FILE_FLAG_BACKUP_SEMANTICS, FILE_FLAG_DELETE_ON_CLOSE, FILE_FLAG_NO_BUFFERING,
33+
FILE_FLAG_OPEN_NO_RECALL, FILE_FLAG_OPEN_REPARSE_POINT, FILE_FLAG_OVERLAPPED,
34+
FILE_FLAG_POSIX_SEMANTICS, FILE_FLAG_RANDOM_ACCESS, FILE_FLAG_SEQUENTIAL_SCAN,
35+
FILE_FLAG_SESSION_AWARE, FILE_FLAG_WRITE_THROUGH, FILE_READ_ATTRIBUTES, FILE_SHARE_MODE,
36+
OPEN_ALWAYS, OPEN_EXISTING, SECURITY_CONTEXT_TRACKING, SECURITY_EFFECTIVE_ONLY,
37+
SECURITY_SQOS_PRESENT, SYNCHRONIZE, TRUNCATE_EXISTING,
3238
};
3339
use windows_sys::Win32::System::Kernel::{OBJ_CASE_INSENSITIVE, OBJ_INHERIT};
3440
use windows_sys::Win32::System::WindowsProgramming::{
35-
FILE_DELETE_ON_CLOSE, FILE_NON_DIRECTORY_FILE, FILE_NO_INTERMEDIATE_BUFFERING, FILE_OPENED,
36-
FILE_OPEN_FOR_BACKUP_INTENT, FILE_OPEN_NO_RECALL, FILE_OPEN_REMOTE_INSTANCE,
37-
FILE_OPEN_REPARSE_POINT, FILE_OVERWRITTEN, FILE_RANDOM_ACCESS, FILE_SEQUENTIAL_ONLY,
38-
FILE_SYNCHRONOUS_IO_NONALERT, FILE_WRITE_THROUGH, IO_STATUS_BLOCK, OBJECT_ATTRIBUTES,
41+
FILE_OPENED, FILE_OPEN_NO_RECALL, FILE_OPEN_REMOTE_INSTANCE, FILE_OVERWRITTEN,
3942
};
43+
use windows_sys::Win32::System::IO::IO_STATUS_BLOCK;
4044

4145
// All currently known `FILE_ATTRIBUTE_*` constants, according to
4246
// windows-sys' documentation.

cap-tempfile/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ rand = "0.8.1"
2424
rustix = { version = "0.38.0", features = ["procfs"] }
2525

2626
[target.'cfg(windows)'.dev-dependencies.windows-sys]
27-
version = "0.48.0"
27+
version = "0.52.0"
2828
features = [
2929
"Win32_Foundation",
3030
]

tests/sys/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(unused_imports)]
2+
13
#[cfg(unix)]
24
mod unix;
35

tests/sys_common/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(unused_imports)]
2+
13
mod symlink_junction;
24

35
pub mod io;

0 commit comments

Comments
 (0)