Add os::unix::net::SocketAddr::from_path#93239
Add os::unix::net::SocketAddr::from_path#93239bors merged 5 commits intorust-lang:masterfrom Thomasdezeeuw:socketaddr_creation
Conversation
Creates a new SocketAddr from a path, supports both regular paths and abstract namespaces.
I don't think we should do that. |
I see you point, but
👍 We could use it internally though, so that |
Depends what you mean with 'valid'. Such paths are not accepted by any api like Linux APIs do not treat AF_UNIX sockaddrs starting with a Using a leading |
That's fair, I'll remove reject |
And change it to disallow NULL bytes.
|
I've renamed it to |
|
(We should also add |
The creation of libc::sockaddr_un is a safe operation, no need for it to be unsafe. This also uses the more performant copy_nonoverlapping instead of an iterator.
Thomasdezeeuw
left a comment
There was a problem hiding this comment.
(We should also add
as_pathfor completeness, but that doesn't have to be part of this PR.)
@m-ou-se what would it do differently from as_pathname?
This comment has been minimized.
This comment has been minimized.
|
I don't know why the CI failed, it seems it received some unexpected signal? |
It's not unique error, it's all over CI #93375 (comment) |
Apologies, I missed that we already had that one. It makes me wonder if we should name this new function Can you open a new tracking issue for
Looks spurious. I've restarted the CI. |
Personally I don't really have a preference here.
I originally linked it to #65275, but I've created #93423.
|
|
@bors r+ |
|
📌 Commit 35f578f has been approved by |
…askrgr Rollup of 10 pull requests Successful merges: - rust-lang#92611 (Add links to the reference and rust by example for asm! docs and lints) - rust-lang#93158 (wasi: implement `sock_accept` and enable networking) - rust-lang#93239 (Add os::unix::net::SocketAddr::from_path) - rust-lang#93261 (Some unwinding related cg_ssa cleanups) - rust-lang#93295 (Avoid double panics when using `TempDir` in tests) - rust-lang#93353 (Unimpl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}<$t> for Saturating<$t>) - rust-lang#93356 (Edit docs introduction for `std::cmp::PartialOrd`) - rust-lang#93375 (fix typo `documenation`) - rust-lang#93399 (rustbuild: Fix compiletest warning when building outside of root.) - rust-lang#93404 (Fix a typo from rust-lang#92899) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
| // null byte for pathname addresses is already there because we zeroed the | ||
| // struct | ||
| // SAFETY: `bytes` and `addr.sun_path` are not overlapping and | ||
| // both point to valid memory. |
There was a problem hiding this comment.
Perhaps add "we checked path is not too long"
Creates a new SocketAddr from a path, supports both regular paths and
abstract namespaces.
Note that
SocketAddr::from_abstract_namespacecould be removed after this asSocketAddr::unixalso supports abstract namespaces.Updates #65275
Unblocks tokio-rs/mio#1527
r? @m-ou-se