docs
[mirrors/Programs.git] / perl / fuse / fs2.pl
1 #!/usr/bin/env perl
2 use Fuse::Simple qw(accessor main nocache saferun runcode);
3 #use threads;
4 #use threads::shared;
5
6 my $randfile = sub {
7 nocache $_[0]." ".rand(23)."\n";
8 };
9
10
11 my $randdir = sub {
12 my $list = {};
13 for(my $i=0;$i<int(rand(15));$i++) {
14 #$list->{$i}="test #$i\n";
15 $list->{$i}=saferun($randfile, $i);
16 }
17 nocache $list;
18 };
19
20 my $var = "this is a variable you can modify. write to me!\n";
21 my $filesystem = {
22 list => sub {
23 nocache("LOOOL:".rand(9999)."\n");
24 },
25 listing => $randdir,
26 foo => "this is the contents of a file called foo\n",
27 subdir => {
28 "foo" => "this foo is in a subdir called subdir\n",
29 "blah" => "this blah is in a subdir called subdir\n",
30 },
31 "blah" => \ "subdir/blah", # scalar refs are symlinks
32 recursion => {
33 "recursion" => \ ".", # scalar refs are symlinks
34 },
35 "magic" => sub { return "42\n" }, # will be called to get value
36 "var" => accessor(\$var), # read and write this variable
37 "var2" => accessor(\$var), # and the same variable
38 "var.b" => accessor(\ my $tmp), # and an anonymous var
39 };
40
41 print "mount....\n";
42 main(
43 #"mountpoint" => "./test", # actually optional
44 "debug" => 0, # for debugging Fuse::Simple. optional
45 "fuse_debug" => 0, # for debugging FUSE itself. optional
46 "threaded" => 0, # optional
47 "/" => $filesystem, # required :-)
48 );
49 print "unmounted\n";
This page took 0.274496 seconds and 4 git commands to generate.