[perltidy]
authorHeiko Schlittermann <hs@schlittermann.de>
Fri, 15 Jan 2010 20:40:14 +0100
changeset 3 1b975c58c5bf
parent 2 1f1d347eff00
child 4 7429b9385f98
child 6 df6ca24871d4
[perltidy]
SI/blkid.pm
SI/lvm.pm
SI/ptable.pm
SI/tools.pm
si
--- a/SI/blkid.pm	Fri Jan 15 20:38:38 2010 +0100
+++ b/SI/blkid.pm	Fri Jan 15 20:40:14 2010 +0100
@@ -5,43 +5,47 @@
 use File::Find;
 
 sub ff($$) {
-	my ($dir, $id) = @_;
-	my $found;
-	find(sub { 
-		return if $found;
-		$found = (stat)[6] == $id ? $File::Find::name : undef;
-		return;
-		}, $dir);
-	return $found;
+    my ($dir, $id) = @_;
+    my $found;
+    find(
+        sub {
+            return if $found;
+            $found = (stat)[6] == $id ? $File::Find::name : undef;
+            return;
+        },
+        $dir
+    );
+    return $found;
 }
 
 sub info($\%) {
-	my ($file, $part) = @_;
+    my ($file, $part) = @_;
 
-	foreach (`blkid -c /dev/null`) {
-		my ($dev) = (split /:/)[0];
+    foreach (`blkid -c /dev/null`) {
+        my ($dev) = (split /:/)[0];
 
-		my ($uuid) = /\sUUID=.(.*?).\s/;
-		my ($type) = /\sTYPE=.(.*?).\s/;
-		my ($label) = /\sLABEL=.(.*?).\s/;
+        my ($uuid)  = /\sUUID=.(.*?).\s/;
+        my ($type)  = /\sTYPE=.(.*?).\s/;
+        my ($label) = /\sLABEL=.(.*?).\s/;
 
-		if ($dev ~~ $part->{physical}) {
-			$part->{physical}{$dev}{uuid} = $uuid;
-			$part->{physical}{$dev}{type} = $type;
-			$part->{physical}{$dev}{label} = $label;
-			next;
-		}
-	
-		# dev mapper names should be replace by nicer ones
-		if ($dev ~~ /^\/dev\/dm-/) {
-			$dev = ff("/dev/mapper", (stat $dev)[6])
-				or next;
-			$part->{logical}{$dev}{uuid} = $uuid;
-			$part->{logical}{$dev}{type} = $type;
-			$part->{logical}{$dev}{label} = $label;
-		}
-		
-	}
+        if ($dev ~~ $part->{physical}) {
+            $part->{physical}{$dev}{uuid}  = $uuid;
+            $part->{physical}{$dev}{type}  = $type;
+            $part->{physical}{$dev}{label} = $label;
+            next;
+        }
+
+        # dev mapper names should be replace by nicer ones
+        if ($dev ~~ /^\/dev\/dm-/) {
+            $dev = ff("/dev/mapper", (stat $dev)[6])
+              or next;
+            $part->{logical}{$dev}{uuid}  = $uuid;
+            $part->{logical}{$dev}{type}  = $type;
+            $part->{logical}{$dev}{label} = $label;
+        }
+
+    }
 }
 
 1;
+# vim:sts=4 sw=4 aw ai si:
--- a/SI/lvm.pm	Fri Jan 15 20:38:38 2010 +0100
+++ b/SI/lvm.pm	Fri Jan 15 20:40:14 2010 +0100
@@ -5,25 +5,28 @@
 use SI::tools;
 
 sub vg_info($\%) {
-	my ($file, $part) = @_;
-	foreach (map { (split /:/)[0] } map { /^\s*(.*)/; } `vgs --noheadings --separator :`) {
-		my $file = sprintf $file, $_;
-		run("vgcfgbackup -f $file >/dev/null");
-	}
+    my ($file, $part) = @_;
+    foreach (map { (split /:/)[0] }
+        map { /^\s*(.*)/; } `vgs --noheadings --separator :`)
+    {
+        my $file = sprintf $file, $_;
+        run("vgcfgbackup -f $file >/dev/null");
+    }
 }
 
 sub lv_info($\%) {
-	my ($file, $part) = @_;
+    my ($file, $part) = @_;
 
-	foreach my $p (keys %$part) {
-	`pvs -o +uuid --nameprefix --noheadings $p` =~ /\bLVM2_PV_UUID='(.*?)'/
-		or next;
+    foreach my $p (keys %$part) {
+        `pvs -o +uuid --nameprefix --noheadings $p` =~ /\bLVM2_PV_UUID='(.*?)'/
+          or next;
 
-	$part->{$p}{type} = "pv";
-	$part->{$p}{uuid} = $1;
+        $part->{$p}{type} = "pv";
+        $part->{$p}{uuid} = $1;
 
-	}
+    }
 
 }
 
 1;
+# vim:sts=4 sw=4 aw ai si:
--- 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:
--- a/SI/tools.pm	Fri Jan 15 20:38:38 2010 +0100
+++ b/SI/tools.pm	Fri Jan 15 20:40:14 2010 +0100
@@ -12,3 +12,4 @@
 }
 
 1;
+# vim:sts=4 sw=4 aw ai si:
--- a/si	Fri Jan 15 20:38:38 2010 +0100
+++ b/si	Fri Jan 15 20:40:14 2010 +0100
@@ -22,3 +22,4 @@
 
 ### %devices;
 
+# vim:sts=4 sw=4 aw ai si: