File tree Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ pub struct Uio {
16
16
}
17
17
18
18
impl okf:: uio:: Uio < Kernel > for Uio {
19
- unsafe fn write ( td : * mut Thread , iov : * mut IoVec ) -> Option < Self > {
19
+ unsafe fn write ( iov : * mut IoVec , td : * mut Thread ) -> Option < Self > {
20
20
let res = ( * iov) . len ;
21
21
22
22
if res > Self :: io_max ( ) {
@@ -34,7 +34,7 @@ impl okf::uio::Uio<Kernel> for Uio {
34
34
} )
35
35
}
36
36
37
- unsafe fn read ( td : * mut Thread , iov : * mut IoVec ) -> Option < Self > {
37
+ unsafe fn read ( iov : * mut IoVec , off : usize , td : * mut Thread ) -> Option < Self > {
38
38
let res = ( * iov) . len ;
39
39
40
40
if res > Self :: io_max ( ) {
@@ -44,7 +44,7 @@ impl okf::uio::Uio<Kernel> for Uio {
44
44
Some ( Self {
45
45
iov,
46
46
len : 1 ,
47
- off : 0 ,
47
+ off : off . try_into ( ) . unwrap ( ) ,
48
48
res : res. try_into ( ) . unwrap ( ) ,
49
49
seg : UioSeg :: Kernel ,
50
50
op : UioRw :: Read ,
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ pub unsafe fn write<K: Kernel>(
75
75
} ;
76
76
77
77
// Write.
78
- let mut uio = K :: Uio :: write ( td , & mut vec) . unwrap ( ) ;
78
+ let mut uio = K :: Uio :: write ( & mut vec, td ) . unwrap ( ) ;
79
79
let errno = kern. kern_writev ( td, fd, & mut uio) ;
80
80
81
81
match NonZero :: new ( errno) {
Original file line number Diff line number Diff line change @@ -7,14 +7,17 @@ pub trait Uio<K: Kernel>: Sized {
7
7
/// # Safety
8
8
/// - `td` cannot be null.
9
9
/// - `iov` cannot be null.
10
- unsafe fn write ( td : * mut K :: Thread , iov : * mut IoVec ) -> Option < Self > ;
10
+ unsafe fn write ( iov : * mut IoVec , td : * mut K :: Thread ) -> Option < Self > ;
11
11
12
12
/// Returns [`None`] if [`IoVec::len`] of `iov` is greater than [`Uio::io_max()`].
13
13
///
14
14
/// # Safety
15
15
/// - `td` cannot be null.
16
16
/// - `iov` cannot be null.
17
- unsafe fn read ( td : * mut K :: Thread , iov : * mut IoVec ) -> Option < Self > ;
17
+ ///
18
+ /// # Panics
19
+ /// If `off` larger than [`isize::MAX`].
20
+ unsafe fn read ( iov : * mut IoVec , off : usize , td : * mut K :: Thread ) -> Option < Self > ;
18
21
19
22
/// Returns value of `UIO_MAXIOV`.
20
23
fn vec_max ( ) -> usize {
You can’t perform that action at this time.
0 commit comments