File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,16 +92,23 @@ fn mount_fex_rootfs() -> Result<()> {
9292 Ok ( ( ) )
9393}
9494
95- pub fn place_etc ( file : & str ) -> Result < ( ) > {
95+ pub fn place_etc ( file : & str , contents : Option < & str > ) -> Result < ( ) > {
9696 let tmp = "/tmp/" . to_string ( ) + file;
9797 let etc = "/etc/" . to_string ( ) + file;
9898
99- let _ = File :: options ( )
100- . write ( true )
101- . create ( true )
102- . truncate ( true )
103- . open ( & tmp)
104- . context ( "Failed to create temp backing of an etc file" ) ?;
99+ {
100+ let mut file = File :: options ( )
101+ . write ( true )
102+ . create ( true )
103+ . truncate ( true )
104+ . open ( & tmp)
105+ . context ( "Failed to create temp backing of an etc file" ) ?;
106+
107+ if let Some ( content) = contents {
108+ file. write_all ( content. as_bytes ( ) )
109+ . context ( "Failed to write tmp backing of etc" ) ?;
110+ }
111+ }
105112
106113 let fd = open_tree (
107114 CWD ,
@@ -127,7 +134,7 @@ pub fn mount_filesystems() -> Result<()> {
127134 println ! ( "Failed to mount FEX rootfs, carrying on without." )
128135 }
129136
130- place_etc ( "resolv.conf" ) ?;
137+ place_etc ( "resolv.conf" , None ) ?;
131138
132139 mount2 (
133140 Some ( "binfmt_misc" ) ,
You can’t perform that action at this time.
0 commit comments