From 21ecf8a4b316031f7a7bd948bcbae0cec5b8f17f Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sat, 7 Aug 2004 15:16:50 +0000 Subject: [PATCH 1/1] better output, read fixes, ctime preserved (so that vi won't complain that your file changed if you save changes and try that again) git-svn-id: svn://svn.rot13.org/fuse_dbi/trunk@8 17f4e80c-d0e0-0310-8903-bfc3ae804c12 --- fuse_dbi.pl | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/fuse_dbi.pl b/fuse_dbi.pl index f08ff92..e4570bf 100755 --- a/fuse_dbi.pl +++ b/fuse_dbi.pl @@ -133,7 +133,7 @@ sub e_getdir { if (! %out) { $out{'no files? bug?'}++; } - print scalar keys %out," files found for '$dirname': ",keys %out,"\n"; + print scalar keys %out," files in dir '$dirname'\n"; return (keys %out),0; } @@ -159,20 +159,20 @@ sub e_read { # (note: 0 means EOF, "0" will give a byte (ascii "0") # to the reading program) my ($file) = filename_fixup(shift); - my ($buf,$off) = @_; + my ($buf_len,$off) = @_; return -ENOENT() unless exists($files{$file}); my $len = length($files{$file}{cont}); - print "read '$file' [$len bytes] offset $off length $buf\n"; + print "read '$file' [$len bytes] offset $off length $buf_len\n"; return -EINVAL() if ($off > $len); return 0 if ($off == $len); - $buf = $len-$off if ($off+$buf > $len); + $buf_len = $buf_len-$off if ($off+$buf_len > $len); - return substr($files{$file}{cont},$off,$buf); + return substr($files{$file}{cont},$off,$buf_len); } sub clear_cont { @@ -190,6 +190,8 @@ sub clear_cont { sub update_db { my $file = shift || die; + $files{$file}{ctime} = time(); + if (!$sth_update->execute($files{$file}{cont},$files{$file}{id})) { print "update problem: ",$sth_update->errstr; clear_cont; @@ -207,23 +209,23 @@ sub update_db { sub e_write { my $file = filename_fixup(shift); - my ($buf,$off) = @_; + my ($buf_len,$off) = @_; return -ENOENT() unless exists($files{$file}); my $len = length($files{$file}{cont}); - print "write '$file' [$len bytes] offset $off length $buf\n"; + print "write '$file' [$len bytes] offset $off length\n"; $files{$file}{cont} = substr($files{$file}{cont},0,$off) . - $buf . - substr($files{$file}{cont},$off+length($buf)); + $buf_len . + substr($files{$file}{cont},$off+length($buf_len)); if (! update_db($file)) { return -ENOSYS(); } else { - return length($buf); + return length($buf_len); } } @@ -242,6 +244,8 @@ sub e_utime { return -ENOENT() unless exists($files{$file}); + print "utime '$file' $atime $mtime\n"; + $files{$file}{time} = $mtime; return 0; } -- 2.20.1