From 8eef31724f67037ad31769d819965010af419e41 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Mon, 13 Sep 2021 16:18:27 +0200 Subject: [PATCH] api: disks/directory: add 'name' property to list of mounts so that we actually have the property that 'match_all' refers to for the templated API path. This is mostly for improving usage of the WIP pbs-shell, i.e., its `ls` command, it has no other functional/semantic impact. Signed-off-by: Dominik Csapak Signed-off-by: Thomas Lamprecht --- src/api2/node/disks/directory.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/api2/node/disks/directory.rs b/src/api2/node/disks/directory.rs index c6d230de..ea01352e 100644 --- a/src/api2/node/disks/directory.rs +++ b/src/api2/node/disks/directory.rs @@ -35,6 +35,8 @@ const BASE_MOUNT_DIR: &str = "/mnt/datastore/"; pub struct DatastoreMountInfo { /// The path of the mount unit. pub unitfile: String, + /// The name of the mount + pub name: String, /// The mount path. pub path: String, /// The mounted device. @@ -83,8 +85,15 @@ pub fn list_datastore_mounts() -> Result, Error> { let config = systemd::config::parse_systemd_mount(&unitfile)?; let data: SystemdMountSection = config.lookup("Mount", "Mount")?; + let name = data + .Where + .strip_prefix(BASE_MOUNT_DIR) + .unwrap_or_else(|| &data.Where) + .to_string(); + list.push(DatastoreMountInfo { unitfile, + name, device: data.What, path: data.Where, filesystem: data.Type,