File tree Expand file tree Collapse file tree 3 files changed +6
-5
lines changed Expand file tree Collapse file tree 3 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ impl Filesystem for Unpfs {
149
149
}
150
150
151
151
fn rread ( & mut self , fid : & mut Fid < Self :: Fid > , offset : u64 , count : u32 ) -> Result < Fcall > {
152
- let file = fid. aux_mut ( ) . file . as_mut ( ) . unwrap ( ) ;
152
+ let file = fid. aux_mut ( ) . file . as_mut ( ) . ok_or ( INVALID_FID ! ( ) ) ? ;
153
153
file. seek ( SeekFrom :: Start ( offset) ) ?;
154
154
155
155
let mut buf = create_buffer ( count as usize ) ;
@@ -160,7 +160,7 @@ impl Filesystem for Unpfs {
160
160
}
161
161
162
162
fn rwrite ( & mut self , fid : & mut Fid < Self :: Fid > , offset : u64 , data : & Data ) -> Result < Fcall > {
163
- let file = fid. aux_mut ( ) . file . as_mut ( ) . unwrap ( ) ;
163
+ let file = fid. aux_mut ( ) . file . as_mut ( ) . ok_or ( INVALID_FID ! ( ) ) ? ;
164
164
file. seek ( SeekFrom :: Start ( offset) ) ?;
165
165
Ok ( Fcall :: Rwrite { count : file. write ( & data. 0 ) ? as u32 } )
166
166
}
@@ -188,7 +188,7 @@ impl Filesystem for Unpfs {
188
188
}
189
189
190
190
fn rfsync ( & mut self , fid : & mut Fid < Self :: Fid > ) -> Result < Fcall > {
191
- fid. aux_mut ( ) . file . as_mut ( ) . unwrap ( ) . sync_all ( ) ?;
191
+ fid. aux_mut ( ) . file . as_mut ( ) . ok_or ( INVALID_FID ! ( ) ) ? . sync_all ( ) ?;
192
192
Ok ( Fcall :: Rfsync )
193
193
}
194
194
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ macro_rules! res { ($err:expr) => { Err(From::from($err)) } }
11
11
macro_rules! io_err { ( $kind: ident, $msg: expr) => {
12
12
:: std:: io:: Error :: new( :: std:: io:: ErrorKind :: $kind, $msg)
13
13
} }
14
+ macro_rules! INVALID_FID { ( ) => ( io_err!( InvalidInput , "Invalid fid" ) ) }
14
15
15
16
pub fn create_buffer ( size : usize ) -> Vec < u8 > {
16
17
let mut buffer = Vec :: with_capacity ( size) ;
Original file line number Diff line number Diff line change 1
1
2
- //! Filesystems library using 9P2000.L protocol, a extended variant of 9P from the Plan 9.
2
+ //! Filesystems library using 9P2000.L protocol, an extended variant of 9P from the Plan 9.
3
3
//!
4
4
//! 9P protocol is originally developed for Plan 9 distributed OS.
5
5
//! As it's extendable and suitable for filesystems 9P is ported to Linux.
6
6
//! However, 9P protocol lacks Linux or unix specific features,
7
7
//! which is the problem for developing serious filesystems.
8
8
//!
9
- //! 9P2000.L is a extended protocol of 9P for Linux.
9
+ //! 9P2000.L is an extended variant protocol of 9P for Linux.
10
10
//! It has Linux specific features and is supported by Linux kernel 9P module.
11
11
//!
12
12
//! rs9p is a library to develop 9P2000.L virtual filesystems in Rust.
You can’t perform that action at this time.
0 commit comments