From: Mark Glines Date: Wed, 26 Jun 2002 01:57:27 +0000 (+0000) Subject: fixed the last bug I know about! X-Git-Tag: debian_version_1_0-1~33 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=a6e354a6145bf958701204cf3cf99c8f2ef1c0b2;p=qemu-gpiodev%2Flibfuse.git fixed the last bug I know about! --- diff --git a/perl/loopback.pl b/perl/loopback.pl index 206eb81..bdc8c22 100644 --- a/perl/loopback.pl +++ b/perl/loopback.pl @@ -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 { diff --git a/perl/test/symlink.t b/perl/test/symlink.t index faf98e6..19cc72d 100644 --- a/perl/test/symlink.t +++ b/perl/test/symlink.t @@ -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");