]>
Commit | Line | Data |
---|---|---|
85ce3f4f | 1 | # |
2 | # Copyright 2015 ClusterHQ | |
3 | # | |
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 | |
7 | # | |
8 | # http://www.apache.org/licenses/LICENSE-2.0 | |
9 | # | |
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. | |
15 | # | |
6abf9225 AG |
16 | |
17 | """ | |
18 | Important `libzfs_core` constants. | |
19 | """ | |
20 | ||
9de8c0cd | 21 | from __future__ import absolute_import, division, print_function |
27641038 RM |
22 | import errno |
23 | import sys | |
24 | ||
25 | ||
26 | # Compat for platform-specific errnos | |
27 | if sys.platform.startswith('freebsd'): | |
28 | ECHRNG = errno.ENXIO | |
29 | ECKSUM = 97 # EINTEGRITY | |
30 | ETIME = errno.ETIMEDOUT | |
31 | else: | |
32 | ECHRNG = errno.ECHRNG | |
33 | ECKSUM = errno.EBADE | |
34 | ETIME = errno.ETIME | |
9de8c0cd | 35 | |
85ce3f4f | 36 | |
37 | # https://stackoverflow.com/a/1695250 | |
a73f361f CS |
38 | def enum_with_offset(offset, sequential, named): |
39 | enums = dict(((b, a + offset) for a, b in enumerate(sequential)), **named) | |
85ce3f4f | 40 | return type('Enum', (), enums) |
41 | ||
42 | ||
a73f361f CS |
43 | def enum(*sequential, **named): |
44 | return enum_with_offset(0, sequential, named) | |
45 | ||
46 | ||
6abf9225 AG |
47 | #: Maximum length of any ZFS name. |
48 | MAXNAMELEN = 255 | |
85ce3f4f | 49 | #: Default channel program limits |
50 | ZCP_DEFAULT_INSTRLIMIT = 10 * 1000 * 1000 | |
51 | ZCP_DEFAULT_MEMLIMIT = 10 * 1024 * 1024 | |
52 | #: Encryption wrapping key length | |
53 | WRAPPING_KEY_LEN = 32 | |
54 | #: Encryption key location enum | |
55 | zfs_key_location = enum( | |
56 | 'ZFS_KEYLOCATION_NONE', | |
57 | 'ZFS_KEYLOCATION_PROMPT', | |
58 | 'ZFS_KEYLOCATION_URI' | |
59 | ) | |
60 | #: Encryption key format enum | |
61 | zfs_keyformat = enum( | |
62 | 'ZFS_KEYFORMAT_NONE', | |
63 | 'ZFS_KEYFORMAT_RAW', | |
64 | 'ZFS_KEYFORMAT_HEX', | |
65 | 'ZFS_KEYFORMAT_PASSPHRASE' | |
66 | ) | |
67 | # Encryption algorithms enum | |
68 | zio_encrypt = enum( | |
69 | 'ZIO_CRYPT_INHERIT', | |
70 | 'ZIO_CRYPT_ON', | |
71 | 'ZIO_CRYPT_OFF', | |
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' | |
78 | ) | |
c962fd6c | 79 | # ZFS-specific error codes |
a73f361f CS |
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', | |
7145123b | 97 | 'ZFS_ERR_STREAM_TRUNCATED', |
4cf6f107 | 98 | 'ZFS_ERR_STREAM_LARGE_BLOCK_MISMATCH', |
9a49d3f3 BB |
99 | 'ZFS_ERR_RESILVER_IN_PROGRESS', |
100 | 'ZFS_ERR_REBUILD_IN_PROGRESS', | |
8fb79fdd | 101 | 'ZFS_ERR_BADPROP', |
2a673e76 | 102 | 'ZFS_ERR_VDEV_NOTSUP', |
4ed5e250 | 103 | 'ZFS_ERR_NOT_USER_NAMESPACE', |
3ed9d688 | 104 | 'ZFS_ERR_RESUME_EXISTS', |
b988f32c | 105 | 'ZFS_ERR_CRYPTO_NOTSUP', |
5caeef02 | 106 | 'ZFS_ERR_RAIDZ_EXPAND_IN_PROGRESS', |
a73f361f CS |
107 | ], |
108 | {} | |
109 | ) | |
110 | # compat before we used the enum helper for these values | |
111 | ZFS_ERR_CHECKPOINT_EXISTS = zfs_errno.ZFS_ERR_CHECKPOINT_EXISTS | |
51946eda | 112 | assert (ZFS_ERR_CHECKPOINT_EXISTS == 1024) |
a73f361f CS |
113 | ZFS_ERR_DISCARDING_CHECKPOINT = zfs_errno.ZFS_ERR_DISCARDING_CHECKPOINT |
114 | ZFS_ERR_NO_CHECKPOINT = zfs_errno.ZFS_ERR_NO_CHECKPOINT | |
115 | ZFS_ERR_DEVRM_IN_PROGRESS = zfs_errno.ZFS_ERR_DEVRM_IN_PROGRESS | |
116 | ZFS_ERR_VDEV_TOO_BIG = zfs_errno.ZFS_ERR_VDEV_TOO_BIG | |
117 | ZFS_ERR_WRONG_PARENT = zfs_errno.ZFS_ERR_WRONG_PARENT | |
2a673e76 | 118 | ZFS_ERR_VDEV_NOTSUP = zfs_errno.ZFS_ERR_VDEV_NOTSUP |
5caeef02 | 119 | ZFS_ERR_RAIDZ_EXPAND_IN_PROGRESS = zfs_errno.ZFS_ERR_RAIDZ_EXPAND_IN_PROGRESS |
c962fd6c | 120 | |
6abf9225 | 121 | # vim: softtabstop=4 tabstop=4 expandtab shiftwidth=4 |