Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Redox Scheme
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
redox-os
Redox Scheme
Commits
d2bfa80a
Commit
d2bfa80a
authored
3 months ago
by
bjorn3
Browse files
Options
Downloads
Patches
Plain Diff
Add support for handling sendfd
parent
dbb9dcb9
No related branches found
Branches containing commit
Tags
v0.3.0
Tags containing commit
1 merge request
!3
Several major breaking changes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib.rs
+64
-2
64 additions, 2 deletions
src/lib.rs
with
64 additions
and
2 deletions
src/lib.rs
+
64
−
2
View file @
d2bfa80a
...
...
@@ -9,8 +9,8 @@ use core::str;
use
libredox
::
flag
;
use
syscall
::
schemev2
::{
Cqe
,
CqeOpcode
,
NewFdFlags
,
Opcode
,
Sqe
};
use
syscall
::{
Error
,
EventFlags
,
MapFlags
,
MunmapFlags
,
Packet
,
Result
,
S
tat
,
StatVfs
,
TimeSpec
,
EBADF
,
EINTR
,
EINVAL
,
ENOENT
,
EOPNOTSUPP
,
Error
,
EventFlags
,
FobtainFdFlags
,
MapFlags
,
MunmapFlags
,
Packet
,
Result
,
S
endFdFlags
,
Stat
,
StatVfs
,
TimeSpec
,
EBADF
,
EINTR
,
EINVAL
,
ENOENT
,
EOPNOTSUPP
,
};
pub
use
self
::
scheme_block
::
SchemeBlock
;
...
...
@@ -78,9 +78,14 @@ pub struct CallRequest {
inner
:
Request
,
}
pub
struct
SendFdRequest
{
inner
:
Request
,
}
pub
enum
RequestKind
{
Call
(
CallRequest
),
Cancellation
(
CancellationRequest
),
SendFd
(
SendFdRequest
),
MsyncMsg
,
MunmapMsg
,
MmapMsg
,
...
...
@@ -397,6 +402,51 @@ impl CallRequest {
}
}
impl
SendFdRequest
{
#[inline]
pub
fn
request
(
&
self
)
->
Request
{
self
.inner
}
pub
fn
id
(
&
self
)
->
usize
{
self
.inner.sqe.args
[
0
]
as
usize
}
pub
fn
flags
(
&
self
)
->
SendFdFlags
{
SendFdFlags
::
from_bits_retain
(
self
.inner.sqe.args
[
1
]
as
usize
)
}
pub
fn
obtain_fd
(
&
self
,
socket
:
&
Socket
,
flags
:
FobtainFdFlags
,
dst_fd_or_ptr
:
Result
<
usize
,
&
mut
usize
>
,
)
->
Result
<
()
>
{
assert!
(
!
flags
.contains
(
FobtainFdFlags
::
MANUAL_FD
));
match
dst_fd_or_ptr
{
Ok
(
dst_fd
)
=>
{
socket
.inner
.write
(
&
Cqe
{
flags
:
CqeOpcode
::
ObtainFd
as
u8
,
extra_raw
:
usize
::
to_ne_bytes
((
flags
|
FobtainFdFlags
::
MANUAL_FD
)
.bits
())[
..
3
]
.try_into
()
.unwrap
(),
tag
:
self
.inner
.request_id
()
.0
,
result
:
dst_fd
as
u64
,
})
?
;
}
Err
(
ptr
)
=>
{
socket
.inner
.write
(
&
Cqe
{
flags
:
CqeOpcode
::
ObtainFd
as
u8
,
extra_raw
:
usize
::
to_ne_bytes
(
flags
.bits
())[
..
3
]
.try_into
()
.unwrap
(),
tag
:
self
.inner
.request_id
()
.0
,
result
:
ptr
as
*
mut
usize
as
u64
,
})
?
;
}
}
Ok
(())
}
}
impl
Request
{
#[inline]
pub
fn
context_id
(
&
self
)
->
usize
{
...
...
@@ -411,6 +461,9 @@ impl Request {
Some
(
Opcode
::
Cancel
)
=>
RequestKind
::
Cancellation
(
CancellationRequest
{
id
:
Id
(
self
.sqe.tag
),
}),
Some
(
Opcode
::
Sendfd
)
=>
RequestKind
::
SendFd
(
SendFdRequest
{
inner
:
Request
{
sqe
:
self
.sqe
},
}),
Some
(
Opcode
::
Msync
)
=>
RequestKind
::
MsyncMsg
,
//Some(Opcode::Munmap) => RequestKind::MunmapMsg,
Some
(
Opcode
::
RequestMmap
)
=>
RequestKind
::
MmapMsg
,
...
...
@@ -491,6 +544,15 @@ impl Response {
tag
:
req
.inner.sqe.tag
,
})
}
pub
fn
for_sendfd
(
req
:
&
SendFdRequest
,
status
:
Result
<
usize
>
)
->
Self
{
Self
(
Cqe
{
flags
:
CqeOpcode
::
RespondRegular
as
u8
,
extra_raw
:
[
0_u8
;
3
],
result
:
Error
::
mux
(
status
)
as
u64
,
tag
:
req
.inner.sqe.tag
,
})
}
}
pub
enum
SignalBehavior
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment