text stringlengths 0 14.1k |
|---|
/* special case for the MOS */ |
(void) snprintf(pathname, len, ""<metadata>:<0x%llx>"", (u_longlong_t) obj); |
return; |
} |
/* get the dataset's name */ |
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); |
zc.zc_obj = dsobj; |
if (ioctl(zhp->zpool_hdl->libzfs_fd, |
ZFS_IOC_DSOBJ_TO_DSNAME, &zc) != 0) { |
/* just write out a path of two object numbers */ |
(void) snprintf(pathname, len, ""<0x%llx>:<0x%llx>"", |
(u_longlong_t) dsobj, (u_longlong_t) obj); |
return; |
} |
(void) strlcpy(dsname, zc.zc_value, sizeof (dsname)); |
/* find out if the dataset is mounted */ |
mounted = is_mounted(zhp->zpool_hdl, dsname, &mntpnt); |
/* get the corrupted object's path */ |
(void) strlcpy(zc.zc_name, dsname, sizeof (zc.zc_name)); |
zc.zc_obj = obj; |
if (ioctl(zhp->zpool_hdl->libzfs_fd, ZFS_IOC_OBJ_TO_PATH, |
&zc) == 0) { |
if (mounted) { |
(void) snprintf(pathname, len, ""%s%s"", mntpnt, |
zc.zc_value); |
} else { |
(void) snprintf(pathname, len, ""%s:%s"", |
dsname, zc.zc_value); |
} |
} else { |
(void) snprintf(pathname, len, ""%s:<0x%llx>"", dsname, (u_longlong_t) obj); |
} |
free(mntpnt); |
} |
/* |
* Read the EFI label from the config, if a label does not exist then |
* pass back the error to the caller. If the caller has passed a non-NULL |
* diskaddr argument then we set it to the starting address of the EFI |
* partition. |
*/ |
/* ZFS-FUSE: not implemented */ |
#if 0 |
static int |
read_efi_label(nvlist_t *config, diskaddr_t *sb) |
{ |
char *path; |
int fd; |
char diskname[MAXPATHLEN]; |
int err = -1; |
if (nvlist_lookup_string(config, ZPOOL_CONFIG_PATH, &path) != 0) |
return (err); |
(void) snprintf(diskname, sizeof (diskname), ""%s%s"", RDISK_ROOT, |
strrchr(path, '/')); |
if ((fd = open(diskname, O_RDONLY|O_NDELAY)) >= 0) { |
struct dk_gpt *vtoc; |
if ((err = efi_alloc_and_read(fd, &vtoc)) >= 0) { |
if (sb != NULL) |
*sb = vtoc->efi_parts[0].p_start; |
efi_free(vtoc); |
} |
(void) close(fd); |
} |
return (err); |
} |
/* |
* determine where a partition starts on a disk in the current |
* configuration |
*/ |
static diskaddr_t |
find_start_block(nvlist_t *config) |
{ |
nvlist_t **child; |
uint_t c, children; |
diskaddr_t sb = MAXOFFSET_T; |
uint64_t wholedisk; |
if (nvlist_lookup_nvlist_array(config, |
ZPOOL_CONFIG_CHILDREN, &child, &children) != 0) { |
if (nvlist_lookup_uint64(config, |
ZPOOL_CONFIG_WHOLE_DISK, |
&wholedisk) != 0 || !wholedisk) { |
return (MAXOFFSET_T); |
} |
if (read_efi_label(config, &sb) < 0) |
sb = MAXOFFSET_T; |
return (sb); |
} |
for (c = 0; c < children; c++) { |
sb = find_start_block(child[c]); |
if (sb != MAXOFFSET_T) { |
return (sb); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.