Skip to content

Commit cd71ea7

Browse files
committed
Auto merge of #43056 - ids1024:nofollow2, r=burntsushi
Redox: Use O_NOFOLLOW for lstat()
2 parents b360b44 + 51260f4 commit cd71ea7

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/libstd/sys/redox/fs.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,10 @@ pub fn stat(p: &Path) -> io::Result<FileAttr> {
447447
}
448448

449449
pub fn lstat(p: &Path) -> io::Result<FileAttr> {
450-
stat(p)
450+
let fd = cvt(syscall::open(p.to_str().unwrap(),
451+
syscall::O_CLOEXEC | syscall::O_STAT | syscall::O_NOFOLLOW))?;
452+
let file = File(FileDesc::new(fd));
453+
file.file_attr()
451454
}
452455

453456
pub fn canonicalize(p: &Path) -> io::Result<PathBuf> {

src/libstd/sys/redox/syscall/flag.rs

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pub const O_EXCL: usize = 0x0800_0000;
5555
pub const O_DIRECTORY: usize = 0x1000_0000;
5656
pub const O_STAT: usize = 0x2000_0000;
5757
pub const O_SYMLINK: usize = 0x4000_0000;
58+
pub const O_NOFOLLOW: usize = 0x8000_0000;
5859
pub const O_ACCMODE: usize = O_RDONLY | O_WRONLY | O_RDWR;
5960

6061
pub const SEEK_SET: usize = 0;

0 commit comments

Comments
 (0)