Debian Codegraph @

src/plugins/loop.h

raw
1 #include <glib.h>
2
3 #ifndef BD_LOOP
4 #define BD_LOOP
5
6 GQuark bd_loop_error_quark (void);
7 #define BD_LOOP_ERROR bd_loop_error_quark ()
8 typedef enum {
9 BD_LOOP_ERROR_TECH_UNAVAIL,
10 BD_LOOP_ERROR_FAIL,
11 BD_LOOP_ERROR_DEVICE,
12 } BDLoopError;
13
14 typedef enum {
15 BD_LOOP_TECH_LOOP = 0,
16 } BDLoopTech;
17
18 typedef enum {
19 BD_LOOP_TECH_MODE_CREATE = 1 << 0,
20 BD_LOOP_TECH_MODE_DESTROY = 1 << 1,
21 BD_LOOP_TECH_MODE_MODIFY = 1 << 2,
22 BD_LOOP_TECH_MODE_QUERY = 1 << 3,
23 } BDLoopTechMode;
24
25 /**
26 * BDLoopInfo:
27 * @backing_file: backing file for the given loop device;
28 * @offset: offset of the start of the device (in @backing_file);
29 * @autoclear: whether the autoclear flag is set or not;
30 * @direct_io: whether direct IO is enabled or not;
31 * @part_scan: whether the partition scan is enforced or not;
32 * @read_only: whether the device is read-only or not;
33 */
34 typedef struct BDLoopInfo {
35 gchar *backing_file;
36 guint64 offset;
37 gboolean autoclear;
38 gboolean direct_io;
39 gboolean part_scan;
40 gboolean read_only;
41 } BDLoopInfo;
42
43
44 void bd_loop_info_free (BDLoopInfo *info);
45 BDLoopInfo* bd_loop_info_copy (BDLoopInfo *info);
46
47
48 /*
49 * If using the plugin as a standalone library, the following functions should
50 * be called to:
51 *
52 * init() - initialize the plugin, returning TRUE on success
53 * close() - clean after the plugin at the end or if no longer used
54 *
55 */
56 gboolean bd_loop_init (void);
57 void bd_loop_close (void);
58
59 gboolean bd_loop_is_tech_avail (BDLoopTech tech, guint64 mode, GError **error);
60
61 BDLoopInfo* bd_loop_info (const gchar *loop, GError **error);
62
63 gchar* bd_loop_get_loop_name (const gchar *file, GError **error);
64 gboolean bd_loop_setup (const gchar *file, guint64 offset, guint64 size, gboolean read_only, gboolean part_scan, guint64 sector_size, const gchar **loop_name, GError **error);
65 gboolean bd_loop_setup_from_fd (gint fd, guint64 offset, guint64 size, gboolean read_only, gboolean part_scan, guint64 sector_size, const gchar **loop_name, GError **error);
66 gboolean bd_loop_teardown (const gchar *loop, GError **error);
67
68 gboolean bd_loop_set_autoclear (const gchar *loop, gboolean autoclear, GError **error);
69 gboolean bd_loop_set_capacity (const gchar *loop, GError **error);
70
71 #endif /* BD_LOOP */