]> git.proxmox.com Git - mirror_zfs.git/blame - contrib/pyzfs/libzfs_core/_constants.py
RAID-Z expansion feature
[mirror_zfs.git] / contrib / pyzfs / libzfs_core / _constants.py
CommitLineData
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"""
18Important `libzfs_core` constants.
19"""
20
9de8c0cd 21from __future__ import absolute_import, division, print_function
27641038
RM
22import errno
23import sys
24
25
26# Compat for platform-specific errnos
27if sys.platform.startswith('freebsd'):
28 ECHRNG = errno.ENXIO
29 ECKSUM = 97 # EINTEGRITY
30 ETIME = errno.ETIMEDOUT
31else:
32 ECHRNG = errno.ECHRNG
33 ECKSUM = errno.EBADE
34 ETIME = errno.ETIME
9de8c0cd 35
85ce3f4f 36
37# https://stackoverflow.com/a/1695250
a73f361f
CS
38def 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
43def enum(*sequential, **named):
44 return enum_with_offset(0, sequential, named)
45
46
6abf9225
AG
47#: Maximum length of any ZFS name.
48MAXNAMELEN = 255
85ce3f4f 49#: Default channel program limits
50ZCP_DEFAULT_INSTRLIMIT = 10 * 1000 * 1000
51ZCP_DEFAULT_MEMLIMIT = 10 * 1024 * 1024
52#: Encryption wrapping key length
53WRAPPING_KEY_LEN = 32
54#: Encryption key location enum
55zfs_key_location = enum(
56 'ZFS_KEYLOCATION_NONE',
57 'ZFS_KEYLOCATION_PROMPT',
58 'ZFS_KEYLOCATION_URI'
59)
60#: Encryption key format enum
61zfs_keyformat = enum(
62 'ZFS_KEYFORMAT_NONE',
63 'ZFS_KEYFORMAT_RAW',
64 'ZFS_KEYFORMAT_HEX',
65 'ZFS_KEYFORMAT_PASSPHRASE'
66)
67# Encryption algorithms enum
68zio_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
80zfs_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
111ZFS_ERR_CHECKPOINT_EXISTS = zfs_errno.ZFS_ERR_CHECKPOINT_EXISTS
51946eda 112assert (ZFS_ERR_CHECKPOINT_EXISTS == 1024)
a73f361f
CS
113ZFS_ERR_DISCARDING_CHECKPOINT = zfs_errno.ZFS_ERR_DISCARDING_CHECKPOINT
114ZFS_ERR_NO_CHECKPOINT = zfs_errno.ZFS_ERR_NO_CHECKPOINT
115ZFS_ERR_DEVRM_IN_PROGRESS = zfs_errno.ZFS_ERR_DEVRM_IN_PROGRESS
116ZFS_ERR_VDEV_TOO_BIG = zfs_errno.ZFS_ERR_VDEV_TOO_BIG
117ZFS_ERR_WRONG_PARENT = zfs_errno.ZFS_ERR_WRONG_PARENT
2a673e76 118ZFS_ERR_VDEV_NOTSUP = zfs_errno.ZFS_ERR_VDEV_NOTSUP
5caeef02 119ZFS_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