From b815e7bd111d804bc940ba0e4b9f629544193198 Mon Sep 17 00:00:00 2001 From: Antoine Jacoutot Date: Thu, 10 Dec 2020 16:19:19 +0100 Subject: [PATCH] - skip device on errors - properly skip RAID devices - skip already mounted partitions --- ChangeLog | 9 +++++++++ toad.pl | 12 ++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index eedb4ec..9ca0a22 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +v1.14 - UNRELEASED +------------------------------------ + +v1.13 - Mon Nov 30 20:48:33 CET 2020 +------------------------------------ +- skip device on errors +- properly skip RAID devices +- skip already mounted partitions + v1.12 - Mon Nov 30 20:48:33 CET 2020 ------------------------------------ - remove some debug output diff --git a/toad.pl b/toad.pl index 3506573..1c481cd 100644 --- a/toad.pl +++ b/toad.pl @@ -283,9 +283,8 @@ sub mount_device { my @allparts; my @parts; - # ignore softraid(4) crypto device attachment - my $sr_crypto = `/sbin/disklabel $devname 2>/dev/null | grep "SR CRYPTO"`; - if ($sr_crypto) { + # XXX skip device on error (e.g. DIOCGDINFO) or softraid(4) attachment + if (system ("set -o pipefail; /sbin/disklabel $devname 2>/dev/null | ! grep -qw RAID") != 0) { return (0); } @@ -308,8 +307,13 @@ sub mount_device { foreach my $part (@parts) { $part =~ s/^\s+//; my $device = "/dev/$devname$part"; - my $devnum = get_mount_point (); + # skip already mounted partition + if (system ("/sbin/mount | grep -q $device") == 0) { + next; + } + + my $devnum = get_mount_point (); create_mount_point ($devnum); create_pkrule ($devname, $devnum, $part);