/[fuse.before_github]/perl-llin/examples/example.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /perl-llin/examples/example.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 67 by dpavlin, Tue Jan 3 16:20:50 2006 UTC revision 108 by dpavlin, Sat Jan 20 12:21:12 2007 UTC
# Line 2  Line 2 
2  use strict;  use strict;
3    
4  use blib;  use blib;
5  use Fuse;  use Fuse qw(fuse_get_context);
6  use POSIX qw(ENOENT EISDIR EINVAL);  use POSIX qw(ENOENT EISDIR EINVAL);
7    
8  my (%files) = (  my (%files) = (
# Line 23  my (%files) = ( Line 23  my (%files) = (
23                  mode => 0644,                  mode => 0644,
24                  ctime => time()-1000                  ctime => time()-1000
25          },          },
26            me => {
27                    size => 45,
28                    type => 0100,
29                    mode => 0644,
30                    ctime => time()-1000
31            },
32  );  );
33    
34  sub filename_fixup {  sub filename_fixup {
# Line 38  sub e_getattr { Line 44  sub e_getattr {
44          $file = '.' unless length($file);          $file = '.' unless length($file);
45          return -ENOENT() unless exists($files{$file});          return -ENOENT() unless exists($files{$file});
46          my ($size) = exists($files{$file}{cont}) ? length($files{$file}{cont}) : 0;          my ($size) = exists($files{$file}{cont}) ? length($files{$file}{cont}) : 0;
47            $size = $files{$file}{size} if exists $files{$file}{size};
48          my ($modes) = ($files{$file}{type}<<9) + $files{$file}{mode};          my ($modes) = ($files{$file}{type}<<9) + $files{$file}{mode};
49          my ($dev, $ino, $rdev, $blocks, $gid, $uid, $nlink, $blksize) = (0,0,0,1,0,0,1,1024);          my ($dev, $ino, $rdev, $blocks, $gid, $uid, $nlink, $blksize) = (0,0,0,1,0,0,1,1024);
50          my ($atime, $ctime, $mtime);          my ($atime, $ctime, $mtime);
# Line 59  sub e_open { Line 66  sub e_open {
66          my ($file) = filename_fixup(shift);          my ($file) = filename_fixup(shift);
67          print("open called\n");          print("open called\n");
68          return -ENOENT() unless exists($files{$file});          return -ENOENT() unless exists($files{$file});
69          return -EISDIR() unless exists($files{$file}{cont});          return -EISDIR() if $files{$file}{type} & 0040;
70          print("open ok\n");          print("open ok\n");
71          return 0;          return 0;
72  }  }
# Line 70  sub e_read { Line 77  sub e_read {
77          my ($file) = filename_fixup(shift);          my ($file) = filename_fixup(shift);
78          my ($buf,$off) = @_;          my ($buf,$off) = @_;
79          return -ENOENT() unless exists($files{$file});          return -ENOENT() unless exists($files{$file});
80            if(!exists($files{$file}{cont})) {
81                    return -EINVAL() if $off > 0;
82                    my $context = fuse_get_context();
83                    return sprintf("pid=0x%08x uid=0x%08x gid=0x%08x\n",@$context{'pid','uid','gid'});
84            }
85          return -EINVAL() if $off > length($files{$file}{cont});          return -EINVAL() if $off > length($files{$file}{cont});
86          return 0 if $off == length($files{$file}{cont});          return 0 if $off == length($files{$file}{cont});
87          return substr($files{$file}{cont},$off,$buf);          return substr($files{$file}{cont},$off,$buf);

Legend:
Removed from v.67  
changed lines
  Added in v.108

  ViewVC Help
Powered by ViewVC 1.1.26