From 5910646c6c6fbb5e48801342677bff9c4609a2ea Mon Sep 17 00:00:00 2001 From: Nazime Hande Harputluoglu Date: Thu, 1 Oct 2020 21:53:57 +0000 Subject: sys/linux: descriptions for USB/IP --- pkg/osutil/osutil.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'pkg/osutil') diff --git a/pkg/osutil/osutil.go b/pkg/osutil/osutil.go index b50b6e45b..5a7a342b1 100644 --- a/pkg/osutil/osutil.go +++ b/pkg/osutil/osutil.go @@ -127,6 +127,16 @@ func IsAccessible(name string) error { return nil } +// IsWritable checks if the file can be written. +func IsWritable(name string) error { + f, err := os.OpenFile(name, os.O_WRONLY, DefaultFilePerm) + if err != nil { + return fmt.Errorf("%v can't be written (%v)", name, err) + } + f.Close() + return nil +} + // FilesExist returns true if all files exist in dir. // Files are assumed to be relative names in slash notation. func FilesExist(dir string, files map[string]bool) bool { -- cgit mrf-deployment