pub fn grow_data_partition(log: &Logger, disk: &str) -> Result<()> {
    let vtoc = prtvtoc(&disk)?;

    if vtoc.sector_size != 512 {
        bail!("only works with 512 byte sectors at the moment");
    }

    let reserved = vtoc.partitions.get("8").unwrap();
    if reserved.tag != "11" || reserved.sector_count != 16384 {
        bail!("slice 8 does not look like a regular reserved partition");
    }

    /*
     * Depending on the image, there may or may not be an EFI System Partition.
     * If there is, it will be partition 0 which will mean the pool is partition
     * 1.
     */
    let datapartname = match vtoc.partitions.len() {
        2 => "0",
        3 => "1",
        n => bail!("found {} partitions, wanted 2 or 3", n),
    };
    let data = vtoc.partitions.get(datapartname).unwrap();
    if data.tag != "4" {
        bail!("slice 1 does not look like a regular data partition");
    }

    if data.sector_last >= reserved.sector_first - 1 {
        /*
         * The data partition is at least as large as expected, so do nothing.
         */
        info!(log, "data partition growth not required");
        return Ok(());
    }

    let delta = reserved.sector_first - 1 - data.sector_last;

    info!(log, "growing data partition...");
    fmthard(log, disk, &data.id, &data.tag, &data.flags,
        data.sector_first, data.sector_count + delta)?;
    info!(log, "partition growth ok");

    Ok(())
}
/**
 * Check to see if the data slice should be grown to fill any unallocated space.
 */
Check to see if the data slice should be grown to fill any unallocated space.
Check to see if the data slice should be grown to fill any unallocated space .
pub fn grow_data_partition(log: &Logger, disk: &str) -> Result<()> {
    let vtoc = prtvtoc(&disk)?;
    if vtoc.sector_size != 512 {
        bail!("only works with 512 byte sectors at the moment");
    }
    let reserved = vtoc.partitions.get("8").unwrap();
    if reserved.tag != "11" || reserved.sector_count != 16384 {
        bail!("slice 8 does not look like a regular reserved partition");
    }
    /*
     * Depending on the image, there may or may not be an EFI System Partition.
     * If there is, it will be partition 0 which will mean the pool is partition
     * 1.
     */
    let datapartname = match vtoc.partitions.len() {
        2 => "0",
        3 => "1",
        n => bail!("found {} partitions, wanted 2 or 3", n),
    };
    let data = vtoc.partitions.get(datapartname).unwrap();
    if data.tag != "4" {
        bail!("slice 1 does not look like a regular data partition");
    }
    if data.sector_last >= reserved.sector_first - 1 {
        /*
         * The data partition is at least as large as expected, so do nothing.
         */
        info!(log, "data partition growth not required");
        return Ok(());
    }
    let delta = reserved.sector_first - 1 - data.sector_last;
    info!(log, "growing data partition...");
    fmthard(log, disk, &data.id, &data.tag, &data.flags,
        data.sector_first, data.sector_count + delta)?;
    info!(log, "partition growth ok");
    Ok(())
}
pub fn grow_data_partition ( log : & Logger , disk : & str ) -> Result < ( ) > { let vtoc = prtvtoc ( & disk ) ? ; if vtoc . sector_size != 512 { bail ! ( " " ) ; } let reserved = vtoc . partitions . get ( " " ) . unwrap ( ) ; if reserved . tag != " " || reserved . sector_count != 16384 { bail ! ( " " ) ; } /*
     * Depending on the image, there may or may not be an EFI System Partition.
     * If there is, it will be partition 0 which will mean the pool is partition
     * 1.
     */ let datapartname = match vtoc . partitions . len ( ) { 2 => " " , 3 => " " , n => bail ! ( " " n ) , } ; let data = vtoc . partitions . get ( datapartname ) . unwrap ( ) ; if data . tag != " " { bail ! ( " " ) ; } if data . sector_last >= reserved . sector_first - 1 { /*
         * The data partition is at least as large as expected, so do nothing.
         */ info ! ( log " " ) ; return Ok ( ( ) ) ; } let delta = reserved . sector_first - 1 - data . sector_last ; info ! ( log " " ) ; fmthard ( log , disk , & data . id , & data . tag , & data . flags , data . sector_first , data . sector_count + delta ) ? ; info ! ( log " " ) ; Ok ( ( ) ) }
Check to see if the data slice should be grown to fill any unallocated space.
Check to see if the data slice should be grown to fill any unallocated space .
log
&Logger
disk
&str
log
&Logger
disk
&str