Replace CD/DVD/BD device names with udev-provided persistent aliases
svn path=/dists/trunk/linux-2.6/; revision=15349
This commit is contained in:
parent
0885a79b40
commit
407faa9cfa
|
@ -12,6 +12,7 @@ linux-2.6 (2.6.33-1~experimental.3) UNRELEASED; urgency=low
|
|||
- Don't accept empty filesystem labels as identifiers (Closes: #572438)
|
||||
- For consistency with fresh installations, use or assign UUIDs rather
|
||||
than labels where both are available (Closes: #572376)
|
||||
- Replace CD/DVD/BD device names with udev-provided persistent aliases
|
||||
|
||||
-- Ben Hutchings <ben@decadent.org.uk> Sun, 28 Feb 2010 17:01:33 +0000
|
||||
|
||||
|
|
|
@ -877,6 +877,20 @@ sub udev_next {
|
|||
return @results;
|
||||
}
|
||||
|
||||
sub udev_parse_symlink_rule {
|
||||
my ($path, $symlink);
|
||||
for (@_) {
|
||||
my ($text, $key, $op, $value) = @$_;
|
||||
next if !defined($key);
|
||||
if ($key eq 'ENV{ID_PATH}' && $op eq '==') {
|
||||
$path = $value;
|
||||
} elsif ($key eq 'SYMLINK' && $op eq '+=') {
|
||||
$symlink = $value;
|
||||
}
|
||||
}
|
||||
return ($path, $symlink);
|
||||
}
|
||||
|
||||
# Find symlink rules using IDE device paths that aren't matched by rules
|
||||
# using the corresponding SCSI device path. Return an array containing
|
||||
# the corresponding path for each rule where this is the case and undef
|
||||
|
@ -891,17 +905,7 @@ sub udev_cd_find_unmatched_ide_rules {
|
|||
my @keys = udev_next($file);
|
||||
last if $#keys < 0;
|
||||
|
||||
my ($path, $symlink);
|
||||
for (@keys) {
|
||||
my ($text, $key, $op, $value) = @$_;
|
||||
next if !defined($key);
|
||||
if ($key eq 'ENV{ID_PATH}' && $op eq '==') {
|
||||
$path = $value;
|
||||
} elsif ($key eq 'SYMLINK' && $op eq '+=') {
|
||||
$symlink = $value;
|
||||
}
|
||||
}
|
||||
|
||||
my ($path, $symlink) = udev_parse_symlink_rule(@keys);
|
||||
if (defined($path) && defined($symlink)) {
|
||||
if ($path =~ /-ide-\d+:\d+$/) {
|
||||
# libata uses the PATA controller and device numbers
|
||||
|
@ -1315,11 +1319,29 @@ sub scan_devices {
|
|||
}
|
||||
}
|
||||
|
||||
# Discard all device ids that are ambiguous.
|
||||
# Discard all labels and UUIDs(!) that are ambiguous.
|
||||
for my $bdev (keys(%bdev_map)) {
|
||||
@{$bdev_map{$bdev}->{ids}} = grep({ $#{$id_map{$_}} == 0 }
|
||||
@{$bdev_map{$bdev}->{ids}});
|
||||
}
|
||||
|
||||
# Add persistent aliases for CD/DVD/BD drives
|
||||
my $cd_rules =
|
||||
new FileHandle('/etc/udev/rules.d/70-persistent-cd.rules', 'r');
|
||||
while (defined($cd_rules)) {
|
||||
my @keys = udev_next($cd_rules);
|
||||
last if $#keys < 0;
|
||||
|
||||
my ($path, $symlink) = udev_parse_symlink_rule(@keys);
|
||||
if (defined($path) && defined($symlink)) {
|
||||
$symlink =~ s{^(?!/)}{/dev/};
|
||||
my $bdev = readlink($symlink) or next;
|
||||
$bdev =~ s{^(?!/)}{/dev/};
|
||||
if (exists($bdev_map{$bdev})) {
|
||||
push @{$bdev_map{$bdev}->{ids}}, $symlink;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub assign_new_ids {
|
||||
|
|
Loading…
Reference in New Issue