| Age | Commit message (Collapse) | Author | Lines |
|
readdir_r has the same problems on FreeBSD as it does on other
platforms: it assumes a fixed NAME_MAX. And readdir has the same
thread-safety guarantee as it does on other platforms: it's safe as long
as only one thread tries to read from the directory stream at a given
time.
Furthermore, readdir_r is likely to be removed for FreeBSD 16, so we
should stop using it now.
|
|
Upstream Solaris flock emulation to libstd from cargo.
This is borrowed from
https://github.com/rust-lang/cargo/blob/3b379fcc541b39321a7758552d37e5e0cc4277b9/src/cargo/util/flock.rs#L502-L536
which was implemented by an Oracle employee.
The code has been in cargo since 2022-12.
Python's `fcntl.flock` emulates like this as well:
https://github.com/python/cpython/blob/c919d02edecfe9d75fe374756fb8aa1db8d95f55/Modules/fcntlmodule.c#L337-L400
We did the same thing in
https://github.com/rust-lang/rust/blob/0d0f4eac8b98133e5da6d3604d86a8f3b5a67844/compiler/rustc_data_structures/src/flock/unix.rs#L13-L39
|
|
Add `read_buf` equivalents for positioned reads
Adds the following items under the ~~`read_buf` (rust-lang/rust#78485)~~ `read_buf_at` (rust-lang/rust#140771) feature:
- `std::os::unix::fs::FileExt::read_buf_at`
- `std::os::unix::fs::FileExt::read_buf_exact_at`
- `std::os::windows::fs::FileExt::seek_read_buf`
try-job: `x86_64-msvc*`
try-job: `test-various*`
try-job: `dist-various*`
|
|
Adds the following items under the `read_buf_at` feature:
- `std::os::unix::fs::FileExt::read_buf_at`
- `std::os::unix::fs::FileExt::read_buf_exact_at`
- `std::os::windows::fs::FileExt::seek_read_buf`
|
|
Previously, attempting to create/truncate a file without write/append access
would result in platform-specific error messages:
- Unix: "Invalid argument"
- Windows: raw OS error code 87
These error codes look like system errors, which could waste hours
of debugging for what is actually an API misuse issue.
|
|
|
|
Rust build fails on OpenBSD after using file_lock feature
PR 130999 added the file_lock feature, but doesn't included OpenBSD in the supported targets (Tier 3 platform), leading to a compilation error ("try_lock() not supported").
Cc `@cberner`
Related to rust-lang/rust#130999
|
|
PR 130999 added the file_lock feature, but doesn't included OpenBSD in the supported targets (Tier 3 platform), leading to a compilation error ("try_lock() not supported").
|
|
Migrate the standard library from using the external `cfg_if` crate to
using the now-built-in `cfg_select` macro.
This does not yet eliminate the dependency from
`library/std/Cargo.toml`, because while the standard library itself no
longer uses `cfg_if`, it also incorporates the `backtrace` crate, which
does.
Migration assisted by the following vim command (after selecting the
full `cfg_if!` invocation):
```
'<,'>s/\(cfg_if::\)\?cfg_if/cfg_select/ | '<,'>s/^\( *\)} else {/\1}\r\1_ => {/c | '<,'>s/^\( *\)} else if #\[cfg(\(.*\))\] /\1}\r\1\2 => /e | '<,'>s/if #\[cfg(\(.*\))\] {/\1 => {/e
```
This is imperfect, but substantially accelerated the process. This
prompts for confirmation on the `} else {` since that can also appear
inside one of the arms. This also requires manual intervention to handle
any multi-line conditions.
|
|
|
|
It uses the file metadata on Unix with a fallback for files incorrectly
reported as zero-sized. It uses `GetFileSizeEx` on Windows.
This reduces the number of syscalls needed for determining the file size
of an open file from 3 to 1.
|
|
|
|
Change signature of File::try_lock and File::try_lock_shared
These methods now return Result<(), TryLockError> instead of Result<bool, Error> to make their use less errorprone
These methods are unstable under the "file_lock" feature. The related tracking issue is https://github.com/rust-lang/rust/pull/130999 and this PR changes the signatures as discussed by libs-api: https://github.com/rust-lang/rust/issues/130994#issuecomment-2770838848
|
|
These methods now return Result<(), TryLockError> instead of
Result<bool, Error> to make their use less errorprone
|
|
in core/alloc/std only for now, and ignoring test files
Co-authored-by: Pavel Grigorenko <GrigorenkoPV@ya.ru>
|
|
Impl new API `std::os::unix::fs::mkfifo` under feature `unix_fifo`
Tracking issue #139324
|
|
Tracking issue #139324
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
|
|
|
|
Previously (https://github.com/rust-lang/rust/pull/115200,
https://github.com/rust-lang/rust/pull/138002), we
added `#[no_sanitize(cfi)]` to all code paths that call to a weakly
linked function.
In https://github.com/rust-lang/rust/pull/138349 we fixed the root cause
for this issue, which means we can now remove the corresponding
attributes.
|
|
Start using `with_native_path` in `std::sys::fs`
Ideally, each platform should use their own native path type internally. This will, for example, allow passing a `CStr` directly to `std::fs::File::open` and therefore avoid the need for allocating a new null-terminated C string.
However, doing that for every function and platform all at once makes for a large PR that is way too prone to breaking. So this PR does some minimal refactoring which should help progress towards that goal. The changes are Unix-only and even then I avoided functions that require more changes so that this PR is just moving things around.
r? joboet
|
|
|
|
Change the syntax to include parameter names and a trailing semicolon.
Motivation:
- Mirror the `syscall!` macro.
- Allow rustfmt to format it (when wrapped in parentheses).
- For better documentation (having the parameter names available in
the source code is a bit nicer).
- Allow future improvements to this macro where we can sometimes use the
symbol directly when it's statically known to be available.
|
|
Add std support to cygwin target
|
|
|
|
Signed-off-by: Ookiineko <chiisaineko@protonmail.com>
|
|
|
|
Currently, when enabling CFI via -Zsanitizer=cfi and executing e.g.
std::sys::random::getrandom, we can observe a CFI violation. This is
the case for all consumers of the std::sys::pal::weak::weak macro,
as it is defining weak functions which don't show up in LLVM IR
metadata. CFI fails for all these functions.
Similar to other such cases in
https://github.com/rust-lang/rust/issues/115199, this change stops
emitting the CFI typecheck for consumers of the macro via the
\#[no_sanitize(cfi)] attribute.
|
|
|