fixed the last bug I know about!
authorMark Glines <mark@glines.org>
Wed, 26 Jun 2002 01:57:27 +0000 (01:57 +0000)
committerMark Glines <mark@glines.org>
Wed, 26 Jun 2002 01:57:27 +0000 (01:57 +0000)
perl/loopback.pl
perl/test/symlink.t

index 206eb81ee6f22a84267f0237c114e18ebfa11edf..bdc8c2218f1d7bb8c23f5c91bc68c575c3992c43 100644 (file)
@@ -1,11 +1,11 @@
-#!/usr/bin/debugperl 
+#!/usr/bin/perl
 
 use strict;
 use Fuse;
 use IO::File;
 use POSIX qw(ENOENT ENOSYS EEXIST EPERM O_RDONLY O_RDWR O_APPEND O_CREAT);
 use Fcntl qw(S_ISBLK S_ISCHR S_ISFIFO SEEK_SET);
-require 'syscall.ph'; # for SYS_mknod
+require 'syscall.ph'; # for SYS_mknod and SYS_lchown
 
 sub fixup { return "/tmp/fusetest" . shift }
 
@@ -67,7 +67,7 @@ sub x_readlink { return readlink(fixup(shift)                 ); }
 sub x_unlink { return unlink(fixup(shift)) ? 0 : -$!;          }
 sub x_rmdir { return err(rmdir(fixup(shift))               ); }
 
-sub x_symlink { return symlink(shift,fixup(shift)) ? 0 : -$!; }
+sub x_symlink { print "symlink\n"; return symlink(shift,fixup(shift)) ? 0 : -$!; }
 
 sub x_rename {
        my ($old) = fixup(shift);
@@ -78,8 +78,13 @@ sub x_rename {
 sub x_link { return link(fixup(shift),fixup(shift)) ? 0 : -$! }
 sub x_chown {
        my ($fn) = fixup(shift);
+       print "nonexistent $fn\n" unless -e $fn;
        my ($uid,$gid) = @_;
-       my ($err) = chown($uid,$gid,$fn) ? 0 : -$!;
+       # perl's chown() does not chown symlinks, it chowns the symlink's
+       # target.  it fails when the link's target doesn't exist, because
+       # the stat64() syscall fails.
+       # this causes error messages when unpacking symlinks in tarballs.
+       my ($err) = syscall(&SYS_lchown,$fn,$uid,$gid,$fn) ? -$! : 0;
        return $err;
 }
 sub x_chmod {
index faf98e6258a5db52ad4c6391bdc5afb8d1aeb2d0..19cc72d446ceec1a01451f5814be55d831feb3fa 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 use test::helper qw($_point $_real);
 use Test::More;
-plan tests => 5;
+plan tests => 6;
 chdir($_point);
 ok(symlink("abc","def"),"symlink created");
 ok(-l "def","symlink exists");
@@ -10,3 +10,10 @@ chdir($_real);
 ok(-l "def","symlink really exists");
 is(readlink("def"),"abc","really worked");
 unlink("def");
+
+# bug: doing a 'cp -a' on a directory which contains a symlink
+# reports an error
+mkdir("dira");
+system("cd dira; touch filea; ln -s filea fileb");
+is(system("cp -a dira dirb")>>8,0,"cp -a");
+system("rm -rf dira dirb");