Changes in uspace/lib/mbr/libmbr.h [9bda5d90:a2aa81cb] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/mbr/libmbr.h
r9bda5d90 ra2aa81cb 1 1 /* 2 * Copyright (c) 2009 Jiri Svoboda 2 3 * Copyright (c) 2011, 2012, 2013 Dominik Taborsky 3 4 * All rights reserved. … … 73 74 74 75 typedef enum { 76 /** Other flags unknown - saving previous state */ 75 77 /** Bootability */ 76 ST_BOOT = 0,78 ST_BOOT = 7, 77 79 /** Logical partition, 0 = primary, 1 = logical*/ 78 ST_LOGIC = 180 ST_LOGIC = 8 79 81 } MBR_FLAGS; 80 82 … … 101 103 /** Partition overlapping */ 102 104 ERR_OVERLAP, 103 /** Logical partition out of bounds */105 /** Partition out of bounds */ 104 106 ERR_OUT_BOUNDS, 105 107 /** No space left for EBR */ … … 107 109 /** Out of memory */ 108 110 ERR_NOMEM, 109 } MBR_ERR_VAL; 111 /** Libblock error */ 112 ERR_LIBBLOCK, 113 } mbr_err_val; 110 114 111 115 … … 143 147 /** Raw access to data */ 144 148 br_block_t raw_data; 145 /** Device where the data are from */146 service_id_t device;147 149 } mbr_t; 148 150 … … 155 157 uint8_t type; 156 158 /** Flags */ 157 uint 8_t status;159 uint16_t status; 158 160 /** Address of first block */ 159 161 uint32_t start_addr; … … 179 181 180 182 /** Both header and partition list */ 181 typedef struct mbr_table { 183 typedef struct mbr_label { 184 /** MBR header */ 182 185 mbr_t * mbr; 186 /** Partition list */ 183 187 mbr_partitions_t * parts; 184 } mbr_table_t; 185 186 /** Read/Write MBR header. 188 /** Device where the data are from (or for) */ 189 service_id_t device; 190 } mbr_label_t; 191 192 /* Alloc complete label structure */ 193 extern mbr_label_t * mbr_alloc_label(void); 194 195 /* Read/Write MBR header. 187 196 * WARNING: when changing both header and partitions, write first header, 188 197 * then partitions. The MBR headers' raw_data is NOT updated to follow 189 198 * partition changes. */ 190 199 extern mbr_t * mbr_alloc_mbr(void); 191 extern mbr_t * mbr_read_mbr(service_id_t dev_handle);192 extern int mbr_write_mbr(mbr_ t * mbr, service_id_t dev_handle);193 extern int mbr_is_mbr(mbr_ t * mbr);194 195 /* *Read/Write/Set MBR partitions.200 extern int mbr_read_mbr(mbr_label_t *, service_id_t); 201 extern int mbr_write_mbr(mbr_label_t *, service_id_t); 202 extern int mbr_is_mbr(mbr_label_t *); 203 204 /* Read/Write/Set MBR partitions. 196 205 * NOTE: Writing partitions writes the complete header as well. */ 197 extern mbr_partitions_t * mbr_read_partitions(mbr_t * mbr);198 extern int mbr_write_partitions(mbr_partitions_t * parts, mbr_t * mbr, service_id_t dev_handle);199 extern mbr_part_t * 206 extern int mbr_read_partitions(mbr_label_t *); 207 extern int mbr_write_partitions(mbr_label_t *, service_id_t); 208 extern mbr_part_t * mbr_alloc_partition(void); 200 209 extern mbr_partitions_t * mbr_alloc_partitions(void); 201 extern MBR_ERR_VAL mbr_add_partition(mbr_partitions_t * parts, mbr_part_t * partition);202 extern int mbr_remove_partition(mbr_partitions_t * parts, size_t idx);203 extern int mbr_get_flag(mbr_part_t * p, MBR_FLAGS flag);204 extern void mbr_set_flag(mbr_part_t * p, MBR_FLAGS flag, bool value);205 extern uint32_t mbr_get_next_aligned(uint32_t addr, unsigned int alignment);210 extern mbr_err_val mbr_add_partition(mbr_label_t *, mbr_part_t *); 211 extern int mbr_remove_partition(mbr_label_t *, size_t); 212 extern int mbr_get_flag(mbr_part_t *, MBR_FLAGS); 213 extern void mbr_set_flag(mbr_part_t *, MBR_FLAGS, bool); 214 extern uint32_t mbr_get_next_aligned(uint32_t, unsigned int); 206 215 207 216 #define mbr_part_foreach(parts, iterator) \ 208 for (iterator = list_get_instance((parts)->list.head.next, mbr_part_t, link); \ 209 iterator != list_get_instance(&((parts)->list.head), mbr_part_t, link); \ 210 iterator = list_get_instance(iterator->link.next, mbr_part_t, link)) 211 212 213 /** free() wrapper functions. */ 214 extern void mbr_free_mbr(mbr_t * mbr); 215 extern void mbr_free_partition(mbr_part_t * p); 216 extern void mbr_free_partitions(mbr_partitions_t * parts); 217 for (iterator = list_get_instance((parts)->list.head.next, mbr_part_t, link); \ 218 iterator != list_get_instance(&((parts)->list.head), mbr_part_t, link); \ 219 iterator = list_get_instance(iterator->link.next, mbr_part_t, link)) 220 221 222 /* free() wrapper functions. */ 223 extern void mbr_free_label(mbr_label_t *); 224 extern void mbr_free_mbr(mbr_t *); 225 extern void mbr_free_partition(mbr_part_t *); 226 extern void mbr_free_partitions(mbr_partitions_t *); 217 227 218 228 #endif
Note:
See TracChangeset
for help on using the changeset viewer.