SI/ptable.pm
changeset 3 1b975c58c5bf
parent 2 1f1d347eff00
child 6 df6ca24871d4
--- a/SI/ptable.pm	Fri Jan 15 20:38:38 2010 +0100
+++ b/SI/ptable.pm	Fri Jan 15 20:40:14 2010 +0100
@@ -10,42 +10,45 @@
 use SI::tools;
 
 sub info($\%) {
-	my ($file, $part) = @_;
+    my ($file, $part) = @_;
 
-	# find major of devmapper
-	my $devmapper = 0;
-	{
-	local $/ = undef;
-	open(my($i), "/proc/devices") or die "ERR: Can't open /proc/devices: $!\n";
-	($devmapper) =  <$i> =~ /^\s*(\d+)\s+device.mapper\b/m;
-	}
+    # find major of devmapper
+    my $devmapper = 0;
+    {
+        local $/ = undef;
+        open(my ($i), "/proc/devices")
+          or die "ERR: Can't open /proc/devices: $!\n";
+        ($devmapper) = <$i> =~ /^\s*(\d+)\s+device.mapper\b/m;
+    }
 
-	my ($current, %dev);
-	foreach (`sfdisk -d 2>/dev/null`) {
-		chomp;
-		### $_
-		if (/^# partition table .*?(\/\S+)/) {
-			$current = (stat $1)[6] >> 8 == $devmapper ? undef : $1
-				and push(@{$dev{$current}}, $_);
-			next;
-		}
-		next if not $current;
-		push @{$dev{$current}}, $_;
-	}
-	### partiton tables of useful blockdevices:
-	### %dev
+    my ($current, %dev);
+    foreach (`sfdisk -d 2>/dev/null`) {
+        chomp;
+        ### $_
+        if (/^# partition table .*?(\/\S+)/) {
+            $current = (stat $1)[6] >> 8 == $devmapper ? undef : $1
+              and push(@{ $dev{$current} }, $_);
+            next;
+        }
+        next if not $current;
+        push @{ $dev{$current} }, $_;
+    }
+    ### partiton tables of useful blockdevices:
+    ### %dev
 
-	# process the partition tables
-	# and output the tables for relevant devices
-	foreach my $dev (keys %dev) {
-		($_ = $dev) =~ s/^.*\///;
-		my $file = sprintf $file, $_;
-		die "ERR: $file exists already\n" if -f $file;
-		open(my $o, ">$file") or die "ERR: Can't open $file: $!\n";
-		print $o join "\n", @{$dev{$dev}}, "";
-	}
+    # process the partition tables
+    # and output the tables for relevant devices
+    foreach my $dev (keys %dev) {
+        ($_ = $dev) =~ s/^.*\///;
+        my $file = sprintf $file, $_;
+        die "ERR: $file exists already\n" if -f $file;
+        open(my $o, ">$file") or die "ERR: Can't open $file: $!\n";
+        print $o join "\n", @{ $dev{$dev} }, "";
+    }
 
-	# reserve entries in %part, one for each partition
-	@{$part->{physical}}{map { (split)[0] } grep { /^\// } map { @$_ } values %dev} = ();
+    # reserve entries in %part, one for each partition
+    @{ $part->{physical} }{ map { (split)[0] }
+          grep { /^\// } map { @$_ } values %dev } = ();
 }
 1;
+# vim:sts=4 sw=4 aw ai si: