summaryrefslogtreecommitdiff
path: root/libbtrfsutil/python/module.c
diff options
context:
space:
mode:
authorOmar Sandoval <osandov@fb.com>2018-01-18 13:33:02 -0800
committerDavid Sterba <dsterba@suse.com>2018-03-06 11:28:36 +0100
commit0d36261bd54a93b1b1b616bdd32d33b3f4278f09 (patch)
treeb292e0e8fed29b1ec9eb031fa09427f764ca85cb /libbtrfsutil/python/module.c
parent8b87811f945bec2a0681334030ed51af1e4828f6 (diff)
libbtrfsutil: add btrfs_util_subvolume_info()
This gets the the information in `btrfs subvolume show` from the root item. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'libbtrfsutil/python/module.c')
-rw-r--r--libbtrfsutil/python/module.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libbtrfsutil/python/module.c b/libbtrfsutil/python/module.c
index 455e909a..7b5d437d 100644
--- a/libbtrfsutil/python/module.c
+++ b/libbtrfsutil/python/module.c
@@ -173,6 +173,14 @@ static PyMethodDef btrfsutil_methods[] = {
"path -- string, bytes, path-like object, or open file descriptor\n"
"id -- if not zero, instead of returning the subvolume path of the\n"
"given path, return the path of the subvolume with this ID"},
+ {"subvolume_info", (PyCFunction)subvolume_info,
+ METH_VARARGS | METH_KEYWORDS,
+ "subvolume_info(path, id=0) -> SubvolumeInfo\n\n"
+ "Get information about a subvolume.\n\n"
+ "Arguments:\n"
+ "path -- string, bytes, path-like object, or open file descriptor\n"
+ "id -- if not zero, instead of returning information about the\n"
+ "given path, return information about the subvolume with this ID"},
{"create_subvolume", (PyCFunction)create_subvolume,
METH_VARARGS | METH_KEYWORDS,
"create_subvolume(path, async=False)\n\n"
@@ -201,6 +209,9 @@ PyInit_btrfsutil(void)
if (PyType_Ready(&BtrfsUtilError_type) < 0)
return NULL;
+ if (PyStructSequence_InitType2(&SubvolumeInfo_type, &SubvolumeInfo_desc) < 0)
+ return NULL;
+
QgroupInherit_type.tp_new = PyType_GenericNew;
if (PyType_Ready(&QgroupInherit_type) < 0)
return NULL;
@@ -213,6 +224,9 @@ PyInit_btrfsutil(void)
PyModule_AddObject(m, "BtrfsUtilError",
(PyObject *)&BtrfsUtilError_type);
+ Py_INCREF(&SubvolumeInfo_type);
+ PyModule_AddObject(m, "SubvolumeInfo", (PyObject *)&SubvolumeInfo_type);
+
Py_INCREF(&QgroupInherit_type);
PyModule_AddObject(m, "QgroupInherit",
(PyObject *)&QgroupInherit_type);