Perl's chdir supports fchdir, just by passing in a dirhandle.
http://perldoc.perl.org/functions/chdir.html

Since 2005, so unsurprising this is the way it is.
https://perl5.git.perl.org/perl.git/commit/c4aca7d03737ddcac23de1ad6d597e98be679214

was released in 5.10.
https://metacpan.org/pod/distribution/perl/pod/perl5100delta.pod#chdir-chmod-and-chown-on-filehandles

OK?


Index: usr.bin/vi/build/recover
===================================================================
RCS file: /cvs/src/usr.bin/vi/build/recover,v
retrieving revision 1.10
diff -u -p -r1.10 recover
--- usr.bin/vi/build/recover    8 Aug 2016 15:09:32 -0000       1.10
+++ usr.bin/vi/build/recover    5 Nov 2016 05:59:51 -0000
@@ -6,7 +6,6 @@
 #
 
 use Fcntl;
-require 'sys/syscall.ph';
 
 $recoverdir = $ARGV[0] || "/tmp/vi.recover";
 $sendmail = "/usr/sbin/sendmail";
@@ -24,13 +23,10 @@ if (!sysopen(DIR, $recoverdir, O_RDONLY|
 
 #
 # Sanity check the vi recovery dir
-# Perl doesn't support fchdir, fchmod, or fchown so we call
-# fchdir(2) via the syscall interface and then just modify ".".
 #
 die "Warning! $recoverdir is not a directory! (ignoring)\n"
     unless -d _;
-die "$0: can't chdir to $recoverdir: $!\n"
-    unless syscall(&SYS_fchdir, fileno(DIR)) == 0;
+die "$0: can't chdir to $recoverdir: $!\n" unless chdir DIR;
 if (! -O _) {
        warn "Warning! $recoverdir is not owned by root! (fixing)\n";
        chown(0, 0, ".");

Reply via email to