2 # Copyright 2015 ClusterHQ
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
18 Important `libzfs_core` constants.
21 from __future__
import absolute_import
, division
, print_function
26 # Compat for platform-specific errnos
27 if sys
.platform
.startswith('freebsd'):
29 ECKSUM
= 97 # EINTEGRITY
30 ETIME
= errno
.ETIMEDOUT
37 # https://stackoverflow.com/a/1695250
38 def enum_with_offset(offset
, sequential
, named
):
39 enums
= dict(((b
, a
+ offset
) for a
, b
in enumerate(sequential
)), **named
)
40 return type('Enum', (), enums
)
43 def enum(*sequential
, **named
):
44 return enum_with_offset(0, sequential
, named
)
47 #: Maximum length of any ZFS name.
49 #: Default channel program limits
50 ZCP_DEFAULT_INSTRLIMIT
= 10 * 1000 * 1000
51 ZCP_DEFAULT_MEMLIMIT
= 10 * 1024 * 1024
52 #: Encryption wrapping key length
54 #: Encryption key location enum
55 zfs_key_location
= enum(
56 'ZFS_KEYLOCATION_NONE',
57 'ZFS_KEYLOCATION_PROMPT',
60 #: Encryption key format enum
65 'ZFS_KEYFORMAT_PASSPHRASE'
67 # Encryption algorithms enum
72 'ZIO_CRYPT_AES_128_CCM',
73 'ZIO_CRYPT_AES_192_CCM',
74 'ZIO_CRYPT_AES_256_CCM',
75 'ZIO_CRYPT_AES_128_GCM',
76 'ZIO_CRYPT_AES_192_GCM',
77 'ZIO_CRYPT_AES_256_GCM'
79 # ZFS-specific error codes
80 zfs_errno
= enum_with_offset(1024, [
81 'ZFS_ERR_CHECKPOINT_EXISTS',
82 'ZFS_ERR_DISCARDING_CHECKPOINT',
83 'ZFS_ERR_NO_CHECKPOINT',
84 'ZFS_ERR_DEVRM_IN_PROGRESS',
85 'ZFS_ERR_VDEV_TOO_BIG',
86 'ZFS_ERR_IOC_CMD_UNAVAIL',
87 'ZFS_ERR_IOC_ARG_UNAVAIL',
88 'ZFS_ERR_IOC_ARG_REQUIRED',
89 'ZFS_ERR_IOC_ARG_BADTYPE',
90 'ZFS_ERR_WRONG_PARENT',
91 'ZFS_ERR_FROM_IVSET_GUID_MISSING',
92 'ZFS_ERR_FROM_IVSET_GUID_MISMATCH',
93 'ZFS_ERR_SPILL_BLOCK_FLAG_MISSING',
94 'ZFS_ERR_UNKNOWN_SEND_STREAM_FEATURE',
95 'ZFS_ERR_EXPORT_IN_PROGRESS',
96 'ZFS_ERR_BOOKMARK_SOURCE_NOT_ANCESTOR',
97 'ZFS_ERR_STREAM_TRUNCATED',
98 'ZFS_ERR_STREAM_LARGE_BLOCK_MISMATCH',
99 'ZFS_ERR_RESILVER_IN_PROGRESS',
100 'ZFS_ERR_REBUILD_IN_PROGRESS',
102 'ZFS_ERR_VDEV_NOTSUP',
103 'ZFS_ERR_NOT_USER_NAMESPACE',
104 'ZFS_ERR_RESUME_EXISTS',
105 'ZFS_ERR_CRYPTO_NOTSUP',
109 # compat before we used the enum helper for these values
110 ZFS_ERR_CHECKPOINT_EXISTS
= zfs_errno
.ZFS_ERR_CHECKPOINT_EXISTS
111 assert (ZFS_ERR_CHECKPOINT_EXISTS
== 1024)
112 ZFS_ERR_DISCARDING_CHECKPOINT
= zfs_errno
.ZFS_ERR_DISCARDING_CHECKPOINT
113 ZFS_ERR_NO_CHECKPOINT
= zfs_errno
.ZFS_ERR_NO_CHECKPOINT
114 ZFS_ERR_DEVRM_IN_PROGRESS
= zfs_errno
.ZFS_ERR_DEVRM_IN_PROGRESS
115 ZFS_ERR_VDEV_TOO_BIG
= zfs_errno
.ZFS_ERR_VDEV_TOO_BIG
116 ZFS_ERR_WRONG_PARENT
= zfs_errno
.ZFS_ERR_WRONG_PARENT
117 ZFS_ERR_VDEV_NOTSUP
= zfs_errno
.ZFS_ERR_VDEV_NOTSUP
119 # vim: softtabstop=4 tabstop=4 expandtab shiftwidth=4