From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bernhard Bitsch To: development@lists.ipfire.org Subject: Re: [PATCHv2 03/12] extrahd.cgi: Abort if a device could not be umounted. Date: Wed, 02 Aug 2023 13:50:22 +0200 Message-ID: <3c2bfe66-9b8a-0dde-5b6b-6d457762508f@ipfire.org> In-Reply-To: <20230801154839.2373-3-stefan.schantl@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4393874705641414212==" List-Id: --===============4393874705641414212== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bernhard Bitsch Am 01.08.2023 um 17:48 schrieb Stefan Schantl: > Signed-off-by: Stefan Schantl > --- > html/cgi-bin/extrahd.cgi | 42 +++++++++++++++++++++------------------- > 1 file changed, 22 insertions(+), 20 deletions(-) >=20 > diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi > index bafdb9fc9..f31bc2c44 100644 > --- a/html/cgi-bin/extrahd.cgi > +++ b/html/cgi-bin/extrahd.cgi > @@ -146,33 +146,35 @@ if ($extrahdsettings{'ACTION'} eq $Lang::tr{'add'}) { > # > } elsif ($extrahdsettings{'ACTION'} eq $Lang::tr{'delete'}) { > # Call helper binary to unmount the device. > - &General::system("/usr/local/bin/extrahdctrl", "umount", "$extrahdsetting= s{'PATH'}"); > + unless(&General::system("/usr/local/bin/extrahdctrl", "umount", "$extrahd= settings{'PATH'}")) { > + # Open the device file for reading. > + open(FILE, "< $devicefile" ) or die "Unable to read $devicefile"; > =20 > - # Open the device file for reading. > - open(FILE, "< $devicefile" ) or die "Unable to read $devicefile"; > + # Read the file content into a temporary array. > + my @tmp =3D ; > =20 > - # Read the file content into a temporary array. > - my @tmp =3D ; > - > - # Close file handle. > - close(FILE); > + # Close file handle. > + close(FILE); > =20 > - # Re-open device file for writing. > - open(FILE, "> $devicefile" ) or die "Unable to write $devicefile"; > + # Re-open device file for writing. > + open(FILE, "> $devicefile" ) or die "Unable to write $devicefile"; > =20 > - # Loop through the previous read file content. > - foreach my $line (sort @tmp) { > - # Split line content and assign nice variables. > - my ($uuid, $fs, $path) =3D split( /\;/, $line ); > + # Loop through the previous read file content. > + foreach my $line (sort @tmp) { > + # Split line content and assign nice variables. > + my ($uuid, $fs, $path) =3D split( /\;/, $line ); > =20 > - # Write the line in case it does not contain our element to delete. > - if ($path ne $extrahdsettings{'PATH'}) { > - print FILE "$line"; > + # Write the line in case it does not contain our element to delete. > + if ($path ne $extrahdsettings{'PATH'}) { > + print FILE "$line"; > + } > } > - } > =20 > - # Close file handle. > - close(FILE); > + # Close file handle. > + close(FILE); > + } else { > + $errormessage =3D "$Lang::tr{'extrahd cant umount'} $extrahdsettings{'PA= TH'}$Lang::tr{'extrahd maybe the device is in use'}?"; > + } > } > =20 > if ($errormessage) { --===============4393874705641414212==--