reserve_size = expected_num_chunk_entries *
get_chunk_entry_size(res_expected_size,
0 != (ctx->write_resource_flags &
- WIM_RESHDR_FLAG_PACKED_STREAMS));
+ WRITE_RESOURCE_FLAG_PACK_STREAMS));
if (ctx->write_resource_flags & WRITE_RESOURCE_FLAG_PACK_STREAMS)
reserve_size += sizeof(struct alt_chunk_table_header_disk);
memset(ctx->chunk_csizes, 0, reserve_size);
chunk_entry_size = get_chunk_entry_size(res_actual_size,
0 != (ctx->write_resource_flags &
- WIM_RESHDR_FLAG_PACKED_STREAMS));
+ WRITE_RESOURCE_FLAG_PACK_STREAMS));
typedef le64 __attribute__((may_alias)) aliased_le64_t;
typedef le32 __attribute__((may_alias)) aliased_le32_t;
*
* @out_ctype
* Compression format to use to write the output streams, specified as one
- * of the WIMLIB_COMPRESSION_TYPE_* constants, excepting
- * WIMLIB_COMPRESSION_TYPE_INVALID but including
- * WIMLIB_COMPRESSION_TYPE_NONE.
+ * of the WIMLIB_COMPRESSION_TYPE_* constants.
+ * WIMLIB_COMPRESSION_TYPE_NONE is allowed.
*
* @out_chunk_size
* Chunk size to use to write the streams. It must be a valid chunk size
}
#if defined(HAVE_SYS_FILE_H) && defined(HAVE_FLOCK)
+
+/* Set advisory lock on WIM file (if not already done so) */
int
-lock_wim_for_append(WIMStruct *wim, int fd)
+lock_wim_for_append(WIMStruct *wim)
{
if (wim->locked_for_append)
return 0;
- if (!flock(fd, LOCK_EX | LOCK_NB)) {
+ if (!flock(wim->in_fd.fd, LOCK_EX | LOCK_NB)) {
wim->locked_for_append = 1;
return 0;
}
return 0;
return WIMLIB_ERR_ALREADY_LOCKED;
}
+
+/* Remove advisory lock on WIM file (if present) */
void
-unlock_wim_for_append(WIMStruct *wim, int fd)
+unlock_wim_for_append(WIMStruct *wim)
{
if (wim->locked_for_append) {
- flock(fd, LOCK_UN);
+ flock(wim->in_fd.fd, LOCK_UN);
wim->locked_for_append = 0;
}
}
if (ret)
goto out_restore_memory_hdr;
- ret = lock_wim_for_append(wim, wim->out_fd.fd);
+ ret = lock_wim_for_append(wim);
if (ret)
goto out_close_wim;
if (ret)
goto out_truncate;
- /* lock was dropped when file descriptor was closed */
- wim->locked_for_append = 0;
+ unlock_wim_for_append(wim);
return 0;
out_truncate:
out_restore_physical_hdr:
(void)write_wim_header_flags(hdr_save.flags, &wim->out_fd);
out_unlock_wim:
- /* lock is dropped when close_wim_writable() closes the file */
- wim->locked_for_append = 0;
+ unlock_wim_for_append(wim);
out_close_wim:
(void)close_wim_writable(wim, write_flags);
out_restore_memory_hdr: