aboutsummaryrefslogtreecommitdiff
path: root/filesystem
diff options
context:
space:
mode:
Diffstat (limited to 'filesystem')
-rw-r--r--filesystem/filesystem_test.go17
-rw-r--r--filesystem/path.go16
2 files changed, 17 insertions, 16 deletions
diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go
index 50c3920..b85ead5 100644
--- a/filesystem/filesystem_test.go
+++ b/filesystem/filesystem_test.go
@@ -21,6 +21,7 @@ package filesystem
import (
"io/ioutil"
+ "log"
"os"
"path/filepath"
"testing"
@@ -110,6 +111,22 @@ func TestRemoveAllMetadata(t *testing.T) {
}
}
+// loggedLstat runs os.Lstat (doesn't dereference trailing symlink), but it logs
+// the error if lstat returns any error other than nil or IsNotExist.
+func loggedLstat(name string) (os.FileInfo, error) {
+ info, err := os.Lstat(name)
+ if err != nil && !os.IsNotExist(err) {
+ log.Print(err)
+ }
+ return info, err
+}
+
+// isSymlink returns true if the path exists and is that of a symlink.
+func isSymlink(path string) bool {
+ info, err := loggedLstat(path)
+ return err == nil && info.Mode()&os.ModeSymlink != 0
+}
+
// Test that when MOUNTPOINT/.fscrypt is a pre-created symlink, fscrypt will
// create/delete the metadata at the location pointed to by the symlink.
//
diff --git a/filesystem/path.go b/filesystem/path.go
index b65bcb9..5fd3fdf 100644
--- a/filesystem/path.go
+++ b/filesystem/path.go
@@ -56,16 +56,6 @@ func loggedStat(name string) (os.FileInfo, error) {
return info, err
}
-// loggedLstat runs os.Lstat (doesn't dereference trailing symlink), but it logs
-// the error if lstat returns any error other than nil or IsNotExist.
-func loggedLstat(name string) (os.FileInfo, error) {
- info, err := os.Lstat(name)
- if err != nil && !os.IsNotExist(err) {
- log.Print(err)
- }
- return info, err
-}
-
// isDir returns true if the path exists and is that of a directory.
func isDir(path string) bool {
info, err := loggedStat(path)
@@ -78,12 +68,6 @@ func isDevice(path string) bool {
return err == nil && info.Mode()&os.ModeDevice != 0
}
-// isSymlink returns true if the path exists and is that of a symlink.
-func isSymlink(path string) bool {
- info, err := loggedLstat(path)
- return err == nil && info.Mode()&os.ModeSymlink != 0
-}
-
// isDirCheckPerm returns true if the path exists and is a directory. If the
// specified permissions and sticky bit of mode do not match the path, an error
// is logged.