Deleted Added
full compact
zfsimpl.c (242241) zfsimpl.c (243674)
1/*-
2 * Copyright (c) 2007 Doug Rabson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2007 Doug Rabson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: stable/9/sys/boot/zfs/zfsimpl.c 242241 2012-10-28 16:10:03Z avg $");
28__FBSDID("$FreeBSD: stable/9/sys/boot/zfs/zfsimpl.c 243674 2012-11-29 14:05:04Z mm $");
29
30/*
31 * Stand-alone ZFS file reader.
32 */
33
34#include <sys/stat.h>
35#include <sys/stdint.h>
36

--- 7 unchanged lines hidden (view full) ---

44 uint64_t rootobj;
45};
46
47/*
48 * List of all vdevs, chained through v_alllink.
49 */
50static vdev_list_t zfs_vdevs;
51
29
30/*
31 * Stand-alone ZFS file reader.
32 */
33
34#include <sys/stat.h>
35#include <sys/stdint.h>
36

--- 7 unchanged lines hidden (view full) ---

44 uint64_t rootobj;
45};
46
47/*
48 * List of all vdevs, chained through v_alllink.
49 */
50static vdev_list_t zfs_vdevs;
51
52 /*
53 * List of ZFS features supported for read
54 */
55static const char *features_for_read[] = {
56 NULL
57};
58
52/*
53 * List of all pools, chained through spa_link.
54 */
55static spa_list_t zfs_pools;
56
57static uint64_t zfs_crc64_table[256];
58static const dnode_phys_t *dnode_cache_obj = 0;
59static uint64_t dnode_cache_bn;

--- 135 unchanged lines hidden (view full) ---

195 pair = p;
196 xdr_int(&p, &encoded_size);
197 xdr_int(&p, &decoded_size);
198 }
199
200 return (EIO);
201}
202
59/*
60 * List of all pools, chained through spa_link.
61 */
62static spa_list_t zfs_pools;
63
64static uint64_t zfs_crc64_table[256];
65static const dnode_phys_t *dnode_cache_obj = 0;
66static uint64_t dnode_cache_bn;

--- 135 unchanged lines hidden (view full) ---

202 pair = p;
203 xdr_int(&p, &encoded_size);
204 xdr_int(&p, &decoded_size);
205 }
206
207 return (EIO);
208}
209
210static int
211nvlist_check_features_for_read(const unsigned char *nvlist)
212{
213 const unsigned char *p, *pair;
214 int junk;
215 int encoded_size, decoded_size;
216 int rc;
217
218 rc = 0;
219
220 p = nvlist;
221 xdr_int(&p, &junk);
222 xdr_int(&p, &junk);
223
224 pair = p;
225 xdr_int(&p, &encoded_size);
226 xdr_int(&p, &decoded_size);
227 while (encoded_size && decoded_size) {
228 int namelen, pairtype;
229 const char *pairname;
230 int i, found;
231
232 found = 0;
233
234 xdr_int(&p, &namelen);
235 pairname = (const char*) p;
236 p += roundup(namelen, 4);
237 xdr_int(&p, &pairtype);
238
239 for (i = 0; features_for_read[i] != NULL; i++) {
240 if (!memcmp(pairname, features_for_read[i], namelen)) {
241 found = 1;
242 break;
243 }
244 }
245
246 if (!found) {
247 printf("ZFS: unsupported feature: %s\n", pairname);
248 rc = EIO;
249 }
250
251 p = pair + encoded_size;
252
253 pair = p;
254 xdr_int(&p, &encoded_size);
255 xdr_int(&p, &decoded_size);
256 }
257
258 return (rc);
259}
260
203/*
204 * Return the next nvlist in an nvlist array.
205 */
206static const unsigned char *
207nvlist_next(const unsigned char *nvlist)
208{
209 const unsigned char *p, *pair;
210 int junk;

--- 611 unchanged lines hidden (view full) ---

822 blkptr_t bp;
823 const unsigned char *nvlist;
824 uint64_t val;
825 uint64_t guid;
826 uint64_t pool_txg, pool_guid;
827 uint64_t is_log;
828 const char *pool_name;
829 const unsigned char *vdevs;
261/*
262 * Return the next nvlist in an nvlist array.
263 */
264static const unsigned char *
265nvlist_next(const unsigned char *nvlist)
266{
267 const unsigned char *p, *pair;
268 int junk;

--- 611 unchanged lines hidden (view full) ---

880 blkptr_t bp;
881 const unsigned char *nvlist;
882 uint64_t val;
883 uint64_t guid;
884 uint64_t pool_txg, pool_guid;
885 uint64_t is_log;
886 const char *pool_name;
887 const unsigned char *vdevs;
888 const unsigned char *features;
830 int i, rc, is_newer;
831 char *upbuf;
832 const struct uberblock *up;
833
834 /*
835 * Load the vdev label and figure out which
836 * uberblock is most current.
837 */

--- 18 unchanged lines hidden (view full) ---

856 nvlist = (const unsigned char *) vdev_label->vp_nvlist + 4;
857
858 if (nvlist_find(nvlist,
859 ZPOOL_CONFIG_VERSION,
860 DATA_TYPE_UINT64, 0, &val)) {
861 return (EIO);
862 }
863
889 int i, rc, is_newer;
890 char *upbuf;
891 const struct uberblock *up;
892
893 /*
894 * Load the vdev label and figure out which
895 * uberblock is most current.
896 */

--- 18 unchanged lines hidden (view full) ---

915 nvlist = (const unsigned char *) vdev_label->vp_nvlist + 4;
916
917 if (nvlist_find(nvlist,
918 ZPOOL_CONFIG_VERSION,
919 DATA_TYPE_UINT64, 0, &val)) {
920 return (EIO);
921 }
922
864 if (val > SPA_VERSION) {
923 if (!SPA_VERSION_IS_SUPPORTED(val)) {
865 printf("ZFS: unsupported ZFS version %u (should be %u)\n",
866 (unsigned) val, (unsigned) SPA_VERSION);
867 return (EIO);
868 }
869
924 printf("ZFS: unsupported ZFS version %u (should be %u)\n",
925 (unsigned) val, (unsigned) SPA_VERSION);
926 return (EIO);
927 }
928
929 /* Check ZFS features for read */
870 if (nvlist_find(nvlist,
930 if (nvlist_find(nvlist,
931 ZPOOL_CONFIG_FEATURES_FOR_READ,
932 DATA_TYPE_NVLIST, 0, &features) == 0
933 && nvlist_check_features_for_read(features) != 0)
934 return (EIO);
935
936 if (nvlist_find(nvlist,
871 ZPOOL_CONFIG_POOL_STATE,
872 DATA_TYPE_UINT64, 0, &val)) {
873 return (EIO);
874 }
875
876 if (val == POOL_STATE_DESTROYED) {
877 /* We don't boot only from destroyed pools. */
878 return (EIO);

--- 1157 unchanged lines hidden ---
937 ZPOOL_CONFIG_POOL_STATE,
938 DATA_TYPE_UINT64, 0, &val)) {
939 return (EIO);
940 }
941
942 if (val == POOL_STATE_DESTROYED) {
943 /* We don't boot only from destroyed pools. */
944 return (EIO);

--- 1157 unchanged lines hidden ---