ia64/xen-unstable

view tools/libfsimage/zfs/fsys_zfs.h @ 19648:f0e2df69a8eb

x86 hvm: Allow cross-vendor migration

Intercept #UD and emulate SYSCALL/SYSENTER/SYSEXIT as necessary.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue May 26 15:01:36 2009 +0100 (2009-05-26)
parents 64f790e90d3d
children
line source
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
4 *
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.
9 *
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.
14 *
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.
18 */
19 /*
20 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
21 * Use is subject to license terms.
22 */
23 #ifndef _FSYS_ZFS_H
24 #define _FSYS_ZFS_H
26 #include <fsimage_grub.h>
27 #include <fsimage_priv.h>
29 #include "zfs-include/zfs.h"
30 #include "zfs-include/dmu.h"
31 #include "zfs-include/spa.h"
32 #include "zfs-include/zio.h"
33 #include "zfs-include/zio_checksum.h"
34 #include "zfs-include/vdev_impl.h"
35 #include "zfs-include/zap_impl.h"
36 #include "zfs-include/zap_leaf.h"
37 #include "zfs-include/uberblock_impl.h"
38 #include "zfs-include/dnode.h"
39 #include "zfs-include/dsl_dir.h"
40 #include "zfs-include/zfs_acl.h"
41 #include "zfs-include/zfs_znode.h"
42 #include "zfs-include/dsl_dataset.h"
43 #include "zfs-include/zil.h"
44 #include "zfs-include/dmu_objset.h"
46 /*
47 * Global Memory addresses to store MOS and DNODE data
48 */
49 #define MOS ((dnode_phys_t *)(((zfs_bootarea_t *) \
50 (ffi->ff_fsi->f_data))->zfs_data))
51 #define DNODE (MOS+1) /* move sizeof(dnode_phys_t) bytes */
52 #define ZFS_SCRATCH ((char *)(DNODE+1))
54 #define MAXNAMELEN 256
56 typedef struct zfs_bootarea {
57 char zfs_current_bootpath[MAXNAMELEN];
58 char zfs_current_rootpool[MAXNAMELEN];
59 char zfs_current_bootfs[MAXNAMELEN];
60 uint64_t zfs_current_bootfs_obj;
61 int zfs_open;
63 /* cache for a file block of the currently zfs_open()-ed file */
64 void *zfs_file_buf;
65 uint64_t zfs_file_start;
66 uint64_t zfs_file_end;
68 /* cache for a dnode block */
69 dnode_phys_t *zfs_dnode_buf;
70 dnode_phys_t *zfs_dnode_mdn;
71 uint64_t zfs_dnode_start;
72 uint64_t zfs_dnode_end;
74 char *zfs_stackbase;
75 char zfs_data[0x400000];
76 } zfs_bootarea_t;
78 /*
79 * Verify dnode type.
80 * Can only be used in functions returning non-0 for failure.
81 */
82 #define VERIFY_DN_TYPE(dnp, type) \
83 if (type && (dnp)->dn_type != type) { \
84 return (ERR_FSYS_CORRUPT); \
85 }
87 /*
88 * Verify object set type.
89 * Can only be used in functions returning 0 for failure.
90 */
91 #define VERIFY_OS_TYPE(osp, type) \
92 if (type && (osp)->os_type != type) { \
93 errnum = ERR_FSYS_CORRUPT; \
94 return (0); \
95 }
97 #define ZPOOL_PROP_BOOTFS "bootfs"
99 /* General macros */
100 #define BSWAP_8(x) ((x) & 0xff)
101 #define BSWAP_16(x) ((BSWAP_8(x) << 8) | BSWAP_8((x) >> 8))
102 #define BSWAP_32(x) ((BSWAP_16(x) << 16) | BSWAP_16((x) >> 16))
103 #define BSWAP_64(x) ((BSWAP_32(x) << 32) | BSWAP_32((x) >> 32))
104 #define P2ROUNDUP(x, align) (-(-(x) & -(align)))
106 /*
107 * XXX Match these macro up with real zfs once we have nvlist support so that we
108 * can support large sector disks.
109 */
110 #define UBERBLOCK_SIZE (1ULL << UBERBLOCK_SHIFT)
111 #undef offsetof
112 #define offsetof(t, m) (size_t)(&(((t *)0)->m))
113 #define VDEV_UBERBLOCK_SHIFT UBERBLOCK_SHIFT
114 #define VDEV_UBERBLOCK_OFFSET(n) \
115 offsetof(vdev_label_t, vl_uberblock[(n) << VDEV_UBERBLOCK_SHIFT])
117 typedef struct uberblock uberblock_t;
119 /* XXX Uberblock_phys_t is no longer in the kernel zfs */
120 typedef struct uberblock_phys {
121 uberblock_t ubp_uberblock;
122 char ubp_pad[UBERBLOCK_SIZE - sizeof (uberblock_t) -
123 sizeof (zio_block_tail_t)];
124 zio_block_tail_t ubp_zbt;
125 } uberblock_phys_t;
127 /*
128 * Macros to get fields in a bp or DVA.
129 */
130 #define P2PHASE(x, align) ((x) & ((align) - 1))
131 #define DVA_OFFSET_TO_PHYS_SECTOR(offset) \
132 ((offset + VDEV_LABEL_START_SIZE) >> SPA_MINBLOCKSHIFT)
134 /*
135 * For nvlist manipulation. (from nvpair.h)
136 */
137 #define NV_ENCODE_NATIVE 0
138 #define NV_ENCODE_XDR 1
139 #define HOST_ENDIAN 1 /* for x86 machine */
140 #define DATA_TYPE_UINT64 8
141 #define DATA_TYPE_STRING 9
142 #define DATA_TYPE_NVLIST 19
143 #define DATA_TYPE_NVLIST_ARRAY 20
145 /*
146 * Decompression Entry - lzjb
147 */
148 #ifndef NBBY
149 #define NBBY 8
150 #endif
152 typedef int zfs_decomp_func_t(void *s_start, void *d_start, size_t s_len,
153 size_t d_len);
154 typedef struct decomp_entry {
155 char *name;
156 zfs_decomp_func_t *decomp_func;
157 } decomp_entry_t;
159 /*
160 * FAT ZAP data structures
161 */
162 #define ZFS_CRC64_POLY 0xC96C5795D7870F42ULL /* ECMA-182, reflected form */
163 #define ZAP_HASH_IDX(hash, n) (((n) == 0) ? 0 : ((hash) >> (64 - (n))))
164 #define CHAIN_END 0xffff /* end of the chunk chain */
166 /*
167 * The amount of space within the chunk available for the array is:
168 * chunk size - space for type (1) - space for next pointer (2)
169 */
170 #define ZAP_LEAF_ARRAY_BYTES (ZAP_LEAF_CHUNKSIZE - 3)
172 #define ZAP_LEAF_HASH_SHIFT(bs) (bs - 5)
173 #define ZAP_LEAF_HASH_NUMENTRIES(bs) (1 << ZAP_LEAF_HASH_SHIFT(bs))
174 #define LEAF_HASH(bs, h) \
175 ((ZAP_LEAF_HASH_NUMENTRIES(bs)-1) & \
176 ((h) >> (64 - ZAP_LEAF_HASH_SHIFT(bs)-l->l_hdr.lh_prefix_len)))
178 /*
179 * The amount of space available for chunks is:
180 * block size shift - hash entry size (2) * number of hash
181 * entries - header space (2*chunksize)
182 */
183 #define ZAP_LEAF_NUMCHUNKS(bs) \
184 (((1<<bs) - 2*ZAP_LEAF_HASH_NUMENTRIES(bs)) / \
185 ZAP_LEAF_CHUNKSIZE - 2)
187 /*
188 * The chunks start immediately after the hash table. The end of the
189 * hash table is at l_hash + HASH_NUMENTRIES, which we simply cast to a
190 * chunk_t.
191 */
192 #define ZAP_LEAF_CHUNK(l, bs, idx) \
193 ((zap_leaf_chunk_t *)(l->l_hash + ZAP_LEAF_HASH_NUMENTRIES(bs)))[idx]
194 #define ZAP_LEAF_ENTRY(l, bs, idx) (&ZAP_LEAF_CHUNK(l, bs, idx).l_entry)
196 extern void fletcher_2_native(const void *, uint64_t, zio_cksum_t *);
197 extern void fletcher_2_byteswap(const void *, uint64_t, zio_cksum_t *);
198 extern void fletcher_4_native(const void *, uint64_t, zio_cksum_t *);
199 extern void fletcher_4_byteswap(const void *, uint64_t, zio_cksum_t *);
200 extern void zio_checksum_SHA256(const void *, uint64_t, zio_cksum_t *);
201 extern int lzjb_decompress(void *, void *, size_t, size_t);
203 #endif /* !_FSYS_ZFS_H */