If we cannot open /dev/zfs try to load zfs.ko automatically and reopen.
This commit is contained in:
parent
264de85e73
commit
902cbe0df8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=168484
@ -490,6 +490,21 @@ libzfs_print_on_error(libzfs_handle_t *hdl, boolean_t printerr)
|
|||||||
hdl->libzfs_printerr = printerr;
|
hdl->libzfs_printerr = printerr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
libzfs_load(void)
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
|
||||||
|
if (modfind("zfs") < 0) {
|
||||||
|
/* Not present in kernel, try loading it. */
|
||||||
|
if (kldload("zfs") < 0 || modfind("zfs") < 0) {
|
||||||
|
if (errno != EEXIST)
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
libzfs_handle_t *
|
libzfs_handle_t *
|
||||||
libzfs_init(void)
|
libzfs_init(void)
|
||||||
{
|
{
|
||||||
@ -500,8 +515,12 @@ libzfs_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((hdl->libzfs_fd = open(ZFS_DEV, O_RDWR)) < 0) {
|
if ((hdl->libzfs_fd = open(ZFS_DEV, O_RDWR)) < 0) {
|
||||||
free(hdl);
|
if (libzfs_load() == 0)
|
||||||
return (NULL);
|
hdl->libzfs_fd = open(ZFS_DEV, O_RDWR);
|
||||||
|
if (hdl->libzfs_fd < 0) {
|
||||||
|
free(hdl);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((hdl->libzfs_mnttab = fopen(MNTTAB, "r")) == NULL) {
|
if ((hdl->libzfs_mnttab = fopen(MNTTAB, "r")) == NULL) {
|
||||||
|
@ -490,6 +490,21 @@ libzfs_print_on_error(libzfs_handle_t *hdl, boolean_t printerr)
|
|||||||
hdl->libzfs_printerr = printerr;
|
hdl->libzfs_printerr = printerr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
libzfs_load(void)
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
|
||||||
|
if (modfind("zfs") < 0) {
|
||||||
|
/* Not present in kernel, try loading it. */
|
||||||
|
if (kldload("zfs") < 0 || modfind("zfs") < 0) {
|
||||||
|
if (errno != EEXIST)
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
libzfs_handle_t *
|
libzfs_handle_t *
|
||||||
libzfs_init(void)
|
libzfs_init(void)
|
||||||
{
|
{
|
||||||
@ -500,8 +515,12 @@ libzfs_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((hdl->libzfs_fd = open(ZFS_DEV, O_RDWR)) < 0) {
|
if ((hdl->libzfs_fd = open(ZFS_DEV, O_RDWR)) < 0) {
|
||||||
free(hdl);
|
if (libzfs_load() == 0)
|
||||||
return (NULL);
|
hdl->libzfs_fd = open(ZFS_DEV, O_RDWR);
|
||||||
|
if (hdl->libzfs_fd < 0) {
|
||||||
|
free(hdl);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((hdl->libzfs_mnttab = fopen(MNTTAB, "r")) == NULL) {
|
if ((hdl->libzfs_mnttab = fopen(MNTTAB, "r")) == NULL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user