/[fuse-comp]/fuse-comp.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 /fuse-comp.pl

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

revision 13 by dpavlin, Mon Jul 9 11:12:48 2007 UTC revision 17 by dpavlin, Mon Jul 9 13:45:53 2007 UTC
# Line 146  sub x_open { Line 146  sub x_open {
146                  rdwr => $mode && O_RDWR,                  rdwr => $mode && O_RDWR,
147                  append => $mode && O_APPEND,                  append => $mode && O_APPEND,
148                  create => $mode && O_CREAT,                  create => $mode && O_CREAT,
149                    trunc => $mode && O_TRUNC,
150          };          };
151          warn "# open( $file, $mode ) pending: ", $pending->{$file}->{open}, " mode: ", dump( $mode_desc ),"\n";          my $path = fixup($file);
152            warn "# open( $file, $mode ) pending: ", $pending->{$file}->{open}, " mode $mode: ", dump( $mode_desc )," $path [", -s $path, "]\n";
153          my $fh;          my $fh;
154    
         my $path = fixup($file);  
155          my $tmp = $mount->{tmp} . '/' . $file;          my $tmp = $mount->{tmp} . '/' . $file;
156          if ( -e $tmp ) {          if ( -e $tmp ) {
157                  $path = $tmp;                  $path = $tmp;
# Line 161  sub x_open { Line 162  sub x_open {
162                  file_copy( '<:gzip', $path, '>', $tmp );                  file_copy( '<:gzip', $path, '>', $tmp );
163                  $path = $tmp;                  $path = $tmp;
164          }          }
165          warn ">>> open abs path: $path [", -s $path, "]\n";          warn ">>> open abs path: $path [", -e $path ? -s $path : 'new' , "]\n";
166          return -$! unless sysopen($fh , $path, $mode);          return -$! unless sysopen($fh , $path, $mode);
167            warn ">>> after open [",-s $path, "]\n";
168          close($fh);          close($fh);
169    
170          $pending->{$file}->{path} = $path;          $pending->{$file}->{path} = $path;
# Line 202  sub x_write { Line 204  sub x_write {
204          return -ENOSYS() unless open($fh,'+<',$pending->{$file}->{path});          return -ENOSYS() unless open($fh,'+<',$pending->{$file}->{path});
205          if($rv = seek( $fh ,$off,SEEK_SET)) {          if($rv = seek( $fh ,$off,SEEK_SET)) {
206                  $rv = print( $fh $buf );                  $rv = print( $fh $buf );
207                  warn "## ", $pending->{$file}->{path}, " $off ",length( $buf ), "\n" if $debug;                  warn "## write ", $pending->{$file}->{path}, " $off ",length( $buf ), "\n" if $debug;
208          }          }
209          $rv = -ENOSYS() unless $rv;          $rv = -ENOSYS() unless $rv;
210          close($fh);          close($fh);
# Line 243  sub x_chmod { Line 245  sub x_chmod {
245          return $err;          return $err;
246  }  }
247    
248  sub x_truncate { return truncate(fixup(shift),shift) ? 0 : -$! ; }  sub x_truncate {
249            my ( $file,$size ) = @_;
250            my $path = fixup($file);
251            my $rv = truncate( $path, $size ) ? 0 : -$! ;
252            if ( $path =~ m/\.gz$/ ) {
253                    my $no_gz = $path;
254                    $no_gz =~ s/\.gz$//;
255                    rename $path, $no_gz || confess "can't rename $path -> $no_gz: $!";
256            }
257            warn "## truncate( $file $size ) $path [", -s $path, "]\n";
258            $pending->{$file}->{write}++;
259            return $rv;
260    }
261  sub x_utime { return utime($_[1],$_[2],fixup($_[0])) ? 0:-$!; }  sub x_utime { return utime($_[1],$_[2],fixup($_[0])) ? 0:-$!; }
262    
263  sub x_mkdir { my ($name, $perm) = @_; return 0 if mkdir(fixup($name),$perm); return -$!; }  sub x_mkdir { my ($name, $perm) = @_; return 0 if mkdir(fixup($name),$perm); return -$!; }
# Line 290  sub x_release { Line 304  sub x_release {
304                          file_copy( '<', $path, '>:gzip', $dest . '.gz' );                          file_copy( '<', $path, '>:gzip', $dest . '.gz' );
305    
306                          # FIXME add timeout to remove uncompressed version?                          # FIXME add timeout to remove uncompressed version?
307                            # FIXME leave uncompressed file if smaller than compressed
308                          unlink $path || warn "can't remove $path: $!";                          unlink $path || warn "can't remove $path: $!";
309                  }                  }
310          } else {          } else {

Legend:
Removed from v.13  
changed lines
  Added in v.17

  ViewVC Help
Powered by ViewVC 1.1.26