storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/cmd/disk-cache-check-support_windows.go (about) 1 //go:build windows 2 // +build windows 3 4 /* 5 * MinIO Cloud Storage, (C) 2019-2020 MinIO, Inc. 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20 package cmd 21 22 import ( 23 "errors" 24 "io/ioutil" 25 "os" 26 27 "github.com/djherbis/atime" 28 "golang.org/x/sys/windows/registry" 29 ) 30 31 // Return error if Atime is disabled on the O/S 32 func checkAtimeSupport(dir string) (err error) { 33 file, err := ioutil.TempFile(dir, "prefix") 34 if err != nil { 35 return 36 } 37 defer os.Remove(file.Name()) 38 defer file.Close() 39 finfo1, err := os.Stat(file.Name()) 40 if err != nil { 41 return 42 } 43 atime.Get(finfo1) 44 45 k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SYSTEM\CurrentControlSet\Control\FileSystem`, registry.QUERY_VALUE) 46 if err != nil { 47 return 48 } 49 defer k.Close() 50 51 setting, _, err := k.GetIntegerValue("NtfsDisableLastAccessUpdate") 52 if err != nil { 53 return 54 } 55 56 lowSetting := setting & 0xFFFF 57 if lowSetting != uint64(0x0000) && lowSetting != uint64(0x0002) { 58 return errors.New("Atime not supported") 59 } 60 return 61 }