Skip to content

Commit

Permalink
Merge pull request #74 from jbaublitz/blkid-verify
Browse files Browse the repository at this point in the history
Add blkid_verify
  • Loading branch information
jbaublitz authored Apr 18, 2022
2 parents dc54807 + ad7a9b7 commit ff0ec09
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
10 changes: 10 additions & 0 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ impl BlkidCache {
})?;
Ok(BlkidDev::new(ptr))
}

/// Verify that a device in the cache exists and remove it if it does not.
pub fn verify(&mut self, dev: BlkidDev) -> Option<BlkidDev> {
let ptr = unsafe { libblkid_rs_sys::blkid_verify(self.0, dev.as_ptr()) };
if ptr.is_null() {
None
} else {
Some(BlkidDev::new(ptr))
}
}
}

impl Drop for BlkidCache {
Expand Down
4 changes: 4 additions & 0 deletions src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ impl BlkidDev {
BlkidDev(inner)
}

pub(crate) fn as_ptr(&self) -> libblkid_rs_sys::blkid_dev {
self.0
}

/// Get the device name for a blkid device
pub fn devname(&self) -> Result<PathBuf> {
let ret = errno_ptr!(unsafe { libblkid_rs_sys::blkid_dev_devname(self.0) })?;
Expand Down
5 changes: 0 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
//! characters are required.
//! * `blkid_get_dev_size` - This method takes a `&Path` in the bindings
//! and provides libblkid with the desired file descriptor.
//!
//! ### List of methods not included
//! * `blkid_verify` - This method is not included because the struct flag
//! that will notify the caller of whether it succeeded or not cannot be accessed
//! from the public API.

#![deny(missing_docs)]

Expand Down

0 comments on commit ff0ec09

Please sign in to comment.