diff options
| author | bors <bors@rust-lang.org> | 2016-02-14 02:17:38 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-02-14 02:17:38 +0000 |
| commit | 09395bbfb0cacc6d53956c37cb85086bb8c837f2 (patch) | |
| tree | 20880054cf09f20ec03fbb6f2aaf81152add2fba /src/libstd/sys | |
| parent | fae516277b6da46b6c1cf568765c90fad2f9ae4b (diff) | |
| parent | aa23c98450063992473d40d707273903f8a3937d (diff) | |
| download | rust-09395bbfb0cacc6d53956c37cb85086bb8c837f2.tar.gz rust-09395bbfb0cacc6d53956c37cb85086bb8c837f2.zip | |
Auto merge of #31551 - alexcrichton:deprecate-std-os-raw, r=brson
This commit is an implementation of [RFC 1415][rfc] which deprecates all types in the `std::os::*::raw` modules. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1415-trim-std-os.md Many of the types in these modules don't actually have a canonical platform representation, for example the definition of `stat` on 32-bit Linux will change depending on whether C code is compiled with LFS support or not. Unfortunately the current types in `std::os::*::raw` are billed as "compatible with C", which in light of this means it isn't really possible. To make matters worse, platforms like Android sometimes define these types as *smaller* than the way they're actually represented in the `stat` structure itself. This means that when methods like `DirEntry::ino` are called on Android the result may be truncated as we're tied to returning a `ino_t` type, not the underlying type. The commit here incorporates two backwards-compatible components: * Deprecate all `raw` types that aren't in `std::os::raw` * Expand the `std::os::*::fs::MetadataExt` trait on all platforms for method accessors of all fields. The fields now returned widened types which are the same across platforms (consistency across platforms is not required, however, it's just convenient). and two also backwards-incompatible components: * Change the definition of all `std::os::*::raw` type aliases to correspond to the newly widened types that are being returned on each platform. * Change the definition of `std::os::*::raw::stat` on Linux to match the LFS definitions rather than the standard ones. The breaking changes here will specifically break code that assumes that `libc` and `std` agree on the definition of `std::os::*::raw` types, or that the `std` types are faithful representations of the types in C. An [audit] has been performed of crates.io to determine the fallout which was determined two be minimal, with the two found cases of breakage having been fixed now. [audit]: https://github.com/rust-lang/rfcs/pull/1415#issuecomment-180645582 --- Ok, so after all that, we're finally able to support LFS on Linux! This commit then simultaneously starts using `stat64` and friends on Linux to ensure that we can open >4GB files on 32-bit Linux. Yay! Closes #28978 Closes #30050 Closes #31549
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/unix/ext/fs.rs | 124 | ||||
| -rw-r--r-- | src/libstd/sys/unix/ext/process.rs | 9 | ||||
| -rw-r--r-- | src/libstd/sys/unix/ext/raw.rs | 6 | ||||
| -rw-r--r-- | src/libstd/sys/unix/ext/thread.rs | 6 | ||||
| -rw-r--r-- | src/libstd/sys/unix/fs.rs | 78 |
5 files changed, 114 insertions, 109 deletions
diff --git a/src/libstd/sys/unix/ext/fs.rs b/src/libstd/sys/unix/ext/fs.rs index 2a3117864d0..bdde25648ed 100644 --- a/src/libstd/sys/unix/ext/fs.rs +++ b/src/libstd/sys/unix/ext/fs.rs @@ -15,69 +15,88 @@ use fs::{self, Permissions, OpenOptions}; use io; use libc; -use os::raw::c_long; +#[allow(deprecated)] use os::unix::raw; use path::Path; -use sys::fs::MetadataExt as UnixMetadataExt; use sys; use sys_common::{FromInner, AsInner, AsInnerMut}; +use sys::platform::fs::MetadataExt as UnixMetadataExt; #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")] #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")] +#[allow(deprecated)] pub const USER_READ: raw::mode_t = 0o400; #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")] #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")] +#[allow(deprecated)] pub const USER_WRITE: raw::mode_t = 0o200; #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")] #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")] +#[allow(deprecated)] pub const USER_EXECUTE: raw::mode_t = 0o100; #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")] #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")] +#[allow(deprecated)] pub const USER_RWX: raw::mode_t = 0o700; #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")] #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")] +#[allow(deprecated)] pub const GROUP_READ: raw::mode_t = 0o040; #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")] #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")] +#[allow(deprecated)] pub const GROUP_WRITE: raw::mode_t = 0o020; #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")] #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")] +#[allow(deprecated)] pub const GROUP_EXECUTE: raw::mode_t = 0o010; #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")] #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")] +#[allow(deprecated)] pub const GROUP_RWX: raw::mode_t = 0o070; #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")] #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")] +#[allow(deprecated)] pub const OTHER_READ: raw::mode_t = 0o004; #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")] #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")] +#[allow(deprecated)] pub const OTHER_WRITE: raw::mode_t = 0o002; #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")] #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")] +#[allow(deprecated)] pub const OTHER_EXECUTE: raw::mode_t = 0o001; #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")] #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")] +#[allow(deprecated)] pub const OTHER_RWX: raw::mode_t = 0o007; #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")] #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")] +#[allow(deprecated)] pub const ALL_READ: raw::mode_t = 0o444; #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")] #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")] +#[allow(deprecated)] pub const ALL_WRITE: raw::mode_t = 0o222; #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")] #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")] +#[allow(deprecated)] pub const ALL_EXECUTE: raw::mode_t = 0o111; #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")] #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")] +#[allow(deprecated)] pub const ALL_RWX: raw::mode_t = 0o777; #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")] #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")] +#[allow(deprecated)] pub const SETUID: raw::mode_t = 0o4000; #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")] #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")] +#[allow(deprecated)] pub const SETGID: raw::mode_t = 0o2000; #[unstable(feature = "fs_mode", reason = "recently added API", issue = "27712")] #[rustc_deprecated(since = "1.7.0", reason = "moved to the libc crate instead")] +#[allow(deprecated)] pub const STICKY_BIT: raw::mode_t = 0o1000; /// Unix-specific extensions to `Permissions` @@ -86,28 +105,30 @@ pub trait PermissionsExt { /// Returns the underlying raw `mode_t` bits that are the standard Unix /// permissions for this file. #[stable(feature = "fs_ext", since = "1.1.0")] - fn mode(&self) -> raw::mode_t; + fn mode(&self) -> u32; - /// Sets the underlying raw `mode_t` bits for this set of permissions. + /// Sets the underlying raw bits for this set of permissions. #[stable(feature = "fs_ext", since = "1.1.0")] - fn set_mode(&mut self, mode: raw::mode_t); + fn set_mode(&mut self, mode: u32); /// Creates a new instance of `Permissions` from the given set of Unix /// permission bits. #[stable(feature = "fs_ext", since = "1.1.0")] - fn from_mode(mode: raw::mode_t) -> Self; + fn from_mode(mode: u32) -> Self; } #[stable(feature = "fs_ext", since = "1.1.0")] impl PermissionsExt for Permissions { - fn mode(&self) -> raw::mode_t { self.as_inner().mode() } + fn mode(&self) -> u32 { + self.as_inner().mode() + } - fn set_mode(&mut self, mode: raw::mode_t) { - *self = FromInner::from_inner(FromInner::from_inner(mode)); + fn set_mode(&mut self, mode: u32) { + *self = Permissions::from_inner(FromInner::from_inner(mode)); } - fn from_mode(mode: raw::mode_t) -> Permissions { - FromInner::from_inner(FromInner::from_inner(mode)) + fn from_mode(mode: u32) -> Permissions { + Permissions::from_inner(FromInner::from_inner(mode)) } } @@ -122,7 +143,7 @@ pub trait OpenOptionsExt { /// The operating system masks out bits with the systems `umask`, to produce /// the final permissions. #[stable(feature = "fs_ext", since = "1.1.0")] - fn mode(&mut self, mode: raw::mode_t) -> &mut Self; + fn mode(&mut self, mode: u32) -> &mut Self; /// Pass custom flags to the `flags` agument of `open`. /// @@ -154,7 +175,7 @@ pub trait OpenOptionsExt { #[stable(feature = "fs_ext", since = "1.1.0")] impl OpenOptionsExt for OpenOptions { - fn mode(&mut self, mode: raw::mode_t) -> &mut OpenOptions { + fn mode(&mut self, mode: u32) -> &mut OpenOptions { self.as_inner_mut().mode(mode); self } @@ -173,62 +194,57 @@ impl OpenOptionsExt for OpenOptions { #[stable(feature = "metadata_ext", since = "1.1.0")] pub trait MetadataExt { #[stable(feature = "metadata_ext", since = "1.1.0")] - fn dev(&self) -> raw::dev_t; + fn dev(&self) -> u64; #[stable(feature = "metadata_ext", since = "1.1.0")] - fn ino(&self) -> raw::ino_t; + fn ino(&self) -> u64; #[stable(feature = "metadata_ext", since = "1.1.0")] - fn mode(&self) -> raw::mode_t; + fn mode(&self) -> u32; #[stable(feature = "metadata_ext", since = "1.1.0")] - fn nlink(&self) -> raw::nlink_t; + fn nlink(&self) -> u64; #[stable(feature = "metadata_ext", since = "1.1.0")] - fn uid(&self) -> raw::uid_t; + fn uid(&self) -> u32; #[stable(feature = "metadata_ext", since = "1.1.0")] - fn gid(&self) -> raw::gid_t; + fn gid(&self) -> u32; #[stable(feature = "metadata_ext", since = "1.1.0")] - fn rdev(&self) -> raw::dev_t; + fn rdev(&self) -> u64; #[stable(feature = "metadata_ext", since = "1.1.0")] - fn size(&self) -> raw::off_t; + fn size(&self) -> u64; #[stable(feature = "metadata_ext", since = "1.1.0")] - fn atime(&self) -> raw::time_t; + fn atime(&self) -> i64; #[stable(feature = "metadata_ext", since = "1.1.0")] - fn atime_nsec(&self) -> c_long; + fn atime_nsec(&self) -> i64; #[stable(feature = "metadata_ext", since = "1.1.0")] - fn mtime(&self) -> raw::time_t; + fn mtime(&self) -> i64; #[stable(feature = "metadata_ext", since = "1.1.0")] - fn mtime_nsec(&self) -> c_long; + fn mtime_nsec(&self) -> i64; #[stable(feature = "metadata_ext", since = "1.1.0")] - fn ctime(&self) -> raw::time_t; + fn ctime(&self) -> i64; #[stable(feature = "metadata_ext", since = "1.1.0")] - fn ctime_nsec(&self) -> c_long; + fn ctime_nsec(&self) -> i64; #[stable(feature = "metadata_ext", since = "1.1.0")] - fn blksize(&self) -> raw::blksize_t; + fn blksize(&self) -> u64; #[stable(feature = "metadata_ext", since = "1.1.0")] - fn blocks(&self) -> raw::blkcnt_t; + fn blocks(&self) -> u64; } #[stable(feature = "metadata_ext", since = "1.1.0")] impl MetadataExt for fs::Metadata { - fn dev(&self) -> raw::dev_t { self.as_raw_stat().st_dev as raw::dev_t } - fn ino(&self) -> raw::ino_t { self.as_raw_stat().st_ino as raw::ino_t } - fn mode(&self) -> raw::mode_t { self.as_raw_stat().st_mode as raw::mode_t } - fn nlink(&self) -> raw::nlink_t { self.as_raw_stat().st_nlink as raw::nlink_t } - fn uid(&self) -> raw::uid_t { self.as_raw_stat().st_uid as raw::uid_t } - fn gid(&self) -> raw::gid_t { self.as_raw_stat().st_gid as raw::gid_t } - fn rdev(&self) -> raw::dev_t { self.as_raw_stat().st_rdev as raw::dev_t } - fn size(&self) -> raw::off_t { self.as_raw_stat().st_size as raw::off_t } - fn atime(&self) -> raw::time_t { self.as_raw_stat().st_atime } - fn atime_nsec(&self) -> c_long { self.as_raw_stat().st_atime_nsec as c_long } - fn mtime(&self) -> raw::time_t { self.as_raw_stat().st_mtime } - fn mtime_nsec(&self) -> c_long { self.as_raw_stat().st_mtime_nsec as c_long } - fn ctime(&self) -> raw::time_t { self.as_raw_stat().st_ctime } - fn ctime_nsec(&self) -> c_long { self.as_raw_stat().st_ctime_nsec as c_long } - - fn blksize(&self) -> raw::blksize_t { - self.as_raw_stat().st_blksize as raw::blksize_t - } - fn blocks(&self) -> raw::blkcnt_t { - self.as_raw_stat().st_blocks as raw::blkcnt_t - } + fn dev(&self) -> u64 { self.st_dev() } + fn ino(&self) -> u64 { self.st_ino() } + fn mode(&self) -> u32 { self.st_mode() } + fn nlink(&self) -> u64 { self.st_nlink() } + fn uid(&self) -> u32 { self.st_uid() } + fn gid(&self) -> u32 { self.st_gid() } + fn rdev(&self) -> u64 { self.st_rdev() } + fn size(&self) -> u64 { self.st_size() } + fn atime(&self) -> i64 { self.st_atime() } + fn atime_nsec(&self) -> i64 { self.st_atime_nsec() } + fn mtime(&self) -> i64 { self.st_mtime() } + fn mtime_nsec(&self) -> i64 { self.st_mtime_nsec() } + fn ctime(&self) -> i64 { self.st_ctime() } + fn ctime_nsec(&self) -> i64 { self.st_ctime_nsec() } + fn blksize(&self) -> u64 { self.st_blksize() } + fn blocks(&self) -> u64 { self.st_blocks() } } /// Add special unix types (block/char device, fifo and socket) @@ -262,12 +278,12 @@ pub trait DirEntryExt { /// Returns the underlying `d_ino` field in the contained `dirent` /// structure. #[stable(feature = "dir_entry_ext", since = "1.1.0")] - fn ino(&self) -> raw::ino_t; + fn ino(&self) -> u64; } #[stable(feature = "dir_entry_ext", since = "1.1.0")] impl DirEntryExt for fs::DirEntry { - fn ino(&self) -> raw::ino_t { self.as_inner().ino() } + fn ino(&self) -> u64 { self.as_inner().ino() } } /// Creates a new symbolic link on the filesystem. @@ -305,12 +321,12 @@ pub trait DirBuilderExt { /// Sets the mode to create new directories with. This option defaults to /// 0o777. #[stable(feature = "dir_builder", since = "1.6.0")] - fn mode(&mut self, mode: raw::mode_t) -> &mut Self; + fn mode(&mut self, mode: u32) -> &mut Self; } #[stable(feature = "dir_builder", since = "1.6.0")] impl DirBuilderExt for fs::DirBuilder { - fn mode(&mut self, mode: raw::mode_t) -> &mut fs::DirBuilder { + fn mode(&mut self, mode: u32) -> &mut fs::DirBuilder { self.as_inner_mut().set_mode(mode); self } diff --git a/src/libstd/sys/unix/ext/process.rs b/src/libstd/sys/unix/ext/process.rs index fa19a2620ba..8cc291d00ee 100644 --- a/src/libstd/sys/unix/ext/process.rs +++ b/src/libstd/sys/unix/ext/process.rs @@ -16,7 +16,6 @@ use prelude::v1::*; use io; use os::unix::io::{FromRawFd, RawFd, AsRawFd, IntoRawFd}; -use os::unix::raw::{uid_t, gid_t}; use process; use sys; use sys_common::{AsInnerMut, AsInner, FromInner, IntoInner}; @@ -28,12 +27,12 @@ pub trait CommandExt { /// `setuid` call in the child process. Failure in the `setuid` /// call will cause the spawn to fail. #[stable(feature = "rust1", since = "1.0.0")] - fn uid(&mut self, id: uid_t) -> &mut process::Command; + fn uid(&mut self, id: u32) -> &mut process::Command; /// Similar to `uid`, but sets the group id of the child process. This has /// the same semantics as the `uid` field. #[stable(feature = "rust1", since = "1.0.0")] - fn gid(&mut self, id: gid_t) -> &mut process::Command; + fn gid(&mut self, id: u32) -> &mut process::Command; /// Create a new session (cf. `setsid(2)`) for the child process. This means /// that the child is the leader of a new process group. The parent process @@ -101,12 +100,12 @@ pub trait CommandExt { #[stable(feature = "rust1", since = "1.0.0")] impl CommandExt for process::Command { - fn uid(&mut self, id: uid_t) -> &mut process::Command { + fn uid(&mut self, id: u32) -> &mut process::Command { self.as_inner_mut().uid(id); self } - fn gid(&mut self, id: gid_t) -> &mut process::Command { + fn gid(&mut self, id: u32) -> &mut process::Command { self.as_inner_mut().gid(id); self } diff --git a/src/libstd/sys/unix/ext/raw.rs b/src/libstd/sys/unix/ext/raw.rs index d1cc6cba51d..96535e88604 100644 --- a/src/libstd/sys/unix/ext/raw.rs +++ b/src/libstd/sys/unix/ext/raw.rs @@ -11,6 +11,12 @@ //! Unix-specific primitives available on all unix platforms #![stable(feature = "raw_ext", since = "1.1.0")] +#![rustc_deprecated(since = "1.8.0", + reason = "these type aliases are no longer supported by \ + the standard library, the `libc` crate on \ + crates.io should be used instead for the correct \ + definitions")] +#![allow(deprecated)] #[stable(feature = "raw_ext", since = "1.1.0")] pub type uid_t = u32; #[stable(feature = "raw_ext", since = "1.1.0")] pub type gid_t = u32; diff --git a/src/libstd/sys/unix/ext/thread.rs b/src/libstd/sys/unix/ext/thread.rs index c1c1609632a..bb8200ff859 100644 --- a/src/libstd/sys/unix/ext/thread.rs +++ b/src/libstd/sys/unix/ext/thread.rs @@ -12,11 +12,13 @@ #![unstable(feature = "thread_extensions", issue = "29791")] -use os::unix::raw::{pthread_t}; +#[allow(deprecated)] +use os::unix::raw::pthread_t; use sys_common::{AsInner, IntoInner}; -use thread::{JoinHandle}; +use thread::JoinHandle; #[unstable(feature = "thread_extensions", issue = "29791")] +#[allow(deprecated)] pub type RawPthread = pthread_t; /// Unix-specific extensions to `std::thread::JoinHandle` diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index ee81c516e33..14f30a62576 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -21,16 +21,20 @@ use path::{Path, PathBuf}; use ptr; use sync::Arc; use sys::fd::FileDesc; -use sys::platform::raw; use sys::time::SystemTime; use sys::{cvt, cvt_r}; use sys_common::{AsInner, FromInner}; +#[cfg(target_os = "linux")] +use libc::{stat64, fstat64, lstat64}; +#[cfg(not(target_os = "linux"))] +use libc::{stat as stat64, fstat as fstat64, lstat as lstat64}; + pub struct File(FileDesc); #[derive(Clone)] pub struct FileAttr { - stat: raw::stat, + stat: stat64, } pub struct ReadDir { @@ -116,14 +120,14 @@ impl FileAttr { impl FileAttr { pub fn modified(&self) -> io::Result<SystemTime> { Ok(SystemTime::from(libc::timespec { - tv_sec: self.stat.st_mtime, + tv_sec: self.stat.st_mtime as libc::time_t, tv_nsec: self.stat.st_mtime_nsec as libc::c_long, })) } pub fn accessed(&self) -> io::Result<SystemTime> { Ok(SystemTime::from(libc::timespec { - tv_sec: self.stat.st_atime, + tv_sec: self.stat.st_atime as libc::time_t, tv_nsec: self.stat.st_atime_nsec as libc::c_long, })) } @@ -133,7 +137,7 @@ impl FileAttr { target_os = "openbsd"))] pub fn created(&self) -> io::Result<SystemTime> { Ok(SystemTime::from(libc::timespec { - tv_sec: self.stat.st_birthtime, + tv_sec: self.stat.st_birthtime as libc::time_t, tv_nsec: self.stat.st_birthtime_nsec as libc::c_long, })) } @@ -148,26 +152,8 @@ impl FileAttr { } } -impl AsInner<raw::stat> for FileAttr { - fn as_inner(&self) -> &raw::stat { &self.stat } -} - -/// OS-specific extension methods for `fs::Metadata` -#[stable(feature = "metadata_ext", since = "1.1.0")] -pub trait MetadataExt { - /// Gain a reference to the underlying `stat` structure which contains the - /// raw information returned by the OS. - /// - /// The contents of the returned `stat` are **not** consistent across Unix - /// platforms. The `os::unix::fs::MetadataExt` trait contains the cross-Unix - /// abstractions contained within the raw stat. - #[stable(feature = "metadata_ext", since = "1.1.0")] - fn as_raw_stat(&self) -> &raw::stat; -} - -#[stable(feature = "metadata_ext", since = "1.1.0")] -impl MetadataExt for ::fs::Metadata { - fn as_raw_stat(&self) -> &raw::stat { &self.as_inner().stat } +impl AsInner<stat64> for FileAttr { + fn as_inner(&self) -> &stat64 { &self.stat } } impl FilePermissions { @@ -179,7 +165,7 @@ impl FilePermissions { self.mode |= 0o222; } } - pub fn mode(&self) -> raw::mode_t { self.mode } + pub fn mode(&self) -> u32 { self.mode as u32 } } impl FileType { @@ -190,8 +176,8 @@ impl FileType { pub fn is(&self, mode: mode_t) -> bool { self.mode & libc::S_IFMT == mode } } -impl FromInner<raw::mode_t> for FilePermissions { - fn from_inner(mode: raw::mode_t) -> FilePermissions { +impl FromInner<u32> for FilePermissions { + fn from_inner(mode: u32) -> FilePermissions { FilePermissions { mode: mode as mode_t } } } @@ -293,15 +279,11 @@ impl DirEntry { #[cfg(any(target_os = "macos", target_os = "ios", target_os = "linux", - target_os = "solaris", - target_os = "emscripten"))] - pub fn ino(&self) -> raw::ino_t { - self.entry.d_ino - } - - #[cfg(target_os = "android")] - pub fn ino(&self) -> raw::ino_t { - self.entry.d_ino as raw::ino_t + target_os = "emscripten", + target_os = "android", + target_os = "solaris"))] + pub fn ino(&self) -> u64 { + self.entry.d_ino as u64 } #[cfg(any(target_os = "freebsd", @@ -309,8 +291,8 @@ impl DirEntry { target_os = "bitrig", target_os = "netbsd", target_os = "dragonfly"))] - pub fn ino(&self) -> raw::ino_t { - self.entry.d_fileno + pub fn ino(&self) -> u64 { + self.entry.d_fileno as u64 } #[cfg(any(target_os = "macos", @@ -364,7 +346,7 @@ impl OpenOptions { pub fn create_new(&mut self, create_new: bool) { self.create_new = create_new; } pub fn custom_flags(&mut self, flags: i32) { self.custom_flags = flags; } - pub fn mode(&mut self, mode: raw::mode_t) { self.mode = mode as mode_t; } + pub fn mode(&mut self, mode: u32) { self.mode = mode as mode_t; } fn get_access_mode(&self) -> io::Result<c_int> { match (self.read, self.write, self.append) { @@ -431,9 +413,9 @@ impl File { } pub fn file_attr(&self) -> io::Result<FileAttr> { - let mut stat: raw::stat = unsafe { mem::zeroed() }; + let mut stat: stat64 = unsafe { mem::zeroed() }; try!(cvt(unsafe { - libc::fstat(self.0.raw(), &mut stat as *mut _ as *mut _) + fstat64(self.0.raw(), &mut stat) })); Ok(FileAttr { stat: stat }) } @@ -506,8 +488,8 @@ impl DirBuilder { Ok(()) } - pub fn set_mode(&mut self, mode: mode_t) { - self.mode = mode; + pub fn set_mode(&mut self, mode: u32) { + self.mode = mode as mode_t; } } @@ -689,18 +671,18 @@ pub fn link(src: &Path, dst: &Path) -> io::Result<()> { pub fn stat(p: &Path) -> io::Result<FileAttr> { let p = try!(cstr(p)); - let mut stat: raw::stat = unsafe { mem::zeroed() }; + let mut stat: stat64 = unsafe { mem::zeroed() }; try!(cvt(unsafe { - libc::stat(p.as_ptr(), &mut stat as *mut _ as *mut _) + stat64(p.as_ptr(), &mut stat as *mut _ as *mut _) })); Ok(FileAttr { stat: stat }) } pub fn lstat(p: &Path) -> io::Result<FileAttr> { let p = try!(cstr(p)); - let mut stat: raw::stat = unsafe { mem::zeroed() }; + let mut stat: stat64 = unsafe { mem::zeroed() }; try!(cvt(unsafe { - libc::lstat(p.as_ptr(), &mut stat as *mut _ as *mut _) + lstat64(p.as_ptr(), &mut stat as *mut _ as *mut _) })); Ok(FileAttr { stat: stat }) } |
