/// Create a new partition on a partitionable device.
Create a new partition on a partitionable device.
Create a new partition on a partitionable device .
pub fn create_as_child_of(
        &mut self,
        parent: DeviceEntity,
        start: Sector,
        end: Sector,
        label: Box<str>,
        what: PartitionCreate,
    ) -> Result<DeviceEntity, Error> {
        self.assert_not_creating_table_on(parent);
        let (offset, length, logical_sector_size, physical_sector_size) = {
            let device_components = &self.components.devices;
            let device = if self.entities.devices[parent].contains(EntityFlags::CREATE) {
                &self.components.queued_changes.devices[parent]
            } else {
                &device_components.devices[parent]
            };
            let sectors = self.can_create_on_device(parent, device, start, end)?;
            (sectors.0, sectors.1, device.logical_sector_size, device.physical_sector_size)
        };
        // Create a new device entity for the new partition.
        let entity = self.entities.devices.insert(EntityFlags::CREATE);
        self.create_partition(
            what,
            entity,
            Some(label),
            offset,
            length,
            logical_sector_size,
            physical_sector_size,
            |manager| {
                let device_components = &manager.components.devices;
                let device = manager
                    .components
                    .queued_changes
                    .devices
                    .get(parent)
                    .or_else(|| device_components.devices.get(parent))
                    .expect("device entity without device component");
                device.path.to_path_buf().into()
            },
        );
        self.components.queued_changes.parents.insert(entity, parent);
        self.entities.devices[parent] |= EntityFlags::CREATE | EntityFlags::CREATE_CHILDREN;
        // Remind the manager that the creation system must be run.
        self.flags |= ManagerFlags::CREATE;
        Ok(entity)
    }
pub fn create_as_child_of ( & mut self , parent : DeviceEntity , start : Sector , end : Sector , label : Box < str > , what : PartitionCreate , ) -> Result < DeviceEntity , Error > { self . assert_not_creating_table_on ( parent ) ; let ( offset , length , logical_sector_size , physical_sector_size ) = { let device_components = & self . components . devices ; let device = if self . entities . devices [ parent ] . contains ( EntityFlags :: CREATE ) { & self . components . queued_changes . devices [ parent ] } else { & device_components . devices [ parent ] } ; let sectors = self . can_create_on_device ( parent , device , start , end ) ? ; ( sectors . 0 , sectors . 1 , device . logical_sector_size , device . physical_sector_size ) } ; // Create a new device entity for the new partition. let entity = self . entities . devices . insert ( EntityFlags :: CREATE ) ; self . create_partition ( what , entity , Some ( label ) , offset , length , logical_sector_size , physical_sector_size , | manager | { let device_components = & manager . components . devices ; let device = manager . components . queued_changes . devices . get ( parent ) . or_else ( | | device_components . devices . get ( parent ) ) . expect ( " " ) ; device . path . to_path_buf ( ) . into ( ) } , ) ; self . components . queued_changes . parents . insert ( entity , parent ) ; self . entities . devices [ parent ] |= EntityFlags :: CREATE | EntityFlags :: CREATE_CHILDREN ; // Remind the manager that the creation system must be run. self . flags |= ManagerFlags :: CREATE ; Ok ( entity ) }
Create a new partition on a partitionable device.
Create a new partition on a partitionable device .
&mut self
parent
DeviceEntity
start
Sector
end
Sector
label
Box<str>
what
PartitionCreate