Changeset 6453e306 in mainline for uspace/lib/mbr/libmbr.h
- Timestamp:
- 2013-12-25T16:09:43Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ac36aed
- Parents:
- d51beba3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/mbr/libmbr.h
rd51beba3 r6453e306 1 1 /* 2 2 * Copyright (c) 2009 Jiri Svoboda 3 * Copyright (c) 2011 , 2012,2013 Dominik Taborsky3 * Copyright (c) 2011-2013 Dominik Taborsky 4 4 * All rights reserved. 5 5 * … … 28 28 */ 29 29 30 30 /** @addtogroup libmbr 31 31 * @{ 32 32 */ … … 40 40 #include "mbr.h" 41 41 42 #define LIBMBR_NAME "libmbr" 42 /* 43 * WARNING: When changing both header and partitions, write first header, 44 * then partitions. The MBR headers' raw_data is not updated to follow 45 * partition changes. 46 * 47 * NOTE: Writing partitions writes the complete header as well. 48 */ 43 49 44 50 typedef enum { … … 48 54 /** Logical partition, 0 = primary, 1 = logical*/ 49 55 ST_LOGIC = 8 50 } MBR_FLAGS;56 } mbr_flags_t; 51 57 52 58 typedef enum { … … 77 83 } mbr_t; 78 84 79 80 85 /** Partition */ 81 86 typedef struct mbr_part { … … 91 96 uint32_t length; 92 97 /** Points to Extended Boot Record of logical partition */ 93 br_block_t * 98 br_block_t *ebr; 94 99 /** EBR address */ 95 100 uint32_t ebr_addr; … … 101 106 unsigned char n_primary; 102 107 /** Index to the extended partition in the array */ 103 link_t * 108 link_t *l_extended; 104 109 /** Number of logical partitions */ 105 110 unsigned int n_logical; … … 111 116 typedef struct mbr_label { 112 117 /** MBR header */ 113 mbr_t * 118 mbr_t *mbr; 114 119 /** Partition list */ 115 120 mbr_partitions_t * parts; … … 118 123 } mbr_label_t; 119 124 120 /* Alloc complete label structure */ 121 extern mbr_label_t * mbr_alloc_label(void); 125 #define mbr_part_foreach(label, iterator) \ 126 for (iterator = list_get_instance((label)->parts->list.head.next, mbr_part_t, link); \ 127 iterator != list_get_instance(&((label)->parts->list.head), mbr_part_t, link); \ 128 iterator = list_get_instance(iterator->link.next, mbr_part_t, link)) 129 130 extern mbr_label_t *mbr_alloc_label(void); 131 122 132 extern void mbr_set_device(mbr_label_t *, service_id_t); 123 124 /* Read/Write MBR header. 125 * WARNING: when changing both header and partitions, write first header, 126 * then partitions. The MBR headers' raw_data is NOT updated to follow 127 * partition changes. */ 128 extern mbr_t * mbr_alloc_mbr(void); 133 extern mbr_t *mbr_alloc_mbr(void); 129 134 extern int mbr_read_mbr(mbr_label_t *, service_id_t); 130 135 extern int mbr_write_mbr(mbr_label_t *, service_id_t); 131 136 extern int mbr_is_mbr(mbr_label_t *); 132 137 133 /* Read/Write/Set MBR partitions. 134 * NOTE: Writing partitions writes the complete header as well. */ 135 extern int mbr_read_partitions(mbr_label_t *); 136 extern int mbr_write_partitions(mbr_label_t *, service_id_t); 137 extern mbr_part_t * mbr_alloc_partition(void); 138 extern mbr_partitions_t * mbr_alloc_partitions(void); 139 extern mbr_err_val mbr_add_partition(mbr_label_t *, mbr_part_t *); 140 extern int mbr_remove_partition(mbr_label_t *, size_t); 141 extern int mbr_get_flag(mbr_part_t *, MBR_FLAGS); 142 extern void mbr_set_flag(mbr_part_t *, MBR_FLAGS, bool); 143 extern uint32_t mbr_get_next_aligned(uint32_t, unsigned int); 144 extern list_t * mbr_get_list(mbr_label_t *); 145 extern mbr_part_t * mbr_get_first_partition(mbr_label_t *); 146 extern mbr_part_t * mbr_get_next_partition(mbr_label_t *, mbr_part_t *); 138 extern int mbr_read_partitions(mbr_label_t *); 139 extern int mbr_write_partitions(mbr_label_t *, service_id_t); 140 extern mbr_part_t *mbr_alloc_partition(void); 141 extern mbr_partitions_t *mbr_alloc_partitions(void); 142 extern mbr_err_val mbr_add_partition(mbr_label_t *, mbr_part_t *); 143 extern int mbr_remove_partition(mbr_label_t *, size_t); 144 extern int mbr_get_flag(mbr_part_t *, mbr_flags_t); 145 extern void mbr_set_flag(mbr_part_t *, mbr_flags_t, bool); 146 extern uint32_t mbr_get_next_aligned(uint32_t, unsigned int); 147 extern list_t *mbr_get_list(mbr_label_t *); 148 extern mbr_part_t *mbr_get_first_partition(mbr_label_t *); 149 extern mbr_part_t *mbr_get_next_partition(mbr_label_t *, mbr_part_t *); 147 150 148 #define mbr_part_foreach(label, iterator) \149 for (iterator = list_get_instance((label)->parts->list.head.next, mbr_part_t, link); \150 iterator != list_get_instance(&((label)->parts->list.head), mbr_part_t, link); \151 iterator = list_get_instance(iterator->link.next, mbr_part_t, link))152 153 154 /* free() wrapper functions. */155 151 extern void mbr_free_label(mbr_label_t *); 156 152 extern void mbr_free_mbr(mbr_t *); … … 159 155 160 156 #endif 161
Note:
See TracChangeset
for help on using the changeset viewer.