--- lib/Cwd.pm.before	2004-10-26 11:55:14.000000000 -0400
+++ lib/Cwd.pm	2004-10-26 11:58:34.000000000 -0400
@@ -676,5 +676,65 @@
   }
 }
 
+# Afs hack
+
+sub _afs_abs_path
+{
+  # Modified fast_abs_path - use cwd(), not getcwd(), in two places
+  # Also, don't cache File::Spec->curdir...
+  my $cwd = cwd();
+  require File::Spec;
+  my $path = @_ ? shift : File::Spec->curdir;
+
+  # Detaint else we'll explode in taint mode.  This is safe because
+  # we're not doing anything dangerous with it.
+  ($path) = $path =~ /(.*)/;
+  ($cwd)  = $cwd  =~ /(.*)/;
+
+  unless (-e $path) {
+    _croak("$path: No such file or directory");
+  }
+
+  unless (-d _) {
+    # Make sure we can be invoked on plain files, not just directories.
+	
+    my ($vol, $dir, $file) = File::Spec->splitpath($path);
+    return File::Spec->catfile($cwd, $path) unless length $dir;
+
+    if (-l $path) {
+      my $link_target = readlink($path);
+      die "Can't resolve link $path: $!" unless defined $link_target;
+	    
+      $link_target = File::Spec->catpath($vol, $dir, $link_target)
+        unless File::Spec->file_name_is_absolute($link_target);
+	    
+      return fast_abs_path($link_target);
+    }
+	
+    return fast_abs_path(File::Spec->catpath($vol, $dir, '')) . '/' . $file;
+  }
+
+  if (!CORE::chdir($path)) {
+      _croak("Cannot chdir to $path: $!");
+  }
+  my $realpath = cwd();
+  if (! ((-d $cwd) && (CORE::chdir($cwd)))) {
+    _croak("Cannot chdir back to $cwd: $!");
+  }
+  $realpath;
+}
+
+{
+  no warnings;
+
+  *getcwd     = \&cwd;
+  *fastgetcwd = \&cwd;
+  *fastcwd    = \&cwd;
+
+  *abs_path      = \&_afs_abs_path;
+  *realpath      = \&_afs_abs_path;
+  *fast_abs_path = \&_afs_abs_path;
+  *fast_realpath = \&_afs_abs_path;
+}
 
 1;
