Skip to content

Commit

Permalink
*: comment fixes
Browse files Browse the repository at this point in the history
It turns out that I often forget to finish sentences when writing
comments while writing code and restructuring things... Oops...

Signed-off-by: Aleksa Sarai <[email protected]>
  • Loading branch information
cyphar committed Aug 30, 2024
1 parent f469501 commit 44276b1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/capi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#![allow(unsafe_code)]
// None of this code is reachable from rust, so including it in coverage doesn't
// make sense.
// TODO: We might want to test the cffi bindings from Rust at some point?
#![cfg_attr(coverage, coverage(off))]

/// Core pathrs function wrappers.
Expand Down
4 changes: 2 additions & 2 deletions src/resolvers/openat2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ pub(crate) fn resolve_partial<F: AsFd>(
// Fall back to returning (root, path) if there was no path found.
//
// TODO: In theory you should never hit this case because
// partial_ancestors() always returns a "root" value. This should probably
// be unreachable!()...
// partial_ancestors() always returns a "root" value. This should
// probably be unreachable!()...
Ok(PartialLookup::Partial {
handle: root
.try_clone_to_owned()
Expand Down
9 changes: 3 additions & 6 deletions src/resolvers/procfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
//! be used within the `pathrs::procfs` helpers that are used by other parts of
//! libpathrs.

// TODO: So much of this code is a copy of opath::resolver, maybe we can merge
// them somehow?

use crate::{
error::{Error, ErrorExt, ErrorImpl},
flags::{OpenFlags, ResolverFlags},
Expand Down Expand Up @@ -318,9 +315,9 @@ fn opath_resolve<F: AsFd, P: AsRef<Path>>(
// We need a limit on the number of symlinks we traverse to avoid
// hitting filesystem loops and DoSing.
//
// Given all of the other restrictions of this lookup code, it seems unlikely
// that you could even run into a symlink loop (procfs doesn't have
// regular symlink loops). But for procfs can
// Given all of the other restrictions of this lookup code, it seems
// unlikely that you could even run into a symlink loop (procfs doesn't
// have regular symlink loops) but we should avoid it just in case.
symlink_traversals += 1;
if symlink_traversals >= MAX_SYMLINK_TRAVERSALS {
Err(ErrorImpl::OsError {
Expand Down
7 changes: 2 additions & 5 deletions src/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,8 +776,8 @@ impl RootRef<'_> {
.and_then(TryInto::try_into)?;

// Re-open the handle with O_DIRECTORY to make sure it's a directory we
// can use as well as to make sure we return
// directoriy
// can use as well as to make sure we return an O_DIRECTORY regardless
// of whether there are any remaining components (for consistency).
let mut current = handle
.reopen(OpenFlags::O_DIRECTORY)
.with_wrap(|| format!("cannot create directories in {}", FrozenFd::from(handle)))?;
Expand Down Expand Up @@ -1092,9 +1092,6 @@ impl RootRef<'_> {
.into()
})
}

// TODO: implement a way to duplicate (and even serialise) Roots so that you
// can send them between processes (presumably with SCM_RIGHTS).
}

impl AsFd for RootRef<'_> {
Expand Down
8 changes: 4 additions & 4 deletions src/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ impl Error {
}
}

// XXX: We might want to switch to nix at some point, but the interfaces
// provided by nix are slightly non-ergonomic. I much prefer these simpler
// C-like bindings. We also have the ability to check for support of each
// syscall.
// TODO: We probably want to switch to rustix for most of these wrappers, though
// the interfaces provided by rustix are slightly non-ergonomic. I much
// prefer these simpler C-like bindings. We also have the ability to check
// for support of each syscall.

/// Wrapper for `fcntl(F_GETFD)` followed by `fcntl(F_SETFD)`, clearing the
/// `FD_CLOEXEC` bit.
Expand Down
1 change: 1 addition & 0 deletions src/tests/test_resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ macro_rules! resolve_tests {
}

resolve_tests! {
// Test the magic-link-related handling.
[Path::new("/proc")] {
proc_pseudo_magiclink: resolve("self/sched") => Ok(("{{/proc/self}}/sched", libc::S_IFREG));
proc_pseudo_magiclink_nosym1: resolve("self", rflags = NO_SYMLINKS) => Err(ErrorKind::OsError(Some(libc::ELOOP)));
Expand Down

0 comments on commit 44276b1

Please sign in to comment.