Struct libparted::Disk
[−]
[src]
pub struct Disk<'a> { /* fields omitted */ }
Methods
impl<'a> Disk<'a>
[src]
pub fn new(device: &'a mut Device) -> Result<Disk<'a>>
[src]
Read the partition table off a device (if one is found).
Warning: May modify the supplied device
if the partition table indicates that the
existing values are incorrect.
pub fn new_fresh(device: &'a mut Device, type_: DiskType) -> Result<Disk<'a>>
[src]
Creates a new partition table on device
.
The new partition table is only created in-memory, and nothing is written to disk until
disk.commit_to_dev()
is called.
pub unsafe fn get_device<'b>(&self) -> Device<'b>
[src]
Obtains the inner device from the disk.
pub unsafe fn get_device_mut<'b>(&'b mut self) -> Device<'b>
[src]
Obtains the inner device from the disk, with mutable access.
pub fn constraint_any<'b>(&self) -> Option<Constraint<'b>>
[src]
Obtains the constraint of the inner device.
pub fn get_disk_type_name<'b>(&'b self) -> Option<&str>
[src]
pub fn needs_clobber(&self) -> bool
[src]
pub fn update_mode(&self) -> bool
[src]
pub fn get_flag_state(&self, flag: DiskFlag) -> bool
[src]
Get the state of a set flag on a disk.
pub fn is_flag_available(&self, flag: DiskFlag) -> bool
[src]
Check whether a given flag is available on a disk
pub fn print(&self)
[src]
Prints a summary of the disk's partitions. Useful for debugging.
ⓘImportant traits for DiskPartIter<'a>pub fn parts<'b>(&'b self) -> DiskPartIter<'b>
[src]
pub fn add_partition(
&mut self,
part: &mut Partition,
constraint: &Constraint
) -> Result<()>
[src]
&mut self,
part: &mut Partition,
constraint: &Constraint
) -> Result<()>
Adds the supplied part
Partition to the disk.
Warning: The partition's geometry may be changed, subject to constraint
. You could
set constraint
to constraint_exact(&part.geom)
, but many partition table schemes have
special requirements on the start and end of partitions. Therefore, having an overly
strict constraint will probably mean that this function will fail (in which case part
will be left unmodified) part
is assigned a number (part.num
) in this process.
pub fn get_last_partition_num(&self) -> Option<u32>
[src]
Get the highest available partition number on the disk.
pub fn get_max_supported_partition_count(&self) -> Option<u32>
[src]
Get the highest supported partition number on the disk.
pub fn get_max_primary_partition_count(&self) -> u32
[src]
Get the maximum number of (primary) partitions that the disk label supports.
pub fn get_max_partition_geometry(
&'a self,
part: &Partition,
constraint: &Constraint
) -> Result<Geometry<'a>>
[src]
&'a self,
part: &Partition,
constraint: &Constraint
) -> Result<Geometry<'a>>
Get the maximum geometry part
can be grown to, subject to constraint
.
pub fn check(&mut self) -> Result<()>
[src]
Perform a sanity check on a partition table
NOTE: The check performed is generic (ie: it does not depend on the label type of the disk).
pub fn clobber(&mut self) -> Result<()>
[src]
Remove all identifying signatures of a partition table.
pub fn commit(&mut self) -> Result<()>
[src]
Writes the in-memory changes to a partition table to disk and informs the operating system of the changes.
NOTE: Equivalent to calling disk.commit_to_dev()
, followed by disk.commit_to_os()
.
pub fn commit_to_dev(&mut self) -> Result<()>
[src]
Write the changes made to the in-memory description of a partition table to the device.
pub fn commit_to_os(&mut self) -> Result<()>
[src]
Tell the operating system kernel about the partition table layout of disk
.
pub fn delete_all(&mut self) -> Result<()>
[src]
Removes and destroys all partitions on disk
.
pub fn duplicate<'b>(&mut self) -> Result<Disk<'b>>
[src]
pub fn extended_partition<'b>(&'b self) -> Option<Partition<'b>>
[src]
pub fn get_partition_alignment(&'a self) -> Result<Alignment<'a>>
[src]
Get the alignment needed for partition boundaries on this disk.
The returned alignment describes the alignment for the start sector of the partition, for all disklabel types which require alignment, except Sun disklables, the end sector must be aligned too. To get the end sector alignment, decrease the Alignment offset by 1.
pub fn get_partition_by_sector(&'a self, sector: i64) -> Option<Partition<'a>>
[src]
Returns the partition that contains sector
. If sector
lies within a logical
partition, then the logical partition is returned (not the extended partition).
pub unsafe fn get_partition_by_sector_raw(
&self,
sector: i64
) -> *mut PedPartition
[src]
&self,
sector: i64
) -> *mut PedPartition
Similar to get_partition_by_sector
, but returns a raw pointer instead.
pub fn get_partition(&'a self, num: u32) -> Option<Partition<'a>>
[src]
Returns the partition numbered num
.
pub unsafe fn get_partition_raw(&self, num: u32) -> *mut PedPartition
[src]
Similar to get_partition
, but returns a raw pointer instead.
pub fn get_primary_partition_count(&self) -> u32
[src]
Get the number of primary partitions.
pub fn max_partition_length(&self) -> i64
[src]
Return the maximum representable length (in sectors) of a partition on the disk.
pub fn max_partition_start_sector(&self) -> i64
[src]
Return the maximum representable start sector of a partition on the disk.
pub fn maximize_partition(
&mut self,
part: &mut Partition,
constraint: &Constraint
) -> Result<()>
[src]
&mut self,
part: &mut Partition,
constraint: &Constraint
) -> Result<()>
Grow the supplied part
to the maximimum size possible, subject to constraint
.
The new geometry will be a superset of the old geometry.
pub fn minimize_extended_partition(&mut self) -> Result<()>
[src]
Reduce the size of the extended partition to a minimum while still wrapping its logical partitions. If there are no logical partitions, remove the extended partition.
pub unsafe fn remove_partition(&mut self, part: *mut PedPartition) -> Result<()>
[src]
Removes the part
Partition from the disk.
If part
is an extended partition, it must not contain any logical partitions.
pub fn remove_partition_by_number(&mut self, num: u32) -> Result<()>
[src]
Removes a partition from the disk by the partition number.
If that partition is an extended partition, it must not contain any logical partitions.
pub fn remove_partition_by_sector(&mut self, sector: i64) -> Result<()>
[src]
Removes a partition from the disk by the sector where that partition lies.alignment
If that partition is an extended partition, it must not contain any logical partitions.
pub fn set_flag(&mut self, flag: DiskFlag, state: bool) -> bool
[src]
Set the state of a flag on a disk.
Note
It is an error to call tis on an unavailable flag. Use disk.is_flag_available()
to determine whhich flags are available for a given disk label.
Throws
Throws PED_EXCEPTION_ERROR
if the requested flag is not available for this label.
pub fn set_partition_geometry(
&mut self,
part: &mut Partition,
constraint: &Constraint,
start: i64,
end: i64
) -> Result<()>
[src]
&mut self,
part: &mut Partition,
constraint: &Constraint,
start: i64,
end: i64
) -> Result<()>
Sets the geometry of part
(IE: change a partition's location).
This can fail for many reasons, such as overlapping with other partitions.
If it does fail, part
will remain unchanged.
pub fn snap_to_boundaries(
&self,
new_geom: &mut Geometry,
old_geom: Option<&Geometry>,
start_range: &Geometry,
end_range: &Geometry
)
[src]
&self,
new_geom: &mut Geometry,
old_geom: Option<&Geometry>,
start_range: &Geometry,
end_range: &Geometry
)