about summary refs log tree commit diff
path: root/library/std/src/sys/wasi/fs.rs
AgeCommit message (Collapse)AuthorLines
2024-01-11std: begin moving platform support modules into `pal`joboet-810/+0
2023-11-15Re-format code with new rustfmtMark Rousskov-6/+7
2023-05-25std: make internal-only items `pub(crate)`Michael Howell-2/+2
This works around a weird problem that looks like a bug in the `exported_private_dependencies` lint.
2023-05-01Inline AsRawFd implementationsKonrad Borowski-0/+1
2023-05-01Inline AsInner implementationsKonrad Borowski-0/+1
2023-03-06Implement read_buf for a few more typesTomasz Miąsko-1/+1
Implement read_buf for TcpStream, Stdin, StdinLock, ChildStdout, ChildStderr (and internally for AnonPipe, Handle, Socket), so that it skips buffer initialization. The other provided methods like read_to_string and read_to_end are implemented in terms of read_buf and so benefit from the optimization as well. This commit also implements read_vectored and is_read_vectored where applicable.
2022-10-03Reduce CString allocations in std as much as possibleAlex Saveau-42/+44
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-10-01Error instead of panicking when setting file times if the passed ↵beetrees-6/+13
`SystemTime` doesn't fit into the required type
2022-08-18Address reviewer commentsNick Cameron-1/+1
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-08-05non-linux platformsNick Cameron-3/+3
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-07-15Support setting file accessed/modified timestampsJosh Triplett-0/+25
Add `struct FileTimes` to contain the relevant file timestamps, since most platforms require setting all of them at once. (This also allows for future platform-specific extensions such as setting creation time.) Add `File::set_file_time` to set the timestamps for a `File`. Implement the `sys` backends for UNIX, macOS (which needs to fall back to `futimes` before macOS 10.13 because it lacks `futimens`), Windows, and WASI.
2022-02-04Hide Repr details from io::Error, and rework `io::Error::new_const`.Thom Chiovoloni-2/+2
2022-01-19Fix CVE-2022-21658 for WASIAlex Crichton-8/+63
2021-11-02more efficent File::read_buf impl for windows and unixDrMeepster-1/+5
2021-08-19I/O safety.Dan Gohman-10/+39
Introduce `OwnedFd` and `BorrowedFd`, and the `AsFd` trait, and implementations of `AsFd`, `From<OwnedFd>` and `From<T> for OwnedFd` for relevant types, along with Windows counterparts for handles and sockets. Tracking issue: - <https://github.com/rust-lang/rust/issues/87074> RFC: - <https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md>
2021-08-13Change WASI's `RawFd` from `u32` to `c_int` (`i32`).Dan Gohman-3/+4
WASI previously used `u32` as its `RawFd` type, since its "file descriptors" are unsigned table indices, and there's no fundamental reason why WASI can't have more than 2^31 handles. However, this creates myriad little incompability problems with code that also supports Unix platforms, where `RawFd` is `c_int`. While WASI isn't a Unix, it often shares code with Unix, and this difference made such shared code inconvenient. #87329 is the most recent example of such code. So, switch WASI to use `c_int`, which is `i32`. This will mean that code intending to support WASI should ideally avoid assuming that negative file descriptors are invalid, even though POSIX itself says that file descriptors are never negative. This is a breaking change, but `RawFd` is considerd an experimental feature in [the documentation]. [the documentation]: https://doc.rust-lang.org/stable/std/os/wasi/io/type.RawFd.html
2021-06-15Rename ErrorKind::Unknown to Uncategorized.Mara Bos-2/+3
2021-06-15Redefine `ErrorKind::Other` and stop using it in std.Mara Bos-2/+2
2021-05-19Move the implementation of `Path::exists` to `sys_common::fs` so platforms ↵Chris Denton-1/+1
can specialize it Windows implementation of `fs::try_exists`
2021-03-27Use DebugStruct::finish_non_exhaustive() in std.Mara Bos-1/+1
2021-03-21Use io::Error::new_const everywhere to avoid allocations.Mara Bos-1/+1
2021-03-05std: Fix a bug on the wasm32-wasi target opening filesAlex Crichton-4/+2
This commit fixes an issue pointed out in #82758 where LTO changed the behavior of a program. It turns out that LTO was not at fault here, it simply uncovered an existing bug. The bindings to `__wasilibc_find_relpath` assumed that the relative portion of the path returned was always contained within thee input `buf` we passed in. This isn't actually the case, however, and sometimes the relative portion of the path may reference a sub-portion of the input string itself. The fix here is to use the relative path pointer coming out of `__wasilibc_find_relpath` as the source of truth. The `buf` used for local storage is discarded in this function and the relative path is copied out unconditionally. We might be able to get away with some `Cow`-like business or such to avoid the extra allocation, but for now this is probably the easiest patch to fix the original issue.
2021-02-24x.py fmtDan Gohman-1/+1
2021-02-24Use `super::` to refer to WASI-specific names.Dan Gohman-1/+1
This ensures that these names resolve to the right place even when building the WASI support on other platforms for generating the documentation.
2021-02-19x.py fmtDan Gohman-6/+1
2021-02-10Make WASI's `hard_link` behavior match other platforms.Dan Gohman-1/+2
Following #78026, `std::fs::hard_link` on most platforms does not follow symlinks. Change the WASI implementation to also not follow symlinks.
2021-01-14std: Update wasi-libc commit of the wasm32-wasi targetAlex Crichton-19/+36
This brings in an implementation of `current_dir` and `set_current_dir` (emulation in `wasi-libc`) as well as an updated version of finding relative paths. This also additionally updates clang to the latest release to build wasi-libc with.
2020-11-14Disambiguate symlink argument namesDavid Tolnay-10/+10
2020-09-03Applied `#![deny(unsafe_op_in_unsafe_fn)]` in library/std/src/wasiAmjad Alsharafi-0/+2
All refactoring needed was only in `alloc.rs`, changed part of the code in `alloc` method to satisfy the SAFETY statement
2020-08-05Fix wasi::fs::OpenOptions to imply write when append is onYuto Kawamura-3/+5
2020-07-31Fix std::fs::File::metadata permission on WASI targetShen-Ta Hsieh-0/+1
Previously `std::fs::File::metadata` on wasm32-wasi would call `fd_filestat_get` to get metadata associated with fd, but that fd is opened without RIGHTS_FD_FILESTAT_GET right, so it will failed on correctly implemented WASI environment. This change instead to add the missing rights when opening an fd.
2020-07-27mv std libs to library/mark-0/+667