[PATCHv2,05/12] extrahd.cgi: Add is_configured function.

Message ID 20230801154839.2373-5-stefan.schantl@ipfire.org
State Staged
Commit 0aa77c2fd50daccb6dd4d71f05a9fd3a187b993e
Headers
Series [PATCHv2,01/12] extrahd.cgi: Add various perl functions deal with block devices |

Commit Message

Stefan Schantl Aug. 1, 2023, 3:48 p.m. UTC
  Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 html/cgi-bin/extrahd.cgi | 12 ++++++++++++
 1 file changed, 12 insertions(+)
  

Comments

Bernhard Bitsch Aug. 2, 2023, 11:54 a.m. UTC | #1
Reviewed-by: Bernhard Bitsch <bbitsch@ipfire.org>


Am 01.08.2023 um 17:48 schrieb Stefan Schantl:
> Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
> ---
>   html/cgi-bin/extrahd.cgi | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi
> index bb0c22610..4db540aae 100644
> --- a/html/cgi-bin/extrahd.cgi
> +++ b/html/cgi-bin/extrahd.cgi
> @@ -690,3 +690,15 @@ sub is_swap ($) {
>   
>   	return 1 if(grep /$device/, @swaps);
>   }
> +
> +#
> +## Returns "True" if a drive is a configured one.
> +#
> +sub is_configured ($) {
> +	my ($path) = @_;
> +
> +	# Loop through the hash of configured drives.
> +	foreach my $uuid (keys %configured_drives) {
> +	       return 1 if($configured_drives{$uuid} eq "$path");
> +	}
> +}
  

Patch

diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi
index bb0c22610..4db540aae 100644
--- a/html/cgi-bin/extrahd.cgi
+++ b/html/cgi-bin/extrahd.cgi
@@ -690,3 +690,15 @@  sub is_swap ($) {
 
 	return 1 if(grep /$device/, @swaps);
 }
+
+#
+## Returns "True" if a drive is a configured one.
+#
+sub is_configured ($) {
+	my ($path) = @_;
+
+	# Loop through the hash of configured drives.
+	foreach my $uuid (keys %configured_drives) {
+	       return 1 if($configured_drives{$uuid} eq "$path");
+	}
+}