Skip to content

Commit 69a3cf4

Browse files
committed
Rename cap-primitives' link to hard_link.
1 parent 87a22f9 commit 69a3cf4

File tree

11 files changed

+32
-32
lines changed

11 files changed

+32
-32
lines changed

cap-async-std/src/fs/dir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use async_std::os::wasi::{
66
};
77
use async_std::{fs, io};
88
use cap_primitives::fs::{
9-
canonicalize, copy, link, mkdir, open, open_ambient_dir, open_dir, read_dir, readlink,
9+
canonicalize, copy, hard_link, mkdir, open, open_ambient_dir, open_dir, read_dir, readlink,
1010
remove_dir_all, remove_open_dir, remove_open_dir_all, rename, rmdir, set_permissions, stat,
1111
unlink, DirOptions, FollowSymlinks, Permissions,
1212
};
@@ -235,7 +235,7 @@ impl Dir {
235235
) -> io::Result<()> {
236236
let src_file = unsafe { as_sync(&self.std_file) };
237237
let dst_file = unsafe { as_sync(&dst_dir.std_file) };
238-
link(&src_file, src.as_ref(), &dst_file, dst.as_ref())
238+
hard_link(&src_file, src.as_ref(), &dst_file, dst.as_ref())
239239
}
240240

241241
/// Given a path, query the file system to get information about a file, directory, etc.

cap-primitives/src/fs/link.rs renamed to cap-primitives/src/fs/hard_link.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
//! This defines `link`, the primary entrypoint to sandboxed hard-link creation.
1+
//! This defines `hard_link`, the primary entrypoint to sandboxed hard-link creation.
22
3-
use crate::fs::link_impl;
3+
use crate::fs::hard_link_impl;
44
#[cfg(racy_asserts)]
55
use crate::fs::{
6-
canonicalize, link_unchecked, map_result, stat_unchecked, FollowSymlinks, Metadata,
6+
canonicalize, hard_link_unchecked, map_result, stat_unchecked, FollowSymlinks, Metadata,
77
};
88
use std::{fs, io, path::Path};
99

1010
/// Perform a `linkat`-like operation, ensuring that the resolution of the path
1111
/// never escapes the directory tree rooted at `start`.
1212
#[cfg_attr(not(racy_asserts), allow(clippy::let_and_return))]
1313
#[inline]
14-
pub fn link(
14+
pub fn hard_link(
1515
old_start: &fs::File,
1616
old_path: &Path,
1717
new_start: &fs::File,
@@ -24,7 +24,7 @@ pub fn link(
2424
);
2525

2626
// Call the underlying implementation.
27-
let result = link_impl(old_start, old_path, new_start, new_path);
27+
let result = hard_link_impl(old_start, old_path, new_start, new_path);
2828

2929
#[cfg(racy_asserts)]
3030
let (old_metadata_after, new_metadata_after) = (
@@ -33,7 +33,7 @@ pub fn link(
3333
);
3434

3535
#[cfg(racy_asserts)]
36-
check_link(
36+
check_hard_link(
3737
old_start,
3838
old_path,
3939
new_start,
@@ -51,7 +51,7 @@ pub fn link(
5151
#[cfg(racy_asserts)]
5252
#[allow(clippy::too_many_arguments)]
5353
#[allow(clippy::enum_glob_use)]
54-
fn check_link(
54+
fn check_hard_link(
5555
old_start: &fs::File,
5656
old_path: &Path,
5757
new_start: &fs::File,
@@ -90,7 +90,7 @@ fn check_link(
9090
map_result(&canonicalize(old_start, old_path)),
9191
map_result(&canonicalize(new_start, new_path)),
9292
) {
93-
(Ok(old_canon), Ok(new_canon)) => match map_result(&link_unchecked(
93+
(Ok(old_canon), Ok(new_canon)) => match map_result(&hard_link_unchecked(
9494
old_start, &old_canon, new_start, &new_canon,
9595
)) {
9696
Err((_unchecked_kind, _unchecked_message)) => {

cap-primitives/src/fs/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ mod dir_options;
1414
mod file_path_by_searching;
1515
mod file_type;
1616
mod follow_symlinks;
17+
mod hard_link;
1718
mod is_read_write;
18-
mod link;
1919
mod maybe_owned_file;
2020
mod metadata;
2121
mod mkdir;
@@ -60,8 +60,8 @@ pub use dir_entry::*;
6060
pub use dir_options::*;
6161
pub use file_type::*;
6262
pub use follow_symlinks::*;
63+
pub use hard_link::*;
6364
pub use is_read_write::is_read_write;
64-
pub use link::*;
6565
pub use metadata::*;
6666
pub use mkdir::*;
6767
pub use open::*;

cap-primitives/src/fs/via_parent/link.rs renamed to cap-primitives/src/fs/via_parent/hard_link.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use super::open_parent;
2-
use crate::fs::{link_unchecked, MaybeOwnedFile};
2+
use crate::fs::{hard_link_unchecked, MaybeOwnedFile};
33
use std::{fs, io, path::Path};
44

5-
/// Implement `link` by `open`ing up the parent component of the path and then
6-
/// calling `link_unchecked` on the last component.
7-
pub(crate) fn link(
5+
/// Implement `hard_link` by `open`ing up the parent component of the path and
6+
/// then calling `hard_link_unchecked` on the last component.
7+
pub(crate) fn hard_link(
88
old_start: &fs::File,
99
old_path: &Path,
1010
new_start: &fs::File,
@@ -16,7 +16,7 @@ pub(crate) fn link(
1616
let (old_dir, old_basename) = open_parent(old_start, old_path)?;
1717
let (new_dir, new_basename) = open_parent(new_start, new_path)?;
1818

19-
link_unchecked(
19+
hard_link_unchecked(
2020
&old_dir,
2121
old_basename.as_ref(),
2222
&new_dir,

cap-primitives/src/fs/via_parent/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! in `mkdir`, the last component names the path to be created, while the
33
//! rest of the components just name the place to create it in.
44
5-
mod link;
5+
mod hard_link;
66
mod mkdir;
77
mod open_parent;
88
#[cfg(not(windows))] // doesn't work on windows; use a windows-specific impl
@@ -18,7 +18,7 @@ mod unlink;
1818

1919
use open_parent::open_parent;
2020

21-
pub(crate) use link::link;
21+
pub(crate) use hard_link::hard_link;
2222
pub(crate) use mkdir::mkdir;
2323
#[cfg(not(windows))] // doesn't work on windows; use a windows-specific impl
2424
pub(crate) use readlink::readlink;

cap-primitives/src/posish/fs/link_unchecked.rs renamed to cap-primitives/src/posish/fs/hard_link_unchecked.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use posish::fs::{linkat, AtFlags};
22
use std::{fs, io, path::Path};
33

4-
/// *Unsandboxed* function similar to `link`, but which does not perform sandboxing.
4+
/// *Unsandboxed* function similar to `hard_link`, but which does not perform sandboxing.
55
///
66
/// Even though POSIX `linkat` has the ability to follow symlinks in `old_path`,
77
/// using `AT_SYMLINK_FOLLOW`, Rust's `hard_link` doesn't need that, so we don't
88
/// expose it here.
9-
pub(crate) fn link_unchecked(
9+
pub(crate) fn hard_link_unchecked(
1010
old_start: &fs::File,
1111
old_path: &Path,
1212
new_start: &fs::File,

cap-primitives/src/posish/fs/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ mod dir_entry_inner;
44
mod dir_options_ext;
55
mod dir_utils;
66
mod file_type_ext;
7+
mod hard_link_unchecked;
78
mod is_read_write_impl;
89
mod is_root_dir;
910
#[cfg(racy_asserts)]
1011
mod is_same_file;
11-
mod link_unchecked;
1212
mod metadata_ext;
1313
mod mkdir_unchecked;
1414
mod oflags;
@@ -62,7 +62,7 @@ pub(crate) use {set_permissions_impl::set_permissions_impl, set_times_impl::set_
6262

6363
#[rustfmt::skip]
6464
pub(crate) use crate::fs::{
65-
via_parent::link as link_impl,
65+
via_parent::hard_link as hard_link_impl,
6666
via_parent::mkdir as mkdir_impl,
6767
via_parent::readlink as readlink_impl,
6868
via_parent::rename as rename_impl,
@@ -79,11 +79,11 @@ pub(crate) use dir_entry_inner::*;
7979
pub(crate) use dir_options_ext::*;
8080
pub(crate) use dir_utils::*;
8181
pub(crate) use file_type_ext::*;
82+
pub(crate) use hard_link_unchecked::*;
8283
pub(crate) use is_read_write_impl::*;
8384
pub(crate) use is_root_dir::*;
8485
#[cfg(racy_asserts)]
8586
pub(crate) use is_same_file::*;
86-
pub(crate) use link_unchecked::*;
8787
pub(crate) use metadata_ext::*;
8888
pub(crate) use mkdir_unchecked::*;
8989
pub(crate) use open_options_ext::*;

cap-primitives/src/winx/fs/link_unchecked.rs renamed to cap-primitives/src/winx/fs/hard_link_unchecked.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use super::get_path::concatenate_or_return_absolute;
22
use std::{fs, io, path::Path};
33

4-
/// *Unsandboxed* function similar to `link`, but which does not perform sandboxing.
5-
pub(crate) fn link_unchecked(
4+
/// *Unsandboxed* function similar to `hard_link`, but which does not perform sandboxing.
5+
pub(crate) fn hard_link_unchecked(
66
old_start: &fs::File,
77
old_path: &Path,
88
new_start: &fs::File,

cap-primitives/src/winx/fs/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ mod dir_options_ext;
66
mod dir_utils;
77
mod file_type_ext;
88
mod get_path;
9+
mod hard_link_unchecked;
910
mod is_read_write_impl;
1011
#[cfg(racy_asserts)]
1112
mod is_same_file;
12-
mod link_unchecked;
1313
mod metadata_ext;
1414
mod mkdir_unchecked;
1515
mod oflags;
@@ -33,7 +33,7 @@ pub(crate) mod errors;
3333
#[rustfmt::skip]
3434
pub(crate) use crate::fs::{
3535
manually::canonicalize as canonicalize_impl,
36-
via_parent::link as link_impl,
36+
via_parent::hard_link as hard_link_impl,
3737
via_parent::mkdir as mkdir_impl,
3838
via_parent::rename as rename_impl,
3939
via_parent::rmdir as rmdir_impl,
@@ -50,10 +50,10 @@ pub(crate) use dir_entry_inner::*;
5050
pub(crate) use dir_options_ext::*;
5151
pub(crate) use dir_utils::*;
5252
pub(crate) use file_type_ext::*;
53+
pub(crate) use hard_link_unchecked::*;
5354
pub(crate) use is_read_write_impl::*;
5455
#[cfg(racy_asserts)]
5556
pub(crate) use is_same_file::*;
56-
pub(crate) use link_unchecked::*;
5757
pub(crate) use manually::open as open_impl;
5858
pub(crate) use metadata_ext::*;
5959
pub(crate) use mkdir_unchecked::*;

cap-std/src/fs/dir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::fs::{DirBuilder, File, Metadata, OpenOptions, ReadDir};
22
use cap_primitives::fs::{
3-
canonicalize, copy, link, mkdir, open, open_ambient_dir, open_dir, read_dir, readlink,
3+
canonicalize, copy, hard_link, mkdir, open, open_ambient_dir, open_dir, read_dir, readlink,
44
remove_dir_all, remove_open_dir, remove_open_dir_all, rename, rmdir, set_permissions, stat,
55
unlink, DirOptions, FollowSymlinks, Permissions,
66
};
@@ -225,7 +225,7 @@ impl Dir {
225225
dst_dir: &Self,
226226
dst: Q,
227227
) -> io::Result<()> {
228-
link(
228+
hard_link(
229229
&self.std_file,
230230
src.as_ref(),
231231
&dst_dir.std_file,

0 commit comments

Comments
 (0)