From b96a197bdb3f4f91ed0ba608b3610aeca9e51487 Mon Sep 17 00:00:00 2001 From: Ian Beckwith Date: Mon, 20 Sep 2010 21:05:24 +0100 Subject: [PATCH 1/1] added stub ID3FS::Path --- lib/ID3FS/Fuse.pm | 26 ++++++++++++-------------- lib/ID3FS/Path.pm | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 14 deletions(-) create mode 100644 lib/ID3FS/Path.pm diff --git a/lib/ID3FS/Fuse.pm b/lib/ID3FS/Fuse.pm index 44fdc6e..68a1b52 100644 --- a/lib/ID3FS/Fuse.pm +++ b/lib/ID3FS/Fuse.pm @@ -2,6 +2,7 @@ package ID3FS::Fuse; use strict; use warnings; +use ID3FS::Path; use Fuse; use POSIX qw(EINVAL EROFS EOPNOTSUPP S_IRUSR S_IRGRP S_IROTH S_IXUSR S_IXGRP S_IXOTH); use vars qw($TYPE_DIR $TYPE_SYMLINK); @@ -69,15 +70,9 @@ sub getattr my($rdev,$size)=(0,1); my($atime,$mtime,$ctime)=(0,0,0); my($blksize,$blocks)=(512,1); - my $mode; - if($filename eq "/") - { - $mode=$self->mode($TYPE_DIR); - } - else - { - $mode=$self->mode($TYPE_SYMLINK); - } + + my $path=ID3FS::Path->new($self->{db}, $filename); + my $mode=$self->mode( $path->isdir() ? $TYPE_DIR : $TYPE_SYMLINK ); return($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks); } @@ -86,18 +81,21 @@ sub readlink { my($self,$filename)=@_; print "READLINK: $filename\n"; - return "FIXME"; + my $path=ID3FS::Path->new($self->{db}, $filename); + return(-EINVAL()) if($path->isdir()); + return $path->dest(); } sub getdir { my($self, $filename)=@_; - print "GETDIR(", ref($self), ": $filename\n"; - if($filename eq "/") + print "GETDIR: $filename\n"; + my $path=ID3FS::Path->new($self->{db}, $filename); + if($path->isdir()) { - return(".", "..", $self->{db}->tags(), 0); + return(".", "..", $path->dirents(), 0); } - return('.',0); + return -ENOTDIR(); } # unused stubs diff --git a/lib/ID3FS/Path.pm b/lib/ID3FS/Path.pm new file mode 100644 index 0000000..b2202c2 --- /dev/null +++ b/lib/ID3FS/Path.pm @@ -0,0 +1,39 @@ +package ID3FS::Path; + +use strict; +use warnings; + +sub new +{ + my $proto=shift; + my $class=ref($proto) || $proto; + my $self={}; + bless($self,$class); + + $self->{db}=shift; + $self->{path}=shift; + + return $self; +} + +sub isdir +{ + my($self)=@_; + return 1 if($self->{path} eq "/"); + return 0; +} + +sub dest +{ + my($self)=@_; + return "FIXME"; +} + +sub dirents +{ + my($self)=@_; + return $self->{db}->tags(); +} + + +1; -- 2.11.0