| 1177 | } |
| 1178 | |
| 1179 | static void write_regions(char *image, int size) |
| 1180 | { |
| 1181 | unsigned int i; |
| 1182 | const struct frba *frba = find_frba(image, size); |
| 1183 | |
| 1184 | if (!frba) |
| 1185 | exit(EXIT_FAILURE); |
| 1186 | |
| 1187 | for (i = 0; i < max_regions; i++) { |
| 1188 | struct region region = get_region(frba, i); |
| 1189 | dump_region(i, frba); |
| 1190 | if (region.size > 0) { |
| 1191 | int region_fd; |
| 1192 | region_fd = open(region_names[i].filename, |
| 1193 | O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, |
| 1194 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 1195 | if (region_fd < 0) { |
| 1196 | perror("Error while trying to open file"); |
| 1197 | exit(EXIT_FAILURE); |
| 1198 | } |
| 1199 | if (write(region_fd, image + region.base, region.size) != region.size) |
| 1200 | perror("Error while writing"); |
| 1201 | close(region_fd); |
| 1202 | } |
| 1203 | } |
| 1204 | } |
| 1205 | |
| 1206 | static void validate_layout(char *image, int size) |
| 1207 | { |
no test coverage detected