* CDDL HEADER END
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "@(#)translate.c 1.3 07/11/09 SMI"
-
#include <libzfs.h>
#undef verify /* both libzfs.h and zfs_context.h want to define this */
#include <sys/dmu.h>
#include <sys/dmu_objset.h>
#include <sys/dnode.h>
+#include <sys/vdev_impl.h>
#include <sys/mkdev.h>
sync();
if ((err = dmu_objset_open(dataset, DMU_OST_ZFS,
- DS_MODE_STANDARD | DS_MODE_READONLY, &os)) != 0) {
+ DS_MODE_USER | DS_MODE_READONLY, &os)) != 0) {
(void) fprintf(stderr, "cannot open dataset '%s': %s\n",
dataset, strerror(err));
return (-1);
* size.
*/
if ((err = dmu_objset_open(dataset, DMU_OST_ANY,
- DS_MODE_STANDARD | DS_MODE_READONLY, &os)) != 0) {
+ DS_MODE_USER | DS_MODE_READONLY, &os)) != 0) {
(void) fprintf(stderr, "cannot open dataset '%s': %s\n",
dataset, strerror(err));
goto out;
}
int
-translate_device(const char *pool, const char *device, zinject_record_t *record)
+translate_device(const char *pool, const char *device, err_type_t label_type,
+ zinject_record_t *record)
{
char *end;
zpool_handle_t *zhp;
record->zi_guid = strtoull(device, &end, 16);
if (record->zi_guid == 0 || *end != '\0') {
- tgt = zpool_find_vdev(zhp, device, &isspare, &iscache);
+ tgt = zpool_find_vdev(zhp, device, &isspare, &iscache, NULL);
if (tgt == NULL) {
(void) fprintf(stderr, "cannot find device '%s' in "
&record->zi_guid) == 0);
}
+ switch (label_type) {
+ case TYPE_LABEL_UBERBLOCK:
+ record->zi_start = offsetof(vdev_label_t, vl_uberblock[0]);
+ record->zi_end = record->zi_start + VDEV_UBERBLOCK_RING - 1;
+ break;
+ case TYPE_LABEL_NVLIST:
+ record->zi_start = offsetof(vdev_label_t, vl_vdev_phys);
+ record->zi_end = record->zi_start + VDEV_PHYS_SIZE - 1;
+ break;
+ }
return (0);
}