@@ -130,26 +130,14 @@ impl CtlCommand {
130
130
/// Runner for `update` verb.
131
131
fn run_update ( ) -> Result < ( ) > {
132
132
ensure_running_in_systemd ( ) ?;
133
- let sysroot = openat:: Dir :: open ( "/" ) . context ( "Opening root dir" ) ?;
134
- let dest_fd = format ! ( "/proc/self/fd/{}" , sysroot. as_raw_fd( ) ) ;
135
- let dest_root = std:: fs:: read_link ( dest_fd) ?;
136
-
137
- let devices = crate :: blockdev:: get_devices ( & dest_root)
138
- . with_context ( || "while looking for parent devices" ) ?;
139
- crate :: blockdev:: init_parent_devices ( devices) ;
133
+ let sysroot = prep_before_update ( ) ?;
140
134
bootupd:: client_run_update ( & sysroot)
141
135
}
142
136
143
137
/// Runner for `update` verb.
144
138
fn run_adopt_and_update ( ) -> Result < ( ) > {
145
139
ensure_running_in_systemd ( ) ?;
146
- let sysroot = openat:: Dir :: open ( "/" ) . context ( "Opening root dir" ) ?;
147
- let dest_fd = format ! ( "/proc/self/fd/{}" , sysroot. as_raw_fd( ) ) ;
148
- let dest_root = std:: fs:: read_link ( dest_fd) ?;
149
-
150
- let devices = crate :: blockdev:: get_devices ( & dest_root)
151
- . with_context ( || "while looking for parent devices" ) ?;
152
- crate :: blockdev:: init_parent_devices ( devices) ;
140
+ let sysroot = prep_before_update ( ) ?;
153
141
bootupd:: client_run_adopt_and_update ( & sysroot)
154
142
}
155
143
@@ -228,3 +216,15 @@ fn run_status_in_container(json_format: bool) -> Result<()> {
228
216
}
229
217
Ok ( ( ) )
230
218
}
219
+
220
+ /// Initialize parent devices to prepare the update
221
+ fn prep_before_update ( ) -> Result < openat:: Dir > {
222
+ let sysroot = openat:: Dir :: open ( "/" ) . context ( "Opening root dir" ) ?;
223
+ let dest_fd = format ! ( "/proc/self/fd/{}" , sysroot. as_raw_fd( ) ) ;
224
+ let dest_root = std:: fs:: read_link ( dest_fd) ?;
225
+
226
+ let devices = crate :: blockdev:: get_devices ( & dest_root)
227
+ . with_context ( || "while looking for parent devices" ) ?;
228
+ crate :: blockdev:: init_parent_devices ( devices) ;
229
+ Ok ( sysroot)
230
+ }
0 commit comments