summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--contrib/pyzfs/libzfs_core/_constants.py13
-rw-r--r--contrib/pyzfs/libzfs_core/_error_translation.py9
-rw-r--r--contrib/pyzfs/libzfs_core/exceptions.py9
3 files changed, 25 insertions, 6 deletions
diff --git a/contrib/pyzfs/libzfs_core/_constants.py b/contrib/pyzfs/libzfs_core/_constants.py
index 16057e9b3..e1364aa33 100644
--- a/contrib/pyzfs/libzfs_core/_constants.py
+++ b/contrib/pyzfs/libzfs_core/_constants.py
@@ -19,6 +19,19 @@ Important `libzfs_core` constants.
"""
from __future__ import absolute_import, division, print_function
+import errno
+import sys
+
+
+# Compat for platform-specific errnos
+if sys.platform.startswith('freebsd'):
+ ECHRNG = errno.ENXIO
+ ECKSUM = 97 # EINTEGRITY
+ ETIME = errno.ETIMEDOUT
+else:
+ ECHRNG = errno.ECHRNG
+ ECKSUM = errno.EBADE
+ ETIME = errno.ETIME
# https://stackoverflow.com/a/1695250
diff --git a/contrib/pyzfs/libzfs_core/_error_translation.py b/contrib/pyzfs/libzfs_core/_error_translation.py
index b97bdd89a..7881715c9 100644
--- a/contrib/pyzfs/libzfs_core/_error_translation.py
+++ b/contrib/pyzfs/libzfs_core/_error_translation.py
@@ -33,6 +33,9 @@ import re
import string
from . import exceptions as lzc_exc
from ._constants import (
+ ECHRNG,
+ ECKSUM,
+ ETIME,
MAXNAMELEN,
ZFS_ERR_CHECKPOINT_EXISTS,
ZFS_ERR_DISCARDING_CHECKPOINT,
@@ -462,7 +465,7 @@ def lzc_receive_translate_errors(
raise lzc_exc.ReadOnlyPool(_pool_name(snapname))
if ret == errno.EAGAIN:
raise lzc_exc.SuspendedPool(_pool_name(snapname))
- if ret == errno.EBADE: # ECKSUM
+ if ret == ECKSUM:
raise lzc_exc.BadStream()
if ret == ZFS_ERR_WRONG_PARENT:
raise lzc_exc.WrongParent(_fs_name(snapname))
@@ -550,7 +553,7 @@ def lzc_channel_program_translate_error(ret, name, error):
return
if ret == errno.ENOENT:
raise lzc_exc.PoolNotFound(name)
- if ret == errno.ETIME:
+ if ret == ETIME:
raise lzc_exc.ZCPTimeout()
if ret == errno.ENOMEM:
raise lzc_exc.ZCPMemoryError()
@@ -558,7 +561,7 @@ def lzc_channel_program_translate_error(ret, name, error):
raise lzc_exc.ZCPSpaceError()
if ret == errno.EPERM:
raise lzc_exc.ZCPPermissionError()
- if ret == errno.ECHRNG:
+ if ret == ECHRNG:
raise lzc_exc.ZCPRuntimeError(error)
if ret == errno.EINVAL:
if error is None:
diff --git a/contrib/pyzfs/libzfs_core/exceptions.py b/contrib/pyzfs/libzfs_core/exceptions.py
index 2206c2f2c..9eeab1d7c 100644
--- a/contrib/pyzfs/libzfs_core/exceptions.py
+++ b/contrib/pyzfs/libzfs_core/exceptions.py
@@ -21,6 +21,9 @@ from __future__ import absolute_import, division, print_function
import errno
from ._constants import (
+ ECHRNG,
+ ECKSUM,
+ ETIME,
ZFS_ERR_CHECKPOINT_EXISTS,
ZFS_ERR_DISCARDING_CHECKPOINT,
ZFS_ERR_NO_CHECKPOINT,
@@ -324,7 +327,7 @@ class DestinationModified(ZFSError):
class BadStream(ZFSError):
- errno = errno.EBADE
+ errno = ECKSUM
message = "Bad backup stream"
@@ -532,7 +535,7 @@ class ZCPSyntaxError(ZCPError):
class ZCPRuntimeError(ZCPError):
- errno = errno.ECHRNG
+ errno = ECHRNG
message = "Channel programs encountered a runtime error"
def __init__(self, details):
@@ -545,7 +548,7 @@ class ZCPLimitInvalid(ZCPError):
class ZCPTimeout(ZCPError):
- errno = errno.ETIME
+ errno = ETIME
message = "Channel program timed out"