2015-12-07 17:12:47 -05:00
|
|
|
/*
|
2020-03-12 21:57:41 -04:00
|
|
|
* MinIO Cloud Storage, (C) 2018-2020 MinIO, Inc.
|
2015-12-07 17:12:47 -05:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2015-10-17 22:09:43 -04:00
|
|
|
package disk
|
|
|
|
|
2016-01-25 02:03:38 -05:00
|
|
|
// Info stat fs struct is container which holds following values
|
2015-10-17 22:09:43 -04:00
|
|
|
// Total - total size of the volume / disk
|
|
|
|
// Free - free size of the volume / disk
|
2017-08-03 23:07:22 -04:00
|
|
|
// Files - total inodes available
|
|
|
|
// Ffree - free inodes available
|
|
|
|
// FSType - file system type
|
2016-01-25 02:03:38 -05:00
|
|
|
type Info struct {
|
2017-08-03 23:07:22 -04:00
|
|
|
Total uint64
|
|
|
|
Free uint64
|
2020-09-30 01:54:02 -04:00
|
|
|
Used uint64
|
2017-08-03 23:07:22 -04:00
|
|
|
Files uint64
|
|
|
|
Ffree uint64
|
2015-10-17 22:09:43 -04:00
|
|
|
FSType string
|
|
|
|
}
|
2020-12-09 03:27:02 -05:00
|
|
|
|
|
|
|
// SameDisk reports whether di1 and di2 describe the same disk.
|
|
|
|
func SameDisk(di1, di2 Info) bool {
|
|
|
|
if di1.Total != di2.Total {
|
|
|
|
// disk total size different
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if di1.Files != di2.Files {
|
|
|
|
// disk total inodes different
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-12-15 14:39:38 -05:00
|
|
|
// returns true only if Used, Free are same, then its the same disk.
|
|
|
|
// we are deliberately not using free inodes as that is unreliable
|
|
|
|
// due the fact that Ffree can vary even for temporary files
|
|
|
|
return di1.Used == di2.Used && di1.Free == di2.Free
|
2020-12-09 03:27:02 -05:00
|
|
|
}
|