]> wimlib.net Git - wimlib/blobdiff - src/integrity.c
xml.c: Fix writing <WINDOWS> element
[wimlib] / src / integrity.c
index 1eeb671aa178e93c1eb1ea44a819bc2500e9d53f..b83b9c06279b642cbcd7e8631cc806d47a603eef 100644 (file)
@@ -110,6 +110,7 @@ static int
 read_integrity_table(WIMStruct *wim, u64 num_checked_bytes,
                     struct integrity_table **table_ret)
 {
+       void *buf;
        struct integrity_table *table;
        int ret;
 
@@ -120,9 +121,10 @@ read_integrity_table(WIMStruct *wim, u64 num_checked_bytes,
              "original_size %"PRIu64")",
              wim->hdr.integrity.offset, wim->hdr.integrity.original_size);
 
-       ret = res_entry_to_data(&wim->hdr.integrity, wim, (void**)&table);
+       ret = res_entry_to_data(&wim->hdr.integrity, wim, &buf);
        if (ret)
                return ret;
+       table = buf;
 
        table->size        = le32_to_cpu(table->size);
        table->num_entries = le32_to_cpu(table->num_entries);
@@ -311,9 +313,7 @@ calculate_integrity_table(struct filedes *in_fd,
  *
  * Return values:
  *     WIMLIB_ERR_SUCCESS (0)
- *     WIMLIB_ERR_INVALID_INTEGRITY_TABLE
  *     WIMLIB_ERR_NOMEM
- *     WIMLIB_ERR_READ
  *     WIMLIB_ERR_UNEXPECTED_END_OF_FILE
  *     WIMLIB_ERR_WRITE
  */
@@ -326,16 +326,16 @@ write_integrity_table(WIMStruct *wim,
        struct integrity_table *old_table;
        struct integrity_table *new_table;
        int ret;
-       off_t cur_offset;
        u32 new_table_size;
 
-       wimlib_assert(old_lookup_table_end <= new_lookup_table_end);
+       DEBUG("Writing integrity table "
+             "(new_lookup_table_end=%"PRIu64", old_lookup_table_end=%"PRIu64")",
+             new_lookup_table_end, old_lookup_table_end);
 
-       cur_offset = wim->out_fd.offset;
+       wimlib_assert(old_lookup_table_end <= new_lookup_table_end);
 
-       if (wim->hdr.integrity.offset == 0 || old_lookup_table_end == 0) {
-               old_table = NULL;
-       } else {
+       old_table = NULL;
+       if (wim_has_integrity_table(wim) && old_lookup_table_end != 0) {
                ret = read_integrity_table(wim,
                                           old_lookup_table_end - WIM_HEADER_DISK_SIZE,
                                           &old_table);
@@ -367,10 +367,12 @@ write_integrity_table(WIMStruct *wim,
                                             WIMLIB_COMPRESSION_TYPE_NONE,
                                             &wim->hdr.integrity,
                                             NULL,
-                                            0);
+                                            0,
+                                            &wim->lzx_context);
        FREE(new_table);
 out_free_old_table:
        FREE(old_table);
+       DEBUG("ret=%d", ret);
        return ret;
 }
 
@@ -478,7 +480,7 @@ check_wim_integrity(WIMStruct *wim, wimlib_progress_func_t progress_func)
        struct integrity_table *table;
        u64 end_lookup_table_offset;
 
-       if (wim->hdr.integrity.offset == 0) {
+       if (!wim_has_integrity_table(wim)) {
                DEBUG("No integrity information.");
                return WIM_INTEGRITY_NONEXISTENT;
        }