2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
21 * Use is subject to license terms.
26 #include <linux/stat.h>
27 #include <linux/time.h>
28 #include <linux/ctype.h>
29 #include <asm/byteorder.h>
30 #include "zfs_common.h"
34 #include <zfs/dnode.h>
35 #include <zfs/uberblock_impl.h>
36 #include <zfs/vdev_impl.h>
37 #include <zfs/zio_checksum.h>
38 #include <zfs/zap_impl.h>
39 #include <zfs/zap_leaf.h>
40 #include <zfs/zfs_znode.h>
42 #include <zfs/dmu_objset.h>
43 #include <zfs/dsl_dir.h>
44 #include <zfs/dsl_dataset.h>
47 fletcher_2_endian(const void *buf, uint64_t size,
51 const uint64_t *ip = buf;
52 const uint64_t *ipend = ip + (size / sizeof(uint64_t));
53 uint64_t a0, b0, a1, b1;
55 for (a0 = b0 = a1 = b1 = 0; ip < ipend; ip += 2) {
56 a0 += zfs_to_cpu64(ip[0], endian);
57 a1 += zfs_to_cpu64(ip[1], endian);
62 zcp->zc_word[0] = cpu_to_zfs64(a0, endian);
63 zcp->zc_word[1] = cpu_to_zfs64(a1, endian);
64 zcp->zc_word[2] = cpu_to_zfs64(b0, endian);
65 zcp->zc_word[3] = cpu_to_zfs64(b1, endian);
69 fletcher_4_endian(const void *buf, uint64_t size, zfs_endian_t endian,
72 const uint32_t *ip = buf;
73 const uint32_t *ipend = ip + (size / sizeof(uint32_t));
76 for (a = b = c = d = 0; ip < ipend; ip++) {
77 a += zfs_to_cpu32(ip[0], endian);
83 zcp->zc_word[0] = cpu_to_zfs64(a, endian);
84 zcp->zc_word[1] = cpu_to_zfs64(b, endian);
85 zcp->zc_word[2] = cpu_to_zfs64(c, endian);
86 zcp->zc_word[3] = cpu_to_zfs64(d, endian);