libct/cgroups/fs: use errors.Unwrap

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin 2020-03-31 19:58:06 -07:00
parent d2dfc635ea
commit bd737f1e94
1 changed files with 4 additions and 12 deletions

View File

@ -110,21 +110,13 @@ func isIgnorableError(rootless bool, err error) bool {
if !rootless {
return false
}
err = errors.Cause(err)
// Is it an ordinary EPERM?
if os.IsPermission(errors.Cause(err)) {
if os.IsPermission(err) {
return true
}
// Try to handle other errnos.
var errno error
switch err := errors.Cause(err).(type) {
case *os.PathError:
errno = err.Err
case *os.LinkError:
errno = err.Err
case *os.SyscallError:
errno = err.Err
}
// Handle some specific syscall errors.
errno := errors.Unwrap(err)
return errno == unix.EROFS || errno == unix.EPERM || errno == unix.EACCES
}