@@ -10,9 +10,7 @@ use std::{cmp, slice, u32};
1010use nix:: libc:: c_ulong;
1111use nix:: libc:: ioctl as nix_ioctl;
1212
13- use crate :: core:: {
14- DevId , Device , DeviceInfo , DmFlags , DmName , DmNameBuf , DmOptions , DmUuid , TargetTypeBuf ,
15- } ;
13+ use crate :: core:: { DevId , Device , DeviceInfo , DmFlags , DmName , DmNameBuf , DmOptions , DmUuid } ;
1614use crate :: result:: { DmError , DmResult } ;
1715
1816use crate :: core:: deviceinfo:: { DM_NAME_LEN , DM_UUID_LEN } ;
@@ -400,7 +398,7 @@ impl DM {
400398 & self ,
401399 id : & DevId ,
402400 options : & DmOptions ,
403- ) -> DmResult < ( DeviceInfo , Vec < ( u64 , u64 , TargetTypeBuf , String ) > ) > {
401+ ) -> DmResult < ( DeviceInfo , Vec < ( u64 , u64 , String , String ) > ) > {
404402 let mut hdr = options. to_ioctl_hdr ( Some ( id) , DmFlags :: DM_QUERY_INACTIVE_TABLE ) ;
405403
406404 let data_out = self . do_ioctl ( dmi:: DM_DEV_WAIT_CMD as u8 , & mut hdr, None ) ?;
@@ -422,15 +420,15 @@ impl DM {
422420 /// # Example
423421 ///
424422 /// ```no_run
425- /// use devicemapper::{DM, DevId, DmName, TargetTypeBuf };
423+ /// use devicemapper::{DM, DevId, DmName};
426424 /// let dm = DM::new().unwrap();
427425 ///
428426 /// // Create a 16MiB device (32768 512-byte sectors) that maps to /dev/sdb1
429427 /// // starting 1MiB into sdb1
430428 /// let table = vec![(
431429 /// 0,
432430 /// 32768,
433- /// TargetTypeBuf::new( "linear".into()).expect("valid" ),
431+ /// "linear".into(),
434432 /// "/dev/sdb1 2048".into()
435433 /// )];
436434 ///
@@ -441,7 +439,7 @@ impl DM {
441439 pub fn table_load (
442440 & self ,
443441 id : & DevId ,
444- targets : & [ ( u64 , u64 , TargetTypeBuf , String ) ] ,
442+ targets : & [ ( u64 , u64 , String , String ) ] ,
445443 ) -> DmResult < DeviceInfo > {
446444 let mut targs = Vec :: new ( ) ;
447445
@@ -547,13 +545,15 @@ impl DM {
547545 /// Panics if there is an error parsing the table.
548546 /// Trims trailing white space off final entry on each line. This
549547 /// canonicalization makes checking identity of tables easier.
548+ /// Postcondition: The length of the next to last entry in any tuple is
549+ /// no more than 16 characters.
550550 // Justification: If the ioctl succeeded, the data is correct and
551551 // complete. An error in parsing can only result from a change in the
552552 // kernel. We rely on DM's interface versioning system. Kernel changes
553553 // will either be backwards-compatible, or will increment
554554 // DM_VERSION_MAJOR. Since calls made with a non-matching major version
555555 // will fail, this protects against callers parsing unknown formats.
556- fn parse_table_status ( count : u32 , buf : & [ u8 ] ) -> Vec < ( u64 , u64 , TargetTypeBuf , String ) > {
556+ fn parse_table_status ( count : u32 , buf : & [ u8 ] ) -> Vec < ( u64 , u64 , String , String ) > {
557557 let mut targets = Vec :: new ( ) ;
558558 if !buf. is_empty ( ) {
559559 let mut next_off = 0 ;
@@ -579,12 +579,7 @@ impl DM {
579579 String :: from_utf8_lossy ( slc) . trim_end ( ) . to_owned ( )
580580 } ;
581581
582- targets. push ( (
583- targ. sector_start ,
584- targ. length ,
585- TargetTypeBuf :: new ( target_type) . expect ( "< sizeof target_spec" ) ,
586- params,
587- ) ) ;
582+ targets. push ( ( targ. sector_start , targ. length , target_type, params) ) ;
588583
589584 next_off = targ. next as usize ;
590585 }
@@ -625,7 +620,7 @@ impl DM {
625620 & self ,
626621 id : & DevId ,
627622 options : & DmOptions ,
628- ) -> DmResult < ( DeviceInfo , Vec < ( u64 , u64 , TargetTypeBuf , String ) > ) > {
623+ ) -> DmResult < ( DeviceInfo , Vec < ( u64 , u64 , String , String ) > ) > {
629624 let mut hdr = options. to_ioctl_hdr (
630625 Some ( id) ,
631626 DmFlags :: DM_NOFLUSH | DmFlags :: DM_STATUS_TABLE | DmFlags :: DM_QUERY_INACTIVE_TABLE ,
0 commit comments