[pbs-devel] [PATCH proxmox-backup v13 23/26] api: node: include removable datastores in directory list
Fabian Grünbichler
f.gruenbichler at proxmox.com
Thu Nov 21 15:54:22 CET 2024
On November 13, 2024 4:00 pm, Hannes Laimer wrote:
> Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
> ---
> src/api2/node/disks/directory.rs | 29 ++++++++++++++++++++++++++++-
> 1 file changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/src/api2/node/disks/directory.rs b/src/api2/node/disks/directory.rs
> index 7e020e27..21d2bcc4 100644
> --- a/src/api2/node/disks/directory.rs
> +++ b/src/api2/node/disks/directory.rs
> @@ -45,6 +45,8 @@ pub struct DatastoreMountInfo {
> pub path: String,
> /// The mounted device.
> pub device: String,
> + /// This is removable
> + pub removable: bool,
> /// File system type
> pub filesystem: Option<String>,
> /// Mount options
> @@ -61,7 +63,7 @@ pub struct DatastoreMountInfo {
> }
> },
> returns: {
> - description: "List of systemd datastore mount units.",
> + description: "List of removable-datastore devices and systemd datastore mount units.",
> type: Array,
> items: {
> type: DatastoreMountInfo,
> @@ -100,6 +102,31 @@ pub fn list_datastore_mounts() -> Result<Vec<DatastoreMountInfo>, Error> {
> path: data.Where,
> filesystem: data.Type,
> options: data.Options,
> + removable: false,
> + });
> + }
> +
> + let (config, _digest) = pbs_config::datastore::config()?;
> + let store_list: Vec<DataStoreConfig> = config.convert_to_typed_array("datastore")?;
> +
> + for item in store_list
> + .into_iter()
> + .filter(|store| store.backing_device.is_some())
> + {
> + let Some(backing_device) = item.backing_device.as_deref() else {
> + continue;
> + };
> + let Some(mount_point) = item.get_mount_point() else {
> + continue;
> + };
this is redundant, get_mount_point will only return Some if there's a
backing_device.. in fact, I think we can remove the get_mount_point fn
entirely, and always check for backing_device (absolute_path will then
return the mountpoint..)
there's only a few places (beside this) where we only look at
get_mount_point, and those can easily be adapted to make backing_device()
*the* single way to check if a datastore is a removable one, which makes
reasoning a lot easier..
> + list.push(DatastoreMountInfo {
> + unitfile: "datastore config".to_string(),
> + name: item.name.clone(),
> + device: format!("/dev/disk/by-uuid/{backing_device}"),
> + path: mount_point,
> + filesystem: None,
> + options: None,
> + removable: true,
> });
> }
>
> --
> 2.39.5
>
>
>
> _______________________________________________
> pbs-devel mailing list
> pbs-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
>
>
>
More information about the pbs-devel
mailing list