Changeset 1626cd4 in mainline for uspace/lib/label/src/gpt.c
- Timestamp:
- 2015-07-02T19:01:37Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6a0d4ce2
- Parents:
- 3faa03d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/label/src/gpt.c
r3faa03d r1626cd4 37 37 #include <byteorder.h> 38 38 #include <errno.h> 39 #include <mem.h> 39 40 #include <stdlib.h> 40 41 … … 46 47 static void gpt_close(label_t *); 47 48 static int gpt_destroy(label_t *); 49 static int gpt_get_info(label_t *, label_info_t *); 48 50 static label_part_t *gpt_part_first(label_t *); 49 51 static label_part_t *gpt_part_next(label_part_t *); … … 52 54 static int gpt_part_destroy(label_part_t *); 53 55 54 static int gpt_pte_to_part(label_t *, gpt_entry_t * );56 static int gpt_pte_to_part(label_t *, gpt_entry_t *, int); 55 57 56 58 const uint8_t efi_signature[8] = { … … 64 66 .close = gpt_close, 65 67 .destroy = gpt_destroy, 68 .get_info = gpt_get_info, 66 69 .part_first = gpt_part_first, 67 70 .part_next = gpt_part_next, … … 83 86 uint64_t ba; 84 87 uint32_t entry; 88 uint64_t ba_min, ba_max; 85 89 int i; 86 90 int rc; … … 126 130 bcnt = (num_entries + esize - 1) / esize; 127 131 ba = uint64_t_le2host(gpt_hdr->entry_lba); 132 ba_min = uint64_t_le2host(gpt_hdr->first_usable_lba); 133 ba_max = uint64_t_le2host(gpt_hdr->last_usable_lba); 128 134 129 135 if (num_entries < 1) { … … 133 139 134 140 if (esize < sizeof(gpt_entry_t)) { 141 rc = EINVAL; 142 goto error; 143 } 144 145 if (ba_max < ba_min) { 135 146 rc = EINVAL; 136 147 goto error; … … 151 162 for (entry = 0; entry < num_entries; entry++) { 152 163 eptr = (gpt_entry_t *)(etable + entry * esize); 153 rc = gpt_pte_to_part(label, eptr );164 rc = gpt_pte_to_part(label, eptr, entry + 1); 154 165 if (rc != EOK) 155 166 goto error; … … 163 174 label->ops = &gpt_label_ops; 164 175 label->ltype = lt_gpt; 176 label->ablock0 = ba_min; 177 label->anblocks = ba_max - ba_min + 1; 165 178 *rlabel = label; 166 179 return EOK; … … 187 200 } 188 201 202 static int gpt_get_info(label_t *label, label_info_t *linfo) 203 { 204 memset(linfo, 0, sizeof(label_info_t)); 205 linfo->dcnt = dc_label; 206 linfo->ltype = lt_gpt; 207 linfo->ablock0 = label->ablock0; 208 linfo->anblocks = label->anblocks; 209 return EOK; 210 } 211 189 212 static label_part_t *gpt_part_first(label_t *label) 190 213 { … … 211 234 static void gpt_part_get_info(label_part_t *part, label_part_info_t *pinfo) 212 235 { 236 pinfo->index = part->index; 213 237 pinfo->block0 = part->block0; 214 238 pinfo->nblocks = part->nblocks; … … 218 242 label_part_t **rpart) 219 243 { 220 return E OK;244 return ENOTSUP; 221 245 } 222 246 223 247 static int gpt_part_destroy(label_part_t *part) 224 248 { 225 return E OK;226 } 227 228 static int gpt_pte_to_part(label_t *label, gpt_entry_t *pte )249 return ENOTSUP; 250 } 251 252 static int gpt_pte_to_part(label_t *label, gpt_entry_t *pte, int index) 229 253 { 230 254 label_part_t *part; … … 250 274 return EINVAL; 251 275 276 part->index = index; 252 277 part->block0 = b0; 253 278 part->nblocks = b1 - b0 + 1;
Note:
See TracChangeset
for help on using the changeset viewer.