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,37 +92,42 @@ fn mount_fex_rootfs() -> Result<()> {
9292 Ok ( ( ) )
9393}
9494
95+ pub fn place_etc ( file : & str ) -> Result < ( ) > {
96+ let tmp = "/tmp/" . to_string ( ) + file;
97+ let etc = "/etc/" . to_string ( ) + file;
98+
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" ) ?;
105+
106+ let fd = open_tree (
107+ CWD ,
108+ & tmp,
109+ OpenTreeFlags :: OPEN_TREE_CLONE | OpenTreeFlags :: OPEN_TREE_CLOEXEC ,
110+ )
111+ . context ( "Failed to open_tree tmp" ) ?;
112+
113+ move_mount (
114+ fd. as_fd ( ) ,
115+ "" ,
116+ CWD ,
117+ etc,
118+ MoveMountFlags :: MOVE_MOUNT_F_EMPTY_PATH ,
119+ )
120+ . context ( "Failed to move_mount tmp to etc" )
121+ }
122+
95123pub fn mount_filesystems ( ) -> Result < ( ) > {
96124 make_tmpfs ( "/var/run" ) ?;
97125
98126 if mount_fex_rootfs ( ) . is_err ( ) {
99127 println ! ( "Failed to mount FEX rootfs, carrying on without." )
100128 }
101129
102- let _ = File :: options ( )
103- . write ( true )
104- . create ( true )
105- . truncate ( true )
106- . open ( "/tmp/resolv.conf" )
107- . context ( "Failed to create `/tmp/resolv.conf`" ) ?;
108-
109- {
110- let fd = open_tree (
111- CWD ,
112- "/tmp/resolv.conf" ,
113- OpenTreeFlags :: OPEN_TREE_CLONE | OpenTreeFlags :: OPEN_TREE_CLOEXEC ,
114- )
115- . context ( "Failed to open_tree `/tmp/resolv.conf`" ) ?;
116-
117- move_mount (
118- fd. as_fd ( ) ,
119- "" ,
120- CWD ,
121- "/etc/resolv.conf" ,
122- MoveMountFlags :: MOVE_MOUNT_F_EMPTY_PATH ,
123- )
124- . context ( "Failed to move_mount `/etc/resolv.conf`" ) ?;
125- }
130+ place_etc ( "resolv.conf" ) ?;
126131
127132 mount2 (
128133 Some ( "binfmt_misc" ) ,
You can’t perform that action at this time.
0 commit comments