]>
git.ipfire.org Git - people/ms/u-boot.git/blob - fs/zfs/zfs_fletcher.c
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
5 * SPDX-License-Identifier: GPL-2.0+
8 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
9 * Use is subject to license terms.
14 #include <linux/stat.h>
15 #include <linux/time.h>
16 #include <linux/ctype.h>
17 #include <asm/byteorder.h>
18 #include "zfs_common.h"
22 #include <zfs/dnode.h>
23 #include <zfs/uberblock_impl.h>
24 #include <zfs/vdev_impl.h>
25 #include <zfs/zio_checksum.h>
26 #include <zfs/zap_impl.h>
27 #include <zfs/zap_leaf.h>
28 #include <zfs/zfs_znode.h>
30 #include <zfs/dmu_objset.h>
31 #include <zfs/dsl_dir.h>
32 #include <zfs/dsl_dataset.h>
35 fletcher_2_endian(const void *buf
, uint64_t size
,
39 const uint64_t *ip
= buf
;
40 const uint64_t *ipend
= ip
+ (size
/ sizeof(uint64_t));
41 uint64_t a0
, b0
, a1
, b1
;
43 for (a0
= b0
= a1
= b1
= 0; ip
< ipend
; ip
+= 2) {
44 a0
+= zfs_to_cpu64(ip
[0], endian
);
45 a1
+= zfs_to_cpu64(ip
[1], endian
);
50 zcp
->zc_word
[0] = cpu_to_zfs64(a0
, endian
);
51 zcp
->zc_word
[1] = cpu_to_zfs64(a1
, endian
);
52 zcp
->zc_word
[2] = cpu_to_zfs64(b0
, endian
);
53 zcp
->zc_word
[3] = cpu_to_zfs64(b1
, endian
);
57 fletcher_4_endian(const void *buf
, uint64_t size
, zfs_endian_t endian
,
60 const uint32_t *ip
= buf
;
61 const uint32_t *ipend
= ip
+ (size
/ sizeof(uint32_t));
64 for (a
= b
= c
= d
= 0; ip
< ipend
; ip
++) {
65 a
+= zfs_to_cpu32(ip
[0], endian
);
71 zcp
->zc_word
[0] = cpu_to_zfs64(a
, endian
);
72 zcp
->zc_word
[1] = cpu_to_zfs64(b
, endian
);
73 zcp
->zc_word
[2] = cpu_to_zfs64(c
, endian
);
74 zcp
->zc_word
[3] = cpu_to_zfs64(d
, endian
);