Adopt pyzfs from ClusterHQ
This commit introduces several changes:
* Update LICENSE and project information
* Give a good PEP8 talk to existing Python source code
* Add RPM/DEB packaging for pyzfs
* Fix some outstanding issues with the existing pyzfs code caused by
changes in the ABI since the last time the code was updated
* Integrate pyzfs Python unittest with the ZFS Test Suite
* Add missing libzfs_core functions: lzc_change_key,
lzc_channel_program, lzc_channel_program_nosync, lzc_load_key,
lzc_receive_one, lzc_receive_resumable, lzc_receive_with_cmdprops,
lzc_receive_with_header, lzc_reopen, lzc_send_resume, lzc_sync,
lzc_unload_key, lzc_remap
Note: this commit slightly changes zfs_ioc_unload_key() ABI. This allow
to differentiate the case where we tried to unload a key on a
non-existing dataset (ENOENT) from the situation where a dataset has
no key loaded: this is consistent with the "change" case where trying
to zfs_ioc_change_key() from a dataset with no key results in EACCES.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes #7230
2018-03-18 08:34:45 +00:00
|
|
|
#
|
|
|
|
# Copyright 2015 ClusterHQ
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
2018-03-03 10:10:34 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
Python bindings for ``libnvpair``.
|
|
|
|
"""
|
2018-08-22 10:59:51 +00:00
|
|
|
from __future__ import absolute_import, division, print_function
|
2018-03-03 10:10:34 +00:00
|
|
|
|
|
|
|
CDEF = """
|
|
|
|
typedef ... nvlist_t;
|
|
|
|
typedef ... nvpair_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
DATA_TYPE_UNKNOWN = 0,
|
|
|
|
DATA_TYPE_BOOLEAN,
|
|
|
|
DATA_TYPE_BYTE,
|
|
|
|
DATA_TYPE_INT16,
|
|
|
|
DATA_TYPE_UINT16,
|
|
|
|
DATA_TYPE_INT32,
|
|
|
|
DATA_TYPE_UINT32,
|
|
|
|
DATA_TYPE_INT64,
|
|
|
|
DATA_TYPE_UINT64,
|
|
|
|
DATA_TYPE_STRING,
|
|
|
|
DATA_TYPE_BYTE_ARRAY,
|
|
|
|
DATA_TYPE_INT16_ARRAY,
|
|
|
|
DATA_TYPE_UINT16_ARRAY,
|
|
|
|
DATA_TYPE_INT32_ARRAY,
|
|
|
|
DATA_TYPE_UINT32_ARRAY,
|
|
|
|
DATA_TYPE_INT64_ARRAY,
|
|
|
|
DATA_TYPE_UINT64_ARRAY,
|
|
|
|
DATA_TYPE_STRING_ARRAY,
|
|
|
|
DATA_TYPE_HRTIME,
|
|
|
|
DATA_TYPE_NVLIST,
|
|
|
|
DATA_TYPE_NVLIST_ARRAY,
|
|
|
|
DATA_TYPE_BOOLEAN_VALUE,
|
|
|
|
DATA_TYPE_INT8,
|
|
|
|
DATA_TYPE_UINT8,
|
|
|
|
DATA_TYPE_BOOLEAN_ARRAY,
|
|
|
|
DATA_TYPE_INT8_ARRAY,
|
|
|
|
DATA_TYPE_UINT8_ARRAY
|
|
|
|
} data_type_t;
|
|
|
|
typedef enum { B_FALSE, B_TRUE } boolean_t;
|
|
|
|
|
|
|
|
typedef unsigned char uchar_t;
|
|
|
|
typedef unsigned int uint_t;
|
|
|
|
|
|
|
|
int nvlist_alloc(nvlist_t **, uint_t, int);
|
|
|
|
void nvlist_free(nvlist_t *);
|
|
|
|
|
|
|
|
int nvlist_unpack(char *, size_t, nvlist_t **, int);
|
|
|
|
|
|
|
|
void dump_nvlist(nvlist_t *, int);
|
|
|
|
int nvlist_dup(nvlist_t *, nvlist_t **, int);
|
|
|
|
|
|
|
|
int nvlist_add_boolean(nvlist_t *, const char *);
|
|
|
|
int nvlist_add_boolean_value(nvlist_t *, const char *, boolean_t);
|
|
|
|
int nvlist_add_byte(nvlist_t *, const char *, uchar_t);
|
|
|
|
int nvlist_add_int8(nvlist_t *, const char *, int8_t);
|
|
|
|
int nvlist_add_uint8(nvlist_t *, const char *, uint8_t);
|
|
|
|
int nvlist_add_int16(nvlist_t *, const char *, int16_t);
|
|
|
|
int nvlist_add_uint16(nvlist_t *, const char *, uint16_t);
|
|
|
|
int nvlist_add_int32(nvlist_t *, const char *, int32_t);
|
|
|
|
int nvlist_add_uint32(nvlist_t *, const char *, uint32_t);
|
|
|
|
int nvlist_add_int64(nvlist_t *, const char *, int64_t);
|
|
|
|
int nvlist_add_uint64(nvlist_t *, const char *, uint64_t);
|
|
|
|
int nvlist_add_string(nvlist_t *, const char *, const char *);
|
|
|
|
int nvlist_add_nvlist(nvlist_t *, const char *, nvlist_t *);
|
2021-12-07 01:19:13 +00:00
|
|
|
int nvlist_add_boolean_array(nvlist_t *, const char *,
|
|
|
|
const boolean_t *, uint_t);
|
|
|
|
int nvlist_add_byte_array(nvlist_t *, const char *,
|
|
|
|
const uchar_t *, uint_t);
|
|
|
|
int nvlist_add_int8_array(nvlist_t *, const char *,
|
|
|
|
const int8_t *, uint_t);
|
|
|
|
int nvlist_add_uint8_array(nvlist_t *, const char *,
|
|
|
|
const uint8_t *, uint_t);
|
|
|
|
int nvlist_add_int16_array(nvlist_t *, const char *,
|
|
|
|
const int16_t *, uint_t);
|
|
|
|
int nvlist_add_uint16_array(nvlist_t *, const char *,
|
|
|
|
const uint16_t *, uint_t);
|
|
|
|
int nvlist_add_int32_array(nvlist_t *, const char *,
|
|
|
|
const int32_t *, uint_t);
|
|
|
|
int nvlist_add_uint32_array(nvlist_t *, const char *,
|
|
|
|
const uint32_t *, uint_t);
|
|
|
|
int nvlist_add_int64_array(nvlist_t *, const char *,
|
|
|
|
const int64_t *, uint_t);
|
|
|
|
int nvlist_add_uint64_array(nvlist_t *, const char *,
|
|
|
|
const uint64_t *, uint_t);
|
|
|
|
int nvlist_add_string_array(nvlist_t *, const char *,
|
|
|
|
const char * const *, uint_t);
|
|
|
|
int nvlist_add_nvlist_array(nvlist_t *, const char *,
|
|
|
|
const nvlist_t * const *, uint_t);
|
2018-03-03 10:10:34 +00:00
|
|
|
|
|
|
|
nvpair_t *nvlist_next_nvpair(nvlist_t *, nvpair_t *);
|
|
|
|
nvpair_t *nvlist_prev_nvpair(nvlist_t *, nvpair_t *);
|
|
|
|
char *nvpair_name(nvpair_t *);
|
|
|
|
data_type_t nvpair_type(nvpair_t *);
|
|
|
|
int nvpair_type_is_array(nvpair_t *);
|
|
|
|
int nvpair_value_boolean_value(nvpair_t *, boolean_t *);
|
|
|
|
int nvpair_value_byte(nvpair_t *, uchar_t *);
|
|
|
|
int nvpair_value_int8(nvpair_t *, int8_t *);
|
|
|
|
int nvpair_value_uint8(nvpair_t *, uint8_t *);
|
|
|
|
int nvpair_value_int16(nvpair_t *, int16_t *);
|
|
|
|
int nvpair_value_uint16(nvpair_t *, uint16_t *);
|
|
|
|
int nvpair_value_int32(nvpair_t *, int32_t *);
|
|
|
|
int nvpair_value_uint32(nvpair_t *, uint32_t *);
|
|
|
|
int nvpair_value_int64(nvpair_t *, int64_t *);
|
|
|
|
int nvpair_value_uint64(nvpair_t *, uint64_t *);
|
|
|
|
int nvpair_value_string(nvpair_t *, char **);
|
|
|
|
int nvpair_value_nvlist(nvpair_t *, nvlist_t **);
|
|
|
|
int nvpair_value_boolean_array(nvpair_t *, boolean_t **, uint_t *);
|
|
|
|
int nvpair_value_byte_array(nvpair_t *, uchar_t **, uint_t *);
|
|
|
|
int nvpair_value_int8_array(nvpair_t *, int8_t **, uint_t *);
|
|
|
|
int nvpair_value_uint8_array(nvpair_t *, uint8_t **, uint_t *);
|
|
|
|
int nvpair_value_int16_array(nvpair_t *, int16_t **, uint_t *);
|
|
|
|
int nvpair_value_uint16_array(nvpair_t *, uint16_t **, uint_t *);
|
|
|
|
int nvpair_value_int32_array(nvpair_t *, int32_t **, uint_t *);
|
|
|
|
int nvpair_value_uint32_array(nvpair_t *, uint32_t **, uint_t *);
|
|
|
|
int nvpair_value_int64_array(nvpair_t *, int64_t **, uint_t *);
|
|
|
|
int nvpair_value_uint64_array(nvpair_t *, uint64_t **, uint_t *);
|
|
|
|
int nvpair_value_string_array(nvpair_t *, char ***, uint_t *);
|
|
|
|
int nvpair_value_nvlist_array(nvpair_t *, nvlist_t ***, uint_t *);
|
|
|
|
"""
|
|
|
|
|
|
|
|
SOURCE = """
|
|
|
|
#include <libzfs/sys/nvpair.h>
|
|
|
|
"""
|
|
|
|
|
|
|
|
LIBRARY = "nvpair"
|
|
|
|
|
|
|
|
# vim: softtabstop=4 tabstop=4 expandtab shiftwidth=4
|