[PATCHv2,09/12] extrahd.cgi: Drop select for FS selection.

Message ID 20230801154839.2373-9-stefan.schantl@ipfire.org
State Staged
Commit 480c5253d04f4eccdd43b77892e3a1daf8347256
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
  This feature does not have any benefit because the linux kernel
knows best which filesystem a device/partition has.

So there is no need for a user to specify this by-hand. This also
prevents from choosing a wrong fs type and as a direct result in a
not mountable device.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 html/cgi-bin/extrahd.cgi | 35 +++++------------------------------
 1 file changed, 5 insertions(+), 30 deletions(-)
  

Comments

Bernhard Bitsch Aug. 2, 2023, 12:09 p.m. UTC | #1
Reviewed-by: Bernhard Bitsch <bbitsch@ipfire.org>


Am 01.08.2023 um 17:48 schrieb Stefan Schantl:
> This feature does not have any benefit because the linux kernel
> knows best which filesystem a device/partition has.
> 
> So there is no need for a user to specify this by-hand. This also
> prevents from choosing a wrong fs type and as a direct result in a
> not mountable device.
> 
> Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
> ---
>   html/cgi-bin/extrahd.cgi | 35 +++++------------------------------
>   1 file changed, 5 insertions(+), 30 deletions(-)
> 
> diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi
> index 0b59a02f7..c621bd72f 100644
> --- a/html/cgi-bin/extrahd.cgi
> +++ b/html/cgi-bin/extrahd.cgi
> @@ -45,16 +45,6 @@ my @valid_mount_dirs = (
>   	"/mnt",
>   );
>   
> -# Array which contains the supported file systems.
> -my @supported_filesystems = (
> -	"auto",
> -	"ext3",
> -	"ext4",
> -	"xfs",
> -	"vfat",
> -	"ntfs-3g"
> -);
> -
>   # Grab all available block devices.
>   my @devices = &get_block_devices();
>   
> @@ -252,6 +242,9 @@ END
>   			# Convert into human-readable format.
>   			my $size = &General::formatBytes($bsize);
>   
> +			# Try to omit the used filesystem.
> +			my $fs = $filesystems{$partition};
> +
>   			# Get the mountpoint.
>   			my $mountpoint = $mountpoints{$partition};
>   
> @@ -279,11 +272,9 @@ END
>   			} elsif (&is_swap($partition)) {
>   				$disabled = "disabled";
>   				$mountpoint = "swap";
> +				$fs = "swap";
>   			}
>   
> -			# Omit the used filesystem.
> -			my $fs = $filesystems{$partition};
> -
>   			print <<END
>   
>   			<form method='post' action='$ENV{'SCRIPT_NAME'}'>
> @@ -291,23 +282,7 @@ END
>   			<tr>
>   			<td align="list">/dev/$partition</td>
>   				<td align="center">$Lang::tr{'size'} $size</td>
> -				<td align="center"><select name="FS" $disabled>
> -END
> -;
> -				# Loop through the array of supported filesystems.
> -				foreach my $filesystem (@supported_filesystems) {
> -					my $selected;
> -
> -					# Mark the used filesystem as selected.
> -					if ($filesystem eq $fs) {
> -						$selected = "selected";
> -					}
> -
> -					print "<option value='$filesystem' $selected>$filesystem</option>\n";
> -				}
> -
> -			print <<END
> -					</select></td>
> +				<td align="center">$fs</td>
>   				<td align="center"><input type='text' name='PATH' value='$mountpoint' $disabled></td>
>   				<td align="center">
>   					<input type='hidden' name='DEVICE' value='/dev/$partition' />
  

Patch

diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi
index 0b59a02f7..c621bd72f 100644
--- a/html/cgi-bin/extrahd.cgi
+++ b/html/cgi-bin/extrahd.cgi
@@ -45,16 +45,6 @@  my @valid_mount_dirs = (
 	"/mnt",
 );
 
-# Array which contains the supported file systems.
-my @supported_filesystems = (
-	"auto",
-	"ext3",
-	"ext4",
-	"xfs",
-	"vfat",
-	"ntfs-3g"
-);
-
 # Grab all available block devices.
 my @devices = &get_block_devices();
 
@@ -252,6 +242,9 @@  END
 			# Convert into human-readable format.
 			my $size = &General::formatBytes($bsize);
 
+			# Try to omit the used filesystem.
+			my $fs = $filesystems{$partition};
+
 			# Get the mountpoint.
 			my $mountpoint = $mountpoints{$partition};
 
@@ -279,11 +272,9 @@  END
 			} elsif (&is_swap($partition)) {
 				$disabled = "disabled";
 				$mountpoint = "swap";
+				$fs = "swap";
 			}
 
-			# Omit the used filesystem.
-			my $fs = $filesystems{$partition};
-
 			print <<END
 
 			<form method='post' action='$ENV{'SCRIPT_NAME'}'>
@@ -291,23 +282,7 @@  END
 			<tr>
 			<td align="list">/dev/$partition</td>
 				<td align="center">$Lang::tr{'size'} $size</td>
-				<td align="center"><select name="FS" $disabled>
-END
-;
-				# Loop through the array of supported filesystems.
-				foreach my $filesystem (@supported_filesystems) {
-					my $selected;
-
-					# Mark the used filesystem as selected.
-					if ($filesystem eq $fs) {
-						$selected = "selected";
-					}
-
-					print "<option value='$filesystem' $selected>$filesystem</option>\n";
-				}
-
-			print <<END
-					</select></td>
+				<td align="center">$fs</td>
 				<td align="center"><input type='text' name='PATH' value='$mountpoint' $disabled></td>
 				<td align="center">
 					<input type='hidden' name='DEVICE' value='/dev/$partition' />