diff options
author | Omar Sandoval <osandov@fb.com> | 2018-01-24 12:48:59 -0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-03-06 11:28:37 +0100 |
commit | f23918016238a67b98740bdcb2509e290715977a (patch) | |
tree | 086a0297dc788c9536c934f32d43c9f990aa4486 /libbtrfsutil/python/subvolume.c | |
parent | 678da5a7f71ed7fbc887e40cc8ef91008c6fe843 (diff) |
libbtrfsutil: add btrfs_util_deleted_subvolumes()
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'libbtrfsutil/python/subvolume.c')
-rw-r--r-- | libbtrfsutil/python/subvolume.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libbtrfsutil/python/subvolume.c b/libbtrfsutil/python/subvolume.c index eb3f6e27..069e606b 100644 --- a/libbtrfsutil/python/subvolume.c +++ b/libbtrfsutil/python/subvolume.c @@ -425,6 +425,36 @@ PyObject *delete_subvolume(PyObject *self, PyObject *args, PyObject *kwds) Py_RETURN_NONE; } +PyObject *deleted_subvolumes(PyObject *self, PyObject *args, PyObject *kwds) +{ + static char *keywords[] = {"path", NULL}; + struct path_arg path = {.allow_fd = true}; + PyObject *ret; + uint64_t *ids; + size_t n; + enum btrfs_util_error err; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&:deleted_subvolumes", + keywords, &path_converter, &path)) + return NULL; + + if (path.path) + err = btrfs_util_deleted_subvolumes(path.path, &ids, &n); + else + err = btrfs_util_deleted_subvolumes_fd(path.fd, &ids, &n); + if (err) { + SetFromBtrfsUtilErrorWithPath(err, &path); + path_cleanup(&path); + return NULL; + } + + path_cleanup(&path); + + ret = list_from_uint64_array(ids, n); + free(ids); + return ret; +} + typedef struct { PyObject_HEAD struct btrfs_util_subvolume_iterator *iter; |