Skip to content

Commit

Permalink
Merge pull request #277 from jbenet/fuse-fix
Browse files Browse the repository at this point in the history
Fix buffer size bug in fuse mounts
  • Loading branch information
jbenet committed Nov 7, 2014
2 parents 3155fa2 + 387d0a9 commit 350b833
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
5 changes: 0 additions & 5 deletions fuse/ipns/ipns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"crypto/rand"
"io/ioutil"
"os"
"runtime"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -300,10 +299,6 @@ func TestFastRepublish(t *testing.T) {

// Test writing a medium sized file one byte at a time
func TestMultiWrite(t *testing.T) {
if runtime.GOOS == "darwin" {
link := "https://github.com/jbenet/go-ipfs/issues/147"
t.Skipf("Skipping as is broken in OSX. See %s", link)
}

_, mnt := setupIpnsTest(t, nil)
defer mnt.Close()
Expand Down
3 changes: 3 additions & 0 deletions fuse/ipns/ipns_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ func (s *Node) Attr() fuse.Attr {
log.Errorf("Error getting size of file: %s", err)
size = 0
}
if size == 0 {
size = s.dagMod.Size()
}
return fuse.Attr{
Mode: 0666,
Size: size,
Expand Down
11 changes: 9 additions & 2 deletions fuse/readonly/readonly_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,20 @@ func (s *Node) Attr() fuse.Attr {
switch s.cached.GetType() {
case ftpb.Data_Directory:
return fuse.Attr{Mode: os.ModeDir | 0555}
case ftpb.Data_File, ftpb.Data_Raw:
size, _ := s.Nd.Size()
case ftpb.Data_File:
size := s.cached.GetFilesize()
return fuse.Attr{
Mode: 0444,
Size: uint64(size),
Blocks: uint64(len(s.Nd.Links)),
}
case ftpb.Data_Raw:
return fuse.Attr{
Mode: 0444,
Size: uint64(len(s.cached.GetData())),
Blocks: uint64(len(s.Nd.Links)),
}

default:
log.Error("Invalid data type.")
return fuse.Attr{}
Expand Down
6 changes: 3 additions & 3 deletions test/t0040-add-and-cat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test_expect_success "generate 100MB file using go-random" '

test_expect_success "sha1 of the file looks ok" '
echo "54dc0dbbc353b2ffb745285793f89af0c9d98449 mountdir/bigfile" >sha1_expected &&
sha1sum mountdir/bigfile >sha1_actual &&
shasum mountdir/bigfile >sha1_actual &&
test_cmp sha1_expected sha1_actual
'

Expand All @@ -63,7 +63,7 @@ test_expect_success "ipfs add bigfile output looks good" '
'

test_expect_success "ipfs cat succeeds" '
ipfs cat $HASH | sha1sum >sha1_actual
ipfs cat $HASH | shasum >sha1_actual
'

test_expect_success "ipfs cat output looks good" '
Expand All @@ -72,7 +72,7 @@ test_expect_success "ipfs cat output looks good" '
'

test_expect_success "cat ipfs/bigfile succeeds" '
cat ipfs/$HASH | sha1sum >sha1_actual
cat ipfs/$HASH | shasum >sha1_actual
'

test_expect_success "cat ipfs/bigfile looks good" '
Expand Down
7 changes: 7 additions & 0 deletions unixfs/io/dagmodifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ func (dm *DagModifier) WriteAt(b []byte, offset uint64) (int, error) {
return origlen, nil
}

func (dm *DagModifier) Size() uint64 {
if dm == nil {
return 0
}
return dm.pbdata.GetFilesize()
}

// splitBytes uses a splitterFunc to turn a large array of bytes
// into many smaller arrays of bytes
func splitBytes(b []byte, spl chunk.BlockSplitter) [][]byte {
Expand Down

0 comments on commit 350b833

Please sign in to comment.