5 use POSIX qw(ENOENT EISDIR EINVAL);
14 cont => "File 'a'.\n",
20 cont => "This is file 'b'.\n",
30 $file = '.' unless length($file);
35 my ($file) = filename_fixup(shift);
37 $file = '.' unless length($file);
38 return -ENOENT() unless exists($files{$file});
39 my ($size) = exists($files{$file}{cont}) ? length($files{$file}{cont}) : 0;
40 my ($modes) = ($files{$file}{type}<<9) + $files{$file}{mode};
41 my ($dev, $ino, $rdev, $blocks, $gid, $uid, $nlink, $blksize) = (0,0,0,1,0,0,1,1024);
42 my ($atime, $ctime, $mtime);
43 $atime = $ctime = $mtime = $files{$file}{ctime};
44 # 2 possible types of return values:
45 #return -ENOENT(); # or any other error you care to
46 #print(join(",",($dev,$ino,$modes,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks)),"\n");
47 return ($dev,$ino,$modes,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks);
51 # return as many text filenames as you like, followed by the retval.
52 print((scalar keys %files)."\n");
53 return (keys %files),0;
57 # VFS sanity check; it keeps all the necessary state, not much to do here.
58 my ($file) = filename_fixup(shift);
59 print("open called\n");
60 return -ENOENT() unless exists($files{$file});
61 return -EISDIR() unless exists($files{$file}{cont});
67 # return an error numeric, or binary/text string. (note: 0 means EOF, "0" will
68 # give a byte (ascii "0") to the reading program)
69 my ($file) = filename_fixup(shift);
71 return -ENOENT() unless exists($files{$file});
72 return -EINVAL() if $off > length($files{$file}{cont});
73 return 0 if $off == length($files{$file}{cont});
74 return substr($files{$file}{cont},$off,$buf);
77 sub e_statfs { return 255, 1, 1, 1, 1, 2 }
79 # If you run the script directly, it will run fusermount, which will in turn
80 # re-run this script. Hence the funky semantics.
81 my ($mountpoint) = "";
82 $mountpoint = shift(@ARGV) if @ARGV;
84 mountpoint=>$mountpoint,
85 getattr=>"main::e_getattr",
86 getdir =>"main::e_getdir",
87 open =>"main::e_open",
88 statfs =>"main::e_statfs",
89 read =>"main::e_read",