]> git.proxmox.com Git - mirror_zfs.git/blob - contrib/pyzfs/libzfs_core/bindings/libzfs_core.py
Implement a new type of zfs receive: corrective receive (-c)
[mirror_zfs.git] / contrib / pyzfs / libzfs_core / bindings / libzfs_core.py
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 #
16
17 """
18 Python bindings for ``libzfs_core``.
19 """
20 from __future__ import absolute_import, division, print_function
21
22 CDEF = """
23
24 enum lzc_send_flags {
25 LZC_SEND_FLAG_EMBED_DATA = 1,
26 LZC_SEND_FLAG_LARGE_BLOCK = 2,
27 LZC_SEND_FLAG_COMPRESS = 4,
28 LZC_SEND_FLAG_RAW = 8
29 };
30
31 typedef enum {
32 DMU_OST_NONE,
33 DMU_OST_META,
34 DMU_OST_ZFS,
35 DMU_OST_ZVOL,
36 DMU_OST_OTHER,
37 DMU_OST_ANY,
38 DMU_OST_NUMTYPES
39 } dmu_objset_type_t;
40
41 #define MAXNAMELEN 256
42
43 struct drr_begin {
44 uint64_t drr_magic;
45 uint64_t drr_versioninfo; /* was drr_version */
46 uint64_t drr_creation_time;
47 dmu_objset_type_t drr_type;
48 uint32_t drr_flags;
49 uint64_t drr_toguid;
50 uint64_t drr_fromguid;
51 char drr_toname[MAXNAMELEN];
52 };
53
54 typedef struct zio_cksum {
55 uint64_t zc_word[4];
56 } zio_cksum_t;
57
58 typedef struct dmu_replay_record {
59 enum {
60 DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS,
61 DRR_WRITE, DRR_FREE, DRR_END, DRR_WRITE_BYREF,
62 DRR_SPILL, DRR_WRITE_EMBEDDED, DRR_NUMTYPES
63 } drr_type;
64 uint32_t drr_payloadlen;
65 union {
66 struct drr_begin drr_begin;
67 /* ... */
68 struct drr_checksum {
69 uint64_t drr_pad[34];
70 zio_cksum_t drr_checksum;
71 } drr_checksum;
72 } drr_u;
73 } dmu_replay_record_t;
74
75 typedef enum {
76 DCP_CMD_NONE,
77 DCP_CMD_RAW_RECV,
78 DCP_CMD_NEW_KEY,
79 DCP_CMD_INHERIT,
80 DCP_CMD_FORCE_NEW_KEY,
81 DCP_CMD_FORCE_INHERIT
82 } dcp_cmd_t;
83
84 int libzfs_core_init(void);
85 void libzfs_core_fini(void);
86
87 int lzc_bookmark(nvlist_t *, nvlist_t **);
88 int lzc_change_key(const char *, uint64_t, nvlist_t *, uint8_t *, uint_t);
89 int lzc_channel_program(const char *, const char *, uint64_t, uint64_t,
90 nvlist_t *, nvlist_t **);
91 int lzc_channel_program_nosync(const char *, const char *, uint64_t,
92 uint64_t, nvlist_t *, nvlist_t **);
93 int lzc_clone(const char *, const char *, nvlist_t *);
94 int lzc_create(const char *, dmu_objset_type_t, nvlist_t *, uint8_t *,
95 uint_t);
96 int lzc_destroy_bookmarks(nvlist_t *, nvlist_t **);
97 int lzc_destroy_snaps(nvlist_t *, boolean_t, nvlist_t **);
98 boolean_t lzc_exists(const char *);
99 int lzc_get_bookmarks(const char *, nvlist_t *, nvlist_t **);
100 int lzc_get_holds(const char *, nvlist_t **);
101 int lzc_hold(nvlist_t *, int, nvlist_t **);
102 int lzc_load_key(const char *, boolean_t, uint8_t *, uint_t);
103 int lzc_promote(const char *, nvlist_t *, nvlist_t **);
104 int lzc_receive(const char *, nvlist_t *, const char *, boolean_t,
105 boolean_t, int);
106 int lzc_receive_one(const char *, nvlist_t *, const char *, boolean_t,
107 boolean_t, boolean_t, int, const dmu_replay_record_t *, int,
108 uint64_t *, uint64_t *, uint64_t *, nvlist_t **);
109 int lzc_receive_resumable(const char *, nvlist_t *, const char *,
110 boolean_t, boolean_t, int);
111 int lzc_receive_with_cmdprops(const char *, nvlist_t *, nvlist_t *,
112 uint8_t *, uint_t, const char *, boolean_t, boolean_t,
113 boolean_t, int, const dmu_replay_record_t *, int, uint64_t *,
114 uint64_t *, uint64_t *, nvlist_t **);
115 int lzc_receive_with_heal(const char *, nvlist_t *, nvlist_t *,
116 uint8_t *, uint_t, const char *, boolean_t, boolean_t, boolean_t,
117 boolean_t, int, const dmu_replay_record_t *, int, uint64_t *,
118 uint64_t *, uint64_t *, nvlist_t **);
119 int lzc_receive_with_header(const char *, nvlist_t *, const char *,
120 boolean_t, boolean_t, boolean_t, int, const dmu_replay_record_t *);
121 int lzc_release(nvlist_t *, nvlist_t **);
122 int lzc_reopen(const char *, boolean_t);
123 int lzc_rollback(const char *, char *, int);
124 int lzc_rollback_to(const char *, const char *);
125 int lzc_send(const char *, const char *, int, enum lzc_send_flags);
126 int lzc_send_resume(const char *, const char *, int, enum lzc_send_flags,
127 uint64_t, uint64_t);
128 int lzc_send_space(const char *, const char *, enum lzc_send_flags,
129 uint64_t *);
130 int lzc_snaprange_space(const char *, const char *, uint64_t *);
131 int lzc_snapshot(nvlist_t *, nvlist_t *, nvlist_t **);
132 int lzc_sync(const char *, nvlist_t *, nvlist_t **);
133 int lzc_unload_key(const char *);
134 int lzc_pool_checkpoint(const char *);
135 int lzc_pool_checkpoint_discard(const char *);
136 int lzc_rename(const char *, const char *);
137 int lzc_destroy(const char *fsname);
138
139 int lzc_inherit(const char *fsname, const char *name, nvlist_t *);
140 int lzc_set_props(const char *, nvlist_t *, nvlist_t *, nvlist_t *);
141 int lzc_list (const char *, nvlist_t *);
142 """
143
144 SOURCE = """
145 #include <libzfs/libzfs_core.h>
146 """
147
148 LIBRARY = "zfs_core"
149
150 # vim: softtabstop=4 tabstop=4 expandtab shiftwidth=4