Commit 6565b52b authored by Aaron Jacobs's avatar Aaron Jacobs

Fixed the documentation to match reality on darwin.

parent 33a476ca
...@@ -51,9 +51,16 @@ type StatFSOp struct { ...@@ -51,9 +51,16 @@ type StatFSOp struct {
// of f_frsize. On OS X this is surfaced as statfs::f_bsize, which plays the // of f_frsize. On OS X this is surfaced as statfs::f_bsize, which plays the
// same roll. // same roll.
// //
// It appears as though the original intent of statvfs::f_frsize in the posix
// standard was to support a smaller addressable unit than statvfs::f_bsize
// (cf. The Linux Programming Interface by Michael Kerrisk,
// https://goo.gl/5LZMxQ). Therefore users should probably arrange for this
// to be no larger than IoSize.
//
// 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 it must // caller of statfs(2) (see the code walk above). On OS X it appears that
// be a power of 2 in the range [2^9, 2^17]. // only powers of 2 in the range [2^9, 2^17] are preserved, and a value of
// 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.
BlockSize uint32 BlockSize uint32
...@@ -77,8 +84,9 @@ type StatFSOp struct { ...@@ -77,8 +84,9 @@ type StatFSOp struct {
// statfs::f_iosize. Both are documented in `man 2 statfs` as "optimal // statfs::f_iosize. Both are documented in `man 2 statfs` as "optimal
// transfer block size". // transfer block size".
// //
// On Linux this can be any value. On OS X it appears it must be a power of 2 // On Linux this can be any value. On OS X it appears that only powers of 2
// in the range [2^9, 2^20]. // in the range [2^12, 2^20] are faithfully preserved, and a value of zero is
// treated as 65536.
IoSize uint32 IoSize uint32
// The total number of inodes in the file system, and how many remain free. // The total number of inodes in the file system, and how many remain free.
......
...@@ -170,27 +170,23 @@ func (t *StatFSTest) IoSizes() { ...@@ -170,27 +170,23 @@ func (t *StatFSTest) IoSizes() {
fsIoSize uint32 fsIoSize uint32
expectedIosize uint32 expectedIosize uint32
}{ }{
0: {0, 4096}, 0: {0, 65536},
1: {1, 512}, 1: {1, 4096},
2: {3, 512}, 2: {3, 4096},
3: {511, 512}, 3: {4095, 4096},
4: {512, 512}, 4: {4096, 4096},
5: {513, 1024}, 5: {4097, 8192},
6: {1023, 1024}, 6: {8191, 8192},
7: {1024, 1024}, 7: {8192, 8192},
8: {4095, 4096}, 8: {8193, 16384},
9: {1 << 16, 1 << 16}, 9: {1<<20 - 1, 1 << 20},
10: {1<<17 - 1, 1 << 17}, 10: {1 << 20, 1 << 20},
11: {1 << 17, 1 << 17}, 11: {1<<20 + 1, 1 << 20},
12: {1<<17 + 1, 1 << 18}, 12: {math.MaxInt32 - 1, 1 << 20},
13: {1<<20 - 1, 1 << 20}, 13: {math.MaxInt32, 1 << 20},
14: {1 << 20, 1 << 20}, 14: {math.MaxInt32 + 1, 4096},
15: {1<<20 + 1, 1 << 20}, 15: {math.MaxInt32 + 1<<15, 1 << 15},
16: {math.MaxInt32 - 1, 1 << 20}, 16: {math.MaxUint32, 1 << 20},
17: {math.MaxInt32, 1 << 20},
18: {math.MaxInt32 + 1, 512},
19: {math.MaxInt32 + 1<<15, 1 << 15},
20: {math.MaxUint32, 1 << 20},
} }
for i, tc := range testCases { for i, tc := range testCases {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment