| 1788 | } |
| 1789 | |
| 1790 | static enum ifwi_ret ifwi_replace(void) |
| 1791 | { |
| 1792 | if (!param.file_name) { |
| 1793 | ERROR("%s: -f option required\n", __func__); |
| 1794 | return COMMAND_ERR; |
| 1795 | } |
| 1796 | |
| 1797 | if (!param.subpart_name) { |
| 1798 | ERROR("%s: -n option required\n", __func__); |
| 1799 | return COMMAND_ERR; |
| 1800 | } |
| 1801 | |
| 1802 | int type = find_type_by_name(param.subpart_name); |
| 1803 | if (type == -1) |
| 1804 | return COMMAND_ERR; |
| 1805 | |
| 1806 | const struct subpart_info *curr_subpart = &subparts[type]; |
| 1807 | |
| 1808 | if (curr_subpart->attr & AUTO_GENERATED) { |
| 1809 | ERROR("Cannot replace auto-generated sub-partitions.\n"); |
| 1810 | return COMMAND_ERR; |
| 1811 | } |
| 1812 | |
| 1813 | if (buffer_size(&ifwi_image.subpart_buf[type]) == 0) { |
| 1814 | ERROR("Image does not contain sub-partition %s(%d).\n", |
| 1815 | param.subpart_name, type); |
| 1816 | return COMMAND_ERR; |
| 1817 | } |
| 1818 | |
| 1819 | if (param.dir_ops) |
| 1820 | return ifwi_dir_replace(type); |
| 1821 | |
| 1822 | return ifwi_raw_replace(type); |
| 1823 | } |
| 1824 | |
| 1825 | static enum ifwi_ret ifwi_create(void) |
| 1826 | { |
nothing calls this directly
no test coverage detected