aboutsummaryrefslogtreecommitdiff
path: root/filesystem
diff options
context:
space:
mode:
authorJoe Richey joerichey@google.com <joerichey@google.com>2017-07-17 13:16:03 -0700
committerJoe Richey joerichey@google.com <joerichey@google.com>2017-07-17 13:16:03 -0700
commit8136a700fa6c3efb7a469e45d846e9db4ec9b4e2 (patch)
treea3cbd46a5df51726043132e0105449830a63907c /filesystem
parent465e31bd92d70d983f45a186ce29b9ff9cd1fd40 (diff)
filesystem: Distinguish support and setup for fs
This commit splits two pieces of functionality. Detecting if the fscrypt metadata exists is now in CheckSetup() and checking if the filesystem supports encryption is now in CheckSupport().
Diffstat (limited to 'filesystem')
-rw-r--r--filesystem/filesystem.go21
1 files changed, 9 insertions, 12 deletions
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index a85d24a..b5fedf9 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -171,13 +171,15 @@ func (m *Mount) err(err error) error {
return errors.Wrapf(err, "filesystem %s", m.Path)
}
-// CheckSetup returns an error if this filesystem does not support fscrypt or
-// all the fscrypt metadata directories do not exist. Will log any unexpected
-// errors or incorrect permissions.
+// CheckSupport returns an error if this filesystem does not support filesystem
+// encryption.
+func (m *Mount) CheckSupport() error {
+ return m.err(metadata.CheckSupport(m.Path))
+}
+
+// CheckSetup returns an error if all the fscrypt metadata directories do not
+// exist. Will log any unexpected errors or incorrect permissions.
func (m *Mount) CheckSetup() error {
- if err := metadata.CheckSupport(m.Path); err != nil {
- return m.err(err)
- }
// Run all the checks so we will always get all the warnings
baseGood := isDirCheckPerm(m.BaseDir(), basePermissions)
policyGood := isDirCheckPerm(m.PolicyDir(), dirPermissions)
@@ -212,13 +214,8 @@ func (m *Mount) makeDirectories() error {
// the filesystem's feature flags. This operation is atomic, it either succeeds
// or no files in the baseDir are created.
func (m *Mount) Setup() error {
- switch err := m.CheckSetup(); errors.Cause(err) {
- case ErrNotSetup:
- break
- case nil:
+ if m.CheckSetup() == nil {
return m.err(ErrAlreadySetup)
- default:
- return err
}
// We build the directories under a temp Mount and then move into place.
temp, err := m.tempMount()