diff options
| author | Joseph Richey <joerichey@google.com> | 2017-07-17 13:28:16 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-17 13:28:16 -0700 |
| commit | 4d6827a49491e941ea535178789b29e4c6b6d51f (patch) | |
| tree | 00f10a4333fb4f5b2226be8372e83f5ea45df44c /filesystem | |
| parent | 465e31bd92d70d983f45a186ce29b9ff9cd1fd40 (diff) | |
| parent | 5d727874440e4e451b45baba4ad7e277b9399730 (diff) | |
Merge pull request #19 from google/fix
Separate encryption support from metadata support
Diffstat (limited to 'filesystem')
| -rw-r--r-- | filesystem/filesystem.go | 21 |
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() |