aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/devctl
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2016-04-27 16:33:17 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2016-04-27 16:33:17 +0000
commit88eb5c506d00e446dcfeb0f84b36d5132a8d9f6b (patch)
tree9d890003db3954532ce3e8f39ed0184a8e9983dc /usr.sbin/devctl
parent3d0338a09278a0cc38785321f102de9775c57ed3 (diff)
Notes
Diffstat (limited to 'usr.sbin/devctl')
-rw-r--r--usr.sbin/devctl/devctl.816
-rw-r--r--usr.sbin/devctl/devctl.c40
2 files changed, 54 insertions, 2 deletions
diff --git a/usr.sbin/devctl/devctl.8 b/usr.sbin/devctl/devctl.8
index bfa6dcc62031..ec8abaff233a 100644
--- a/usr.sbin/devctl/devctl.8
+++ b/usr.sbin/devctl/devctl.8
@@ -59,6 +59,10 @@
.Nm
.Cm rescan
.Ar device
+.Nm
+.Cm delete
+.Op Fl f
+.Ar device
.Sh DESCRIPTION
The
.Nm
@@ -132,6 +136,18 @@ the device will not be changed.
.It Cm rescan Ar device
Rescan a bus device checking for devices that have been added or
removed.
+.It Xo Cm delete
+.Op Fl
+.Ar device
+.Xc
+Delete the device from the device tree.
+If the
+.Fl f
+flag is specified,
+the device will be deleted even if it is physically present.
+This command should be used with care as a device that is deleted but present
+can no longer be used unless the parent bus device rediscovers the device via
+a rescan request.
.El
.Sh SEE ALSO
.Xr devctl 3 ,
diff --git a/usr.sbin/devctl/devctl.c b/usr.sbin/devctl/devctl.c
index 545224b502d1..824b9075c04e 100644
--- a/usr.sbin/devctl/devctl.c
+++ b/usr.sbin/devctl/devctl.c
@@ -70,14 +70,16 @@ DEVCTL_TABLE(top, set);
static void
usage(void)
{
- fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
+ fprintf(stderr, "%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 set driver [-f] device driver",
+ " devctl rescan device",
+ " devctl delete [-f] device");
exit(1);
}
@@ -271,6 +273,40 @@ rescan(int ac, char **av)
}
DEVCTL_COMMAND(top, rescan, rescan);
+static void
+delete_usage(void)
+{
+
+ fprintf(stderr, "usage: devctl delete [-f] device\n");
+ exit(1);
+}
+
+static int
+delete(int ac, char **av)
+{
+ bool force;
+ int ch;
+
+ force = false;
+ while ((ch = getopt(ac, av, "f")) != -1)
+ switch (ch) {
+ case 'f':
+ force = true;
+ break;
+ default:
+ delete_usage();
+ }
+ ac -= optind;
+ av += optind;
+
+ if (ac != 1)
+ delete_usage();
+ if (devctl_delete(av[0], force) < 0)
+ err(1, "Failed to delete %s", av[0]);
+ return (0);
+}
+DEVCTL_COMMAND(top, delete, delete);
+
int
main(int ac, char *av[])
{