@@ -170,6 +170,8 @@ pub(crate) fn install_create_rootfs(
170
170
// Verify that the target is empty (if not already wiped in particular, but it's
171
171
// also good to verify that the wipe worked)
172
172
let device = crate :: blockdev:: list_dev ( & opts. device ) ?;
173
+ // Canonicalize devpath
174
+ let devpath: Utf8PathBuf = device. path ( ) . into ( ) ;
173
175
174
176
// Handle wiping any existing data
175
177
if opts. wipe {
@@ -193,20 +195,6 @@ pub(crate) fn install_create_rootfs(
193
195
if mntdir. exists ( ) {
194
196
std:: fs:: remove_dir_all ( & mntdir) ?;
195
197
}
196
- let devdir = mntdir. join ( "dev" ) ;
197
- std:: fs:: create_dir_all ( & devdir) ?;
198
- Task :: new ( "Mounting devtmpfs" , "mount" )
199
- . args ( [ "devtmpfs" , "-t" , "devtmpfs" , devdir. as_str ( ) ] )
200
- . quiet ( )
201
- . run ( ) ?;
202
-
203
- // Now at this point, our /dev is a stale snapshot because we don't have udev running.
204
- // So from hereon after, we prefix devices with our temporary devtmpfs mount.
205
- let reldevice = opts
206
- . device
207
- . strip_prefix ( "/dev/" )
208
- . context ( "Absolute device path in /dev/ required" ) ?;
209
- let device = devdir. join ( reldevice) ;
210
198
211
199
// Use the install configuration to find the block setup, if we have one
212
200
let block_setup = if let Some ( config) = state. install_config . as_ref ( ) {
@@ -245,7 +233,7 @@ pub(crate) fn install_create_rootfs(
245
233
// sgdisk is too verbose
246
234
sgdisk. cmd . stdout ( Stdio :: null ( ) ) ;
247
235
sgdisk. cmd . arg ( "-Z" ) ;
248
- sgdisk. cmd . arg ( & device) ;
236
+ sgdisk. cmd . arg ( device. path ( ) ) ;
249
237
sgdisk. cmd . args ( [ "-U" , "R" ] ) ;
250
238
#[ allow( unused_assignments) ]
251
239
if cfg ! ( target_arch = "x86_64" ) {
@@ -316,27 +304,28 @@ pub(crate) fn install_create_rootfs(
316
304
{
317
305
let mut f = std:: fs:: OpenOptions :: new ( )
318
306
. write ( true )
319
- . open ( & device )
320
- . with_context ( || format ! ( "opening {device }" ) ) ?;
307
+ . open ( & devpath )
308
+ . with_context ( || format ! ( "opening {devpath }" ) ) ?;
321
309
crate :: blockdev:: reread_partition_table ( & mut f, true )
322
310
. context ( "Rereading partition table" ) ?;
323
311
}
324
312
313
+ // Full udev sync; it'd obviously be better to await just the devices
314
+ // we're targeting, but this is a simple coarse hammer.
325
315
crate :: blockdev:: udev_settle ( ) ?;
326
316
327
317
// Now inspect the partitioned device again so we can find the names of the child devices.
328
- let device_partitions = crate :: blockdev:: list_dev ( & device ) ?
318
+ let device_partitions = crate :: blockdev:: list_dev ( & devpath ) ?
329
319
. children
330
320
. ok_or_else ( || anyhow:: anyhow!( "Failed to find children after partitioning" ) ) ?;
331
321
// Given a partition number, return the path to its device.
332
322
let findpart = |idx : u32 | -> Result < String > {
333
323
// checked_sub is here because our partition numbers start at 1, but the vec starts at 0
334
- let devname = device_partitions
324
+ let devpath = device_partitions
335
325
. get ( idx. checked_sub ( 1 ) . unwrap ( ) as usize )
336
326
. ok_or_else ( || anyhow:: anyhow!( "Missing partition for index {idx}" ) ) ?
337
- . name
338
- . as_str ( ) ;
339
- Ok ( devdir. join ( devname) . to_string ( ) )
327
+ . path ( ) ;
328
+ Ok ( devpath)
340
329
} ;
341
330
342
331
let base_rootdev = findpart ( rootpn) ?;
@@ -448,7 +437,7 @@ pub(crate) fn install_create_rootfs(
448
437
} ;
449
438
Ok ( RootSetup {
450
439
luks_device,
451
- device,
440
+ device : devpath ,
452
441
rootfs,
453
442
rootfs_fd,
454
443
rootfs_uuid : Some ( root_uuid. to_string ( ) ) ,
0 commit comments