Struct libatasmart::Disk
source · pub struct Disk {
pub disk: PathBuf,
/* private fields */
}
Expand description
Our ata smart disk
Fields§
§disk: PathBuf
The path in the filesystem to the hard drive
Implementations§
source§impl Disk
impl Disk
sourcepub fn new(disk_path: &Path) -> Result<Disk, Errno>
pub fn new(disk_path: &Path) -> Result<Disk, Errno>
This will initialize a new Disk by asking libatasmart to open it. Note that this requires root permissions usually to succeed.
sourcepub fn refresh_smart_data(&mut self) -> Result<(), Errno>
pub fn refresh_smart_data(&mut self) -> Result<(), Errno>
Refreshes cached SMART attribute values.
SMART attribute values are read once in Disk::new and cached. Methods such as
get_temperature
use these cached values and do not access the disk. Call this method to
refresh the cached values.
Note: calling this method might cause the disk to wake up from sleep. Consider checking if
the disk is asleep using check_sleep_mode
before calling this method to avoid this.
sourcepub fn get_disk_size(&mut self) -> Result<u64, Errno>
pub fn get_disk_size(&mut self) -> Result<u64, Errno>
Returns a u64 representing the size of the disk in bytes.
sourcepub fn check_sleep_mode(&mut self) -> Result<bool, Errno>
pub fn check_sleep_mode(&mut self) -> Result<bool, Errno>
Returns a bool of true if sleep mode is supported, false otherwise.
sourcepub fn get_power_on(&mut self) -> Result<u64, Errno>
pub fn get_power_on(&mut self) -> Result<u64, Errno>
Returns a u64 representing the power on time in milliseconds
sourcepub fn get_power_cycle_count(&mut self) -> Result<u64, Errno>
pub fn get_power_cycle_count(&mut self) -> Result<u64, Errno>
Returns a u64 representing the number of power on cycles
sourcepub fn get_bad_sectors(&mut self) -> Result<u64, Errno>
pub fn get_bad_sectors(&mut self) -> Result<u64, Errno>
Returns a u64 representing the number of bad sections on the disk
sourcepub fn get_temperature(&mut self) -> Result<u64, Errno>
pub fn get_temperature(&mut self) -> Result<u64, Errno>
Returns a u64 representing the mkelvin of the disk
sourcepub fn get_smart_status(&mut self) -> Result<bool, Errno>
pub fn get_smart_status(&mut self) -> Result<bool, Errno>
Returns true if the disk passed smart, false otherwise.
sourcepub fn dump(&mut self) -> Result<(), Errno>
pub fn dump(&mut self) -> Result<(), Errno>
This will dump all available information to stdout about the drive
pub fn identify_is_available(&mut self) -> Result<bool, Errno>
sourcepub fn smart_is_available(&mut self) -> Result<bool, Errno>
pub fn smart_is_available(&mut self) -> Result<bool, Errno>
Query the device and return whether or not smart is supported on it
pub fn parse_attributes(
&mut self,
parser_callback: extern "C" fn(_: *mut SkDisk, _: *const SkSmartAttributeParsedData, _: *mut c_void)
) -> Result<(), Errno>
sourcepub fn smart_test_available(
&mut self,
test_attributes: &mut SkSmartParsedData,
test_type: SkSmartSelfTest
) -> Result<bool, Errno>
pub fn smart_test_available(
&mut self,
test_attributes: &mut SkSmartParsedData,
test_type: SkSmartSelfTest
) -> Result<bool, Errno>
Query the device and return whether or not a particular smart test is supported on it
pub fn execute_smart_self_test(
&mut self,
test_type: SkSmartSelfTest
) -> Result<(), Errno>
pub fn smart_get_overall(&mut self) -> Result<SkSmartOverall, Errno>
sourcepub fn identify_parse(&mut self) -> Result<IdentifyParsedData, Errno>
pub fn identify_parse(&mut self) -> Result<IdentifyParsedData, Errno>
Get the model, firmware, and serial of the disk as a IdentifyParsedDatastruct If Errno::EINVAL gets returned there is a problem with the C string parser