]> wimlib.net Git - wimlib/blobdiff - src/integrity.c
--disable-verify-compression by default
[wimlib] / src / integrity.c
index 837a1d8dbbdc1a117ddc32848f1409c651656b56..bbabaea289a2680180f227284c4b867ae9af3323 100644 (file)
@@ -3,11 +3,11 @@
  *
  * WIM files can optionally contain a table of SHA1 message digests at the end,
  * one digest for each chunk of the file of some specified size (often 10 MB).
- * This file implements the checking and writing this table.
+ * This file implements the checking and writing of this table.
  */
 
 /*
- * Copyright (C) 2012 Eric Biggers
+ * Copyright (C) 2012, 2013 Eric Biggers
  *
  * This file is part of wimlib, a library for working with WIM files.
  *
@@ -45,8 +45,9 @@ struct integrity_table {
        u8  sha1sums[0][20];
 };
 
-static int calculate_chunk_sha1(FILE *fp, size_t this_chunk_size,
-                               off_t offset, u8 sha1_md[])
+static int
+calculate_chunk_sha1(FILE *fp, size_t this_chunk_size,
+                    off_t offset, u8 sha1_md[])
 {
        int ret;
        u8 buf[BUFFER_SIZE];
@@ -86,7 +87,7 @@ static int calculate_chunk_sha1(FILE *fp, size_t this_chunk_size,
 
 
 /*
- * Reads the integrity table from a WIM file.
+ * read_integrity_table: -  Reads the integrity table from a WIM file.
  *
  * @res_entry:
  *     The resource entry that specifies the location of the integrity table.
@@ -109,10 +110,11 @@ static int calculate_chunk_sha1(FILE *fp, size_t this_chunk_size,
  *                                 data.
  *     * WIMLIB_ERR_READ:   Could not read the integrity data from the WIM file.
  */
-static int read_integrity_table(const struct resource_entry *res_entry,
-                               FILE *fp,
-                               u64 num_checked_bytes,
-                               struct integrity_table **table_ret)
+static int
+read_integrity_table(const struct resource_entry *res_entry,
+                    FILE *fp,
+                    u64 num_checked_bytes,
+                    struct integrity_table **table_ret)
 {
        struct integrity_table *table = NULL;
        int ret = 0;
@@ -199,6 +201,8 @@ out:
 }
 
 /*
+ * calculate_integrity_table():
+ *
  * Calculates an integrity table for the data in a file beginning at offset 208
  * (WIM_HEADER_DISK_SIZE).
  *
@@ -210,7 +214,7 @@ out:
  *     Offset of byte after the last byte to be checked.
  *
  * @old_table:
- *     If non-NULL, a pointer to the table containing previously contained
+ *     If non-NULL, a pointer to the table containing the previously calculated
  *     integrity data for a prefix of this file.
  *
  * @old_check_end:
@@ -227,12 +231,13 @@ out:
  *
  * Returns 0 on success; nonzero on failure.
  */
-static int calculate_integrity_table(FILE *fp,
-                                    off_t new_check_end,
-                                    const struct integrity_table *old_table,
-                                    off_t old_check_end,
-                                    wimlib_progress_func_t progress_func,
-                                    struct integrity_table **integrity_table_ret)
+static int
+calculate_integrity_table(FILE *fp,
+                         off_t new_check_end,
+                         const struct integrity_table *old_table,
+                         off_t old_check_end,
+                         wimlib_progress_func_t progress_func,
+                         struct integrity_table **integrity_table_ret)
 {
        int ret = 0;
        size_t chunk_size = INTEGRITY_CHUNK_SIZE;
@@ -317,6 +322,8 @@ static int calculate_integrity_table(FILE *fp,
 }
 
 /*
+ * write_integrity_table():
+ *
  * Writes a WIM integrity table (a list of SHA1 message digests of raw 10 MiB
  * chunks of the file).
  *
@@ -356,11 +363,12 @@ static int calculate_integrity_table(FILE *fp,
  *        * WIMLIB_ERR_READ:   Could not read a chunk of data that needed
  *                             to be checked.
  */
-int write_integrity_table(FILE *fp,
-                         struct resource_entry *integrity_res_entry,
-                         off_t new_lookup_table_end,
-                         off_t old_lookup_table_end,
-                         wimlib_progress_func_t progress_func)
+int
+write_integrity_table(FILE *fp,
+                     struct resource_entry *integrity_res_entry,
+                     off_t new_lookup_table_end,
+                     off_t old_lookup_table_end,
+                     wimlib_progress_func_t progress_func)
 {
        struct integrity_table *old_table;
        struct integrity_table *new_table;
@@ -426,6 +434,8 @@ out_free_old_table:
 }
 
 /*
+ * verify_integrity():
+ *
  * Checks a WIM for consistency with the integrity table.
  *
  * @fp:
@@ -448,10 +458,11 @@ out_free_old_table:
  *     were no inconsistencies.
  *     -1 (WIM_INTEGRITY_NOT_OK) if the WIM failed the integrity check.
  */
-static int verify_integrity(FILE *fp, const char *filename,
-                           const struct integrity_table *table,
-                           u64 bytes_to_check,
-                           wimlib_progress_func_t progress_func)
+static int
+verify_integrity(FILE *fp, const tchar *filename,
+                const struct integrity_table *table,
+                u64 bytes_to_check,
+                wimlib_progress_func_t progress_func)
 {
        int ret;
        u64 offset = WIM_HEADER_DISK_SIZE;
@@ -496,6 +507,8 @@ static int verify_integrity(FILE *fp, const char *filename,
 
 
 /*
+ * check_wim_integrity():
+ *
  * Verifies the integrity of the WIM by making sure the SHA1 message digests of
  * ~10 MiB chunks of the WIM match up with the values given in the integrity
  * table.
@@ -515,7 +528,8 @@ static int verify_integrity(FILE *fp, const char *filename,
  *     -2 (WIM_INTEGRITY_NONEXISTENT) if the WIM contains no integrity
  *     information.
  */
-int check_wim_integrity(WIMStruct *w, wimlib_progress_func_t progress_func)
+int
+check_wim_integrity(WIMStruct *w, wimlib_progress_func_t progress_func)
 {
        int ret;
        u64 bytes_to_check;