aboutsummaryrefslogtreecommitdiff
path: root/lib/libdevctl
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2018-08-23 05:05:47 +0000
committerWarner Losh <imp@FreeBSD.org>2018-08-23 05:05:47 +0000
commit5fa29797910346fc0c54829bd979856e83b9b7ea (patch)
tree461c4837323a9d9612e2ccd14735ea250d763699 /lib/libdevctl
parent67b60a1b7d46d959bdd4925944b149eebbfb593f (diff)
downloadsrc-5fa29797910346fc0c54829bd979856e83b9b7ea.tar.gz
src-5fa29797910346fc0c54829bd979856e83b9b7ea.zip
Create devctl freeze/thaw.
This adds it to devctl, libdevctl, defines the two IOCTLs and implements the kernel bits. causes any new drivers that are added via kldload to be deferred until a 'thaw' comes in. These do not stack: it is an error to freeze while frozen, or thaw while thawed. Differential Revision: https://reviews.freebsd.org/D16735
Notes
Notes: svn path=/head/; revision=338233
Diffstat (limited to 'lib/libdevctl')
-rw-r--r--lib/libdevctl/devctl.318
-rw-r--r--lib/libdevctl/devctl.c14
-rw-r--r--lib/libdevctl/devctl.h2
3 files changed, 33 insertions, 1 deletions
diff --git a/lib/libdevctl/devctl.3 b/lib/libdevctl/devctl.3
index a4fe0620ac3f..8749515ecd74 100644
--- a/lib/libdevctl/devctl.3
+++ b/lib/libdevctl/devctl.3
@@ -36,10 +36,12 @@
.Nm devctl_detach ,
.Nm devctl_disable ,
.Nm devctl_enable ,
+.Nm devctl_freeze ,
.Nm devctl_rescan ,
.Nm devctl_resume ,
.Nm devctl_set_driver ,
-.Nm devctl_suspend
+.Nm devctl_suspend ,
+.Nm devctl_thaw
.Nd device control library
.Sh LIBRARY
.Lb libdevctl
@@ -58,6 +60,8 @@
.Ft int
.Fn devctl_enable "const char *device"
.Ft int
+.Fn devctl_freeze "void"
+.Ft int
.Fn devctl_rescan "const char *device"
.Ft int
.Fn devctl_resume "const char *device"
@@ -65,6 +69,8 @@
.Fn devctl_set_driver "const char *device" "const char *driver" "bool force"
.Ft int
.Fn devctl_suspend "const char *device"
+.Ft int
+.Fn devctl_thaw "void"
.Sh DESCRIPTION
The
.Nm
@@ -189,6 +195,16 @@ The
.Fn devctl_rescan
function rescans a bus device checking for devices that have been added or
removed.
+.Pp
+The
+.Fn devctl_freeze
+function freezes probe and attach processing initiated in response to
+drivers being loaded.
+.Pp
+The
+.Fn devctl_thaw
+function resumes (thaws the freeze) probe and attach processing
+initiated in response to drivers being loaded.
.Sh RETURN VALUES
.Rv -std devctl_attach devctl_clear_driver devctl_delete devctl_detach \
devctl_disable devctl_enable devctl_suspend devctl_rescan devctl_resume \
diff --git a/lib/libdevctl/devctl.c b/lib/libdevctl/devctl.c
index 5013fb0b9d57..9c9ab7805672 100644
--- a/lib/libdevctl/devctl.c
+++ b/lib/libdevctl/devctl.c
@@ -145,3 +145,17 @@ devctl_delete(const char *device, bool force)
return (devctl_simple_request(DEV_DELETE, device, force ?
DEVF_FORCE_DELETE : 0));
}
+
+int
+devctl_freeze(void)
+{
+
+ return (devctl_simple_request(DEV_FREEZE, "", 0));
+}
+
+int
+devctl_thaw(void)
+{
+
+ return (devctl_simple_request(DEV_THAW, "", 0));
+}
diff --git a/lib/libdevctl/devctl.h b/lib/libdevctl/devctl.h
index d49199ad0b59..11a21753809d 100644
--- a/lib/libdevctl/devctl.h
+++ b/lib/libdevctl/devctl.h
@@ -41,5 +41,7 @@ int devctl_set_driver(const char *device, const char *driver, bool force);
int devctl_clear_driver(const char *device, bool force);
int devctl_rescan(const char *device);
int devctl_delete(const char *device, bool force);
+int devctl_freeze(void);
+int devctl_thaw(void);
#endif /* !__DEVCTL_H__ */