From 7888165dad1d6e8dd937a67d0eac461471002e6a Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Fri, 19 Jul 2002 21:39:34 +0000 Subject: add functions to_devfs and from_devfs. These only work for devices entries which can go devfs -> normal and normal -> devfs --- perl-install/devices.pm | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/perl-install/devices.pm b/perl-install/devices.pm index 260793e30..8c45a41f7 100644 --- a/perl-install/devices.pm +++ b/perl-install/devices.pm @@ -182,4 +182,39 @@ sub make($) { $file; } + +#- only isomorphic entries are allowed, +#- i.e. entries which can go devfs -> normal and normal -> devfs +my %to_devfs = ( + psaux => 'misc/psaux', + usbmouse => 'input/mouse0', +); +my %to_devfs_prefix = ( + ttyS => 'tts/', +); + +sub to_devfs { + my ($dev) = @_; + if (my $r = $to_devfs{$dev}) { + return $r; + } elsif ($dev =~ /(.*?)(\d+)$/) { + my $r = $to_devfs_prefix{$1}; + return "$r$2" if $r; + } + undef; +} + +sub from_devfs { + my ($dev) = @_; + my %from_devfs = reverse %to_devfs; + if (my $r = $from_devfs{$dev}) { + return $r; + } elsif ($dev =~ /(.*?)(\d+)$/) { + my %from_devfs_prefix = reverse %to_devfs_prefix; + my $r = $from_devfs_prefix{$1}; + return "$r$2" if $r; + } + undef; +} + 1; -- cgit v1.2.1