Skip to content

Commit 8d59f35

Browse files
harshavardhanadeekoder
authored andcommitted
Add GetInfo() support for solaris (minio#5174)
Fixes minio#5173
1 parent f460ece commit 8d59f35

File tree

184 files changed

+43325
-28014
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+43325
-28014
lines changed

pkg/disk/stat_bsd.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ func GetInfo(path string) (info Info, err error) {
2929
if err != nil {
3030
return Info{}, err
3131
}
32-
fsReservedBlocks := uint64(s.Bfree) - uint64(s.Bavail)
32+
reservedBlocks := uint64(s.Bfree) - uint64(s.Bavail)
3333
info = Info{
34-
Total: uint64(s.Bsize) * (uint64(s.Blocks) - fsReservedBlocks),
34+
Total: uint64(s.Bsize) * (uint64(s.Blocks) - reservedBlocks),
3535
Free: uint64(s.Bsize) * uint64(s.Bavail),
3636
Files: uint64(s.Files),
3737
Ffree: uint64(s.Ffree),
38-
FSType: getFSType(s.Fstypename),
38+
FSType: getFSType(s.Fstypename[:]),
3939
}
4040
return info, nil
4141
}

pkg/disk/stat_fallback.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build netbsd solaris
1+
// +build netbsd
22

33
/*
44
* Minio Cloud Storage, (C) 2017 Minio, Inc.

pkg/disk/stat_linux.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ func GetInfo(path string) (info Info, err error) {
2929
if err != nil {
3030
return Info{}, err
3131
}
32-
fsReservedBlocks := uint64(s.Bfree) - uint64(s.Bavail)
32+
reservedBlocks := uint64(s.Bfree) - uint64(s.Bavail)
3333
info = Info{
34-
Total: uint64(s.Bsize) * (uint64(s.Blocks) - fsReservedBlocks),
35-
Free: uint64(s.Bsize) * uint64(s.Bavail),
34+
Total: uint64(s.Frsize) * (uint64(s.Blocks) - reservedBlocks),
35+
Free: uint64(s.Frsize) * uint64(s.Bavail),
3636
Files: uint64(s.Files),
3737
Ffree: uint64(s.Ffree),
3838
FSType: getFSType(int64(s.Type)),

pkg/disk/stat_openbsd.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ func GetInfo(path string) (info Info, err error) {
2929
if err != nil {
3030
return Info{}, err
3131
}
32-
fsReservedBlocks := uint64(s.F_bfree) - uint64(s.F_bavail)
32+
reservedBlocks := uint64(s.F_bfree) - uint64(s.F_bavail)
3333
info = Info{
34-
Total: uint64(s.F_bsize) * (uint64(s.F_blocks) - fsReservedBlocks),
34+
Total: uint64(s.F_bsize) * (uint64(s.F_blocks) - reservedBlocks),
3535
Free: uint64(s.F_bsize) * uint64(s.F_bavail),
3636
Files: uint64(s.F_files),
3737
Ffree: uint64(s.F_ffree),
38-
FSType: getFSType(s.F_fstypename),
38+
FSType: getFSType(s.F_fstypename[:]),
3939
}
4040
return info, nil
4141
}

pkg/disk/stat_solaris.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// +build solaris
2+
3+
/*
4+
* Minio Cloud Storage, (C) 2017 Minio, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package disk
20+
21+
import (
22+
"golang.org/x/sys/unix"
23+
)
24+
25+
// GetInfo returns total and free bytes available in a directory, e.g. `/`.
26+
func GetInfo(path string) (info Info, err error) {
27+
s := unix.Statvfs_t{}
28+
if err = unix.Statvfs(path, &s); err != nil {
29+
return Info{}, err
30+
}
31+
reservedBlocks := uint64(s.Bfree) - uint64(s.Bavail)
32+
info = Info{
33+
Total: uint64(s.Frsize) * (uint64(s.Blocks) - reservedBlocks),
34+
Free: uint64(s.Frsize) * uint64(s.Bavail),
35+
Files: uint64(s.Files),
36+
Ffree: uint64(s.Ffree),
37+
FSType: getFSType(s.Fstr[:]),
38+
}
39+
return info, nil
40+
}

pkg/disk/type_bsd.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build darwin freebsd dragonfly openbsd
1+
// +build darwin freebsd dragonfly openbsd solaris
22

33
/*
44
* Minio Cloud Storage, (C) 2017 Minio, Inc.
@@ -19,9 +19,9 @@
1919
package disk
2020

2121
// getFSType returns the filesystem type of the underlying mounted filesystem
22-
func getFSType(fstype [16]int8) string {
23-
b := make([]byte, len(fstype[:]))
24-
for i, v := range fstype[:] {
22+
func getFSType(fstype []int8) string {
23+
b := make([]byte, len(fstype))
24+
for i, v := range fstype {
2525
b[i] = byte(v)
2626
}
2727
return string(b)

vendor/golang.org/x/sys/unix/asm_openbsd_arm.s

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/sys/unix/asm_solaris_amd64.s

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/sys/unix/cap_freebsd.go

Lines changed: 195 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/golang.org/x/sys/unix/dev_darwin.go

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)