| 1560 | } |
| 1561 | |
| 1562 | static enum ifwi_ret ifwi_dir_extract(int type) |
| 1563 | { |
| 1564 | if (!(subparts[type].attr & CONTAINS_DIR)) { |
| 1565 | ERROR("Sub-Partition %s(%d) does not support dir ops.\n", |
| 1566 | subparts[type].name, type); |
| 1567 | return COMMAND_ERR; |
| 1568 | } |
| 1569 | |
| 1570 | if (!param.dentry_name) { |
| 1571 | ERROR("%s: -e option required.\n", __func__); |
| 1572 | return COMMAND_ERR; |
| 1573 | } |
| 1574 | |
| 1575 | struct buffer subpart_dir_buff; |
| 1576 | parse_subpart_dir(&subpart_dir_buff, &ifwi_image.subpart_buf[type], |
| 1577 | subparts[type].name); |
| 1578 | |
| 1579 | uint32_t i; |
| 1580 | struct subpart_dir *s = buffer_get(&subpart_dir_buff); |
| 1581 | |
| 1582 | for (i = 0; i < s->h.num_entries; i++) { |
| 1583 | if (!strncmp((char *)s->e[i].name, param.dentry_name, |
| 1584 | sizeof(s->e[i].name))) |
| 1585 | break; |
| 1586 | } |
| 1587 | |
| 1588 | if (i == s->h.num_entries) { |
| 1589 | ERROR("Entry %s not found in subpartition for %s.\n", |
| 1590 | param.dentry_name, param.subpart_name); |
| 1591 | exit(-1); |
| 1592 | } |
| 1593 | |
| 1594 | struct buffer dst; |
| 1595 | |
| 1596 | DEBUG("Splicing buffer at 0x%x size 0x%x\n", s->e[i].offset, |
| 1597 | s->e[i].length); |
| 1598 | buffer_splice(&dst, &ifwi_image.subpart_buf[type], s->e[i].offset, |
| 1599 | s->e[i].length); |
| 1600 | |
| 1601 | if (buffer_write_file(&dst, param.file_name)) |
| 1602 | return COMMAND_ERR; |
| 1603 | |
| 1604 | printf("Sub-Partition %s(%d), entry(%s) stored in %s.\n", |
| 1605 | param.subpart_name, type, param.dentry_name, param.file_name); |
| 1606 | |
| 1607 | return NO_ACTION_REQUIRED; |
| 1608 | } |
| 1609 | |
| 1610 | static enum ifwi_ret ifwi_raw_extract(int type) |
| 1611 | { |
no test coverage detected