minio: add NetBSD support (from upstream pull req)

This commit is contained in:
Tobias Nygren 2020-08-14 12:03:53 +02:00
parent a6fb8c4cba
commit f4a79c7e5e
3 changed files with 80 additions and 0 deletions

View File

@ -2293,3 +2293,5 @@ RMD160 (sigs.k8s.io_yaml_@v_v1.1.0.mod) = b062175dc1ba92e8c5a80661fa0e953f8b16ce
SHA512 (sigs.k8s.io_yaml_@v_v1.1.0.mod) = 78f6402daccb04510f4ef35ee457ee13e4f447fba8e6aa33b4d32aa666e925861bf3b3f22c5ba9573871ec7e830f99e4caae0969724a54eadf40e6a7ed7931a0
Size (sigs.k8s.io_yaml_@v_v1.1.0.mod) = 24 bytes
SHA1 (patch-go.mod) = b3622e712e2903ef1d50052b77aa489529dacac7
SHA1 (patch-pkg_disk_stat__fallback.go) = e11b4828f0cf31c349cd471f41b900dece37b125
SHA1 (patch-pkg_disk_stat__netbsd.go) = cd53f62964bb9db08bb1dc174820f17fc6637d08

View File

@ -0,0 +1,31 @@
$NetBSD$
https://github.com/minio/minio/pull/10257
--- pkg/disk/stat_fallback.go.orig 2020-07-27 16:03:38.000000000 +0000
+++ pkg/disk/stat_fallback.go
@@ -1,24 +0,0 @@
-// +build netbsd
-
-/*
- * MinIO Cloud Storage, (C) 2017 MinIO, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package disk
-
-// GetInfo returns total and free bytes available in a directory, e.g. `/`.
-func GetInfo(path string) (info Info, err error) {
- return Info{}, nil
-}

View File

@ -0,0 +1,47 @@
$NetBSD$
https://github.com/minio/minio/pull/10257
--- pkg/disk/stat_netbsd.go.orig 2020-08-14 09:58:55.219409957 +0000
+++ pkg/disk/stat_netbsd.go
@@ -0,0 +1,40 @@
+// +build netbsd
+
+/*
+ * MinIO Cloud Storage, (C) 2020 MinIO, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package disk
+
+import (
+ "golang.org/x/sys/unix"
+)
+
+// GetInfo returns total and free bytes available in a directory, e.g. `/`.
+func GetInfo(path string) (info Info, err error) {
+ s := unix.Statvfs_t{}
+ if err = unix.Statvfs(path, &s); err != nil {
+ return Info{}, err
+ }
+ reservedBlocks := uint64(s.Bfree) - uint64(s.Bavail)
+ info = Info{
+ Total: uint64(s.Frsize) * (uint64(s.Blocks) - reservedBlocks),
+ Free: uint64(s.Frsize) * uint64(s.Bavail),
+ Files: uint64(s.Files),
+ Ffree: uint64(s.Ffree),
+ FSType: string(s.Fstypename[:]),
+ }
+ return info, nil
+}