| Age | Commit message (Collapse) | Author | Lines |
|
Implement some basics in UEFI fs
- Just getting some basics out of the way while waiting for #138236 to be merged.
- Adds `fs::canonicalize`. Should be same as absolute in case of UEFI since there is no symlink support and absolute path is guaranteed to be uniqe according to spec.
- Make `fs::lstat` same as `fs::stat`. Should be same since UEFI does not have symlink support.
- Implement `OptionOptions`.
cc ````@nicholasbishop```` ````@dvdhrm````
|
|
UEFI does not have specific modes for create_new, truncate and append.
So those need to to be simulated after opening the file.
Signed-off-by: Ayush Singh <ayush@beagleboard.org>
|
|
- UEFI does not have symlinks. So lstat and stat should behave the same.
Signed-off-by: Ayush Singh <ayush@beagleboard.org>
|
|
- Should be same as absolute in UEFI since there are no symlinks.
- Also each absolute path representation should be unique according to
the UEFI specification.
Signed-off-by: Ayush Singh <ayush@beagleboard.org>
|
|
PRs #136842 (Add libstd support for Trusty targets), #137793 (Stablize
anonymous pipe), and #136929 (std: move process implementations to
`sys`) merged around the same time, so update Trusty to take them into
account.
|
|
Fix `FileType` `PartialEq` implementation on Windows
Fixes #138668
On Windows the [`FileType`](https://doc.rust-lang.org/stable/std/fs/struct.FileType.html) struct was deriving `PartialEq` which in turn means it was doing a bit-for-bit comparison on the file attributes and reparse point. This is wrong because `attributes` may contain many things unrelated to file type.
`FileType` on Windows allows for four possible combinations (see also [`FileTypeExt`](https://doc.rust-lang.org/stable/std/os/windows/fs/trait.FileTypeExt.html)): `file`, `dir`, `symlink_file` and `symlink_dir`. So the new implementation makes sure both symlink and directory information match (and only those things).
This could be considered just a bug fix but it is a behaviour change so someone from libs-api might want to FCP this (or might not)...
|
|
std: uefi: fs: Implement mkdir
- Since there is no direct mkdir in UEFI, first check if a file/dir with same path exists and then create the directory.
cc `@dvdhrm` `@nicholasbishop`
|
|
Update test for SGX now implementing `read_buf`
In #108326, `read_buf` was implemented for a variety of types, but SGX was saved for later. Update a test from then, now that #137355 implemented it for SGX types.
cc ````@jethrogb````
|
|
uefi: Add OwnedEvent abstraction
- Events are going to become quite important for Networking, so needed owned abstractions.
- Switch to OwnedEvent abstraction for Exit boot services event.
cc ````@nicholasbishop````
|
|
std: move process implementations to `sys`
As per #117276, this moves the implementations of `Process` and friends out of the `pal` module and into the `sys` module, removing quite a lot of error-prone `#[path]` imports in the process (hah, get it ;-)). I've also made the `zircon` module a dedicated submodule of `pal::unix`, hopefully we can move some other definitions there as well (they are currently quite a lot of duplications in `sys`). Also, the `ensure_no_nuls` function on Windows now lives in `sys::pal::windows` – it's not specific to processes and shared by the argument implementation.
|
|
Provide optional `Read`/`Write` methods for stdio
Override more of the default methods for `io::Read` and `io::Write` for stdio types, when efficient to do so, and deduplicate unsupported types.
Tracked in https://github.com/rust-lang/rust/issues/136756.
try-job: x86_64-msvc-1
|
|
Rollup of 8 pull requests
Successful merges:
- #138018 (rustdoc: Use own logic to print `#[repr(..)]` attributes in JSON output.)
- #138294 (Mark some std tests as requiring `panic = "unwind"`)
- #138468 (rustdoc js: add nonnull helper and typecheck src-script.js)
- #138675 (Add release notes for 1.85.1)
- #138765 (Fix Thread::set_name on cygwin)
- #138786 (Move some driver code around)
- #138793 (target spec check: better error when llvm-floatabi is missing)
- #138822 (De-Stabilize `file_lock`)
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
Rollup of 7 pull requests
Successful merges:
- #138609 (Add stack overflow handler for cygwin)
- #138639 (Clean UI tests 2 of n)
- #138773 (catch_unwind intrinsic: document return value)
- #138782 (test(ui): add tuple-struct-where-clause-suggestion ui test for #91520)
- #138794 (expand: Do not report `cfg_attr` traces on macros as unused attributes)
- #138801 (triagebot: add autolabel rules for D-* and L-*)
- #138804 (Allow inlining for `Atomic*::from_ptr`)
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
De-Stabilize `file_lock`
This reverts #136794
FCP on the tracking issue (#130994) passsed successfully https://github.com/rust-lang/rust/issues/130994#issuecomment-2646158607 but there are now concerns about the suitability of the proposed API (https://github.com/rust-lang/rust/issues/130994#issuecomment-2734608366)
On zullip it was [suggested](https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/File.3A.3Atry_lock.20API.3A.20Result.3Cbool.3E/near/506823067) that it would be better to temporarily(?) destabilize the feature ASAP to buy us some more time reflecting on the API.
This PR implements the revert.
The feature is not currently on beta (https://github.com/rust-lang/rust/blob/beta/library/std/src/fs.rs#L672) so a beta backport is not yet neccessary.
If this revert is accepted, the tracking issue (#130994) should be reopened
|
|
Fix Thread::set_name on cygwin
Just like Linux, Cygwin also sets a limitation to thread name.
https://github.com/cygwin/cygwin/blob/8e50c7af7c49819245739d6f626f6fecc394ef7f/winsup/cygwin/thread.cc#L3175
|
|
Mark some std tests as requiring `panic = "unwind"`
This allows these test modules to pass on builds/targets without unwinding support, where `panic = "abort"` - the ignored tests are for functionality that's not supported on those targets.
|
|
As per #117276, this moves the implementations of `Process` and friends out of the `pal` module and into the `sys` module, removing quite a lot of error-prone `#[path]` imports in the process (hah, get it ;-)). I've also made the `zircon` module a dedicated submodule of `pal::unix`, hopefully we can move some other definitions there as well (they are currently quite a lot of duplications in `sys`). Also, the `ensure_no_nuls` function on Windows now lives in `sys::pal::windows` – it's not specific to processes and shared by the argument implementation.
|
|
Add stack overflow handler for cygwin
The cygwin runtime handles stack overflow exception and converts it to `SIGSEGV`, but the passed `si_addr` is obtained from `ExceptionInformation[1]` which is actually an undocumented value when stack overflows. Thus I choose to use Windows API directly to register handler, just like how std does on native Windows. The code is basically copied from the Windows one.
Ref:
* https://github.com/cygwin/cygwin/blob/5ec497dc80bcb7ad78cc07bb919b2624b361f017/winsup/cygwin/exceptions.cc#L822-L823
* https://learn.microsoft.com/zh-cn/windows/win32/api/winnt/ns-winnt-exception_record
|
|
Fix build failure on Trusty
This target is currently broken due to update to 2024 editon.
```console
$ cargo new --lib repro
$ cd repro
$ cargo check -Z build-std=std --target aarch64-unknown-trusty
Compiling std v0.0.0 ($HOME/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std)
error: extern blocks must be unsafe
--> $HOME/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/sys/random/trusty.rs:1:1
|
1 | / extern "C" {
2 | | fn trusty_rng_secure_rand(randomBuffer: *mut core::ffi::c_void, randomBufferLen: libc::size_t);
3 | | }
| |_^
error: could not compile `std` (lib) due to 1 previous error
```
cc ```@randomPoison``` ```@ahomescu``` ([target maintainers](https://doc.rust-lang.org/nightly/rustc/platform-support/trusty.html#target-maintainers))
|
|
Forward `stream_position` in `Arc<File>` as well
It was missed in #137165.
|
|
This seems to be the pattern for newer pal stdio types.
|
|
|
|
Match what `std::io::Empty` does, since it is very similar. However,
still evaluate the `fmt::Arguments` in `write_fmt` to be consistent with
other platforms.
|
|
|
|
This reverts commit 82af73dd4c58cd6bec5fb44cf02f7ac96b1ed48b.
|
|
Optimize `io::Write::write_fmt` for constant strings
When the formatting args to `fmt::Write::write_fmt` are a statically known string, it simplifies to only calling `write_str` without a runtime branch. Do the same in `io::Write::write_fmt` with `write_all`.
Also, match the convention of `fmt::Write` for the name of `args`.
|
|
Document results of non-positive logarithms
The integer versions of logarithm functions panic on non-positive numbers. The floating point versions have different, undocumented behaviour (-inf on 0, NaN on <0). This PR documents that.
try-job: aarch64-gnu
|
|
|
|
The default stack size for the main thread is 1 MB as specified by linker options.
However, the default stack size for threads was only 64 kB.
This is surprisingly small and thus we increase it to 1 MB to match the
main thread.
|
|
|
|
Implement default methods for `io::Empty` and `io::Sink`
Implements default methods of `io::Read`, `io::BufRead`, and `io::Write` for `io::Empty` and `io::Sink`. These implementations are equivalent to the defaults, except in doing less unnecessary work.
`Read::read_to_string` and `BufRead::read_line` both have a redundant call to `str::from_utf8` which can't be inlined from `core` and `Write::write_all_vectored` has slicing logic which can't be simplified (See on [Compiler Explorer](https://rust.godbolt.org/z/KK6xcrWr4)). The rest are optimized to the minimal with `-C opt-level=3`, but this PR gives that benefit to unoptimized builds.
This includes an implementation of `Write::write_fmt` which just ignores the `fmt::Arguments<'_>`. This could be problematic whenever a user formatting impl is impure, but the docs do not guarantee that the args will be expanded.
Tracked in https://github.com/rust-lang/rust/issues/136756.
r? `@m-ou-se`
|
|
`MaybeUninit` inherent slice methods part 2
These were moved out of #129259 since they require additional libs-api approval. Tracking issue: #117428.
New API surface:
```rust
impl<T> [MaybeUninit<T>] {
// replacing fill; renamed to avoid conflict
pub fn write_filled(&mut self, value: T) -> &mut [T] where T: Clone;
// replacing fill_with; renamed to avoid conflict
pub fn write_with<F>(&mut self, value: F) -> &mut [T] where F: FnMut() -> T;
// renamed to remove "fill" terminology, since this is closer to the write_*_of_slice methods
pub fn write_iter<I>(&mut self, iter: I) -> (&mut [T], &mut Self) where I: Iterator<Item = T>;
}
```
Relevant motivation for these methods; see #129259 for earlier methods' motiviations.
* I chose `write_filled` since `filled` is being used as an object here, whereas it's being used as an action in `fill`.
* I chose `write_with` instead of `write_filled_with` since it's shorter and still matches well.
* I chose `write_iter` because it feels completely different from the fill methods, and still has the intent clear.
In all of the methods, it felt appropriate to ensure that they contained `write` to clarify that they are effectively just special ways of doing `MaybeUninit::write` for each element of a slice.
Tracking issue: https://github.com/rust-lang/rust/issues/117428
r? libs-api
|
|
Rollup of 10 pull requests
Successful merges:
- #136177 (clarify BufRead::{fill_buf, consume} docs)
- #138654 (Remove the regex dependency from coretests)
- #138655 (rustc-dev-guide sync)
- #138656 (Remove double nesting in post-merge workflow)
- #138658 (CI: mirror alpine and centos images to ghcr)
- #138659 (coverage: Don't store a body span in `FunctionCoverageInfo`)
- #138661 (Revert: Add *_value methods to proc_macro lib)
- #138670 (Remove existing AFIDT implementation)
- #138674 (Various codegen_llvm cleanups)
- #138684 (use then in docs for `fuse` to enhance readability)
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
|
|
Rollup of 7 pull requests
Successful merges:
- #136320 (exit: document interaction with C)
- #138080 (Leave a breadcrumb towards bootstrap config documentation in `bootstrap.toml`)
- #138301 (Implement `read_buf` for Hermit)
- #138569 (rustdoc-json: Add tests for `#[repr(...)]`)
- #138635 (Extract `for_each_immediate_subpat` from THIR pattern visitors)
- #138642 (Unvacation myself)
- #138644 (Add `#[cfg(test)]` for Transition in dfa in `rustc_transmute`)
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
clarify BufRead::{fill_buf, consume} docs
Fixes #85394
|
|
|
|
|
|
|
|
|
|
|
|
- Since there is no direct mkdir in UEFI, first check if a file/dir with
same path exists and then create the directory.
Signed-off-by: Ayush Singh <ayush@beagleboard.org>
|
|
Co-authored-by: Ibraheem Ahmed <ibraheem@ibraheem.ca>
|
|
Implement `read_buf` for Hermit
Following https://github.com/hermit-os/kernel/pull/1606, it is now safe to implement `Read::read_buf` for file descriptors on Hermit.
cc ```@mkroening```
|
|
exit: document interaction with C
Cc https://github.com/rust-lang/rust/issues/126600
|
|
uefi: fs: Implement exists
Also adds the initial file abstractions.
The file opening algorithm is inspired from UEFI shell. It starts by classifying if the Path is Shell mapping, text representation of device path protocol, or a relative path and converts into an absolute text representation of device path protocol.
After that, it queries all handles supporting
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL and opens the volume that matches the device path protocol prefix (similar to Windows drive). After that, it opens the file in the volume using the remaining pat.
It also introduces OwnedDevicePath and BorrowedDevicePath abstractions to allow working with the base UEFI and Shell device paths efficiently.
DevicePath in UEFI behaves like an a group of nodes laied out in the memory contiguously and thus can be modeled using iterators.
This is an effort to break the original PR (https://github.com/rust-lang/rust/pull/129700) into much smaller chunks for faster upstreaming.
|
|
When the formatting args to `fmt::Write::write_fmt` are a statically
known string, it simplifies to only calling `write_str` without a
runtime branch. Do the same in `io::Write::write_fmt` with `write_all`.
Also, match the convention of `fmt::Write` for the name of `args`.
|
|
Also adds the initial file abstractions.
The file opening algorithm is inspired from UEFI shell. It starts by
classifying if the Path is Shell mapping, text representation of device
path protocol, or a relative path and converts into an absolute text
representation of device path protocol.
After that, it queries all handles supporting
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL and opens the volume that matches the
device path protocol prefix (similar to Windows drive). After that, it
opens the file in the volume using the remaining pat.
It also introduces OwnedDevicePath and BorrowedDevicePath abstractions
to allow working with the base UEFI and Shell device paths efficiently.
DevicePath in UEFI behaves like an a group of nodes laied out in the
memory contiguously and thus can be modeled using iterators.
Signed-off-by: Ayush Singh <ayush@beagleboard.org>
|
|
In #108326, `read_buf` was implemented for a variety of types, but SGX
was saved for later. Update a test from then, now that #137355
implemented it for SGX types.
|
|
|