pub fn format_expand(log: &Logger, disk: &str) -> Result<()> {
    /*
     * We need a temporary file with a list of commands for format(1M) to
     * execute using the "-f" option.
     */
    let tf = tempfile::NamedTempFile::new()?;
    info!(log, "TEMP FILE: {:?}", tf.path().to_str().unwrap());
    let mut w = std::io::BufWriter::new(tf.as_file());
    w.write_all("partition\nexpand\nlabel\nquit\nquit\n".as_bytes())?;
    w.flush()?;

    let output = std::process::Command::new("/usr/sbin/format")
        .env_clear()
        .arg("-d").arg(disk)
        .arg("-f").arg(tf.path().to_str().unwrap())
        .output()?;

    if !output.status.success() {
        bail!("format failure: {}", output.info());
    }

    info!(log, "format stdout: |{}|", String::from_utf8_lossy(&output.stdout));
    info!(log, "format stderr: |{}|", String::from_utf8_lossy(&output.stderr));

    Ok(())
}
/**
 * Use the "expand" command in format(1M) to expand the GPT table into the
 * enlarged underlying volume.  This interface is clunky and unfortunate, but
 * I'm not currently aware of a better way.
 */
Use the "expand" command in format(1M) to expand the GPT table into the
enlarged underlying volume.  This interface is clunky and unfortunate, but
I'm not currently aware of a better way.
Use the " expand " command in format ( 1M ) to expand the GPT table into the enlarged underlying volume . This interface is clunky and unfortunate but I ' m not currently aware of a better way .
pub fn format_expand(log: &Logger, disk: &str) -> Result<()> {
    /*
     * We need a temporary file with a list of commands for format(1M) to
     * execute using the "-f" option.
     */
    let tf = tempfile::NamedTempFile::new()?;
    info!(log, "TEMP FILE: {:?}", tf.path().to_str().unwrap());
    let mut w = std::io::BufWriter::new(tf.as_file());
    w.write_all("partition\nexpand\nlabel\nquit\nquit\n".as_bytes())?;
    w.flush()?;
    let output = std::process::Command::new("/usr/sbin/format")
        .env_clear()
        .arg("-d").arg(disk)
        .arg("-f").arg(tf.path().to_str().unwrap())
        .output()?;
    if !output.status.success() {
        bail!("format failure: {}", output.info());
    }
    info!(log, "format stdout: |{}|", String::from_utf8_lossy(&output.stdout));
    info!(log, "format stderr: |{}|", String::from_utf8_lossy(&output.stderr));
    Ok(())
}
pub fn format_expand ( log : & Logger , disk : & str ) -> Result < ( ) > { /*
     * We need a temporary file with a list of commands for format(1M) to
     * execute using the "-f" option.
     */ let tf = tempfile :: NamedTempFile :: new ( ) ? ; info ! ( log " " tf path ( ) to_str ( ) unwrap ( ) ) ; let mut w = std :: io :: BufWriter :: new ( tf . as_file ( ) ) ; w . write_all ( " \n \n \n \n \n " . as_bytes ( ) ) ? ; w . flush ( ) ? ; let output = std :: process :: Command :: new ( " " ) . env_clear ( ) . arg ( " " ) . arg ( disk ) . arg ( " " ) . arg ( tf . path ( ) . to_str ( ) . unwrap ( ) ) . output ( ) ? ; if ! output . status . success ( ) { bail ! ( " " output info ( ) ) ; } info ! ( log " " String from_utf8_lossy ( output stdout ) ) ; info ! ( log " " String from_utf8_lossy ( output stderr ) ) ; Ok ( ( ) ) }
Use the "expand" command in format(1M) to expand the GPT table into the
 enlarged underlying volume.
Use the " expand " command in format ( 1M ) to expand the GPT table into the enlarged underlying volume .
log
&Logger
disk
&str
log
&Logger
disk
&str