Struct libparted::Disk
[−]
[src]
pub struct Disk<'a> { /* fields omitted */ }
Methods
impl<'a> Disk<'a>
[src]
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.
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.
unsafe fn get_device<'b>(&self) -> Device<'b>
[src]
Obtains the inner device from the disk.
unsafe fn get_device_mut<'b>(&'b mut self) -> Device<'b>
[src]
Obtains the inner device from the disk, with mutable access.
fn constraint_any<'b>(&self) -> Option<Constraint<'b>>
[src]
Obtains the constraint of the inner device.
fn get_disk_type_name<'b>(&'b self) -> Option<&str>
[src]
fn needs_clobber(&self) -> bool
[src]
fn update_mode(&self) -> bool
[src]
fn get_flag_state(&self, flag: DiskFlag) -> bool
[src]
Get the state of a set flag on a disk.
fn is_flag_available(&self, flag: DiskFlag) -> bool
[src]
Check whether a given flag is available on a disk
fn print(&self)
[src]
Prints a summary of the disk's partitions. Useful for debugging.
fn parts<'b>(&'b self) -> DiskPartIter<'b>
[src]
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.
fn get_last_partition_num(&self) -> Option<u32>
[src]
Get the highest available partition number on the disk.
fn get_max_supported_partition_count(&self) -> Option<u32>
[src]
Get the highest supported partition number on the disk.
fn get_max_primary_partition_count(&self) -> u32
[src]
Get the maximum number of (primary) partitions that the disk label supports.
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
.
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).
fn clobber(&mut self) -> Result<()>
[src]
Remove all identifying signatures of a partition table.
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()
.
fn commit_to_dev(&mut self) -> Result<()>
[src]
Write the changes made to the in-memory description of a partition table to the device.
fn commit_to_os(&mut self) -> Result<()>
[src]
Tell the operating system kernel about the partition table layout of disk
.
fn delete_all(&mut self) -> Result<()>
[src]
Removes and destroys all partitions on disk
.
fn delete_partition(&mut self, num: u32) -> Result<()>
[src]
Removes part
from disk, and destroys part
.
fn duplicate<'b>(&mut self) -> Result<Disk<'b>>
[src]
fn extended_partition<'b>(&'b self) -> Option<Partition<'b>>
[src]
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.
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).
fn get_partition(&'a self, num: u32) -> Option<Partition<'a>>
[src]
Returns the partition numbered num
.
fn get_primary_partition_count(&self) -> u32
[src]
Get the number of primary partitions.
fn max_partition_length(&self) -> i64
[src]
Return the maximum representable length (in sectors) of a partition on the disk.
fn max_partition_start_sector(&self) -> i64
[src]
Return the maximum representable start sector of a partition on the disk.
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.
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.
fn remove_partition(&mut self, num: u32) -> Result<()>
[src]
Removes the part
Partition from the disk.
If part
is an extended partition, it must not contain any logical partitions.
Note that part
will not be destroyed when passed into this function.
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.
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.
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
)