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 { if !rootless {
return false return false
} }
err = errors.Cause(err)
// Is it an ordinary EPERM? // Is it an ordinary EPERM?
if os.IsPermission(errors.Cause(err)) { if os.IsPermission(err) {
return true return true
} }
// Handle some specific syscall errors.
// Try to handle other errnos. errno := errors.Unwrap(err)
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
}
return errno == unix.EROFS || errno == unix.EPERM || errno == unix.EACCES return errno == unix.EROFS || errno == unix.EPERM || errno == unix.EACCES
} }