Skip to content

Commit

Permalink
Export the value via a newly added FetchProperties key
Browse files Browse the repository at this point in the history
Signed-off-by: mulhern <[email protected]>
  • Loading branch information
mulkieran committed Aug 20, 2021
1 parent 88f30b5 commit 027ee34
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/dbus_api/blockdev/fetch_properties_3_0/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ use crate::dbus_api::{
blockdev::shared::blockdev_operation, consts, types::TData, util::result_to_tuple,
};

const ALL_PROPERTIES: [&str; 1] = [consts::BLOCKDEV_TOTAL_SIZE_PROP];
const ALL_PROPERTIES: [&str; 2] = [
consts::BLOCKDEV_TOTAL_SIZE_ALLOCATED_PROP,
consts::BLOCKDEV_TOTAL_SIZE_PROP,
];

fn get_properties_shared(
m: &MethodInfo<MTSync<TData>, TData>,
Expand All @@ -37,6 +40,14 @@ fn get_properties_shared(
|_, bd| Ok((*bd.size().bytes()).to_string()),
)),
)),
consts::BLOCKDEV_TOTAL_SIZE_ALLOCATED_PROP => Some((
prop,
result_to_tuple(blockdev_operation(
m.tree,
object_path.get_name(),
|_, bd| Ok((*bd.allocated().bytes()).to_string()),
)),
)),
_ => None,
})
.collect();
Expand Down
1 change: 1 addition & 0 deletions src/dbus_api/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub const BLOCKDEV_TIER_PROP: &str = "Tier";
pub const BLOCKDEV_PHYSICAL_PATH_PROP: &str = "PhysicalPath";

pub const BLOCKDEV_TOTAL_SIZE_PROP: &str = "TotalPhysicalSize";
pub const BLOCKDEV_TOTAL_SIZE_ALLOCATED_PROP: &str = "TotalPhysicalSizeAllocated";

/// Get a list of all the FetchProperties interfaces
pub fn fetch_properties_interfaces() -> Vec<String> {
Expand Down

0 comments on commit 027ee34

Please sign in to comment.