Skip to content

Commit 6aeb0f0

Browse files
Rollup merge of #43100 - ids1024:stat2, r=aturon
Redox: add stat methods(); support is_symlink()
2 parents 2510116 + 4d58b04 commit 6aeb0f0

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/libstd/sys/redox/ext/fs.rs

+15
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ pub trait MetadataExt {
177177
#[stable(feature = "metadata_ext", since = "1.1.0")]
178178
fn mode(&self) -> u32;
179179
#[stable(feature = "metadata_ext", since = "1.1.0")]
180+
fn nlink(&self) -> u64;
181+
#[stable(feature = "metadata_ext", since = "1.1.0")]
180182
fn uid(&self) -> u32;
181183
#[stable(feature = "metadata_ext", since = "1.1.0")]
182184
fn gid(&self) -> u32;
@@ -194,6 +196,10 @@ pub trait MetadataExt {
194196
fn ctime(&self) -> i64;
195197
#[stable(feature = "metadata_ext", since = "1.1.0")]
196198
fn ctime_nsec(&self) -> i64;
199+
#[stable(feature = "metadata_ext", since = "1.1.0")]
200+
fn blksize(&self) -> u64;
201+
#[stable(feature = "metadata_ext", since = "1.1.0")]
202+
fn blocks(&self) -> u64;
197203
}
198204

199205
#[stable(feature = "metadata_ext", since = "1.1.0")]
@@ -207,6 +213,9 @@ impl MetadataExt for fs::Metadata {
207213
fn mode(&self) -> u32 {
208214
self.as_inner().as_inner().st_mode as u32
209215
}
216+
fn nlink(&self) -> u64 {
217+
self.as_inner().as_inner().st_nlink as u64
218+
}
210219
fn uid(&self) -> u32 {
211220
self.as_inner().as_inner().st_uid as u32
212221
}
@@ -234,6 +243,12 @@ impl MetadataExt for fs::Metadata {
234243
fn ctime_nsec(&self) -> i64 {
235244
self.as_inner().as_inner().st_ctime_nsec as i64
236245
}
246+
fn blksize(&self) -> u64 {
247+
self.as_inner().as_inner().st_blksize as u64
248+
}
249+
fn blocks(&self) -> u64 {
250+
self.as_inner().as_inner().st_blocks as u64
251+
}
237252
}
238253

239254
/// Add special Redox types (block/char device, fifo and socket)

src/libstd/sys/redox/fs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ impl FilePermissions {
119119
impl FileType {
120120
pub fn is_dir(&self) -> bool { self.is(syscall::MODE_DIR) }
121121
pub fn is_file(&self) -> bool { self.is(syscall::MODE_FILE) }
122-
pub fn is_symlink(&self) -> bool { false /*FIXME: Implement symlink mode*/ }
122+
pub fn is_symlink(&self) -> bool { self.is(syscall::MODE_SYMLINK) }
123123

124124
pub fn is(&self, mode: u16) -> bool {
125-
self.mode & (syscall::MODE_DIR | syscall::MODE_FILE) == mode
125+
self.mode & syscall::MODE_TYPE == mode
126126
}
127127
}
128128

0 commit comments

Comments
 (0)