File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -33,4 +33,22 @@ impl okf::uio::Uio<Kernel> for Uio {
33
33
td,
34
34
} )
35
35
}
36
+
37
+ unsafe fn read ( td : * mut Thread , iov : * mut IoVec ) -> Option < Self > {
38
+ let res = ( * iov) . len ;
39
+
40
+ if res > Self :: io_max ( ) {
41
+ return None ;
42
+ }
43
+
44
+ Some ( Self {
45
+ iov,
46
+ len : 1 ,
47
+ off : 0 ,
48
+ res : res. try_into ( ) . unwrap ( ) ,
49
+ seg : UioSeg :: Kernel ,
50
+ op : UioRw :: Read ,
51
+ td,
52
+ } )
53
+ }
36
54
}
Original file line number Diff line number Diff line change @@ -9,6 +9,13 @@ pub trait Uio<K: Kernel>: Sized {
9
9
/// - `iov` cannot be null.
10
10
unsafe fn write ( td : * mut K :: Thread , iov : * mut IoVec ) -> Option < Self > ;
11
11
12
+ /// Returns [`None`] if [`IoVec::len`] of `iov` is greater than [`Uio::io_max()`].
13
+ ///
14
+ /// # Safety
15
+ /// - `td` cannot be null.
16
+ /// - `iov` cannot be null.
17
+ unsafe fn read ( td : * mut K :: Thread , iov : * mut IoVec ) -> Option < Self > ;
18
+
12
19
/// Returns value of `UIO_MAXIOV`.
13
20
fn vec_max ( ) -> usize {
14
21
1024
You can’t perform that action at this time.
0 commit comments