@@ -14,6 +14,7 @@ pub struct CmdlineOptions {
1414 pub nfsroot : Option < String > ,
1515 pub init : String ,
1616 pub cleanup : bool ,
17+ pub bind_mount : Vec < String > ,
1718}
1819
1920const SBIN_INIT : & str = "/sbin/init" ;
@@ -28,6 +29,7 @@ impl Default for CmdlineOptions {
2829 nfsroot : None ,
2930 init : SBIN_INIT . into ( ) ,
3031 cleanup : true ,
32+ bind_mount : Vec :: new ( ) ,
3133 }
3234 }
3335}
@@ -45,6 +47,9 @@ fn parse_option(key: &str, value: Option<&str>, options: &mut CmdlineOptions) ->
4547 "rw" => options. rootfsflags . remove ( MsFlags :: MS_RDONLY ) ,
4648 "nfsroot" => options. nfsroot = Some ( ensure_value ( key, value) ?. to_string ( ) ) ,
4749 "init" => options. init = ensure_value ( key, value) ?. into ( ) ,
50+ "rsinit.bind" => options
51+ . bind_mount
52+ . push ( ensure_value ( key, value) ?. to_string ( ) ) ,
4853 _ => ( ) ,
4954 }
5055 Ok ( ( ) )
@@ -236,4 +241,19 @@ mod tests {
236241
237242 assert_eq ! ( options, expected) ;
238243 }
244+
245+ #[ test]
246+ fn test_rsinit_bind ( ) {
247+ let cmdline = "root=/dev/root rsinit.bind=/lib/modules rsinit.bind=/usr/lib/modules\n " ;
248+
249+ let expected = CmdlineOptions {
250+ root : Some ( "/dev/root" . into ( ) ) ,
251+ bind_mount : vec ! [ "/lib/modules" . into( ) , "/usr/lib/modules" . into( ) ] ,
252+ ..Default :: default ( )
253+ } ;
254+
255+ let options = parse_cmdline ( cmdline) . expect ( "failed" ) ;
256+
257+ assert_eq ! ( options, expected) ;
258+ }
239259}
0 commit comments