aboutsummaryrefslogtreecommitdiffstats
path: root/perl/loopback.pl
diff options
context:
space:
mode:
authorMark Glines <mark@glines.org>2002-04-18 14:53:55 +0000
committerMark Glines <mark@glines.org>2002-04-18 14:53:55 +0000
commita0c0d5c9f433ac8b57df9996686a53e75e1002f9 (patch)
tree3d6915c2d89201abbc159f1b3d9d28ba3d295447 /perl/loopback.pl
parent65ba219885aefa096437c2bd92ad8394a5ecda75 (diff)
downloadlibfuse-a0c0d5c9f433ac8b57df9996686a53e75e1002f9.tar.gz
use fuse_mount_ioslave(), and get rid of that lame argv-rebuilding crap
disable threads indefinitely, pending stabilization of the perl threads API loopback.pl: fix open() and mknod() ghettoness
Diffstat (limited to 'perl/loopback.pl')
-rw-r--r--perl/loopback.pl34
1 files changed, 13 insertions, 21 deletions
diff --git a/perl/loopback.pl b/perl/loopback.pl
index e58d90a..ac3a7b0 100644
--- a/perl/loopback.pl
+++ b/perl/loopback.pl
@@ -5,6 +5,7 @@ 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);
+require 'syscall.ph'; # for SYS_mknod
sub debug {
print(STDERR join(",",@_),"\n");
@@ -31,10 +32,10 @@ sub x_getdir {
sub x_open {
my ($file) = fixup(shift);
- my ($fd) = POSIX::open($file,@_);
- return -ENOSYS() if(!defined($fd));
- return $fd if $fd < 0;
- POSIX::close($fd);
+ my ($mode) = shift;
+ debug("open",$file,$mode);
+ return -$! unless sysopen(FILE,$file,$mode);
+ close(FILE);
return 0;
}
@@ -106,21 +107,12 @@ sub x_mknod {
# since this is called for ALL files, not just devices, I'll do some checks
# and possibly run the real mknod command.
my ($file, $modes, $dev) = @_;
- return -EEXIST() if -e ($file = fixup($file));
- return -EPERM() if (system("touch $file 2>/dev/null") >> 8);
- if(S_ISBLK($modes) || S_ISCHR($modes) || S_ISFIFO($modes)) {
- system("rm -f $file 2>/dev/null");
- my ($chr) = 'c';
- my ($omodes) = sprintf("%o",$modes & 0x1ff);
- $chr = 'b' if S_ISBLK($modes);
- if(S_ISFIFO($modes)) {
- $chr = 'p';
- $dev = "";
- } else {
- $dev = (($dev>>8) & 255) . " " . ($dev & 255);
- }
- system("mknod --mode=$omodes '$file' $chr $dev");
- }
+ $file = fixup($file);
+ $! = 0;
+ debug("mknod",@_);
+ syscall(&SYS_mknod,$file,$modes);
+ debug("mknod retval",$!);
+ return -$!;
}
# kludge
@@ -128,7 +120,6 @@ sub x_statfs {return 255,1000000,500000,1000000,500000,4096}
my ($mountpoint) = "";
$mountpoint = shift(@ARGV) if @ARGV;
Fuse::main(
- unthreaded=>1,
mountpoint=>$mountpoint,
getattr=>\&x_getattr,
readlink=>\&x_readlink,
@@ -147,5 +138,6 @@ Fuse::main(
open=>\&x_open,
read=>\&x_read,
write=>\&x_write,
- statfs=>\&x_statfs
+ statfs=>\&x_statfs,
+ debug=>1
);