Fix issues around statfs(2) changes with osxfuse 3.

Tested on OS X 10.11.6 (15G1004) with osxfuse 3.5.2.
geesefs-0-30-9
Aaron Jacobs 2016-10-16 09:12:42 +01:00
parent b2c3396382
commit a067b22c1d
2 changed files with 44 additions and 32 deletions

View File

@ -59,7 +59,7 @@ type StatFSOp struct {
// //
// On Linux this can be any value, and will be faithfully returned to the // On Linux this can be any value, and will be faithfully returned to the
// caller of statfs(2) (see the code walk above). On OS X it appears that // caller of statfs(2) (see the code walk above). On OS X it appears that
// only powers of 2 in the range [2^9, 2^17] are preserved, and a value of // only powers of 2 in the range [2^7, 2^20] are preserved, and a value of
// zero is treated as 4096. // zero is treated as 4096.
// //
// This interface does not distinguish between blocks and block fragments. // This interface does not distinguish between blocks and block fragments.
@ -85,7 +85,7 @@ type StatFSOp struct {
// transfer block size". // transfer block size".
// //
// On Linux this can be any value. On OS X it appears that only powers of 2 // On Linux this can be any value. On OS X it appears that only powers of 2
// in the range [2^12, 2^20] are faithfully preserved, and a value of zero is // in the range [2^12, 2^25] are faithfully preserved, and a value of zero is
// treated as 65536. // treated as 65536.
IoSize uint32 IoSize uint32

View File

@ -70,7 +70,7 @@ func (t *StatFSTest) Syscall_ZeroValues() {
ExpectEq(0, stat.Bavail) ExpectEq(0, stat.Bavail)
ExpectEq(0, stat.Files) ExpectEq(0, stat.Files)
ExpectEq(0, stat.Ffree) ExpectEq(0, stat.Ffree)
ExpectEq("osxfusefs", convertName(stat.Fstypename[:])) ExpectEq("osxfuse", convertName(stat.Fstypename[:]))
ExpectEq(t.canonicalDir, convertName(stat.Mntonname[:])) ExpectEq(t.canonicalDir, convertName(stat.Mntonname[:]))
ExpectEq(fsName, convertName(stat.Mntfromname[:])) ExpectEq(fsName, convertName(stat.Mntfromname[:]))
} }
@ -105,7 +105,7 @@ func (t *StatFSTest) Syscall_NonZeroValues() {
ExpectEq(canned.BlocksAvailable, stat.Bavail) ExpectEq(canned.BlocksAvailable, stat.Bavail)
ExpectEq(canned.Inodes, stat.Files) ExpectEq(canned.Inodes, stat.Files)
ExpectEq(canned.InodesFree, stat.Ffree) ExpectEq(canned.InodesFree, stat.Ffree)
ExpectEq("osxfusefs", convertName(stat.Fstypename[:])) ExpectEq("osxfuse", convertName(stat.Fstypename[:]))
ExpectEq(t.canonicalDir, convertName(stat.Mntonname[:])) ExpectEq(t.canonicalDir, convertName(stat.Mntonname[:]))
ExpectEq(fsName, convertName(stat.Mntfromname[:])) ExpectEq(fsName, convertName(stat.Mntfromname[:]))
} }
@ -120,8 +120,8 @@ func (t *StatFSTest) BlockSizes() {
expectedBsize uint32 expectedBsize uint32
}{ }{
0: {0, 4096}, 0: {0, 4096},
1: {1, 512}, 1: {1, 128},
2: {3, 512}, 2: {3, 128},
3: {511, 512}, 3: {511, 512},
4: {512, 512}, 4: {512, 512},
5: {513, 1024}, 5: {513, 1024},
@ -129,16 +129,22 @@ func (t *StatFSTest) BlockSizes() {
7: {1024, 1024}, 7: {1024, 1024},
8: {4095, 4096}, 8: {4095, 4096},
9: {1 << 16, 1 << 16}, 9: {1 << 16, 1 << 16},
10: {1<<17 - 1, 1 << 17}, 10: {1 << 17, 1 << 17},
11: {1 << 17, 1 << 17}, 11: {1 << 18, 1 << 18},
12: {1<<17 + 1, 1 << 17}, 12: {1 << 19, 1 << 19},
13: {1 << 18, 1 << 17},
14: {1 << 20, 1 << 17}, 13: {1<<20 - 1, 1 << 20},
15: {math.MaxInt32 - 1, 1 << 17}, 14: {1 << 20, 1 << 20},
16: {math.MaxInt32, 1 << 17}, 15: {1<<20 + 1, 1 << 20},
17: {math.MaxInt32 + 1, 512},
18: {math.MaxInt32 + 1<<15, 1 << 15}, 16: {1 << 21, 1 << 20},
19: {math.MaxUint32, 1 << 17}, 17: {1 << 22, 1 << 20},
18: {math.MaxInt32 - 1, 1 << 20},
19: {math.MaxInt32, 1 << 20},
20: {math.MaxInt32 + 1, 128},
21: {math.MaxInt32 + 1<<15, 1 << 15},
22: {math.MaxUint32, 1 << 20},
} }
for i, tc := range testCases { for i, tc := range testCases {
@ -170,23 +176,29 @@ func (t *StatFSTest) IoSizes() {
fsIoSize uint32 fsIoSize uint32
expectedIosize uint32 expectedIosize uint32
}{ }{
0: {0, 65536}, 0: {0, 65536},
1: {1, 4096}, 1: {1, 4096},
2: {3, 4096}, 2: {3, 4096},
3: {4095, 4096}, 3: {4095, 4096},
4: {4096, 4096}, 4: {4096, 4096},
5: {4097, 8192}, 5: {4097, 8192},
6: {8191, 8192}, 6: {8191, 8192},
7: {8192, 8192}, 7: {8192, 8192},
8: {8193, 16384}, 8: {8193, 16384},
9: {1<<20 - 1, 1 << 20},
9: {1 << 18, 1 << 18},
10: {1 << 20, 1 << 20}, 10: {1 << 20, 1 << 20},
11: {1<<20 + 1, 1 << 20}, 11: {1 << 23, 1 << 23},
12: {math.MaxInt32 - 1, 1 << 20},
13: {math.MaxInt32, 1 << 20}, 12: {1<<25 - 1, 1 << 25},
14: {math.MaxInt32 + 1, 4096}, 13: {1 << 25, 1 << 25},
15: {math.MaxInt32 + 1<<15, 1 << 15}, 14: {1<<25 + 1, 1 << 25},
16: {math.MaxUint32, 1 << 20},
15: {math.MaxInt32 - 1, 1 << 25},
16: {math.MaxInt32, 1 << 25},
17: {math.MaxInt32 + 1, 4096},
18: {math.MaxInt32 + 1<<15, 1 << 15},
19: {math.MaxUint32, 1 << 25},
} }
for i, tc := range testCases { for i, tc := range testCases {