]> wimlib.net Git - wimlib/blobdiff - src/write.c
Remove WIMLIB_COMPRESSION_TYPE_INVALID from library
[wimlib] / src / write.c
index 0114618f1658384dc1a99401bc7ba615f35413bd..5bca038a61afd909b5d868391ed21ebf37d49a5c 100644 (file)
@@ -451,7 +451,7 @@ begin_chunk_table(struct write_streams_ctx *ctx, u64 res_expected_size)
                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);
@@ -499,7 +499,7 @@ end_chunk_table(struct write_streams_ctx *ctx, u64 res_actual_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;
@@ -1261,9 +1261,8 @@ remove_zero_length_streams(struct list_head *stream_list)
  *
  * @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
@@ -2400,12 +2399,14 @@ finish_write(WIMStruct *wim, int image, int write_flags,
 }
 
 #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;
        }
@@ -2413,11 +2414,13 @@ lock_wim_for_append(WIMStruct *wim, int fd)
                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;
        }
 }
@@ -3060,7 +3063,7 @@ overwrite_wim_inplace(WIMStruct *wim, int write_flags, unsigned num_threads)
        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;
 
@@ -3096,8 +3099,7 @@ overwrite_wim_inplace(WIMStruct *wim, int write_flags, unsigned num_threads)
        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:
@@ -3111,8 +3113,7 @@ 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: