diff --git a/cap-primitives/src/fs/file.rs b/cap-primitives/src/fs/file.rs index 5b6a8c14..3acf1bef 100644 --- a/cap-primitives/src/fs/file.rs +++ b/cap-primitives/src/fs/file.rs @@ -172,16 +172,6 @@ pub trait FileExt { /// Create a directory. fn create_directory>(&self, dir: P) -> io::Result<()>; - /// Read the contents of a symbolic link. - fn read_link>(&self, path: P) -> io::Result; - - /// Return the attributes of a file or directory. - fn metadata_at>( - &self, - lookup_flags: u32, - path: P, - ) -> io::Result; - /// Unlink a file. fn remove_file>(&self, path: P) -> io::Result<()>; diff --git a/cap-primitives/src/fs/metadata.rs b/cap-primitives/src/fs/metadata.rs index 738fe7b9..93498373 100644 --- a/cap-primitives/src/fs/metadata.rs +++ b/cap-primitives/src/fs/metadata.rs @@ -250,14 +250,6 @@ pub trait MetadataExt { fn ino(&self) -> u64; /// Returns the number of hard links pointing to this file. fn nlink(&self) -> u64; - /// Returns the total size of this file in bytes. - fn size(&self) -> u64; - /// Returns the last access time of the file, in seconds since Unix Epoch. - fn atim(&self) -> u64; - /// Returns the last modification time of the file, in seconds since Unix Epoch. - fn mtim(&self) -> u64; - /// Returns the last status change time of the file, in seconds since Unix Epoch. - fn ctim(&self) -> u64; } /// Windows-specific extensions to [`Metadata`]. @@ -385,26 +377,6 @@ impl MetadataExt for Metadata { fn nlink(&self) -> u64 { crate::fs::MetadataExt::nlink(&self.ext) } - - #[inline] - fn size(&self) -> u64 { - crate::fs::MetadataExt::size(&self.ext) - } - - #[inline] - fn atim(&self) -> u64 { - crate::fs::MetadataExt::atim(&self.ext) - } - - #[inline] - fn mtim(&self) -> u64 { - crate::fs::MetadataExt::mtim(&self.ext) - } - - #[inline] - fn ctim(&self) -> u64 { - crate::fs::MetadataExt::ctim(&self.ext) - } } #[cfg(target_os = "vxworks")] diff --git a/cap-primitives/src/rustix/fs/dir_utils.rs b/cap-primitives/src/rustix/fs/dir_utils.rs index 1093fac4..50011e71 100644 --- a/cap-primitives/src/rustix/fs/dir_utils.rs +++ b/cap-primitives/src/rustix/fs/dir_utils.rs @@ -111,12 +111,9 @@ pub(crate) fn open_ambient_dir_impl( let mut options = fs::OpenOptions::new(); options.read(true); - #[cfg(not(target_os = "wasi"))] // This is for `std::fs`, so we don't have `dir_required`, so set // `O_DIRECTORY` manually. options.custom_flags((OFlags::DIRECTORY | target_o_path()).bits() as i32); - #[cfg(target_os = "wasi")] - options.directory(true); options.open(path) } diff --git a/cap-primitives/src/rustix/fs/metadata_ext.rs b/cap-primitives/src/rustix/fs/metadata_ext.rs index 43654fd0..b13ab136 100644 --- a/cap-primitives/src/rustix/fs/metadata_ext.rs +++ b/cap-primitives/src/rustix/fs/metadata_ext.rs @@ -20,6 +20,7 @@ pub(crate) struct ImplMetadataExt { gid: u32, #[cfg(not(target_os = "wasi"))] rdev: u64, + #[cfg(not(target_os = "wasi"))] size: u64, #[cfg(not(target_os = "wasi"))] atime: i64, @@ -37,12 +38,6 @@ pub(crate) struct ImplMetadataExt { blksize: u64, #[cfg(not(target_os = "wasi"))] blocks: u64, - #[cfg(target_os = "wasi")] - atim: u64, - #[cfg(target_os = "wasi")] - mtim: u64, - #[cfg(target_os = "wasi")] - ctim: u64, } impl ImplMetadataExt { @@ -72,6 +67,7 @@ impl ImplMetadataExt { gid: std.gid(), #[cfg(not(target_os = "wasi"))] rdev: std.rdev(), + #[cfg(not(target_os = "wasi"))] size: std.size(), #[cfg(not(target_os = "wasi"))] atime: std.atime(), @@ -89,12 +85,6 @@ impl ImplMetadataExt { blksize: std.blksize(), #[cfg(not(target_os = "wasi"))] blocks: std.blocks(), - #[cfg(target_os = "wasi")] - atim: std.atim(), - #[cfg(target_os = "wasi")] - mtim: std.mtim(), - #[cfg(target_os = "wasi")] - ctim: std.ctim(), } } @@ -179,6 +169,7 @@ impl ImplMetadataExt { gid: stat.st_gid, #[cfg(not(target_os = "wasi"))] rdev: u64::try_from(stat.st_rdev).unwrap(), + #[cfg(not(target_os = "wasi"))] size: u64::try_from(stat.st_size).unwrap(), #[cfg(not(target_os = "wasi"))] atime: i64::try_from(stat.st_atime).unwrap(), @@ -196,21 +187,6 @@ impl ImplMetadataExt { blksize: u64::try_from(stat.st_blksize).unwrap(), #[cfg(not(target_os = "wasi"))] blocks: u64::try_from(stat.st_blocks).unwrap(), - #[cfg(target_os = "wasi")] - atim: u64::try_from( - stat.st_atim.tv_sec as u64 * 1000000000 + stat.st_atim.tv_nsec as u64, - ) - .unwrap(), - #[cfg(target_os = "wasi")] - mtim: u64::try_from( - stat.st_mtim.tv_sec as u64 * 1000000000 + stat.st_mtim.tv_nsec as u64, - ) - .unwrap(), - #[cfg(target_os = "wasi")] - ctim: u64::try_from( - stat.st_ctim.tv_sec as u64 * 1000000000 + stat.st_ctim.tv_nsec as u64, - ) - .unwrap(), }, } } @@ -319,6 +295,7 @@ impl crate::fs::MetadataExt for ImplMetadataExt { self.rdev } + #[cfg(not(target_os = "wasi"))] #[inline] fn size(&self) -> u64 { self.size @@ -371,21 +348,6 @@ impl crate::fs::MetadataExt for ImplMetadataExt { fn blocks(&self) -> u64 { self.blocks } - - #[cfg(target_os = "wasi")] - fn atim(&self) -> u64 { - self.atim - } - - #[cfg(target_os = "wasi")] - fn mtim(&self) -> u64 { - self.mtim - } - - #[cfg(target_os = "wasi")] - fn ctim(&self) -> u64 { - self.ctim - } } /// It should be possible to represent times before the Epoch. diff --git a/cap-std/src/fs/file.rs b/cap-std/src/fs/file.rs index 5774c359..fd9053af 100644 --- a/cap-std/src/fs/file.rs +++ b/cap-std/src/fs/file.rs @@ -552,23 +552,6 @@ impl crate::fs::FileExt for File { std::os::wasi::fs::FileExt::create_directory(&self.std, dir) } - #[inline] - fn read_link>( - &self, - path: P, - ) -> std::result::Result { - std::os::wasi::fs::FileExt::read_link(&self.std, path) - } - - #[inline] - fn metadata_at>( - &self, - lookup_flags: u32, - path: P, - ) -> std::result::Result { - std::os::wasi::fs::FileExt::metadata_at(&self.std, lookup_flags, path) - } - #[inline] fn remove_file>(&self, path: P) -> std::result::Result<(), io::Error> { std::os::wasi::fs::FileExt::remove_file(&self.std, path) diff --git a/cap-std/src/fs_utf8/file.rs b/cap-std/src/fs_utf8/file.rs index bac22a8d..2fd2bd19 100644 --- a/cap-std/src/fs_utf8/file.rs +++ b/cap-std/src/fs_utf8/file.rs @@ -551,25 +551,6 @@ impl crate::fs::FileExt for File { self.cap_std.create_directory(path) } - #[inline] - fn read_link>( - &self, - path: P, - ) -> std::result::Result { - let path = path.as_ref(); - self.cap_std.read_link(path) - } - - #[inline] - fn metadata_at>( - &self, - lookup_flags: u32, - path: P, - ) -> std::result::Result { - let path = path.as_ref(); - self.cap_std.metadata_at(lookup_flags, path) - } - #[inline] fn remove_file>(&self, path: P) -> std::result::Result<(), io::Error> { let path = path.as_ref();