Skip to content

Commit 9c5cfdc

Browse files
committed
libbtrfsutil: python: add aliases for 0.1.3 update
The update of util library 0.1.3 added aliases of the C API unifying the naming conventions. However this was not updated in the python interface, and some of the existing symbols are not exported. The definition table needs to copy the entry in module.c, no other simple tricks. Issue: #995 Signed-off-by: David Sterba <[email protected]>
1 parent 8e498fe commit 9c5cfdc

File tree

1 file changed

+143
-0
lines changed

1 file changed

+143
-0
lines changed

libbtrfsutil/python/module.c

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,37 @@ void path_cleanup(struct path_arg *path)
120120
}
121121

122122
static PyMethodDef btrfsutil_methods[] = {
123+
/* Aliases: sync, fs_sync */
123124
{"sync", (PyCFunction)filesystem_sync,
124125
METH_VARARGS | METH_KEYWORDS,
125126
"sync(path)\n\n"
126127
"Sync a specific Btrfs filesystem.\n\n"
127128
"Arguments:\n"
128129
"path -- string, bytes, path-like object, or open file descriptor"},
130+
{"fs_sync", (PyCFunction)filesystem_sync,
131+
METH_VARARGS | METH_KEYWORDS,
132+
"fs_sync(path)\n\n"
133+
"Sync a specific Btrfs filesystem.\n\n"
134+
"Arguments:\n"
135+
"path -- string, bytes, path-like object, or open file descriptor"},
136+
137+
/* Aliases: start_sync, fs_start_sync */
129138
{"start_sync", (PyCFunction)start_sync,
130139
METH_VARARGS | METH_KEYWORDS,
131140
"start_sync(path) -> int\n\n"
132141
"Start a sync on a specific Btrfs filesystem and return the\n"
133142
"transaction ID.\n\n"
134143
"Arguments:\n"
135144
"path -- string, bytes, path-like object, or open file descriptor"},
145+
{"fs_start_sync", (PyCFunction)start_sync,
146+
METH_VARARGS | METH_KEYWORDS,
147+
"fs_start_sync(path) -> int\n\n"
148+
"Start a sync on a specific Btrfs filesystem and return the\n"
149+
"transaction ID.\n\n"
150+
"Arguments:\n"
151+
"path -- string, bytes, path-like object, or open file descriptor"},
152+
153+
/* Aliases: wait_sync, fs_wait_sync */
136154
{"wait_sync", (PyCFunction)wait_sync,
137155
METH_VARARGS | METH_KEYWORDS,
138156
"wait_sync(path, transid=0)\n\n"
@@ -141,18 +159,44 @@ static PyMethodDef btrfsutil_methods[] = {
141159
"path -- string, bytes, path-like object, or open file descriptor\n"
142160
"transid -- int transaction ID to wait for, or zero for the current\n"
143161
"transaction"},
162+
{"fs_wait_sync", (PyCFunction)wait_sync,
163+
METH_VARARGS | METH_KEYWORDS,
164+
"fs_wait_sync(path, transid=0)\n\n"
165+
"Wait for a transaction to sync.\n"
166+
"Arguments:\n"
167+
"path -- string, bytes, path-like object, or open file descriptor\n"
168+
"transid -- int transaction ID to wait for, or zero for the current\n"
169+
"transaction"},
170+
171+
/* Aliases: is_subvolume, subvolume_is_valid */
144172
{"is_subvolume", (PyCFunction)is_subvolume,
145173
METH_VARARGS | METH_KEYWORDS,
146174
"is_subvolume(path) -> bool\n\n"
147175
"Get whether a file is a subvolume.\n\n"
148176
"Arguments:\n"
149177
"path -- string, bytes, path-like object, or open file descriptor"},
178+
{"subvolume_is_valid", (PyCFunction)is_subvolume,
179+
METH_VARARGS | METH_KEYWORDS,
180+
"subvolume_is_valid(path) -> bool\n\n"
181+
"Get whether a file is a subvolume.\n\n"
182+
"Arguments:\n"
183+
"path -- string, bytes, path-like object, or open file descriptor"},
184+
185+
/* Aliases: subvolume_id, subvolume_get_id */
150186
{"subvolume_id", (PyCFunction)subvolume_id,
151187
METH_VARARGS | METH_KEYWORDS,
152188
"subvolume_id(path) -> int\n\n"
153189
"Get the ID of the subvolume containing a file.\n\n"
154190
"Arguments:\n"
155191
"path -- string, bytes, path-like object, or open file descriptor"},
192+
{"subvolume_get_id", (PyCFunction)subvolume_id,
193+
METH_VARARGS | METH_KEYWORDS,
194+
"subvolume_id(path) -> int\n\n"
195+
"Get the ID of the subvolume containing a file.\n\n"
196+
"Arguments:\n"
197+
"path -- string, bytes, path-like object, or open file descriptor"},
198+
199+
/* Aliases: subvolume_path, subvolume_get_path */
156200
{"subvolume_path", (PyCFunction)subvolume_path,
157201
METH_VARARGS | METH_KEYWORDS,
158202
"subvolume_path(path, id=0) -> int\n\n"
@@ -161,6 +205,16 @@ static PyMethodDef btrfsutil_methods[] = {
161205
"path -- string, bytes, path-like object, or open file descriptor\n"
162206
"id -- if not zero, instead of returning the subvolume path of the\n"
163207
"given path, return the path of the subvolume with this ID"},
208+
{"subvolume_get_path", (PyCFunction)subvolume_path,
209+
METH_VARARGS | METH_KEYWORDS,
210+
"subvolume_get_path(path, id=0) -> int\n\n"
211+
"Get the path of a subvolume relative to the filesystem root.\n\n"
212+
"Arguments:\n"
213+
"path -- string, bytes, path-like object, or open file descriptor\n"
214+
"id -- if not zero, instead of returning the subvolume path of the\n"
215+
"given path, return the path of the subvolume with this ID"},
216+
217+
/* Aliases: subvolume_info, subvolume_get_info */
164218
{"subvolume_info", (PyCFunction)subvolume_info,
165219
METH_VARARGS | METH_KEYWORDS,
166220
"subvolume_info(path, id=0) -> SubvolumeInfo\n\n"
@@ -169,25 +223,60 @@ static PyMethodDef btrfsutil_methods[] = {
169223
"path -- string, bytes, path-like object, or open file descriptor\n"
170224
"id -- if not zero, instead of returning information about the\n"
171225
"given path, return information about the subvolume with this ID"},
226+
{"subvolume_get_info", (PyCFunction)subvolume_info,
227+
METH_VARARGS | METH_KEYWORDS,
228+
"subvolume_get_info(path, id=0) -> SubvolumeInfo\n\n"
229+
"Get information about a subvolume.\n\n"
230+
"Arguments:\n"
231+
"path -- string, bytes, path-like object, or open file descriptor\n"
232+
"id -- if not zero, instead of returning information about the\n"
233+
"given path, return information about the subvolume with this ID"},
234+
235+
/* Aliases get_subvolume_read_only, subvolume_get_read_only */
172236
{"get_subvolume_read_only", (PyCFunction)get_subvolume_read_only,
173237
METH_VARARGS | METH_KEYWORDS,
174238
"get_subvolume_read_only(path) -> bool\n\n"
175239
"Get whether a subvolume is read-only.\n\n"
176240
"Arguments:\n"
177241
"path -- string, bytes, path-like object, or open file descriptor"},
242+
{"subvolume_get_read_only", (PyCFunction)get_subvolume_read_only,
243+
METH_VARARGS | METH_KEYWORDS,
244+
"subvolume_get_read_only(path) -> bool\n\n"
245+
"Get whether a subvolume is read-only.\n\n"
246+
"Arguments:\n"
247+
"path -- string, bytes, path-like object, or open file descriptor"},
248+
249+
/* Aliases set_subvolume_read_only, subvolume_set_read_only */
178250
{"set_subvolume_read_only", (PyCFunction)set_subvolume_read_only,
179251
METH_VARARGS | METH_KEYWORDS,
180252
"set_subvolume_read_only(path, read_only=True)\n\n"
181253
"Set whether a subvolume is read-only.\n\n"
182254
"Arguments:\n"
183255
"path -- string, bytes, path-like object, or open file descriptor\n"
184256
"read_only -- bool flag value"},
257+
{"subvolume_set_read_only", (PyCFunction)set_subvolume_read_only,
258+
METH_VARARGS | METH_KEYWORDS,
259+
"subvolume_set_read_only(path, read_only=True)\n\n"
260+
"Set whether a subvolume is read-only.\n\n"
261+
"Arguments:\n"
262+
"path -- string, bytes, path-like object, or open file descriptor\n"
263+
"read_only -- bool flag value"},
264+
265+
/* Aliases get_default_subvolume, subvolume_get_default */
185266
{"get_default_subvolume", (PyCFunction)get_default_subvolume,
186267
METH_VARARGS | METH_KEYWORDS,
187268
"get_default_subvolume(path) -> int\n\n"
188269
"Get the ID of the default subvolume of a filesystem.\n\n"
189270
"Arguments:\n"
190271
"path -- string, bytes, path-like object, or open file descriptor"},
272+
{"subvolume_get_default", (PyCFunction)get_default_subvolume,
273+
METH_VARARGS | METH_KEYWORDS,
274+
"subvolume_get_default(path) -> int\n\n"
275+
"Get the ID of the default subvolume of a filesystem.\n\n"
276+
"Arguments:\n"
277+
"path -- string, bytes, path-like object, or open file descriptor"},
278+
279+
/* Aliases: set_default_subvolume, subvolume_set_default */
191280
{"set_default_subvolume", (PyCFunction)set_default_subvolume,
192281
METH_VARARGS | METH_KEYWORDS,
193282
"set_default_subvolume(path, id=0)\n\n"
@@ -196,6 +285,16 @@ static PyMethodDef btrfsutil_methods[] = {
196285
"path -- string, bytes, path-like object, or open file descriptor\n"
197286
"id -- if not zero, set the default subvolume to the subvolume with\n"
198287
"this ID instead of the given path"},
288+
{"subvolume_set_default", (PyCFunction)set_default_subvolume,
289+
METH_VARARGS | METH_KEYWORDS,
290+
"subvolume_set_default(path, id=0)\n\n"
291+
"Set the default subvolume of a filesystem.\n\n"
292+
"Arguments:\n"
293+
"path -- string, bytes, path-like object, or open file descriptor\n"
294+
"id -- if not zero, set the default subvolume to the subvolume with\n"
295+
"this ID instead of the given path"},
296+
297+
/* Aliases: create_subvolume, subvolume_create */
199298
{"create_subvolume", (PyCFunction)create_subvolume,
200299
METH_VARARGS | METH_KEYWORDS,
201300
"create_subvolume(path, async_=False, qgroup_inherit=None)\n\n"
@@ -205,6 +304,17 @@ static PyMethodDef btrfsutil_methods[] = {
205304
"async_ -- no longer used\n"
206305
"qgroup_inherit -- optional QgroupInherit object of qgroups to\n"
207306
"inherit from"},
307+
{"subvolume_create", (PyCFunction)create_subvolume,
308+
METH_VARARGS | METH_KEYWORDS,
309+
"subvolume_create(path, async_=False, qgroup_inherit=None)\n\n"
310+
"Create a new subvolume.\n\n"
311+
"Arguments:\n"
312+
"path -- string, bytes, or path-like object\n"
313+
"async_ -- no longer used\n"
314+
"qgroup_inherit -- optional QgroupInherit object of qgroups to\n"
315+
"inherit from"},
316+
317+
/* Aliases: create_snapshot, subvolume_snapshot */
208318
{"create_snapshot", (PyCFunction)create_snapshot,
209319
METH_VARARGS | METH_KEYWORDS,
210320
"create_snapshot(source, path, recursive=False, read_only=False,\n"
@@ -218,6 +328,21 @@ static PyMethodDef btrfsutil_methods[] = {
218328
"async_ -- no longer used\n"
219329
"qgroup_inherit -- optional QgroupInherit object of qgroups to\n"
220330
"inherit from"},
331+
{"subvolume_snapshot", (PyCFunction)create_snapshot,
332+
METH_VARARGS | METH_KEYWORDS,
333+
"subvolume_snapshot(source, path, recursive=False, read_only=False,\n"
334+
" async_=False, qgroup_inherit=None)\n\n"
335+
"Create a new snapshot.\n\n"
336+
"Arguments:\n"
337+
"source -- string, bytes, path-like object, or open file descriptor\n"
338+
"path -- string, bytes, or path-like object\n"
339+
"recursive -- also snapshot child subvolumes\n"
340+
"read_only -- create a read-only snapshot\n"
341+
"async_ -- no longer used\n"
342+
"qgroup_inherit -- optional QgroupInherit object of qgroups to\n"
343+
"inherit from"},
344+
345+
/* Aliases: delete_subvolume, subvolume_delete */
221346
{"delete_subvolume", (PyCFunction)delete_subvolume,
222347
METH_VARARGS | METH_KEYWORDS,
223348
"delete_subvolume(path, recursive=False)\n\n"
@@ -226,13 +351,31 @@ static PyMethodDef btrfsutil_methods[] = {
226351
"path -- string, bytes, or path-like object\n"
227352
"recursive -- if the given subvolume has child subvolumes, delete\n"
228353
"them instead of failing"},
354+
{"subvolume_delete", (PyCFunction)delete_subvolume,
355+
METH_VARARGS | METH_KEYWORDS,
356+
"subvolume_delete(path, recursive=False)\n\n"
357+
"Delete a subvolume or snapshot.\n\n"
358+
"Arguments:\n"
359+
"path -- string, bytes, or path-like object\n"
360+
"recursive -- if the given subvolume has child subvolumes, delete\n"
361+
"them instead of failing"},
362+
363+
/* Aliases: deleted_subvolumes, subvolume_list_deleted */
229364
{"deleted_subvolumes", (PyCFunction)deleted_subvolumes,
230365
METH_VARARGS | METH_KEYWORDS,
231366
"deleted_subvolumes(path)\n\n"
232367
"Get the list of subvolume IDs which have been deleted but not yet\n"
233368
"cleaned up\n\n"
234369
"Arguments:\n"
235370
"path -- string, bytes, path-like object, or open file descriptor"},
371+
{"subvolume_list_deleted", (PyCFunction)deleted_subvolumes,
372+
METH_VARARGS | METH_KEYWORDS,
373+
"subvolumes_list_deleted(path)\n\n"
374+
"Get the list of subvolume IDs which have been deleted but not yet\n"
375+
"cleaned up\n\n"
376+
"Arguments:\n"
377+
"path -- string, bytes, path-like object, or open file descriptor"},
378+
236379
{},
237380
};
238381

0 commit comments

Comments
 (0)