From fbc161a77962fe64e3caad80efb535d28d8c1f74 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sat, 9 May 2020 14:52:07 -0700 Subject: metadata: improve errors ErrBadOwners: Rename to ErrDirectoryNotOwned for clarity, move it from cmd/fscrypt/ to metadata/ where it better belongs, and improve the message. ErrEncrypted: Rename to ErrAlreadyEncrypted for clarity, and include the path. ErrNotEncrypted: Include the path. ErrBadEncryptionOptions: Include the path and bad options. ErrEncryptionNotSupported: ErrEncryptionNotEnabled: Don't wrap with "get encryption policy %s", in preparation for wrapping these with filesystem-level context instead. Also avoid mixing together the error handling for the "get policy" and "set policy" ioctls. Make it very clear how we're handling the errors from each ioctl. --- cli-tests/t_status.out | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'cli-tests/t_status.out') diff --git a/cli-tests/t_status.out b/cli-tests/t_status.out index b036712..08ce3b2 100644 --- a/cli-tests/t_status.out +++ b/cli-tests/t_status.out @@ -10,10 +10,10 @@ ext4 filesystem "MNT" has 0 protectors and 0 policies # Get status of unencrypted directory on setup mountpoint -[ERROR] fscrypt status: get encryption policy MNT/dir: file - or directory not encrypted -[ERROR] fscrypt status: get encryption policy MNT/dir: file - or directory not encrypted +[ERROR] fscrypt status: file or directory "MNT/dir" is not + encrypted +[ERROR] fscrypt status: file or directory "MNT/dir" is not + encrypted # Remove fscrypt metadata from MNT -- cgit v1.2.3 From 66fb4c557644ba2c37951a7568c06c47a6c718a7 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sat, 9 May 2020 14:52:07 -0700 Subject: filesystem: improve errors Introduce filesystem.ErrEncryptionNotEnabled and filesystem.ErrEncryptionNotSupported which include the Mount as context, and translate the corresponding metadata/ errors into them. Then make these errors show much better suggestions. Also replace lots of other filesystem/ errors with either custom types or with unnamed one-off errors that include more context. Fix backwards wrapping in lots of cases. Finally, don't include the mountpoint in places where it's not useful, like OS-level errors that already include the path. --- cli-tests/t_status.out | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'cli-tests/t_status.out') diff --git a/cli-tests/t_status.out b/cli-tests/t_status.out index 08ce3b2..0d478b5 100644 --- a/cli-tests/t_status.out +++ b/cli-tests/t_status.out @@ -24,21 +24,25 @@ ext4 supported No ext4 supported No # Get status of not-setup mountpoint -[ERROR] fscrypt status: filesystem MNT: not setup for use +[ERROR] fscrypt status: filesystem MNT is not setup for use with fscrypt -Run "fscrypt setup MOUNTPOINT" to use fscrypt on this filesystem. -[ERROR] fscrypt status: filesystem MNT: not setup for use +Run "sudo fscrypt setup MNT" to use fscrypt on this +filesystem. +[ERROR] fscrypt status: filesystem MNT is not setup for use with fscrypt -Run "fscrypt setup MOUNTPOINT" to use fscrypt on this filesystem. +Run "sudo fscrypt setup MNT" to use fscrypt on this +filesystem. # Get status of unencrypted directory on not-setup mountpoint -[ERROR] fscrypt status: filesystem MNT: not setup for use +[ERROR] fscrypt status: filesystem MNT is not setup for use with fscrypt -Run "fscrypt setup MOUNTPOINT" to use fscrypt on this filesystem. -[ERROR] fscrypt status: filesystem MNT: not setup for use +Run "sudo fscrypt setup MNT" to use fscrypt on this +filesystem. +[ERROR] fscrypt status: filesystem MNT is not setup for use with fscrypt -Run "fscrypt setup MOUNTPOINT" to use fscrypt on this filesystem. +Run "sudo fscrypt setup MNT" to use fscrypt on this +filesystem. -- cgit v1.2.3