diff --git a/src/capi/mod.rs b/src/capi.rs similarity index 100% rename from src/capi/mod.rs rename to src/capi.rs diff --git a/src/capi/procfs.rs b/src/capi/procfs.rs index 50359d1d..b6e660d6 100644 --- a/src/capi/procfs.rs +++ b/src/capi/procfs.rs @@ -24,10 +24,7 @@ use crate::{ procfs::{ProcfsBase, GLOBAL_PROCFS_HANDLE}, }; -use std::{ - convert::TryFrom, - os::unix::io::{OwnedFd, RawFd}, -}; +use std::os::unix::io::{OwnedFd, RawFd}; use libc::{c_char, c_int, size_t}; use open_enum::open_enum; diff --git a/src/flags.rs b/src/flags.rs index 5d4ed7ea..9521ecc4 100644 --- a/src/flags.rs +++ b/src/flags.rs @@ -23,6 +23,8 @@ use crate::syscalls; +use bitflags::bitflags; + bitflags! { /// Wrapper for the underlying `libc`'s `O_*` flags. /// diff --git a/src/lib.rs b/src/lib.rs index 40958b87..0ee5dc5a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -151,10 +151,6 @@ // #![cfg_attr(coverage, feature(coverage_attribute))] -#[macro_use] -extern crate bitflags; -extern crate libc; - // `Handle` implementation. mod handle; #[doc(inline)] diff --git a/src/resolvers/mod.rs b/src/resolvers.rs similarity index 97% rename from src/resolvers/mod.rs rename to src/resolvers.rs index 80b9af15..9e88bca5 100644 --- a/src/resolvers/mod.rs +++ b/src/resolvers.rs @@ -36,9 +36,17 @@ use std::{ use once_cell::sync::Lazy; /// `O_PATH`-based userspace resolver. -pub(crate) mod opath; +pub(crate) mod opath { + mod r#impl; + pub(crate) use r#impl::*; + + mod symlink_stack; + pub(crate) use symlink_stack::{SymlinkStack, SymlinkStackError}; +} + /// `openat2(2)`-based in-kernel resolver. pub(crate) mod openat2; + /// A limited resolver only used for `/proc` lookups in `ProcfsHandle`. pub(crate) mod procfs; diff --git a/src/resolvers/opath/mod.rs b/src/resolvers/opath/mod.rs deleted file mode 100644 index 6b863f96..00000000 --- a/src/resolvers/opath/mod.rs +++ /dev/null @@ -1,24 +0,0 @@ -/* - * libpathrs: safe path resolution on Linux - * Copyright (C) 2019-2024 Aleksa Sarai - * Copyright (C) 2019-2024 SUSE LLC - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -mod r#impl; -pub(crate) use r#impl::*; - -mod symlink_stack; -pub(crate) use symlink_stack::{SymlinkStack, SymlinkStackError}; diff --git a/src/syscalls.rs b/src/syscalls.rs index b2923f23..9d83c6d6 100644 --- a/src/syscalls.rs +++ b/src/syscalls.rs @@ -37,6 +37,7 @@ use std::{ path::{Path, PathBuf}, }; +use bitflags::bitflags; use once_cell::sync::Lazy; use rustix::{ fs::{ diff --git a/src/tests/mod.rs b/src/tests.rs similarity index 52% rename from src/tests/mod.rs rename to src/tests.rs index b19a7ec1..d6368e43 100644 --- a/src/tests/mod.rs +++ b/src/tests.rs @@ -17,11 +17,48 @@ * along with this program. If not, see . */ -pub(crate) mod common; +pub(crate) mod common { + mod root; + pub(crate) use root::*; + + mod mntns; + pub(in crate::tests) use mntns::*; + + mod handle; + pub(in crate::tests) use handle::*; +} #[cfg(feature = "capi")] -pub(in crate::tests) mod capi; -pub(in crate::tests) mod traits; +#[allow(unsafe_code)] +pub(in crate::tests) mod capi { + mod utils; + + mod root; + pub(in crate::tests) use root::*; + + mod handle; + pub(in crate::tests) use handle::*; + + mod procfs; + pub(in crate::tests) use procfs::*; +} + +pub(in crate::tests) mod traits { + // TODO: Unless we can figure out a way to get Deref working, we might want + // to have these traits be included in the actual library... + + mod root; + pub(in crate::tests) use root::*; + + mod handle; + pub(in crate::tests) use handle::*; + + mod procfs; + pub(in crate::tests) use procfs::*; + + mod error; + pub(in crate::tests) use error::*; +} mod test_procfs; mod test_resolve; diff --git a/src/tests/capi/mod.rs b/src/tests/capi/mod.rs deleted file mode 100644 index 0f8968d9..00000000 --- a/src/tests/capi/mod.rs +++ /dev/null @@ -1,31 +0,0 @@ -/* - * libpathrs: safe path resolution on Linux - * Copyright (C) 2019-2024 Aleksa Sarai - * Copyright (C) 2019-2024 SUSE LLC - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -#![allow(unsafe_code)] - -mod utils; - -mod root; -pub(in crate::tests) use root::*; - -mod handle; -pub(in crate::tests) use handle::*; - -mod procfs; -pub(in crate::tests) use procfs::*; diff --git a/src/tests/common/mod.rs b/src/tests/common/mod.rs deleted file mode 100644 index 3d515360..00000000 --- a/src/tests/common/mod.rs +++ /dev/null @@ -1,27 +0,0 @@ -/* - * libpathrs: safe path resolution on Linux - * Copyright (C) 2019-2024 Aleksa Sarai - * Copyright (C) 2019-2024 SUSE LLC - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -mod root; -pub(crate) use root::*; - -mod mntns; -pub(in crate::tests) use mntns::*; - -mod handle; -pub(in crate::tests) use handle::*; diff --git a/src/tests/traits/mod.rs b/src/tests/traits/mod.rs deleted file mode 100644 index b3200ac4..00000000 --- a/src/tests/traits/mod.rs +++ /dev/null @@ -1,33 +0,0 @@ -/* - * libpathrs: safe path resolution on Linux - * Copyright (C) 2019-2024 Aleksa Sarai - * Copyright (C) 2019-2024 SUSE LLC - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -// TODO: Unless we can figure out a way to get Deref working, we might want to -// have these traits be included in the actual library... - -mod root; -pub(in crate::tests) use root::*; - -mod handle; -pub(in crate::tests) use handle::*; - -mod procfs; -pub(in crate::tests) use procfs::*; - -mod error; -pub(in crate::tests) use error::*; diff --git a/src/utils/mod.rs b/src/utils.rs similarity index 100% rename from src/utils/mod.rs rename to src/utils.rs