4 use POSIX qw(ENOENT EISDIR EINVAL);
13 cont => "File 'a'.\n",
19 cont => "This is file 'b'.\n",
29 $file = '.' unless length($file);
34 my ($file) = filename_fixup(shift);
36 $file = '.' unless length($file);
37 return -ENOENT() unless exists($files{$file});
38 my ($size) = exists($files{$file}{cont}) ? length($files{$file}{cont}) : 0;
39 my ($modes) = ($files{$file}{type}<<9) + $files{$file}{mode};
40 my ($dev, $ino, $rdev, $blocks, $gid, $uid, $nlink, $blksize) = (0,0,0,1,0,0,1,1024);
41 my ($atime, $ctime, $mtime);
42 $atime = $ctime = $mtime = $files{$file}{ctime};
43 # 2 possible types of return values:
44 #return -ENOENT(); # or any other error you care to
45 #print(join(",",($dev,$ino,$modes,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks)),"\n");
46 return ($dev,$ino,$modes,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks);
50 # return as many text filenames as you like, followed by the retval.
51 print((scalar keys %files)."\n");
52 return (keys %files),0;
56 # VFS sanity check; it keeps all the necessary state, not much to do here.
57 my ($file) = filename_fixup(shift);
58 print("open called\n");
59 return -ENOENT() unless exists($files{$file});
60 return -EISDIR() unless exists($files{$file}{cont});
66 # return an error numeric, or binary/text string. (note: 0 means EOF, "0" will
67 # give a byte (ascii "0") to the reading program)
68 my ($file) = filename_fixup(shift);
70 return -ENOENT() unless exists($files{$file});
71 return -EINVAL() if $off > length($files{$file}{cont});
72 return 0 if $off == length($files{$file}{cont});
73 return substr($files{$file}{cont},$off,$buf);
76 sub e_statfs { return 255, 1, 1, 1, 1, 2 }
78 # If you run the script directly, it will run fusermount, which will in turn
79 # re-run this script. Hence the funky semantics.
80 my ($mountpoint) = "";
81 $mountpoint = shift(@ARGV) if @ARGV;
83 mountpoint=>$mountpoint,
89 #debug=>1, threaded=>0