Changeset View
Changeset View
Standalone View
Standalone View
stand/libsa/zfs/zfs.c
Show All 27 Lines | |||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
/* | /* | ||||
* Stand-alone file reading package. | * Stand-alone file reading package. | ||||
*/ | */ | ||||
#include <stand.h> | |||||
#include <sys/disk.h> | #include <sys/disk.h> | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/time.h> | #include <sys/time.h> | ||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
#include <disk.h> | |||||
#include <part.h> | #include <part.h> | ||||
#include <stddef.h> | #include <stddef.h> | ||||
#include <stdarg.h> | #include <stdarg.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <stand.h> | |||||
#include <bootstrap.h> | #include <bootstrap.h> | ||||
#include "libzfs.h" | #include "libzfs.h" | ||||
#include "zfsimpl.c" | #include "zfsimpl.c" | ||||
/* Define the range of indexes to be populated with ZFS Boot Environments */ | /* Define the range of indexes to be populated with ZFS Boot Environments */ | ||||
#define ZFS_BE_FIRST 4 | #define ZFS_BE_FIRST 4 | ||||
▲ Show 20 Lines • Show All 459 Lines • ▼ Show 20 Lines | zfs_probe_partition(void *arg, const char *partname, | ||||
} | } | ||||
close(pa.fd); | close(pa.fd); | ||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
zfs_probe_dev(const char *devname, uint64_t *pool_guid) | zfs_probe_dev(const char *devname, uint64_t *pool_guid) | ||||
{ | { | ||||
struct disk_devdesc *dev; | |||||
struct ptable *table; | struct ptable *table; | ||||
struct zfs_probe_args pa; | struct zfs_probe_args pa; | ||||
uint64_t mediasz; | uint64_t mediasz; | ||||
int ret; | int ret; | ||||
if (pool_guid) | if (pool_guid) | ||||
*pool_guid = 0; | *pool_guid = 0; | ||||
pa.fd = open(devname, O_RDONLY); | pa.fd = open(devname, O_RDONLY); | ||||
if (pa.fd == -1) | if (pa.fd == -1) | ||||
return (ENXIO); | return (ENXIO); | ||||
/* | /* | ||||
* We will not probe the whole disk, we can not boot from such | * We will not probe the whole disk, we can not boot from such | ||||
* disks and some systems will misreport the disk sizes and will | * disks and some systems will misreport the disk sizes and will | ||||
* hang while accessing the disk. | * hang while accessing the disk. | ||||
*/ | */ | ||||
if (archsw.arch_getdev((void **)&dev, devname, NULL) == 0) { | |||||
int partition = dev->d_partition; | |||||
int slice = dev->d_slice; | |||||
free(dev); | |||||
if (partition != -1 && slice != -1) { | |||||
ret = zfs_probe(pa.fd, pool_guid); | |||||
if (ret == 0) | |||||
return (0); | |||||
} | |||||
} | |||||
/* Probe each partition */ | /* Probe each partition */ | ||||
ret = ioctl(pa.fd, DIOCGMEDIASIZE, &mediasz); | ret = ioctl(pa.fd, DIOCGMEDIASIZE, &mediasz); | ||||
if (ret == 0) | if (ret == 0) | ||||
ret = ioctl(pa.fd, DIOCGSECTORSIZE, &pa.secsz); | ret = ioctl(pa.fd, DIOCGSECTORSIZE, &pa.secsz); | ||||
if (ret == 0) { | if (ret == 0) { | ||||
pa.devname = devname; | pa.devname = devname; | ||||
pa.pool_guid = pool_guid; | pa.pool_guid = pool_guid; | ||||
▲ Show 20 Lines • Show All 462 Lines • Show Last 20 Lines |