summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorOliver Tappe2007-05-13 19:22:27 +0200
committerOliver Tappe2007-05-13 19:22:27 +0200
commit304e8df5559677ff57d39f9091f5b00925334c8b (patch)
tree26df61c0812551b7c47530df8bc1a7dff15f0492 /lib
parentMake mkdxsinitrd able to follow symlinks in kernel module directory (diff)
downloadcore-304e8df5559677ff57d39f9091f5b00925334c8b.tar.gz
core-304e8df5559677ff57d39f9091f5b00925334c8b.tar.xz
core-304e8df5559677ff57d39f9091f5b00925334c8b.zip
* added utility function followLink() and made use of it
* reworked search for required kernel modules to be able to return the matching paths to the caller (not currently used though) git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1069 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'lib')
-rw-r--r--lib/OpenSLX/Utils.pm19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/OpenSLX/Utils.pm b/lib/OpenSLX/Utils.pm
index d86167a2..779640d5 100644
--- a/lib/OpenSLX/Utils.pm
+++ b/lib/OpenSLX/Utils.pm
@@ -21,7 +21,7 @@ $VERSION = 1.01;
@ISA = qw(Exporter);
@EXPORT = qw(
- &copyFile &fakeFile &linkFile &slurpFile
+ &copyFile &fakeFile &linkFile &slurpFile &followLink
);
################################################################################
@@ -86,4 +86,21 @@ sub slurpFile
return $text;
}
+sub followLink
+{
+ my $path = shift;
+ my $prefixedPath = shift || '';
+
+ my $target;
+ while (-l "$path") {
+ $target = readlink "$path";
+ if (substr($target, 1, 1) eq '/') {
+ $path = "$prefixedPath/$target";
+ } else {
+ $path = $prefixedPath.dirname($path).'/'.$target;
+ }
+ }
+ return $path;
+}
+
1; \ No newline at end of file