From: Stefan Schantl <stefan.schantl@ipfire.org>
To: development@lists.ipfire.org
Subject: [PATCH 3/8] extrahd.cgi: Abort if a device could not be umounted.
Date: Fri, 23 Jun 2023 06:01:19 +0200 [thread overview]
Message-ID: <20230623040124.3826-3-stefan.schantl@ipfire.org> (raw)
In-Reply-To: <20230623040124.3826-1-stefan.schantl@ipfire.org>
[-- Attachment #1: Type: text/plain, Size: 2379 bytes --]
Signed-off-by: Stefan Schantl <stefan.schantl(a)ipfire.org>
---
| 42 +++++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 20 deletions(-)
--git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi
index 117890f08..dde4e7356 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", "$extrahdsettings{'PATH'}");
+ unless(&General::system("/usr/local/bin/extrahdctrl", "umount", "$extrahdsettings{'PATH'}")) {
+ # Open the device file for reading.
+ open(FILE, "< $devicefile" ) or die "Unable to read $devicefile";
- # 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 = <FILE>;
- # Read the file content into a temporary array.
- my @tmp = <FILE>;
-
- # Close file handle.
- close(FILE);
+ # Close file handle.
+ close(FILE);
- # 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";
- # Loop through the previous read file content.
- foreach my $line (sort @tmp) {
- # Split line content and assign nice variables.
- my ($uuid, $fs, $path) = 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) = split( /\;/, $line );
- # 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";
+ }
}
- }
- # Close file handle.
- close(FILE);
+ # Close file handle.
+ close(FILE);
+ } else {
+ $errormessage = "$Lang::tr{'extrahd cant umount'} $extrahdsettings{'PATH'}$Lang::tr{'extrahd maybe the device is in use'}?";
+ }
}
if ($errormessage) {
--
2.39.2
next prev parent reply other threads:[~2023-06-23 4:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-23 4:01 [PATCH 1/8] extrahd.cgi: Add various perl functions deal with block devices Stefan Schantl
2023-06-23 4:01 ` [PATCH 2/8] extrahd.cgi: Refactor code to use new introduced perl functions Stefan Schantl
2023-06-23 4:01 ` Stefan Schantl [this message]
2023-06-23 4:01 ` [PATCH 4/8] extrahd.cgi: Store configured drives in a hash Stefan Schantl
2023-06-23 4:01 ` [PATCH 5/8] extrahd.cgi: Add is_configured function Stefan Schantl
2023-06-23 4:01 ` [PATCH 6/8] extrahd.cgi: Display mount status next to the corresponding drive Stefan Schantl
2023-06-23 4:01 ` [PATCH 7/8] extrahd.cgi: Re-order sanity check logic Stefan Schantl
2023-06-23 4:01 ` [PATCH 8/8] extrahd.cgi: Add missing translation strings Stefan Schantl
2023-06-25 3:43 ` [PATCH 1/8] extrahd.cgi: Add various perl functions deal with block devices jon
2023-07-01 9:19 ` Michael Tremer
2023-07-01 14:54 ` Stefan Schantl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230623040124.3826-3-stefan.schantl@ipfire.org \
--to=stefan.schantl@ipfire.org \
--cc=development@lists.ipfire.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox