- u8 buf[4];
- put_u16(&buf[0], i);
- put_u16(&buf[2], total_parts);
-
- if (fseek(fp, 40, SEEK_SET) != 0 ||
- fwrite(buf, 1, sizeof(buf), fp) != sizeof(buf) ||
- fclose(fp) != 0)
- {
- ERROR_WITH_ERRNO("Error overwriting header of `%"TS"'",
+ put_u16(&part_data_buf[0], i);
+ put_u16(&part_data_buf[2], total_parts);
+
+ bytes_written = full_pwrite(part_fd, part_data_buf,
+ sizeof(part_data_buf), 40);
+ ret = close(part_fd);
+ if (bytes_written != sizeof(part_data_buf) || ret != 0) {
+ ERROR_WITH_ERRNO("Error updating header of `%"TS"'",