summaryrefslogtreecommitdiff
path: root/libbtrfsutil/python/btrfsutilpy.h
blob: 59c7e99418345c657f1666fc05ca4f5e05634e7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * Copyright (C) 2018 Facebook
 *
 * This file is part of libbtrfsutil.
 *
 * libbtrfsutil is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * libbtrfsutil is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with libbtrfsutil.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef BTRFSUTILPY_H
#define BTRFSUTILPY_H

#define PY_SSIZE_T_CLEAN

#include <stdbool.h>
#include <stddef.h>
#include <Python.h>
#include "structmember.h"

#include <btrfsutil.h>

typedef struct {
	PyObject_HEAD
	struct btrfs_util_qgroup_inherit *inherit;
} QgroupInherit;

extern PyTypeObject BtrfsUtilError_type;
extern PyStructSequence_Desc SubvolumeInfo_desc;
extern PyTypeObject SubvolumeInfo_type;
extern PyTypeObject SubvolumeIterator_type;
extern PyTypeObject QgroupInherit_type;

/*
 * Helpers for path arguments based on posixmodule.c in CPython.
 */
struct path_arg {
	bool allow_fd;
	char *path;
	int fd;
	Py_ssize_t length;
	PyObject *object;
	PyObject *cleanup;
};
int path_converter(PyObject *o, void *p);
void path_cleanup(struct path_arg *path);

void SetFromBtrfsUtilError(enum btrfs_util_error err);
void SetFromBtrfsUtilErrorWithPath(enum btrfs_util_error err,
				   struct path_arg *path);
void SetFromBtrfsUtilErrorWithPaths(enum btrfs_util_error err,
				    struct path_arg *path1,
				    struct path_arg *path2);

PyObject *filesystem_sync(PyObject *self, PyObject *args, PyObject *kwds);
PyObject *start_sync(PyObject *self, PyObject *args, PyObject *kwds);
PyObject *wait_sync(PyObject *self, PyObject *args, PyObject *kwds);
PyObject *is_subvolume(PyObject *self, PyObject *args, PyObject *kwds);
PyObject *subvolume_id(PyObject *self, PyObject *args, PyObject *kwds);
PyObject *subvolume_path(PyObject *self, PyObject *args, PyObject *kwds);
PyObject *subvolume_info(PyObject *self, PyObject *args, PyObject *kwds);
PyObject *get_subvolume_read_only(PyObject *self, PyObject *args, PyObject *kwds);
PyObject *set_subvolume_read_only(PyObject *self, PyObject *args, PyObject *kwds);
PyObject *get_default_subvolume(PyObject *self, PyObject *args, PyObject *kwds);
PyObject *set_default_subvolume(PyObject *self, PyObject *args, PyObject *kwds);
PyObject *create_subvolume(PyObject *self, PyObject *args, PyObject *kwds);
PyObject *create_snapshot(PyObject *self, PyObject *args, PyObject *kwds);

void add_module_constants(PyObject *m);

#endif /* BTRFSUTILPY_H */