aboutsummaryrefslogtreecommitdiff
path: root/filesystem/path.go
diff options
context:
space:
mode:
authorJoseph Richey <joerichey@google.com>2020-03-23 14:24:23 -0700
committerGitHub <noreply@github.com>2020-03-23 14:24:23 -0700
commitab531eea551598170e4dd973fa5955f01b5c0318 (patch)
treead01ed9d6ffa3d9715c40ff14041f95978107ba7 /filesystem/path.go
parentb43cb6970da16fea7aa2c073a83891909a2833b1 (diff)
parent02ec13d8d96fc16282998f8355074dad53271591 (diff)
Merge pull request #205 from ebiggers/autoselect-v2
Automatically enable policy_version 2 when kernel support is detected
Diffstat (limited to 'filesystem/path.go')
-rw-r--r--filesystem/path.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/filesystem/path.go b/filesystem/path.go
index b9b403d..274dc0a 100644
--- a/filesystem/path.go
+++ b/filesystem/path.go
@@ -78,6 +78,12 @@ func isRegularFile(path string) bool {
return err == nil && info.Mode().IsRegular()
}
+// HaveReadAccessTo returns true if the process has read access to a file or
+// directory, without actually opening it.
+func HaveReadAccessTo(path string) bool {
+ return unix.Access(path, unix.R_OK) == nil
+}
+
// DeviceNumber represents a combined major:minor device number.
type DeviceNumber uint64