*
* Support for writing WIM files; write a WIM file, overwrite a WIM file, write
* compressed file resources, etc.
*
* Support for writing WIM files; write a WIM file, overwrite a WIM file, write
* compressed file resources, etc.
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option) any
- * later version.
+ * wimlib is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
- * This library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
- * You should have received a copy of the GNU Lesser General Public License along
- * with this library; if not, write to the Free Software Foundation, Inc., 59
- * Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with wimlib; if not, see http://www.gnu.org/licenses/.
ret = wimlib_write(w, tmpfile, WIM_ALL_IMAGES, flags);
if (ret != 0) {
ret = wimlib_write(w, tmpfile, WIM_ALL_IMAGES, flags);
if (ret != 0) {
/* Rename the new file to the old file .*/
if (rename(tmpfile, wimfile_name) != 0) {
/* Rename the new file to the old file .*/
if (rename(tmpfile, wimfile_name) != 0) {
- ERROR("Failed to rename `%s' to `%s': %m\n", tmpfile,
- wimfile_name);
+ ERROR_WITH_ERRNO("Failed to rename `%s' to `%s'",
+ tmpfile, wimfile_name);
/* Overwrite the XML data. */
if (fseeko(fp, w->hdr.xml_res_entry.offset, SEEK_SET) != 0) {
/* Overwrite the XML data. */
if (fseeko(fp, w->hdr.xml_res_entry.offset, SEEK_SET) != 0) {
- ERROR("Failed to seek to byte %"PRIu64" for XML data: "
- "%m\n", w->hdr.xml_res_entry.offset);
+ ERROR_WITH_ERRNO("Failed to seek to byte %"PRIu64" "
+ "for XML data", w->hdr.xml_res_entry.offset);
w->hdr.integrity.offset = xml_end;
if (integrity_table) {
/* The existing integrity table was saved. */
bytes_written = fwrite(integrity_table, 1,
w->hdr.integrity.size, fp);
if (bytes_written != w->hdr.integrity.size) {
w->hdr.integrity.offset = xml_end;
if (integrity_table) {
/* The existing integrity table was saved. */
bytes_written = fwrite(integrity_table, 1,
w->hdr.integrity.size, fp);
if (bytes_written != w->hdr.integrity.size) {
/* No integrity table to write. The file should be truncated
* because it's possible that the old file was longer (due to it
* including an integrity table, or due to its XML data being
* longer) */
if (fflush(fp) != 0) {
/* No integrity table to write. The file should be truncated
* because it's possible that the old file was longer (due to it
* including an integrity table, or due to its XML data being
* longer) */
if (fflush(fp) != 0) {
/* Overwrite the header. */
if (fseeko(fp, 0, SEEK_SET) != 0) {
/* Overwrite the header. */
if (fseeko(fp, 0, SEEK_SET) != 0) {
- DEBUG("Writing file resources for image %u\n", w->current_image);
- return for_dentry_in_tree(wim_root_dentry(w), write_file_resource, w);
+ DEBUG("Writing file resources for image %u.", w->current_image);
+ return for_dentry_in_tree(wim_root_dentry(w), write_dentry_resources, w);
-/* Write lookup table, xml data, lookup table, and rewrite header
+/* Write the lookup table, xml data, and integrity table, then overwrite the WIM
+ * header.
/* Write the lookup table. */
ret = write_lookup_table(w->lookup_table, out);
if (ret != 0)
/* Write the lookup table. */
ret = write_lookup_table(w->lookup_table, out);
if (ret != 0)
/* @hdr will be the header for the new WIM. First copy all the data
* from the header in the WIMStruct; then set all the fields that may
/* @hdr will be the header for the new WIM. First copy all the data
* from the header in the WIMStruct; then set all the fields that may
sizeof(struct resource_entry));
} else {
memcpy(&hdr.boot_metadata_res_entry,
sizeof(struct resource_entry));
} else {
memcpy(&hdr.boot_metadata_res_entry,
- &w->image_metadata[hdr.boot_idx - 1].lookup_table_entry->
- output_resource_entry,
- sizeof(struct resource_entry));
+ &w->image_metadata[
+ hdr.boot_idx - 1].metadata_lte->output_resource_entry,
+ sizeof(struct resource_entry));
goto done;
}
ret = finish_write(w, image, flags, 1);
done:
goto done;
}
ret = finish_write(w, image, flags, 1);
done: