Add comment to source code

Signed-off-by: 陈德 <chende@caicloud.io>
This commit is contained in:
陈德 2018-08-27 15:18:19 +08:00
parent ecadd564b1
commit 0a62485365

View File

@ -57,6 +57,11 @@ func (d *driver) Cap() (*storage.Capacity, error) {
return nil, err return nil, err
} }
// When container is run in MacOS, `bsize` obtained by `statfs` syscall is not the fundamental block size,
// but the `iosize` (optimal transfer block size) instead, it's usually 1024 times larger than the `bsize`.
// for example `4096 * 1024`. To get the correct block size, we should use `frsize`. But `frsize` isn't
// guaranteed to be supported everywhere, so we need to check whether it's supported before use it.
// For more details, please refer to: https://github.com/docker/for-mac/issues/2136
bSize := uint64(stat.Bsize) bSize := uint64(stat.Bsize)
field := reflect.ValueOf(&stat).Elem().FieldByName("Frsize") field := reflect.ValueOf(&stat).Elem().FieldByName("Frsize")
if field.IsValid() { if field.IsValid() {