How to handle large number of disk devices in "arbitrary" order?

Carsten Aulbert carsten at welcomes-you.com
Thu Nov 17 08:39:45 CET 2011


Hi

On Tuesday 15 November 2011 10:26:12 Michael Tautschnig wrote:
> > Although a proper 'lstat' might be more perlish ;)
> 
> Hmm, how would that best be implemented? (I'm always open to all kinds of
> perl hints!!)

Actually, Cwd might help here, what about:



diff --git a/lib/setup-storage/Parser.pm b/lib/setup-storage/Parser.pm
index b767c8b..9c7041d 100644
--- a/lib/setup-storage/Parser.pm
+++ b/lib/setup-storage/Parser.pm
@@ -35,6 +35,7 @@ use strict;
 ################################################################################

 use Parse::RecDescent;
+use Cwd 'abs_path';

 package FAI;

@@ -106,7 +107,7 @@ sub resolve_disk_shortname {
   ($disk =~ m{^/}) or $disk = "/dev/$disk";
   my @candidates = glob($disk);
   die "Failed to resolve $disk to a unique device name\n" if (scalar(@candidates) > 1);
-  $disk = $candidates[0] if (scalar(@candidates) == 1);
+  $disk = abs_path($candidates[0]) if (scalar(@candidates) == 1);
   die "Device name $disk could not be substituted\n" if ($disk =~ m{[\*\?\[\{\~]});

   return $disk;



At least for me, that seems to work nicely (so far)

Please correct me, but this code path is only ever executed for "full" disks, 
never on partitioned, right?

If so, should not any trailing /-part[0-9]+/ be cut out/ignored from the potential list 
of candidates? E.g. (fully untested, just random idea)

my @candidates = ();
for (glob($disk)) {
	push @candidates unless /-part[0-9]+$/;
}

Cheers

Carsten


More information about the linux-fai mailing list