pub struct Device<'a> { /* private fields */ }
Implementations§
Source§impl<'a> Device<'a>
impl<'a> Device<'a>
Sourcepub fn check(&self, start: i64, count: i64) -> Option<u64>
pub fn check(&self, start: i64, count: i64) -> Option<u64>
Returns the first bad sector if a bad sector was found.
§Binding Note
Not 100% sure if this is what this method does, as libparted’s source
code did not document the behavior of the function. Am basing this
off the check()
method that was documented for Geometry.
Sourcepub fn devices<'b>(probe: bool) -> DeviceIter<'b> ⓘ
pub fn devices<'b>(probe: bool) -> DeviceIter<'b> ⓘ
Attempts to detect all devices, constructing an Iterator which will
contain a list of all of the devices. If you want to use a device that isn’t
on the list, use the new()
method, or an OS-specific constructor such as
new_from_store()
.
Sourcepub fn get<P: AsRef<Path>>(path: P) -> Result<Device<'a>>
pub fn get<P: AsRef<Path>>(path: P) -> Result<Device<'a>>
Obtains a handle to the device, but does not open it.
Sourcepub fn new<P: AsRef<Path>>(path: P) -> Result<Device<'a>>
pub fn new<P: AsRef<Path>>(path: P) -> Result<Device<'a>>
Attempts to get the device of the given path
, then attempts to open that device.
pub unsafe fn from_ped_device(device: *mut PedDevice) -> Device<'a>
pub unsafe fn ped_device(&self) -> *mut PedDevice
Sourcepub fn external_access<'b>(&'b mut self) -> Result<DeviceExternalAccess<'a, 'b>>
pub fn external_access<'b>(&'b mut self) -> Result<DeviceExternalAccess<'a, 'b>>
Begins external access mode.
External access mode allows you to safely do I/O on the device. If a device is open, then you should not do any I/O on that device, such as by calling an external program like e2fsck, unless you put it in external access mode. You should not use any libparted commands that do I/O to a device while a device is in external access mode.
§Note:
You should not close a device while it is in external access mode.
Sourcepub fn sync(&mut self) -> Result<()>
pub fn sync(&mut self) -> Result<()>
Flushes all write-behind caches that might be holding up writes.
It is slow because it guarantees cache coherency among all relevant caches.
Sourcepub fn sync_fast(&mut self) -> Result<()>
pub fn sync_fast(&mut self) -> Result<()>
Flushes all write-behind caches that might be holding writes.
It does not ensure cache coherency with other caches.
Sourcepub fn write_to_sectors(
&mut self,
buffer: &[u8],
start_sector: i64,
sectors: i64,
) -> Result<()>
pub fn write_to_sectors( &mut self, buffer: &[u8], start_sector: i64, sectors: i64, ) -> Result<()>
Attempts to write the data within the buffer to the device, starting at the start_sector, and spanning across sectors.
Sourcepub fn get_constraint<'b>(&self) -> Result<Constraint<'b>>
pub fn get_constraint<'b>(&self) -> Result<Constraint<'b>>
Get a constraint that represents hardware requirements on geometry.
This function will return a constraint representing the limits imposed by the size of the disk. It will not provide any alignment constraints.
Alignment constraint may be desirable when using media that has a physical sector size that is a multiple of the logical sector size, as in this case proper partition alignment can benefit disk performance significantly.
§Note:
When you want a constraint with alignment info, use the following methods:
Device::get_minimal_aligned_constraint()
Device::get_optimal_aligned_constraint()
Sourcepub fn constraint_any<'b>(&self) -> Option<Constraint<'b>>
pub fn constraint_any<'b>(&self) -> Option<Constraint<'b>>
Return a constraint that any region on the given device will satisfy.
pub fn constraint_from_start_end<'b>( &self, range_start: &Geometry<'_>, range_end: &Geometry<'_>, ) -> Result<Constraint<'b>>
Sourcepub fn get_minimal_aligned_constraint<'b>(&self) -> Result<Constraint<'b>>
pub fn get_minimal_aligned_constraint<'b>(&self) -> Result<Constraint<'b>>
Get a constraint that represents hardware requirements on geometry and alignment.
This function will return a constraint representing the limits imposed by the size of the disk and the minimal alignment requirements for proper performance of the disk.
Sourcepub fn get_optimal_aligned_constraint<'b>(&self) -> Result<Constraint<'b>>
pub fn get_optimal_aligned_constraint<'b>(&self) -> Result<Constraint<'b>>
Get a constraint that represents hardware requirements on geometry and alignment.
This function will return a constraint representing the limits imposed by the size of the disk and the alignment requirements for optimal performance of the disk.
Sourcepub fn get_minimum_alignment<'b>(&self) -> Option<Alignment<'b>>
pub fn get_minimum_alignment<'b>(&self) -> Option<Alignment<'b>>
Get an alignment that represents minimum hardware requirements on alignment.
When using media that has a physical sector size that is a multiple of the logical sector size, it is desirable to have disk accesses (and thus partitions) properly aligned. Having partitions not aligned to the minimum hardware requirements may lead to a performance penalty.
The returned alignment describes the alignment for the start sector of the partition. The end sector should be aligned too. To get the end sector alignment, decrease the returned alignment’s offset by 1.
Sourcepub fn get_optimum_alignment<'b>(&self) -> Option<Alignment<'b>>
pub fn get_optimum_alignment<'b>(&self) -> Option<Alignment<'b>>
Get an alignment that represents the hardware requirements for optimal performance.
The returned alignment describes the alignment for the start sector of the partition. The end sector should be aligned too. To get the end alignment, decrease the returned alignment’s offset by 1.
Sourcepub fn clobber(&mut self) -> Result<()>
pub fn clobber(&mut self) -> Result<()>
Remove all identifying signatures of a partition table.