Deleted Added
full compact
zfsimpl.c (235390) zfsimpl.c (236884)
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: head/sys/boot/zfs/zfsimpl.c 235390 2012-05-13 09:22:18Z avg $");
28__FBSDID("$FreeBSD: head/sys/boot/zfs/zfsimpl.c 236884 2012-06-11 11:35:22Z 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;

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

193 pair = p;
194 xdr_int(&p, &encoded_size);
195 xdr_int(&p, &decoded_size);
196 }
197
198 return (EIO);
199}
200
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;

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

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

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

783 blkptr_t bp;
784 const unsigned char *nvlist;
785 uint64_t val;
786 uint64_t guid;
787 uint64_t pool_txg, pool_guid;
788 uint64_t is_log;
789 const char *pool_name;
790 const unsigned char *vdevs;
259/*
260 * Return the next nvlist in an nvlist array.
261 */
262static const unsigned char *
263nvlist_next(const unsigned char *nvlist)
264{
265 const unsigned char *p, *pair;
266 int junk;

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

841 blkptr_t bp;
842 const unsigned char *nvlist;
843 uint64_t val;
844 uint64_t guid;
845 uint64_t pool_txg, pool_guid;
846 uint64_t is_log;
847 const char *pool_name;
848 const unsigned char *vdevs;
849 const unsigned char *features;
791 int i, rc, is_newer;
792 char *upbuf;
793 const struct uberblock *up;
794
795 /*
796 * Load the vdev label and figure out which
797 * uberblock is most current.
798 */

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

817 nvlist = (const unsigned char *) vdev_label->vp_nvlist + 4;
818
819 if (nvlist_find(nvlist,
820 ZPOOL_CONFIG_VERSION,
821 DATA_TYPE_UINT64, 0, &val)) {
822 return (EIO);
823 }
824
850 int i, rc, is_newer;
851 char *upbuf;
852 const struct uberblock *up;
853
854 /*
855 * Load the vdev label and figure out which
856 * uberblock is most current.
857 */

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

876 nvlist = (const unsigned char *) vdev_label->vp_nvlist + 4;
877
878 if (nvlist_find(nvlist,
879 ZPOOL_CONFIG_VERSION,
880 DATA_TYPE_UINT64, 0, &val)) {
881 return (EIO);
882 }
883
825 if (val > SPA_VERSION) {
884 if (!SPA_VERSION_IS_SUPPORTED(val)) {
826 printf("ZFS: unsupported ZFS version %u (should be %u)\n",
827 (unsigned) val, (unsigned) SPA_VERSION);
828 return (EIO);
829 }
830
885 printf("ZFS: unsupported ZFS version %u (should be %u)\n",
886 (unsigned) val, (unsigned) SPA_VERSION);
887 return (EIO);
888 }
889
890 /* Check ZFS features for read */
891 rc = nvlist_find(nvlist, ZPOOL_CONFIG_FEATURES_FOR_READ,
892 DATA_TYPE_NVLIST, 0, &features);
893 if (nvlist_check_features_for_read(features) != 0)
894 return (EIO);
895
831 if (nvlist_find(nvlist,
832 ZPOOL_CONFIG_POOL_STATE,
833 DATA_TYPE_UINT64, 0, &val)) {
834 return (EIO);
835 }
836
837 if (val == POOL_STATE_DESTROYED) {
838 /* We don't boot only from destroyed pools. */

--- 1153 unchanged lines hidden ---
896 if (nvlist_find(nvlist,
897 ZPOOL_CONFIG_POOL_STATE,
898 DATA_TYPE_UINT64, 0, &val)) {
899 return (EIO);
900 }
901
902 if (val == POOL_STATE_DESTROYED) {
903 /* We don't boot only from destroyed pools. */

--- 1153 unchanged lines hidden ---