| 1 |
#include <glib.h> |
| 2 |
|
| 3 |
#ifndef BD_PART |
| 4 |
#define BD_PART |
| 5 |
|
| 6 |
GQuark bd_part_error_quark (void); |
| 7 |
#define BD_PART_ERROR bd_part_error_quark () |
| 8 |
typedef enum { |
| 9 |
BD_PART_ERROR_TECH_UNAVAIL, |
| 10 |
BD_PART_ERROR_FAIL, |
| 11 |
BD_PART_ERROR_INVAL, |
| 12 |
BD_PART_ERROR_EXISTS, |
| 13 |
} BDPartError; |
| 14 |
|
| 15 |
typedef enum { |
| 16 |
BD_PART_TABLE_MSDOS, |
| 17 |
BD_PART_TABLE_GPT, |
| 18 |
BD_PART_TABLE_UNDEF, |
| 19 |
} BDPartTableType; |
| 20 |
|
| 21 |
typedef enum { |
| 22 |
BD_PART_TYPE_NORMAL = 0x00, |
| 23 |
BD_PART_TYPE_LOGICAL = 0x01, |
| 24 |
BD_PART_TYPE_EXTENDED = 0x02, |
| 25 |
BD_PART_TYPE_FREESPACE = 0x04, |
| 26 |
BD_PART_TYPE_METADATA = 0x08, |
| 27 |
BD_PART_TYPE_PROTECTED = 0x10 |
| 28 |
} BDPartType; |
| 29 |
|
| 30 |
typedef enum { |
| 31 |
BD_PART_TYPE_REQ_NORMAL = 0x00, |
| 32 |
BD_PART_TYPE_REQ_LOGICAL = 0x01, |
| 33 |
BD_PART_TYPE_REQ_EXTENDED = 0x02, |
| 34 |
BD_PART_TYPE_REQ_NEXT = 0x04 |
| 35 |
} BDPartTypeReq; |
| 36 |
|
| 37 |
typedef enum { |
| 38 |
BD_PART_ALIGN_NONE, |
| 39 |
BD_PART_ALIGN_MINIMAL, |
| 40 |
BD_PART_ALIGN_OPTIMAL, |
| 41 |
} BDPartAlign; |
| 42 |
|
| 43 |
typedef struct BDPartSpec { |
| 44 |
gchar *path; |
| 45 |
gchar *name; |
| 46 |
gchar *uuid; |
| 47 |
gchar *id; |
| 48 |
gchar *type_guid; |
| 49 |
guint64 type; |
| 50 |
guint64 start; |
| 51 |
guint64 size; |
| 52 |
gboolean bootable; |
| 53 |
guint64 attrs; |
| 54 |
gchar *type_name; |
| 55 |
} BDPartSpec; |
| 56 |
|
| 57 |
BDPartSpec* bd_part_spec_copy (BDPartSpec *data); |
| 58 |
void bd_part_spec_free (BDPartSpec *data); |
| 59 |
|
| 60 |
typedef struct BDPartDiskSpec { |
| 61 |
gchar *path; |
| 62 |
BDPartTableType table_type; |
| 63 |
guint64 size; |
| 64 |
guint64 sector_size; |
| 65 |
} BDPartDiskSpec; |
| 66 |
|
| 67 |
BDPartDiskSpec* bd_part_disk_spec_copy (BDPartDiskSpec *data); |
| 68 |
void bd_part_disk_spec_free (BDPartDiskSpec *data); |
| 69 |
|
| 70 |
typedef enum { |
| 71 |
BD_PART_TECH_MBR = 0, |
| 72 |
BD_PART_TECH_GPT, |
| 73 |
} BDPartTech; |
| 74 |
|
| 75 |
typedef enum { |
| 76 |
BD_PART_TECH_MODE_CREATE_TABLE = 1 << 0, |
| 77 |
BD_PART_TECH_MODE_MODIFY_TABLE = 1 << 1, |
| 78 |
BD_PART_TECH_MODE_QUERY_TABLE = 1 << 2, |
| 79 |
BD_PART_TECH_MODE_MODIFY_PART = 1 << 3, |
| 80 |
BD_PART_TECH_MODE_QUERY_PART = 1 << 4, |
| 81 |
} BDPartTechMode; |
| 82 |
|
| 83 |
/* |
| 84 |
* If using the plugin as a standalone library, the following functions should |
| 85 |
* be called to: |
| 86 |
* |
| 87 |
* init() - initialize the plugin, returning TRUE on success |
| 88 |
* close() - clean after the plugin at the end or if no longer used |
| 89 |
* |
| 90 |
*/ |
| 91 |
gboolean bd_part_init (void); |
| 92 |
void bd_part_close (void); |
| 93 |
|
| 94 |
gboolean bd_part_is_tech_avail (BDPartTech tech, guint64 mode, GError **error); |
| 95 |
|
| 96 |
gboolean bd_part_create_table (const gchar *disk, BDPartTableType type, gboolean ignore_existing, GError **error); |
| 97 |
|
| 98 |
BDPartSpec* bd_part_get_part_spec (const gchar *disk, const gchar *part, GError **error); |
| 99 |
BDPartSpec* bd_part_get_part_by_pos (const gchar *disk, guint64 position, GError **error); |
| 100 |
BDPartDiskSpec* bd_part_get_disk_spec (const gchar *disk, GError **error); |
| 101 |
BDPartSpec** bd_part_get_disk_parts (const gchar *disk, GError **error); |
| 102 |
BDPartSpec** bd_part_get_disk_free_regions (const gchar *disk, GError **error); |
| 103 |
BDPartSpec* bd_part_get_best_free_region (const gchar *disk, BDPartType type, guint64 size, GError **error); |
| 104 |
|
| 105 |
BDPartSpec* bd_part_create_part (const gchar *disk, BDPartTypeReq type, guint64 start, guint64 size, BDPartAlign align, GError **error); |
| 106 |
gboolean bd_part_delete_part (const gchar *disk, const gchar *part, GError **error); |
| 107 |
gboolean bd_part_resize_part (const gchar *disk, const gchar *part, guint64 size, BDPartAlign align, GError **error); |
| 108 |
|
| 109 |
gboolean bd_part_set_part_name (const gchar *disk, const gchar *part, const gchar *name, GError **error); |
| 110 |
gboolean bd_part_set_part_type (const gchar *disk, const gchar *part, const gchar *type_guid, GError **error); |
| 111 |
gboolean bd_part_set_part_id (const gchar *disk, const gchar *part, const gchar *part_id, GError **error); |
| 112 |
gboolean bd_part_set_part_bootable (const gchar *disk, const gchar *part, gboolean bootable, GError **error); |
| 113 |
gboolean bd_part_set_part_attributes (const gchar *disk, const gchar *part, guint64 attrs, GError **error); |
| 114 |
gboolean bd_part_set_part_uuid (const gchar *disk, const gchar *part, const gchar *uuid, GError **error); |
| 115 |
|
| 116 |
const gchar* bd_part_get_part_table_type_str (BDPartTableType type, GError **error); |
| 117 |
const gchar* bd_part_get_type_str (BDPartType type, GError **error); |
| 118 |
|
| 119 |
#endif /* BD_PART */ |