pub fn create_as_logical_volume_of(
        &mut self,
        parent: VgEntity,
        sector: Sector,
        name: Box<str>,
        what: PartitionCreate,
    ) -> Result<DeviceEntity, Error> {
        let mut lazy_lvpath = None;
        let (length, dmname);

        {
            let vg_components = &self.components.vgs;
            let vg = self
                .components
                .queued_changes
                .volume_groups
                .get(parent)
                .or_else(|| vg_components.volume_groups.get(parent))
                .expect("vg entity without vg component");

            length = self.can_create_on_vg(parent, vg, sector)?;

            dmname = [vg.name.replace("-", "--").as_str(), "-", name.replace("-", "--").as_str()]
                .concat()
                .into();
        }

        let fetch_lv_path = |manager: &Self, device: VgEntity, lvname: &str| -> Box<Path> {
            let vg_components = &manager.components.vgs;

            let vg = manager
                .components
                .queued_changes
                .volume_groups
                .get(device)
                .or_else(|| vg_components.volume_groups.get(device))
                .expect("vg entity without vg component");

            PathBuf::from(["/dev/mapper/", &vg.name, "/", lvname].concat()).into()
        };

        // Create a new device entity for the new partition.
        let entity = self.entities.devices.insert(EntityFlags::CREATE);

        let lvpf = |manager: &mut Self| {
            let path = fetch_lv_path(&manager, parent, &name);
            lazy_lvpath = Some(path.clone());
            path
        };

        self.create_partition(what, entity, None, 0, length, 512, 512, lvpf);

        // Associate the newly-queued device with the parent.
        self.components.queued_changes.vg_parents.insert(entity, parent);

        let path: Box<Path> =
            lazy_lvpath.take().unwrap_or_else(|| fetch_lv_path(&self, parent, &name));

        let lv = LvmLv { name, path, uuid: Box::from("") };

        let queued = &mut self.components.queued_changes;
        queued.device_maps.insert(entity, dmname);
        queued.lvs.insert(entity, (lv, parent));

        Ok(entity)
    }
/// Create a new logical volume on a volume group.
Create a new logical volume on a volume group.
Create a new logical volume on a volume group .
pub fn create_as_logical_volume_of(
        &mut self,
        parent: VgEntity,
        sector: Sector,
        name: Box<str>,
        what: PartitionCreate,
    ) -> Result<DeviceEntity, Error> {
        let mut lazy_lvpath = None;
        let (length, dmname);
        {
            let vg_components = &self.components.vgs;
            let vg = self
                .components
                .queued_changes
                .volume_groups
                .get(parent)
                .or_else(|| vg_components.volume_groups.get(parent))
                .expect("vg entity without vg component");
            length = self.can_create_on_vg(parent, vg, sector)?;
            dmname = [vg.name.replace("-", "--").as_str(), "-", name.replace("-", "--").as_str()]
                .concat()
                .into();
        }
        let fetch_lv_path = |manager: &Self, device: VgEntity, lvname: &str| -> Box<Path> {
            let vg_components = &manager.components.vgs;
            let vg = manager
                .components
                .queued_changes
                .volume_groups
                .get(device)
                .or_else(|| vg_components.volume_groups.get(device))
                .expect("vg entity without vg component");
            PathBuf::from(["/dev/mapper/", &vg.name, "/", lvname].concat()).into()
        };
        // Create a new device entity for the new partition.
        let entity = self.entities.devices.insert(EntityFlags::CREATE);
        let lvpf = |manager: &mut Self| {
            let path = fetch_lv_path(&manager, parent, &name);
            lazy_lvpath = Some(path.clone());
            path
        };
        self.create_partition(what, entity, None, 0, length, 512, 512, lvpf);
        // Associate the newly-queued device with the parent.
        self.components.queued_changes.vg_parents.insert(entity, parent);
        let path: Box<Path> =
            lazy_lvpath.take().unwrap_or_else(|| fetch_lv_path(&self, parent, &name));
        let lv = LvmLv { name, path, uuid: Box::from("") };
        let queued = &mut self.components.queued_changes;
        queued.device_maps.insert(entity, dmname);
        queued.lvs.insert(entity, (lv, parent));
        Ok(entity)
    }
pub fn create_as_logical_volume_of ( & mut self , parent : VgEntity , sector : Sector , name : Box < str > , what : PartitionCreate , ) -> Result < DeviceEntity , Error > { let mut lazy_lvpath = None ; let ( length , dmname ) ; { let vg_components = & self . components . vgs ; let vg = self . components . queued_changes . volume_groups . get ( parent ) . or_else ( | | vg_components . volume_groups . get ( parent ) ) . expect ( " " ) ; length = self . can_create_on_vg ( parent , vg , sector ) ? ; dmname = [ vg . name . replace ( " " , " " ) . as_str ( ) , " " , name . replace ( " " , " " ) . as_str ( ) ] . concat ( ) . into ( ) ; } let fetch_lv_path = | manager : & Self , device : VgEntity , lvname : & str | -> Box < Path > { let vg_components = & manager . components . vgs ; let vg = manager . components . queued_changes . volume_groups . get ( device ) . or_else ( | | vg_components . volume_groups . get ( device ) ) . expect ( " " ) ; PathBuf :: from ( [ " " , & vg . name , " " , lvname ] . concat ( ) ) . into ( ) } ; // Create a new device entity for the new partition. let entity = self . entities . devices . insert ( EntityFlags :: CREATE ) ; let lvpf = | manager : & mut Self | { let path = fetch_lv_path ( & manager , parent , & name ) ; lazy_lvpath = Some ( path . clone ( ) ) ; path } ; self . create_partition ( what , entity , None , 0 , length , 512 , 512 , lvpf ) ; // Associate the newly-queued device with the parent. self . components . queued_changes . vg_parents . insert ( entity , parent ) ; let path : Box < Path > = lazy_lvpath . take ( ) . unwrap_or_else ( | | fetch_lv_path ( & self , parent , & name ) ) ; let lv = LvmLv { name , path , uuid : Box :: from ( " " ) } ; let queued = & mut self . components . queued_changes ; queued . device_maps . insert ( entity , dmname ) ; queued . lvs . insert ( entity , ( lv , parent ) ) ; Ok ( entity ) }
Create a new logical volume on a volume group.
Create a new logical volume on a volume group .
&mut self
parent
VgEntity
sector
Sector
name
Box<str>
what
PartitionCreate
&mut self
parent
VgEntity
sector
Sector
name
Box<str>
what
PartitionCreate