]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
cramfs: revert crc32 changes
authorKarel Zak <kzak@redhat.com>
Wed, 19 Oct 2016 11:33:15 +0000 (13:33 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 19 Oct 2016 11:33:15 +0000 (13:33 +0200)
We cannot use our crc32 without changes in the code, because our
ul_crc32() assumes that post-conditioning (xor) is done by
application. The zlib implementation does everything.

Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/fsck.cramfs.c
disk-utils/mkfs.cramfs.c

index 173ac9b4aea291e5103f09744dd8811912e25431..915c0c93c35c2e22d28babe8b066c54563dccca0 100644 (file)
 #include <getopt.h>
 #include <utime.h>
 #include <fcntl.h>
+
+/* We don't use our include/crc32.h, but crc32 from zlib!
+ *
+ * The zlib implemenation performs pre/post-conditioning. The util-linux
+ * imlemenation requires post-conditioning (xor) in the applications.
+ */
 #include <zlib.h>
 
 #include <sys/types.h>
@@ -53,7 +59,6 @@
 #include "c.h"
 #include "cramfs.h"
 #include "nls.h"
-#include "crc32.h"
 #include "blkdev.h"
 #include "exitcodes.h"
 #include "strutils.h"
@@ -215,7 +220,7 @@ static void test_crc(int start)
                return;
        }
 
-       crc = ul_crc32(0L, Z_NULL, 0);
+       crc = crc32(0L, Z_NULL, 0);
 
        buf =
            mmap(NULL, super.size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
@@ -232,8 +237,8 @@ static void test_crc(int start)
        }
        if (buf != MAP_FAILED) {
                ((struct cramfs_super *)((unsigned char *) buf + start))->fsid.crc =
-                   ul_crc32(0L, Z_NULL, 0);
-               crc = ul_crc32(crc, (unsigned char *) buf + start, super.size - start);
+                   crc32(0L, Z_NULL, 0);
+               crc = crc32(crc, (unsigned char *) buf + start, super.size - start);
                munmap(buf, super.size);
        } else {
                int retval;
@@ -250,15 +255,15 @@ static void test_crc(int start)
                                break;
                        if (length == 0)
                                ((struct cramfs_super *)buf)->fsid.crc =
-                                   ul_crc32(0L, Z_NULL, 0);
+                                   crc32(0L, Z_NULL, 0);
                        length += retval;
                        if (length > (super.size - start)) {
-                               crc = ul_crc32(crc, buf,
+                               crc = crc32(crc, buf,
                                          retval - (length -
                                                    (super.size - start)));
                                break;
                        }
-                       crc = ul_crc32(crc, buf, retval);
+                       crc = crc32(crc, buf, retval);
                }
                free(buf);
        }
index 098f9afaf5087cd1d8b917cf7ed598bbcfaac08d..bf7f00838745118f9c10627c029f53d9937c06f2 100644 (file)
 #include <string.h>
 #include <getopt.h>
 #include <zconf.h>
+
+/* We don't use our include/crc32.h, but crc32 from zlib!
+ *
+ * The zlib implemenation performs pre/post-conditioning. The util-linux
+ * imlemenation requires post-conditioning (xor) in the applications.
+ */
 #include <zlib.h>
 
 #include "c.h"
 #include "cramfs.h"
-#include "crc32.h"
 #include "md5.h"
 #include "nls.h"
 #include "exitcodes.h"
@@ -407,7 +412,7 @@ static unsigned int write_superblock(struct entry *root, char *base, int size)
        super->size = size;
        memcpy(super->signature, CRAMFS_SIGNATURE, sizeof(super->signature));
 
-       super->fsid.crc = ul_crc32(0L, Z_NULL, 0);
+       super->fsid.crc = crc32(0L, Z_NULL, 0);
        super->fsid.edition = opt_edition;
        super->fsid.blocks = total_blocks;
        super->fsid.files = total_nodes;
@@ -701,7 +706,7 @@ int main(int argc, char **argv)
        loff_t fslen_ub = sizeof(struct cramfs_super);
        unsigned int fslen_max;
        char const *dirname, *outfile;
-       uint32_t crc = ul_crc32(0L, Z_NULL, 0);
+       uint32_t crc = crc32(0L, Z_NULL, 0);
        int c;
        cramfs_is_big_endian = HOST_IS_BIG_ENDIAN; /* default is to use host order */
 
@@ -857,7 +862,7 @@ int main(int argc, char **argv)
                       sizeof(struct cramfs_super));
 
        /* Put the checksum in. */
-       crc = ul_crc32(crc, (unsigned char *) (rom_image+opt_pad), (offset-opt_pad));
+       crc = crc32(crc, (unsigned char *) (rom_image+opt_pad), (offset-opt_pad));
        ((struct cramfs_super *) (rom_image+opt_pad))->fsid.crc = u32_toggle_endianness(cramfs_is_big_endian, crc);
        if (verbose)
                printf(_("CRC: %x\n"), crc);