Witam
Probuje od jakiegos czsus oganąć fuse pod perlem ale jakos nie zabardzo mogę sobie poradzić z dodawaniem nowego pliku.
otóż ma, taki kod
use Fuse::Simple qw(accessor main);
use Data::Dumper;
use threads;
use threads::shared;
use File::ExtAttr ':all';
use IO::File;
use POSIX qw(ENOENT ENOSYS EEXIST EPERM O_RDONLY O_RDWR O_APPEND O_CREAT O_ACCMODE);
use Fcntl qw(S_ISBLK S_ISCHR S_ISFIFO SEEK_SET);
require 'syscall.ph'; # for SYS_mknod and SYS_lchown
my $rootdir="test";
print $rootdir;
my $var = "this is a variable you can modify. write to me!\n";
my $filesystem = {
foo => "this is the contents of a file called foo\n",
subdir => {
"foo" => "this foo is in a subdir called subdir\n",
"blah" => "this blah is in a subdir called subdir\n",
},
"blah" => \ "subdir/blah", # scalar refs are symlinks
"magic" => sub { return "42\n" }, # will be called to get value
"var" => accessor(\$var), # read and write this variable
"var2" => accessor(\$var), # and the same variable
"var.b" => accessor(\ my $tmp), # and an anonymous var
};
print Dumper $filesystem;
sub x_mknod {
my ($file, $modes, $dev) = @_;
$! = 0;
$file=$rootdir.'/'.$file;
syscall(&SYS_mknod,$file,$modes,$dev);
return -!$;
}
main(
"mountpoint" => "./test", # actually optional
"debug" => 0, # for debugging Fuse::Simple. optional
"fuse_debug" => 0, # for debugging FUSE itself. optional
"threaded" => 0, # optional
"/" => $filesystem, # required :-)
mknod => "main::x_mknod",
);
i niestety w czasie tworzenia nowego pliku skrypt sie zawiesza.
Mogł by mi ktos podpowiedz co jest nie tak .\
Probuje zrobic program ,ktory montuje chmure (np mega.co.nz) z mozliwoscia zapisywania.
Witam ponowie
po dluższej przerwie znow wróciłem do tematu. Akturat na python-fuse lepiej dziala. Nie wywala sie przede wszystkim.
Niestety potrzebowałbym malej porady.
Swoj skrypt oparłem na przykladowym pliku hello.py z python-fuse.
No i oczywiscie proboje utworzyc plik przy pomocy "touch test.txt".
Z czego się zrojentowalem to touch najpierw sprawdza czy plik istnieje (tak mysle). W getattr jesli nie znajdzie pliku zwraca -errno.ENOENT.
Niestety w touch dostaje touch: setting times of ‘test.txt’: No such file or directory. Natomiast w logu mam tylko wpisy z getattr.
def open(self, path, flags):
os.system("echo 'open "+path+"' >> /tmp/cloud.log")
for i in self.Arootdir:
if(path == i[5] and i[1] == '1'):
accmode=os.O_RDONLY | os.O_WRONLY | os.O_RDWR
if(flags & accmode) != os.O_RDONLY:
return -errno.EACCES
return -errno.ENOENT
def mknode(self, path,mode, dev):
os.system("echo 'mknode "+path+"' >> /tmp/cloud.log")
a=['','1','','','',path]
Arootdir.append(a)
#fuse.mknode("."+path,mode,dev)
return st
def read(self, path, size, offset):
os.system("echo 'read "+path+"' >> /tmp/cloud.log")
if(path == 'test.txt'):
return 0
return 0
def getattr(self, path):
st = MyStat()
# if path == '/':
y=False
os.system("echo 'getattr "+path+"' >> /tmp/cloud.log")
for i in self.Arootdir:
os.system("echo '"+path+" "+i[1]+" "+i[5]+"' >> /tmp/cloud.log")
if(
path =='/' or (i[5]==path and (i[1]=='3' or i[1]=='2' or i[1]=='4') )
):
y=True
st.st_mode = stat.S_IFDIR | 0755
st.st_nlink = 2
break
if(i[5] == path and i[1] == '1'):
y=True
st.st_mode = stat.S_IFREG | 0666
st.st_nlink = 1
break
if(y == False):
os.system("echo 'brak "+path+"' >> /tmp/cloud.log")
return -errno.ENOENT
# st.st_mode = stat.S_IFREG | 0000
# st.st_nlink = 0
# a=['','1','','','',path]
# self.Arootdir.append(a)
return st