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