*/
/*
- * Copyright (C) 2012, 2013, 2014, 2015 Eric Biggers
+ * Copyright (C) 2012-2016 Eric Biggers
*
* This file 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
blob_hdr.flags = cpu_to_le32(reshdr_flags);
ret = full_write(out_fd, &blob_hdr, sizeof(blob_hdr));
if (ret)
- ERROR_WITH_ERRNO("Write error");
+ ERROR_WITH_ERRNO("Error writing blob header to WIM file");
return ret;
}
reserve_size += sizeof(struct alt_chunk_table_header_disk);
memset(ctx->chunk_csizes, 0, reserve_size);
ret = full_write(ctx->out_fd, ctx->chunk_csizes, reserve_size);
- if (ret)
+ if (ret) {
+ ERROR_WITH_ERRNO("Error reserving space for chunk "
+ "table in WIM file");
return ret;
+ }
}
return 0;
}
return 0;
write_error:
- ERROR_WITH_ERRNO("Write error");
+ ERROR_WITH_ERRNO("Error writing chunk table to WIM file");
return ret;
}
{
int ret;
struct wim_inode *inode;
+ const tchar *path;
tchar *cookie1;
tchar *cookie2;
if (--inode->i_num_remaining_streams > 0)
return 0;
- cookie1 = progress_get_streamless_path(blob->file_on_disk);
- cookie2 = progress_get_win32_path(blob->file_on_disk);
+ path = blob_file_path(blob);
- ret = done_with_file(blob->file_on_disk, progfunc, progctx);
+ cookie1 = progress_get_streamless_path(path);
+ cookie2 = progress_get_win32_path(path);
+
+ ret = done_with_file(path, progfunc, progctx);
progress_put_win32_path(cookie2);
progress_put_streamless_path(cookie1);
* Exception: if the compressed size happens to be *exactly* the same as
* the uncompressed size, then the blob *must* be written uncompressed
* in order to remain compatible with the Windows Overlay Filesystem
- * Filter Driver (WOF).
+ * filter driver (WOF).
*
* TODO: we are currently assuming that the optimization for
* single-chunk resources in maybe_rewrite_blob_uncompressed() prevents
completed_blob_count, false);
write_error:
- ERROR_WITH_ERRNO("Write error");
+ ERROR_WITH_ERRNO("Error writing chunk data to WIM file");
return ret;
}
ret = full_pread(in_fd, buf, bytes_to_read,
cur_read_offset);
- if (ret)
+ if (ret) {
+ ERROR_WITH_ERRNO("Error reading raw data "
+ "from WIM file");
return ret;
+ }
ret = full_write(out_fd, buf, bytes_to_read);
- if (ret)
+ if (ret) {
+ ERROR_WITH_ERRNO("Error writing raw data "
+ "to WIM file");
return ret;
+ }
cur_read_offset += bytes_to_read;
ret = WIMLIB_ERR_WRITE;
if (unlikely(write_flags & WIMLIB_WRITE_FLAG_UNSAFE_COMPACT)) {
/* Truncate any data the compaction freed up. */
- if (ftruncate(wim->out_fd.fd, wim->out_fd.offset)) {
+ if (ftruncate(wim->out_fd.fd, wim->out_fd.offset) &&
+ errno != EINVAL) /* allow compaction on untruncatable files,
+ e.g. block devices */
+ {
ERROR_WITH_ERRNO("Failed to truncate the output WIM file");
goto out;
}
WIMLIB_WRITE_FLAG_UNSAFE_COMPACT))) {
WARNING("Truncating \"%"TS"\" to its original size "
"(%"PRIu64" bytes)", wim->filename, old_wim_end);
- /* Return value of ftruncate() is ignored because this is
- * already an error path. */
- (void)ftruncate(wim->out_fd.fd, old_wim_end);
+ if (ftruncate(wim->out_fd.fd, old_wim_end))
+ WARNING_WITH_ERRNO("Failed to truncate WIM file!");
}
out_restore_hdr:
(void)write_wim_header_flags(wim->hdr.flags, &wim->out_fd);