File tree Expand file tree Collapse file tree 2 files changed +10
-13
lines changed Expand file tree Collapse file tree 2 files changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -54,18 +54,18 @@ fn read_file(filename: &str) -> std::result::Result<String, String> {
5454}
5555
5656fn wait_for_device ( root_device : & str ) -> Result < ( ) > {
57- let mut counter = 0 ;
58- while !Path :: new ( & root_device) . exists ( ) {
59- let duration = time:: Duration :: from_millis ( 5 ) ;
57+ let duration = time:: Duration :: from_millis ( 5 ) ;
58+ let path = Path :: new ( & root_device) ;
6059
61- if counter > 1000 {
62- return Err ( "timout reached while waiting for the device" . into ( ) ) ;
60+ for _ in 0 ..1000 {
61+ if path. exists ( ) {
62+ return Ok ( ( ) ) ;
6363 }
6464
6565 thread:: sleep ( duration) ;
66- counter += 1 ;
6766 }
68- Ok ( ( ) )
67+
68+ Err ( "timout reached while waiting for the device" . into ( ) )
6969}
7070
7171/*
Original file line number Diff line number Diff line change @@ -49,13 +49,10 @@ pub fn mount_root(options: &CmdlineOptions) -> Result<()> {
4949 return Err ( "root= not found in /proc/cmdline" . into ( ) ) ;
5050 }
5151
52- if options. rootfstype != Some ( "nfs" . to_string ( ) ) &&
53- options. rootfstype != Some ( "9p" . to_string ( ) )
54- {
55- let root_device = options. root . as_ref ( ) . ok_or ( "No root device argument" ) ?;
56- wait_for_device ( root_device) ?;
52+ match options. rootfstype . as_deref ( ) {
53+ Some ( "nfs" ) | Some ( "9p" ) => ( ) ,
54+ _ => wait_for_device ( root) ?,
5755 }
58-
5956 mkdir ( "/root" ) ?;
6057
6158 debug ! (
You can’t perform that action at this time.
0 commit comments