aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/devctl
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 /usr.sbin/devctl
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 'usr.sbin/devctl')
-rw-r--r--usr.sbin/devctl/devctl.c64
1 files changed, 53 insertions, 11 deletions
diff --git a/usr.sbin/devctl/devctl.c b/usr.sbin/devctl/devctl.c
index 6b266f42fe40..81fafcfd265b 100644
--- a/usr.sbin/devctl/devctl.c
+++ b/usr.sbin/devctl/devctl.c
@@ -71,17 +71,19 @@ DEVCTL_TABLE(top, set);
static void
usage(void)
{
- fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
- "usage: devctl attach device",
- " devctl detach [-f] device",
- " devctl disable [-f] device",
- " devctl enable device",
- " devctl suspend device",
- " devctl resume device",
- " devctl set driver [-f] device driver",
- " devctl clear driver [-f] device",
- " devctl rescan device",
- " devctl delete [-f] device");
+ fprintf(stderr,
+ "usage: devctl attach device\n"
+ " devctl detach [-f] device\n"
+ " devctl disable [-f] device\n"
+ " devctl enable device\n"
+ " devctl suspend device\n"
+ " devctl resume device\n"
+ " devctl set driver [-f] device driver\n"
+ " devctl clear driver [-f] device\n"
+ " devctl rescan device\n"
+ " devctl delete [-f] device\n"
+ " devctl freeze\n"
+ " devctl thaw\n");
exit(1);
}
@@ -343,6 +345,46 @@ delete(int ac, char **av)
}
DEVCTL_COMMAND(top, delete, delete);
+static void
+freeze_usage(void)
+{
+
+ fprintf(stderr, "usage: devctl freeze\n");
+ exit(1);
+}
+
+static int
+freeze(int ac, char **av __unused)
+{
+
+ if (ac != 1)
+ freeze_usage();
+ if (devctl_freeze() < 0)
+ err(1, "Failed to freeze probe/attach");
+ return (0);
+}
+DEVCTL_COMMAND(top, freeze, freeze);
+
+static void
+thaw_usage(void)
+{
+
+ fprintf(stderr, "usage: devctl thaw\n");
+ exit(1);
+}
+
+static int
+thaw(int ac, char **av __unused)
+{
+
+ if (ac != 1)
+ thaw_usage();
+ if (devctl_thaw() < 0)
+ err(1, "Failed to thaw probe/attach");
+ return (0);
+}
+DEVCTL_COMMAND(top, thaw, thaw);
+
int
main(int ac, char *av[])
{