/[fuse.before_github]/perl-llin/examples/loopback_t.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /perl-llin/examples/loopback_t.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 25 by dpavlin, Mon Jan 2 22:04:31 2006 UTC revision 112 by dpavlin, Thu Nov 15 09:32:08 2007 UTC
# Line 8  use Fuse; Line 8  use Fuse;
8  use IO::File;  use IO::File;
9  use POSIX qw(ENOENT ENOSYS EEXIST EPERM O_RDONLY O_RDWR O_APPEND O_CREAT);  use POSIX qw(ENOENT ENOSYS EEXIST EPERM O_RDONLY O_RDWR O_APPEND O_CREAT);
10  use Fcntl qw(S_ISBLK S_ISCHR S_ISFIFO SEEK_SET);  use Fcntl qw(S_ISBLK S_ISCHR S_ISFIFO SEEK_SET);
11  require 'syscall.ph'; # for SYS_mknod and SYS_lchown  my $can_syscall = eval {
12            require 'syscall.ph'; # for SYS_mknod and SYS_lchown
13    };
14    if (!$can_syscall && open my $fh, '<', '/usr/include/sys/syscall.h') {
15            my %sys = do { local $/ = undef;
16                            <$fh> =~ m/\#define \s+ (\w+) \s+ (\d+)/gxms;
17            };
18            close $fh;
19            if ($sys{SYS_mknod} && $sys{SYS_lchown}) {
20                    *SYS_mknod  = sub { $sys{SYS_mknod}  };
21                    *SYS_lchown = sub { $sys{SYS_lchown} };
22                    $can_syscall = 1;
23            }
24    }
25    
26  sub fixup { return "/tmp/fusetest-" . $ENV{LOGNAME} . shift }  sub fixup { return "/tmp/fusetest-" . $ENV{LOGNAME} . shift }
27    
# Line 79  sub x_rename { Line 92  sub x_rename {
92  }  }
93  sub x_link { return link(fixup(shift),fixup(shift)) ? 0 : -$! }  sub x_link { return link(fixup(shift),fixup(shift)) ? 0 : -$! }
94  sub x_chown {  sub x_chown {
95            return -ENOSYS() if ! $can_syscall;
96          my ($fn) = fixup(shift);          my ($fn) = fixup(shift);
97          print "nonexistent $fn\n" unless -e $fn;          print "nonexistent $fn\n" unless -e $fn;
98          my ($uid,$gid) = @_;          my ($uid,$gid) = @_;
# Line 102  sub x_mkdir { my ($name, $perm) = @_; re Line 116  sub x_mkdir { my ($name, $perm) = @_; re
116  sub x_rmdir { return 0 if rmdir fixup(shift); return -$!; }  sub x_rmdir { return 0 if rmdir fixup(shift); return -$!; }
117    
118  sub x_mknod {  sub x_mknod {
119            return -ENOSYS() if ! $can_syscall;
120          # since this is called for ALL files, not just devices, I'll do some checks          # since this is called for ALL files, not just devices, I'll do some checks
121          # and possibly run the real mknod command.          # and possibly run the real mknod command.
122          my ($file, $modes, $dev) = @_;          my ($file, $modes, $dev) = @_;

Legend:
Removed from v.25  
changed lines
  Added in v.112

  ViewVC Help
Powered by ViewVC 1.1.26