2017-02-26 19:25:23 +01:00
|
|
|
// Package exitcodes contains all well-defined exit codes that gocryptfs
|
|
|
|
// can return.
|
|
|
|
package exitcodes
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2017-05-14 13:51:13 +02:00
|
|
|
// Usage - usage error like wrong cli syntax, wrong number of parameters.
|
2017-05-07 22:15:01 +02:00
|
|
|
Usage = 1
|
|
|
|
// 2 is reserved because it is used by Go panic
|
2017-05-14 13:51:13 +02:00
|
|
|
// 3 is reserved because it was used by earlier gocryptfs version as a generic
|
|
|
|
// "mount" error.
|
2017-05-07 22:15:01 +02:00
|
|
|
|
2017-05-14 14:02:08 +02:00
|
|
|
// CipherDir means that the CIPHERDIR does not exist, is not empty, or is not
|
|
|
|
// a directory.
|
2017-05-07 22:15:01 +02:00
|
|
|
CipherDir = 6
|
|
|
|
// Init is an error on filesystem init
|
|
|
|
Init = 7
|
|
|
|
// LoadConf is an error while loading gocryptfs.conf
|
|
|
|
LoadConf = 8
|
|
|
|
// ReadPassword means something went wrong reading the password
|
|
|
|
ReadPassword = 9
|
|
|
|
// MountPoint error means that the mountpoint is invalid (not empty etc).
|
|
|
|
MountPoint = 10
|
2017-02-26 19:25:23 +01:00
|
|
|
// Other error - please inspect the message
|
|
|
|
Other = 11
|
2017-05-14 13:51:13 +02:00
|
|
|
// PasswordIncorrect - the password was incorrect when mounting or when
|
|
|
|
// changing the password.
|
2017-02-26 19:25:23 +01:00
|
|
|
PasswordIncorrect = 12
|
2017-05-07 22:15:01 +02:00
|
|
|
// ScryptParams means that scrypt was called with invalid parameters
|
|
|
|
ScryptParams = 13
|
|
|
|
// MasterKey means that something went wrong when parsing the "-masterkey"
|
|
|
|
// command line option
|
|
|
|
MasterKey = 14
|
|
|
|
// SigInt means we got SIGINT
|
|
|
|
SigInt = 15
|
2017-05-14 13:51:13 +02:00
|
|
|
// PanicLogNotEmpty means the panic log was not empty when we were unmounted
|
|
|
|
PanicLogNotEmpty = 16
|
2017-05-07 22:15:01 +02:00
|
|
|
// ForkChild means forking the worker child failed
|
|
|
|
ForkChild = 17
|
|
|
|
// OpenSSL means you tried to enable OpenSSL, but we were compiled without it.
|
|
|
|
OpenSSL = 18
|
2017-05-14 13:51:13 +02:00
|
|
|
// FuseNewServer - this exit code means that the call to fuse.NewServer failed.
|
|
|
|
// This usually means that there was a problem executing fusermount, or
|
|
|
|
// fusermount could not attach the mountpoint to the kernel.
|
|
|
|
FuseNewServer = 19
|
|
|
|
// CtlSock - the control socket file could not be created.
|
|
|
|
CtlSock = 20
|
2017-05-23 18:01:21 +02:00
|
|
|
// Downgraded to a warning in gocryptfs v1.4
|
|
|
|
//PanicLogCreate = 21
|
|
|
|
|
2017-05-14 14:02:08 +02:00
|
|
|
// PasswordEmpty - we received an empty password
|
|
|
|
PasswordEmpty = 22
|
2017-05-14 14:30:50 +02:00
|
|
|
// OpenConf - the was an error opening the gocryptfs.conf file for reading
|
|
|
|
OpenConf = 23
|
|
|
|
// WriteConf - could not write the gocryptfs.conf
|
|
|
|
WriteConf = 24
|
2018-12-27 12:03:00 +01:00
|
|
|
// Profiler - error occurred when trying to write cpu or memory profile or
|
2017-06-05 22:45:11 +02:00
|
|
|
// execution trace
|
|
|
|
Profiler = 25
|
2018-04-01 21:23:32 +02:00
|
|
|
// FsckErrors - the filesystem check found errors
|
|
|
|
FsckErrors = 26
|
2018-04-02 18:43:50 +02:00
|
|
|
// DeprecatedFS - this filesystem is deprecated
|
|
|
|
DeprecatedFS = 27
|
2019-12-27 22:27:57 +01:00
|
|
|
// skip 28
|
2018-12-27 12:03:00 +01:00
|
|
|
// ExcludeError - an error occurred while processing "-exclude"
|
2018-08-11 23:26:49 +02:00
|
|
|
ExcludeError = 29
|
2019-01-05 14:12:00 +01:00
|
|
|
// DevNull means that /dev/null could not be opened
|
|
|
|
DevNull = 30
|
2017-02-26 19:25:23 +01:00
|
|
|
)
|
|
|
|
|
2017-05-07 12:22:15 +02:00
|
|
|
// Err wraps an error with an associated numeric exit code
|
2017-02-26 19:25:23 +01:00
|
|
|
type Err struct {
|
|
|
|
error
|
|
|
|
code int
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewErr returns an error containing "msg" and the exit code "code".
|
|
|
|
func NewErr(msg string, code int) Err {
|
|
|
|
return Err{
|
|
|
|
error: fmt.Errorf(msg),
|
|
|
|
code: code,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-29 14:50:58 +02:00
|
|
|
// Exit extracts the numeric exit code from "err" (if available) and exits the
|
|
|
|
// application.
|
2017-02-26 19:25:23 +01:00
|
|
|
func Exit(err error) {
|
|
|
|
err2, ok := err.(Err)
|
|
|
|
if !ok {
|
|
|
|
os.Exit(Other)
|
|
|
|
}
|
|
|
|
os.Exit(err2.code)
|
|
|
|
}
|