From 5fa29797910346fc0c54829bd979856e83b9b7ea Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Thu, 23 Aug 2018 05:05:47 +0000 Subject: 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 --- lib/libdevctl/devctl.3 | 18 +++++++++++++++++- lib/libdevctl/devctl.c | 14 ++++++++++++++ lib/libdevctl/devctl.h | 2 ++ 3 files changed, 33 insertions(+), 1 deletion(-) (limited to 'lib/libdevctl') 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__ */ -- cgit v1.3