CVS commit: src/sbin/drvctl
Module Name:src Committed By: mlelstv Date: Sun Aug 21 07:51:31 UTC 2022 Modified Files: src/sbin/drvctl: drvctl.c Log Message: When extracting properties, don't bail for non-existent or invalid path elements, but continue with next properry. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/drvctl
Module Name:src Committed By: mlelstv Date: Sun Aug 21 07:51:31 UTC 2022 Modified Files: src/sbin/drvctl: drvctl.c Log Message: When extracting properties, don't bail for non-existent or invalid path elements, but continue with next properry. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/drvctl/drvctl.c diff -u src/sbin/drvctl/drvctl.c:1.21 src/sbin/drvctl/drvctl.c:1.22 --- src/sbin/drvctl/drvctl.c:1.21 Thu Jun 11 13:49:57 2020 +++ src/sbin/drvctl/drvctl.c Sun Aug 21 07:51:30 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: drvctl.c,v 1.21 2020/06/11 13:49:57 thorpej Exp $ */ +/* $NetBSD: drvctl.c,v 1.22 2022/08/21 07:51:30 mlelstv Exp $ */ /* * Copyright (c) 2004 @@ -230,17 +230,20 @@ extract_property(prop_dictionary_t dict, case PROP_TYPE_DICTIONARY: obj = prop_dictionary_get(obj, cur); if (obj == NULL) -exit(EXIT_FAILURE); +p = NULL; break; case PROP_TYPE_ARRAY: ind = strtoul(cur, NULL, 0); obj = prop_array_get(obj, ind); if (obj == NULL) -exit(EXIT_FAILURE); +p = NULL; break; default: - errx(EXIT_FAILURE, "Select neither dict nor array with" - " `%s'", cur); + fprintf(stderr, "Select neither dict nor array with" + " `%s'\n", cur); + obj = NULL; + p = NULL; + break; } }
CVS commit: src/sbin/drvctl
Module Name:src Committed By: thorpej Date: Thu Jun 11 13:49:57 UTC 2020 Modified Files: src/sbin/drvctl: drvctl.c Log Message: Update for proplib(3) API changes. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/drvctl
Module Name:src Committed By: thorpej Date: Thu Jun 11 13:49:57 UTC 2020 Modified Files: src/sbin/drvctl: drvctl.c Log Message: Update for proplib(3) API changes. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/drvctl/drvctl.c diff -u src/sbin/drvctl/drvctl.c:1.20 src/sbin/drvctl/drvctl.c:1.21 --- src/sbin/drvctl/drvctl.c:1.20 Wed Feb 14 17:43:09 2018 +++ src/sbin/drvctl/drvctl.c Thu Jun 11 13:49:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: drvctl.c,v 1.20 2018/02/14 17:43:09 jakllsch Exp $ */ +/* $NetBSD: drvctl.c,v 1.21 2020/06/11 13:49:57 thorpej Exp $ */ /* * Copyright (c) 2004 @@ -76,9 +76,8 @@ main(int argc, char **argv) struct devrescanargs raa; int *locs, i; prop_dictionary_t command_dict, args_dict, results_dict, data_dict; - prop_string_t string; - prop_number_t number; char *xml; + int drvctl_error; mode = 0; while ((c = getopt(argc, argv, "QRSa:dlnprt")) != -1) { @@ -164,17 +163,12 @@ main(int argc, char **argv) command_dict = prop_dictionary_create(); args_dict = prop_dictionary_create(); - string = prop_string_create_cstring_nocopy("get-properties"); - prop_dictionary_set(command_dict, "drvctl-command", string); - prop_object_release(string); - - string = prop_string_create_cstring(argv[0]); - prop_dictionary_set(args_dict, "device-name", string); - prop_object_release(string); - - prop_dictionary_set(command_dict, "drvctl-arguments", + prop_dictionary_set_string_nocopy(command_dict, + "drvctl-command", "get-properties"); + prop_dictionary_set_string(args_dict, "device-name", + argv[0]); + prop_dictionary_set_and_rel(command_dict, "drvctl-arguments", args_dict); - prop_object_release(args_dict); res = prop_dictionary_sendrecv_ioctl(command_dict, fd, DRVCTLCOMMAND, _dict); @@ -182,11 +176,10 @@ main(int argc, char **argv) if (res) errc(EXIT_FAILURE, res, "DRVCTLCOMMAND"); - number = prop_dictionary_get(results_dict, "drvctl-error"); - if (prop_number_integer_value(number) != 0) { - errc(EXIT_FAILURE, - (int)prop_number_integer_value(number), - "get-properties"); + if (prop_dictionary_get_int(results_dict, "drvctl-error", + _error) && + drvctl_error != 0) { + errc(EXIT_FAILURE, drvctl_error, "get-properties"); } data_dict = prop_dictionary_get(results_dict, @@ -271,10 +264,10 @@ display_object(prop_object_t obj, bool n printf("%s\n", prop_bool_true(obj) ? "true" : "false"); break; case PROP_TYPE_NUMBER: - printf("%" PRId64 "\n", prop_number_integer_value(obj)); + printf("%" PRId64 "\n", prop_number_signed_value(obj)); break; case PROP_TYPE_STRING: - printf("%s\n", prop_string_cstring_nocopy(obj)); + printf("%s\n", prop_string_value(obj)); break; case PROP_TYPE_DICTIONARY: xml = prop_dictionary_externalize(obj);
CVS commit: src/sbin/drvctl
Module Name:src Committed By: wiz Date: Wed Aug 7 19:08:10 UTC 2019 Modified Files: src/sbin/drvctl: drvctl.8 Log Message: Remove superfluous Pp. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sbin/drvctl/drvctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/drvctl
Module Name:src Committed By: wiz Date: Wed Aug 7 19:08:10 UTC 2019 Modified Files: src/sbin/drvctl: drvctl.8 Log Message: Remove superfluous Pp. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sbin/drvctl/drvctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/drvctl/drvctl.8 diff -u src/sbin/drvctl/drvctl.8:1.19 src/sbin/drvctl/drvctl.8:1.20 --- src/sbin/drvctl/drvctl.8:1.19 Tue Aug 6 10:45:14 2019 +++ src/sbin/drvctl/drvctl.8 Wed Aug 7 19:08:10 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: drvctl.8,v 1.19 2019/08/06 10:45:14 mrg Exp $ +.\" $NetBSD: drvctl.8,v 1.20 2019/08/07 19:08:10 wiz Exp $ .\" .\" Copyright (c) 2004 .\" Matthias Drochner. All rights reserved. @@ -174,7 +174,6 @@ attributes, try one or both of these: # drvctl -r -a usbifif uhub3 # drvctl -r -a usbdevif uhub3 .Ed -.Pp .Sh SEE ALSO .Xr proplib 3 , .Xr drvctl 4 ,
CVS commit: src/sbin/drvctl
Module Name:src Committed By: mrg Date: Tue Aug 6 10:45:14 UTC 2019 Modified Files: src/sbin/drvctl: drvctl.8 Log Message: add an example about reattaching USB devices To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sbin/drvctl/drvctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/drvctl/drvctl.8 diff -u src/sbin/drvctl/drvctl.8:1.18 src/sbin/drvctl/drvctl.8:1.19 --- src/sbin/drvctl/drvctl.8:1.18 Sun Sep 11 02:59:11 2016 +++ src/sbin/drvctl/drvctl.8 Tue Aug 6 10:45:14 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: drvctl.8,v 1.18 2016/09/11 02:59:11 sevan Exp $ +.\" $NetBSD: drvctl.8,v 1.19 2019/08/06 10:45:14 mrg Exp $ .\" .\" Copyright (c) 2004 .\" Matthias Drochner. All rights reserved. @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd September 11, 2016 +.Dd August 6, 2019 .Dt DRVCTL 8 .Os .Sh NAME @@ -157,6 +157,24 @@ attribute: .Bd -literal -offset indent # drvctl -r -a ata_hl atabus1 .Ed +.Pp +To scan for devices on a USB hub +.Pa uhub3 , +that have not been discovered by normal methods (or were detached +with the +.Fl d +option for +.Nm ) , +need to use the +.Qq usbifif +or +.Qq usbdevif +attributes, try one or both of these: +.Bd -literal -offset indent +# drvctl -r -a usbifif uhub3 +# drvctl -r -a usbdevif uhub3 +.Ed +.Pp .Sh SEE ALSO .Xr proplib 3 , .Xr drvctl 4 ,
CVS commit: src/sbin/drvctl
Module Name:src Committed By: mrg Date: Tue Aug 6 10:45:14 UTC 2019 Modified Files: src/sbin/drvctl: drvctl.8 Log Message: add an example about reattaching USB devices To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sbin/drvctl/drvctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/drvctl
Module Name:src Committed By: jakllsch Date: Wed Feb 14 17:43:09 UTC 2018 Modified Files: src/sbin/drvctl: drvctl.c Log Message: Revert functional changes in previous, at expense of strict KNF conformance. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/drvctl
Module Name:src Committed By: jakllsch Date: Wed Feb 14 17:43:09 UTC 2018 Modified Files: src/sbin/drvctl: drvctl.c Log Message: Revert functional changes in previous, at expense of strict KNF conformance. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/drvctl/drvctl.c diff -u src/sbin/drvctl/drvctl.c:1.19 src/sbin/drvctl/drvctl.c:1.20 --- src/sbin/drvctl/drvctl.c:1.19 Sun Jan 7 15:26:43 2018 +++ src/sbin/drvctl/drvctl.c Wed Feb 14 17:43:09 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: drvctl.c,v 1.19 2018/01/07 15:26:43 christos Exp $ */ +/* $NetBSD: drvctl.c,v 1.20 2018/02/14 17:43:09 jakllsch Exp $ */ /* * Copyright (c) 2004 @@ -86,18 +86,18 @@ main(int argc, char **argv) case 'Q': case 'R': case 'S': - case 'a': - attr = optarg; - break; case 'd': - case 'n': - nflag = true; - break; case 'l': case 'p': case 'r': mode = c; break; + case 'a': + attr = optarg; + break; + case 'n': + nflag = true; + break; case 't': tflag = nflag = true; break;
CVS commit: src/sbin/drvctl
Module Name:src Committed By: christos Date: Sun Jan 7 15:26:43 UTC 2018 Modified Files: src/sbin/drvctl: drvctl.c Log Message: KNF. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/drvctl/drvctl.c diff -u src/sbin/drvctl/drvctl.c:1.18 src/sbin/drvctl/drvctl.c:1.19 --- src/sbin/drvctl/drvctl.c:1.18 Sun Dec 6 22:34:00 2015 +++ src/sbin/drvctl/drvctl.c Sun Jan 7 10:26:43 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: drvctl.c,v 1.18 2015/12/07 03:34:00 pgoyette Exp $ */ +/* $NetBSD: drvctl.c,v 1.19 2018/01/07 15:26:43 christos Exp $ */ /* * Copyright (c) 2004 @@ -37,7 +37,6 @@ #include #include -#define OPTS "QRSa:dlnprt" #define OPEN_MODE(mode) \ (((mode) == 'd' || (mode) == 'r') ? O_RDWR \ @@ -51,6 +50,7 @@ static void list_children(int, char *, b static void usage(void) { + const char *p = getprogname(); fprintf(stderr, "Usage: %s -r [-a attribute] busdevice [locator ...]\n" " %s -d device\n" @@ -58,10 +58,8 @@ usage(void) " %s [-n] -p device [property]\n" " %s -Q device\n" " %s -R device\n" - " %s -S device\n", - getprogname(), getprogname(), getprogname(), getprogname(), - getprogname(), getprogname(), getprogname()); - exit(1); + " %s -S device\n", p, p, p, p, p, p, p); + exit(EXIT_FAILURE); } int @@ -73,34 +71,33 @@ main(int argc, char **argv) extern char *optarg; extern int optind; int fd, res; - struct devpmargs paa = {.devname = "", .flags = 0}; + struct devpmargs paa = { .devname = "", .flags = 0 }; struct devdetachargs daa; struct devrescanargs raa; int *locs, i; - prop_dictionary_t command_dict, args_dict, results_dict, - data_dict; + prop_dictionary_t command_dict, args_dict, results_dict, data_dict; prop_string_t string; prop_number_t number; char *xml; mode = 0; - while ((c = getopt(argc, argv, OPTS)) != -1) { + while ((c = getopt(argc, argv, "QRSa:dlnprt")) != -1) { switch (c) { case 'Q': case 'R': case 'S': - case 'd': - case 'l': - case 'p': - case 'r': - mode = c; - break; case 'a': attr = optarg; break; + case 'd': case 'n': nflag = true; break; + case 'l': + case 'p': + case 'r': + mode = c; + break; case 't': tflag = nflag = true; break; @@ -117,8 +114,8 @@ main(int argc, char **argv) usage(); fd = open(DRVCTLDEV, OPEN_MODE(mode), 0); - if (fd < 0) - err(2, "open %s", DRVCTLDEV); + if (fd == -1) + err(EXIT_FAILURE, "open %s", DRVCTLDEV); switch (mode) { case 'Q': @@ -128,19 +125,19 @@ main(int argc, char **argv) strlcpy(paa.devname, argv[0], sizeof(paa.devname)); if (ioctl(fd, DRVRESUMEDEV, ) == -1) - err(3, "DRVRESUMEDEV"); + err(EXIT_FAILURE, "DRVRESUMEDEV"); break; case 'S': strlcpy(paa.devname, argv[0], sizeof(paa.devname)); if (ioctl(fd, DRVSUSPENDDEV, ) == -1) - err(3, "DRVSUSPENDDEV"); + err(EXIT_FAILURE, "DRVSUSPENDDEV"); break; case 'd': strlcpy(daa.devname, argv[0], sizeof(daa.devname)); if (ioctl(fd, DRVDETACHDEV, ) == -1) - err(3, "DRVDETACHDEV"); + err(EXIT_FAILURE, "DRVDETACHDEV"); break; case 'l': list_children(fd, argc ? argv[0] : NULL, nflag, tflag, 0); @@ -153,7 +150,7 @@ main(int argc, char **argv) if (argc > 1) { locs = malloc((argc - 1) * sizeof(int)); if (!locs) -err(5, "malloc int[%d]", argc - 1); +err(EXIT_FAILURE, "malloc int[%d]", argc - 1); for (i = 0; i < argc - 1; i++) locs[i] = atoi(argv[i + 1]); raa.numlocators = argc - 1; @@ -161,10 +158,9 @@ main(int argc, char **argv) } if (ioctl(fd, DRVRESCANBUS, ) == -1) - err(3, "DRVRESCANBUS"); + err(EXIT_FAILURE, "DRVRESCANBUS"); break; case 'p': - command_dict = prop_dictionary_create(); args_dict = prop_dictionary_create(); @@ -177,26 +173,27 @@ main(int argc, char **argv) prop_object_release(string); prop_dictionary_set(command_dict, "drvctl-arguments", -args_dict); + args_dict); prop_object_release(args_dict); res = prop_dictionary_sendrecv_ioctl(command_dict, fd, - DRVCTLCOMMAND, - _dict); + DRVCTLCOMMAND, _dict); prop_object_release(command_dict); if (res) - errx(3, "DRVCTLCOMMAND: %s", strerror(res)); + errc(EXIT_FAILURE, res, "DRVCTLCOMMAND"); number = prop_dictionary_get(results_dict, "drvctl-error"); if (prop_number_integer_value(number) != 0) { - errx(3, "get-properties: %s", - strerror((int)prop_number_integer_value(number))); + errc(EXIT_FAILURE, + (int)prop_number_integer_value(number), + "get-properties"); } data_dict = prop_dictionary_get(results_dict, - "drvctl-result-data"); + "drvctl-result-data"); if (data_dict == NULL) { - errx(3, "get-properties: failed to
CVS commit: src/sbin/drvctl
Module Name:src Committed By: christos Date: Sun Jan 7 15:26:43 UTC 2018 Modified Files: src/sbin/drvctl: drvctl.c Log Message: KNF. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/drvctl
Module Name:src Committed By: sevan Date: Sun Sep 11 02:59:11 UTC 2016 Modified Files: src/sbin/drvctl: drvctl.8 Log Message: Document the version drvctl appeard. Reword bad sentence. Remove space in License. Bump date. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sbin/drvctl/drvctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/drvctl
Module Name:src Committed By: sevan Date: Sun Sep 11 02:59:11 UTC 2016 Modified Files: src/sbin/drvctl: drvctl.8 Log Message: Document the version drvctl appeard. Reword bad sentence. Remove space in License. Bump date. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sbin/drvctl/drvctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/drvctl/drvctl.8 diff -u src/sbin/drvctl/drvctl.8:1.17 src/sbin/drvctl/drvctl.8:1.18 --- src/sbin/drvctl/drvctl.8:1.17 Sat Aug 8 07:52:52 2015 +++ src/sbin/drvctl/drvctl.8 Sun Sep 11 02:59:11 2016 @@ -1,7 +1,7 @@ -.\" $NetBSD: drvctl.8,v 1.17 2015/08/08 07:52:52 mrg Exp $ +.\" $NetBSD: drvctl.8,v 1.18 2016/09/11 02:59:11 sevan Exp $ .\" .\" Copyright (c) 2004 -.\" Matthias Drochner. All rights reserved. +.\" Matthias Drochner. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 8, 2015 +.Dd September 11, 2016 .Dt DRVCTL 8 .Os .Sh NAME @@ -62,7 +62,7 @@ The .Nm program works with the .Xr drvctl 4 -pseudo-driver, and allows to rescan busses and to detach +pseudo-driver to allow the rescan of busses and to detach drivers from devices. .Pp The following options are available: @@ -161,6 +161,11 @@ attribute: .Xr proplib 3 , .Xr drvctl 4 , .Xr autoconf 9 +.Sh HISTORY +A +.Nm +utility appeard in +.Nx 4.0 . .Sh BUGS Currently, there is no good way to get information about locator lengths and default values (which is present at kernel configuration
CVS commit: src/sbin/drvctl
Module Name:src Committed By: pgoyette Date: Mon Dec 7 03:34:00 UTC 2015 Modified Files: src/sbin/drvctl: drvctl.c Log Message: synch usage() with the man page. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/drvctl/drvctl.c diff -u src/sbin/drvctl/drvctl.c:1.17 src/sbin/drvctl/drvctl.c:1.18 --- src/sbin/drvctl/drvctl.c:1.17 Tue Feb 24 18:15:29 2015 +++ src/sbin/drvctl/drvctl.c Mon Dec 7 03:34:00 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: drvctl.c,v 1.17 2015/02/24 18:15:29 mlelstv Exp $ */ +/* $NetBSD: drvctl.c,v 1.18 2015/12/07 03:34:00 pgoyette Exp $ */ /* * Copyright (c) 2004 @@ -55,7 +55,7 @@ usage(void) fprintf(stderr, "Usage: %s -r [-a attribute] busdevice [locator ...]\n" " %s -d device\n" " %s [-nt] -l [device]\n" - " %s [-n] -p device [prop]\n" + " %s [-n] -p device [property]\n" " %s -Q device\n" " %s -R device\n" " %s -S device\n",
CVS commit: src/sbin/drvctl
Module Name:src Committed By: pgoyette Date: Mon Dec 7 03:34:00 UTC 2015 Modified Files: src/sbin/drvctl: drvctl.c Log Message: synch usage() with the man page. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/drvctl
Module Name:src Committed By: mrg Date: Sat Aug 8 07:52:52 UTC 2015 Modified Files: src/sbin/drvctl: drvctl.8 Log Message: add an example for rescanning ATA busses. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sbin/drvctl/drvctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/drvctl/drvctl.8 diff -u src/sbin/drvctl/drvctl.8:1.16 src/sbin/drvctl/drvctl.8:1.17 --- src/sbin/drvctl/drvctl.8:1.16 Wed May 13 07:28:49 2015 +++ src/sbin/drvctl/drvctl.8 Sat Aug 8 07:52:52 2015 @@ -1,4 +1,4 @@ -.\ $NetBSD: drvctl.8,v 1.16 2015/05/13 07:28:49 mlelstv Exp $ +.\ $NetBSD: drvctl.8,v 1.17 2015/08/08 07:52:52 mrg Exp $ .\ .\ Copyright (c) 2004 .\ Matthias Drochner. All rights reserved. @@ -24,7 +24,7 @@ .\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\ SUCH DAMAGE. .\ -.Dd February 25, 2015 +.Dd August 8, 2015 .Dt DRVCTL 8 .Os .Sh NAME @@ -148,6 +148,15 @@ output. .El .Sh FILES .Pa /dev/drvctl +.Sh EXAMPLES +To scan for IDE/SATA/eSATA disks on +.Pa atabus1 , +which need to use the +.Qq ata_hl +attribute: +.Bd -literal -offset indent +# drvctl -r -a ata_hl atabus1 +.Ed .Sh SEE ALSO .Xr proplib 3 , .Xr drvctl 4 ,
CVS commit: src/sbin/drvctl
Module Name:src Committed By: mrg Date: Sat Aug 8 07:52:52 UTC 2015 Modified Files: src/sbin/drvctl: drvctl.8 Log Message: add an example for rescanning ATA busses. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sbin/drvctl/drvctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/drvctl
Module Name:src Committed By: wiz Date: Wed Feb 25 09:01:08 UTC 2015 Modified Files: src/sbin/drvctl: drvctl.8 Log Message: Bump date for previous. New sentence, new line. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sbin/drvctl/drvctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/drvctl
Module Name:src Committed By: wiz Date: Wed Feb 25 09:01:08 UTC 2015 Modified Files: src/sbin/drvctl: drvctl.8 Log Message: Bump date for previous. New sentence, new line. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sbin/drvctl/drvctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/drvctl/drvctl.8 diff -u src/sbin/drvctl/drvctl.8:1.14 src/sbin/drvctl/drvctl.8:1.15 --- src/sbin/drvctl/drvctl.8:1.14 Tue Feb 24 18:15:29 2015 +++ src/sbin/drvctl/drvctl.8 Wed Feb 25 09:01:08 2015 @@ -1,4 +1,4 @@ -.\ $NetBSD: drvctl.8,v 1.14 2015/02/24 18:15:29 mlelstv Exp $ +.\ $NetBSD: drvctl.8,v 1.15 2015/02/25 09:01:08 wiz Exp $ .\ .\ Copyright (c) 2004 .\ Matthias Drochner. All rights reserved. @@ -24,7 +24,7 @@ .\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\ SUCH DAMAGE. .\ -.Dd January 16, 2012 +.Dd February 25, 2015 .Dt DRVCTL 8 .Os .Sh NAME @@ -114,8 +114,8 @@ argument. If .Ar property is specified, the value of that property is printed, otherwise -the properties are displayed as an XML property list. The -property can be given as a path of dictionary keys and numeric +the properties are displayed as an XML property list. +The property can be given as a path of dictionary keys and numeric array indexes separated by slashes. .It Fl Q Resume the ancestors of
CVS commit: src/sbin/drvctl
Module Name:src Committed By: mlelstv Date: Tue Feb 24 18:15:29 UTC 2015 Modified Files: src/sbin/drvctl: drvctl.8 drvctl.c Log Message: Let drvctl -p select elements from an array property by numeric index. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sbin/drvctl/drvctl.8 cvs rdiff -u -r1.16 -r1.17 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/drvctl
Module Name:src Committed By: mlelstv Date: Tue Feb 24 18:15:29 UTC 2015 Modified Files: src/sbin/drvctl: drvctl.8 drvctl.c Log Message: Let drvctl -p select elements from an array property by numeric index. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sbin/drvctl/drvctl.8 cvs rdiff -u -r1.16 -r1.17 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/drvctl/drvctl.8 diff -u src/sbin/drvctl/drvctl.8:1.13 src/sbin/drvctl/drvctl.8:1.14 --- src/sbin/drvctl/drvctl.8:1.13 Mon Jan 16 19:43:50 2012 +++ src/sbin/drvctl/drvctl.8 Tue Feb 24 18:15:29 2015 @@ -1,4 +1,4 @@ -.\ $NetBSD: drvctl.8,v 1.13 2012/01/16 19:43:50 pgoyette Exp $ +.\ $NetBSD: drvctl.8,v 1.14 2015/02/24 18:15:29 mlelstv Exp $ .\ .\ Copyright (c) 2004 .\ Matthias Drochner. All rights reserved. @@ -114,7 +114,9 @@ argument. If .Ar property is specified, the value of that property is printed, otherwise -the properties are displayed as an XML property list. +the properties are displayed as an XML property list. The +property can be given as a path of dictionary keys and numeric +array indexes separated by slashes. .It Fl Q Resume the ancestors of .Ar device , Index: src/sbin/drvctl/drvctl.c diff -u src/sbin/drvctl/drvctl.c:1.16 src/sbin/drvctl/drvctl.c:1.17 --- src/sbin/drvctl/drvctl.c:1.16 Tue Jan 17 08:22:09 2012 +++ src/sbin/drvctl/drvctl.c Tue Feb 24 18:15:29 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: drvctl.c,v 1.16 2012/01/17 08:22:09 wiz Exp $ */ +/* $NetBSD: drvctl.c,v 1.17 2015/02/24 18:15:29 mlelstv Exp $ */ /* * Copyright (c) 2004 @@ -226,21 +226,37 @@ extract_property(prop_dictionary_t dict, { char *s, *p, *cur, *ep = NULL; prop_object_t obj; + unsigned long ind; + obj = dict; + cur = NULL; s = strdup(prop); p = strtok_r(s, /, ep); while (p) { cur = p; p = strtok_r(NULL, /, ep); - if (p) { - if (prop_dictionary_get_dict(dict, cur, dict) == false) + + switch (prop_object_type(obj)) { + case PROP_TYPE_DICTIONARY: + obj = prop_dictionary_get(obj, cur); + if (obj == NULL) exit(EXIT_FAILURE); - } else { - obj = prop_dictionary_get(dict, cur); - display_object(obj, nflag); + break; + case PROP_TYPE_ARRAY: + ind = strtoul(cur, NULL, 0); + obj = prop_array_get(obj, ind); + if (obj == NULL) +exit(EXIT_FAILURE); + break; + default: + fprintf(stderr, select neither dict nor array with '%s'\n, cur); + exit(EXIT_FAILURE); } } + if (obj != NULL cur != NULL) + display_object(obj, nflag); + free(s); }
CVS commit: src/sbin/drvctl
Module Name:src Committed By: wiz Date: Tue Jan 17 08:22:09 UTC 2012 Modified Files: src/sbin/drvctl: drvctl.c Log Message: Add -n to usage. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/drvctl/drvctl.c diff -u src/sbin/drvctl/drvctl.c:1.15 src/sbin/drvctl/drvctl.c:1.16 --- src/sbin/drvctl/drvctl.c:1.15 Mon Jan 16 19:43:50 2012 +++ src/sbin/drvctl/drvctl.c Tue Jan 17 08:22:09 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: drvctl.c,v 1.15 2012/01/16 19:43:50 pgoyette Exp $ */ +/* $NetBSD: drvctl.c,v 1.16 2012/01/17 08:22:09 wiz Exp $ */ /* * Copyright (c) 2004 @@ -55,7 +55,7 @@ usage(void) fprintf(stderr, Usage: %s -r [-a attribute] busdevice [locator ...]\n %s -d device\n %s [-nt] -l [device]\n - %s -p device [prop]\n + %s [-n] -p device [prop]\n %s -Q device\n %s -R device\n %s -S device\n,
CVS commit: src/sbin/drvctl
Module Name:src Committed By: wiz Date: Tue Jan 17 08:22:09 UTC 2012 Modified Files: src/sbin/drvctl: drvctl.c Log Message: Add -n to usage. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/drvctl
Module Name:src Committed By: pgoyette Date: Mon Jan 16 19:43:50 UTC 2012 Modified Files: src/sbin/drvctl: drvctl.8 drvctl.c Log Message: Enhance drvctl -p processing to handle new autoconfig info in property dictionaries. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sbin/drvctl/drvctl.8 cvs rdiff -u -r1.14 -r1.15 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/drvctl/drvctl.8 diff -u src/sbin/drvctl/drvctl.8:1.12 src/sbin/drvctl/drvctl.8:1.13 --- src/sbin/drvctl/drvctl.8:1.12 Sun Aug 7 13:00:35 2011 +++ src/sbin/drvctl/drvctl.8 Mon Jan 16 19:43:50 2012 @@ -1,4 +1,4 @@ -.\ $NetBSD: drvctl.8,v 1.12 2011/08/07 13:00:35 jmcneill Exp $ +.\ $NetBSD: drvctl.8,v 1.13 2012/01/16 19:43:50 pgoyette Exp $ .\ .\ Copyright (c) 2004 .\ Matthias Drochner. All rights reserved. @@ -24,7 +24,7 @@ .\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\ SUCH DAMAGE. .\ -.Dd August 7, 2011 +.Dd January 16, 2012 .Dt DRVCTL 8 .Os .Sh NAME @@ -44,6 +44,7 @@ .Fl l .Op Ar device .Nm +.Op Fl n .Fl p .Ar device .Op Ar property ... @@ -72,6 +73,13 @@ attached to (and which defines the inter the locator information). This will only be needed in rare cases where the bus has multiple attributes. +If there are multiple attributes, and one is not specified, +.Nm +will return an Invalid argument. +In such cases, the +.Fl p +option can be used to determine the available interface +attributes. .It Fl d Detach the device driver from the device given by the .Ar device @@ -96,6 +104,9 @@ The second column is the child. Suppress first column in .Fl l output. +Suppress non-XML headers in +.Fl p +output. .It Fl p Get properties for the device specified by the .Ar device @@ -143,4 +154,4 @@ output. Currently, there is no good way to get information about locator lengths and default values (which is present at kernel configuration time) out of a running kernel. -Thus the locator handling is less intelligent as it could be. +Thus the locator handling is less intelligent than it could be. Index: src/sbin/drvctl/drvctl.c diff -u src/sbin/drvctl/drvctl.c:1.14 src/sbin/drvctl/drvctl.c:1.15 --- src/sbin/drvctl/drvctl.c:1.14 Wed Oct 19 22:13:46 2011 +++ src/sbin/drvctl/drvctl.c Mon Jan 16 19:43:50 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: drvctl.c,v 1.14 2011/10/19 22:13:46 dyoung Exp $ */ +/* $NetBSD: drvctl.c,v 1.15 2012/01/16 19:43:50 pgoyette Exp $ */ /* * Copyright (c) 2004 @@ -44,7 +44,8 @@ : O_RDONLY) __dead static void usage(void); -static void extract_property(prop_dictionary_t, const char *); +static void extract_property(prop_dictionary_t, const char *, bool); +static void display_object(prop_object_t, bool); static void list_children(int, char *, bool, bool, int); static void @@ -208,7 +209,7 @@ main(int argc, char **argv) free(xml); } else { for (i = 1; i argc; i++) -extract_property(data_dict, argv[i]); +extract_property(data_dict, argv[i], nflag); } prop_object_release(results_dict); @@ -221,9 +222,9 @@ main(int argc, char **argv) } static void -extract_property(prop_dictionary_t dict, const char *prop) +extract_property(prop_dictionary_t dict, const char *prop, bool nflag) { - char *s, *p, *cur, *ep = NULL, *xml; + char *s, *p, *cur, *ep = NULL; prop_object_t obj; s = strdup(prop); @@ -236,31 +237,7 @@ extract_property(prop_dictionary_t dict, exit(EXIT_FAILURE); } else { obj = prop_dictionary_get(dict, cur); - if (obj == NULL) -exit(EXIT_FAILURE); - switch (prop_object_type(obj)) { - case PROP_TYPE_BOOL: -printf(%s\n, -prop_bool_true(obj) ? true : false); -break; - case PROP_TYPE_NUMBER: -printf(% PRId64 \n, -prop_number_integer_value(obj)); -break; - case PROP_TYPE_STRING: -printf(%s\n, -prop_string_cstring_nocopy(obj)); -break; - case PROP_TYPE_DICTIONARY: -xml = prop_dictionary_externalize(obj); -printf(%s, xml); -free(xml); -break; - default: -fprintf(stderr, unhandled type %d\n, -prop_object_type(obj)); -exit(EXIT_FAILURE); - } + display_object(obj, nflag); } } @@ -268,6 +245,43 @@ extract_property(prop_dictionary_t dict, } static void +display_object(prop_object_t obj, bool nflag) +{ + char *xml; + prop_object_t next_obj; + prop_object_iterator_t iter; + + if (obj == NULL) + exit(EXIT_FAILURE); + switch (prop_object_type(obj)) { + case PROP_TYPE_BOOL: + printf(%s\n, prop_bool_true(obj) ? true : false); + break; + case PROP_TYPE_NUMBER: + printf(% PRId64 \n, prop_number_integer_value(obj)); + break; + case PROP_TYPE_STRING: + printf(%s\n, prop_string_cstring_nocopy(obj)); + break; + case PROP_TYPE_DICTIONARY: + xml = prop_dictionary_externalize(obj); + printf(%s, xml); + free(xml); + break; + case PROP_TYPE_ARRAY: + iter =
CVS commit: src/sbin/drvctl
Module Name:src Committed By: pgoyette Date: Mon Jan 16 19:43:50 UTC 2012 Modified Files: src/sbin/drvctl: drvctl.8 drvctl.c Log Message: Enhance drvctl -p processing to handle new autoconfig info in property dictionaries. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sbin/drvctl/drvctl.8 cvs rdiff -u -r1.14 -r1.15 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/drvctl
Module Name:src Committed By: dyoung Date: Wed Oct 19 22:13:46 UTC 2011 Modified Files: src/sbin/drvctl: drvctl.c Log Message: Don't print the silly header, Properties for device `xxx0':, before the device properties if the -n option was given. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/drvctl/drvctl.c diff -u src/sbin/drvctl/drvctl.c:1.13 src/sbin/drvctl/drvctl.c:1.14 --- src/sbin/drvctl/drvctl.c:1.13 Mon Aug 29 14:34:59 2011 +++ src/sbin/drvctl/drvctl.c Wed Oct 19 22:13:46 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: drvctl.c,v 1.13 2011/08/29 14:34:59 joerg Exp $ */ +/* $NetBSD: drvctl.c,v 1.14 2011/10/19 22:13:46 dyoung Exp $ */ /* * Copyright (c) 2004 @@ -200,8 +200,11 @@ main(int argc, char **argv) if (argc == 1) { xml = prop_dictionary_externalize(data_dict); - printf(Properties for device `%s':\n%s, - argv[0], xml); + if (!nflag) { +printf(Properties for device `%s':\n, +argv[0]); + } + printf(%s, xml); free(xml); } else { for (i = 1; i argc; i++)
CVS commit: src/sbin/drvctl
Module Name:src Committed By: dyoung Date: Wed Oct 19 22:13:46 UTC 2011 Modified Files: src/sbin/drvctl: drvctl.c Log Message: Don't print the silly header, Properties for device `xxx0':, before the device properties if the -n option was given. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/drvctl
Module Name:src Committed By: jmcneill Date: Sun Aug 7 12:00:11 UTC 2011 Modified Files: src/sbin/drvctl: drvctl.8 drvctl.c Log Message: add an optional argument to the -p flag that lets you extract specific property values from the command-line: $ drvctl -p wd0 disk-info/geometry/cylinders-per-unit 620181 $ drvctl -p wd0 device-driver device-unit wd 0 $ drvctl -p wd0 nonexistent || echo not found not found To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sbin/drvctl/drvctl.8 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/drvctl/drvctl.8 diff -u src/sbin/drvctl/drvctl.8:1.10 src/sbin/drvctl/drvctl.8:1.11 --- src/sbin/drvctl/drvctl.8:1.10 Mon Apr 20 22:07:23 2009 +++ src/sbin/drvctl/drvctl.8 Sun Aug 7 12:00:11 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: drvctl.8,v 1.10 2009/04/20 22:07:23 wiz Exp $ +.\ $NetBSD: drvctl.8,v 1.11 2011/08/07 12:00:11 jmcneill Exp $ .\ .\ Copyright (c) 2004 .\ Matthias Drochner. All rights reserved. @@ -24,7 +24,7 @@ .\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\ SUCH DAMAGE. .\ -.Dd April 20, 2009 +.Dd August 7, 2011 .Dt DRVCTL 8 .Os .Sh NAME @@ -46,6 +46,7 @@ .Nm .Fl p .Ar device +.Op Ar property ... .Nm .Fl Q .Ar device @@ -96,10 +97,13 @@ .Fl l output. .It Fl p -Get the properties for the device specified by the +Get properties for the device specified by the .Ar device argument. -The properties are displayed as an XML property list. +If +.Ar property +is specified, the value of that property is printed, otherwise +the properties are displayed as an XML property list. .It Fl Q Resume the ancestors of .Ar device , Index: src/sbin/drvctl/drvctl.c diff -u src/sbin/drvctl/drvctl.c:1.10 src/sbin/drvctl/drvctl.c:1.11 --- src/sbin/drvctl/drvctl.c:1.10 Mon Apr 20 21:41:50 2009 +++ src/sbin/drvctl/drvctl.c Sun Aug 7 12:00:11 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: drvctl.c,v 1.10 2009/04/20 21:41:50 dyoung Exp $ */ +/* $NetBSD: drvctl.c,v 1.11 2011/08/07 12:00:11 jmcneill Exp $ */ /* * Copyright (c) 2004 @@ -26,6 +26,7 @@ * SUCH DAMAGE. */ +#include inttypes.h #include stdbool.h #include stdio.h #include stdlib.h @@ -43,6 +44,7 @@ : O_RDONLY) static void usage(void); +static void extract_property(prop_dictionary_t, const char *); static void usage(void) @@ -51,7 +53,7 @@ fprintf(stderr, Usage: %s -r [-a attribute] busdevice [locator ...]\n %s -d device\n %s [-n] -l [device]\n - %s -p device\n + %s -p device [prop]\n %s -Q device\n %s -R device\n %s -S device\n, @@ -219,12 +221,17 @@ errx(3, get-properties: failed to return result data); } - xml = prop_dictionary_externalize(data_dict); - prop_object_release(results_dict); + if (argc == 1) { + xml = prop_dictionary_externalize(data_dict); + printf(Properties for device `%s':\n%s, + argv[0], xml); + free(xml); + } else { + for (i = 1; i argc; i++) +extract_property(data_dict, argv[i]); + } - printf(Properties for device `%s':\n%s, - argv[0], xml); - free(xml); + prop_object_release(results_dict); break; default: errx(4, unknown command); @@ -232,3 +239,50 @@ return (0); } + +static void +extract_property(prop_dictionary_t dict, const char *prop) +{ + char *s, *p, *cur, *ep = NULL, *xml; + prop_object_t obj; + + s = strdup(prop); + p = strtok_r(s, /, ep); + while (p) { + cur = p; + p = strtok_r(NULL, /, ep); + if (p) { + if (prop_dictionary_get_dict(dict, cur, dict) == false) +exit(EXIT_FAILURE); + } else { + obj = prop_dictionary_get(dict, cur); + if (obj == NULL) +exit(EXIT_FAILURE); + switch (prop_object_type(obj)) { + case PROP_TYPE_BOOL: +printf(%s\n, +prop_bool_true(obj) ? true : false); +break; + case PROP_TYPE_NUMBER: +printf(% PRId64 \n, +prop_number_integer_value(obj)); +break; + case PROP_TYPE_STRING: +printf(%s\n, +prop_string_cstring_nocopy(obj)); +break; + case PROP_TYPE_DICTIONARY: +xml = prop_dictionary_externalize(obj); +printf(%s, xml); +free(xml); +break; + default: +fprintf(stderr, unhandled type %d\n, +prop_object_type(obj)); +exit(EXIT_FAILURE); + } + } + } + + free(s); +}
CVS commit: src/sbin/drvctl
Module Name:src Committed By: jmcneill Date: Sun Aug 7 13:00:35 UTC 2011 Modified Files: src/sbin/drvctl: drvctl.8 drvctl.c Log Message: add the -t option that modifies -l behaviour to recursively scan for child devices and print them in tree format: $ drvctl -lt usb0 uhub0 uhub6 uhidev0 ukbd0 wskbd1 uhidev1 ums0 wsmouse1 uhid0 ubt0 To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sbin/drvctl/drvctl.8 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/drvctl/drvctl.8 diff -u src/sbin/drvctl/drvctl.8:1.11 src/sbin/drvctl/drvctl.8:1.12 --- src/sbin/drvctl/drvctl.8:1.11 Sun Aug 7 12:00:11 2011 +++ src/sbin/drvctl/drvctl.8 Sun Aug 7 13:00:35 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: drvctl.8,v 1.11 2011/08/07 12:00:11 jmcneill Exp $ +.\ $NetBSD: drvctl.8,v 1.12 2011/08/07 13:00:35 jmcneill Exp $ .\ .\ Copyright (c) 2004 .\ Matthias Drochner. All rights reserved. @@ -40,7 +40,7 @@ .Fl d .Ar device .Nm -.Op Fl n +.Op Fl nt .Fl l .Op Ar device .Nm @@ -128,6 +128,10 @@ and .Ar device itself. +.It Fl t +Print a tree of devices in +.Fl l +output. .El .Sh FILES .Pa /dev/drvctl Index: src/sbin/drvctl/drvctl.c diff -u src/sbin/drvctl/drvctl.c:1.11 src/sbin/drvctl/drvctl.c:1.12 --- src/sbin/drvctl/drvctl.c:1.11 Sun Aug 7 12:00:11 2011 +++ src/sbin/drvctl/drvctl.c Sun Aug 7 13:00:35 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: drvctl.c,v 1.11 2011/08/07 12:00:11 jmcneill Exp $ */ +/* $NetBSD: drvctl.c,v 1.12 2011/08/07 13:00:35 jmcneill Exp $ */ /* * Copyright (c) 2004 @@ -37,7 +37,7 @@ #include sys/ioctl.h #include sys/drvctlio.h -#define OPTS QRSa:dlnpr +#define OPTS QRSa:dlnprt #define OPEN_MODE(mode) \ (((mode) == 'd' || (mode) == 'r') ? O_RDWR \ @@ -45,6 +45,7 @@ static void usage(void); static void extract_property(prop_dictionary_t, const char *); +static void list_children(int, char *, bool, bool, int); static void usage(void) @@ -52,7 +53,7 @@ fprintf(stderr, Usage: %s -r [-a attribute] busdevice [locator ...]\n %s -d device\n - %s [-n] -l [device]\n + %s [-nt] -l [device]\n %s -p device [prop]\n %s -Q device\n %s -R device\n @@ -65,16 +66,13 @@ int main(int argc, char **argv) { - bool nflag = false; + bool nflag = false, tflag = false; int c, mode; char *attr = 0; extern char *optarg; extern int optind; int fd, res; - size_t children; struct devpmargs paa = {.devname = , .flags = 0}; - struct devlistargs laa = {.l_devname = , .l_childname = NULL, - .l_children = 0}; struct devdetachargs daa; struct devrescanargs raa; int *locs, i; @@ -102,6 +100,9 @@ case 'n': nflag = true; break; + case 't': + tflag = nflag = true; + break; case '?': default: usage(); @@ -141,31 +142,7 @@ err(3, DRVDETACHDEV); break; case 'l': - if (argc == 0) - *laa.l_devname = '\0'; - else - strlcpy(laa.l_devname, argv[0], sizeof(laa.l_devname)); - - if (ioctl(fd, DRVLISTDEV, laa) == -1) - err(3, DRVLISTDEV); - - children = laa.l_children; - - laa.l_childname = malloc(children * sizeof(laa.l_childname[0])); - if (laa.l_childname == NULL) - err(5, DRVLISTDEV); - if (ioctl(fd, DRVLISTDEV, laa) == -1) - err(3, DRVLISTDEV); - if (laa.l_children children) - err(6, DRVLISTDEV: number of children grew); - - for (i = 0; i (int)laa.l_children; i++) { - if (!nflag) { -printf(%s , -(argc == 0) ? root : laa.l_devname); - } - printf(%s\n, laa.l_childname[i]); - } + list_children(fd, argc ? argv[0] : NULL, nflag, tflag, 0); break; case 'r': memset(raa, 0, sizeof(raa)); @@ -286,3 +263,49 @@ free(s); } + +static void +list_children(int fd, char *dvname, bool nflag, bool tflag, int depth) +{ + struct devlistargs laa = {.l_devname = , .l_childname = NULL, + .l_children = 0}; + size_t children; + int i, n; + + if (dvname == NULL) { + if (depth 0) + return; + *laa.l_devname = '\0'; + } else { + strlcpy(laa.l_devname, dvname, sizeof(laa.l_devname)); + } + + if (ioctl(fd, DRVLISTDEV, laa) == -1) + err(3, DRVLISTDEV); + + children = laa.l_children; + + laa.l_childname = malloc(children * sizeof(laa.l_childname[0])); + if (laa.l_childname == NULL) + err(5, DRVLISTDEV); + if (ioctl(fd, DRVLISTDEV, laa) == -1) + err(3, DRVLISTDEV); + if (laa.l_children children) + err(6, DRVLISTDEV: number of children grew); + + for (i = 0; i (int)laa.l_children; i++) { + for (n = 0; n depth; n++) + printf( ); + if (!nflag) { + printf(%s , + (dvname == NULL) ? root : laa.l_devname); + } + printf(%s\n, laa.l_childname[i]); + if (tflag) { + list_children(fd, laa.l_childname[i], nflag, + tflag, depth + 1); + } + } + + free(laa.l_childname); +}
CVS commit: src/sbin/drvctl
Module Name:src Committed By: jmcneill Date: Sun Aug 7 12:00:11 UTC 2011 Modified Files: src/sbin/drvctl: drvctl.8 drvctl.c Log Message: add an optional argument to the -p flag that lets you extract specific property values from the command-line: $ drvctl -p wd0 disk-info/geometry/cylinders-per-unit 620181 $ drvctl -p wd0 device-driver device-unit wd 0 $ drvctl -p wd0 nonexistent || echo not found not found To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sbin/drvctl/drvctl.8 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/drvctl
Module Name:src Committed By: jmcneill Date: Sun Aug 7 13:00:35 UTC 2011 Modified Files: src/sbin/drvctl: drvctl.8 drvctl.c Log Message: add the -t option that modifies -l behaviour to recursively scan for child devices and print them in tree format: $ drvctl -lt usb0 uhub0 uhub6 uhidev0 ukbd0 wskbd1 uhidev1 ums0 wsmouse1 uhid0 ubt0 To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sbin/drvctl/drvctl.8 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/drvctl
Module Name:src Committed By: dyoung Date: Mon Apr 20 21:41:51 UTC 2009 Modified Files: src/sbin/drvctl: drvctl.c Log Message: Mention -n in usage. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sbin/drvctl/drvctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/drvctl/drvctl.c diff -u src/sbin/drvctl/drvctl.c:1.9 src/sbin/drvctl/drvctl.c:1.10 --- src/sbin/drvctl/drvctl.c:1.9 Mon Apr 20 21:40:42 2009 +++ src/sbin/drvctl/drvctl.c Mon Apr 20 21:41:50 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: drvctl.c,v 1.9 2009/04/20 21:40:42 dyoung Exp $ */ +/* $NetBSD: drvctl.c,v 1.10 2009/04/20 21:41:50 dyoung Exp $ */ /* * Copyright (c) 2004 @@ -50,7 +50,7 @@ fprintf(stderr, Usage: %s -r [-a attribute] busdevice [locator ...]\n %s -d device\n - %s -l [device]\n + %s [-n] -l [device]\n %s -p device\n %s -Q device\n %s -R device\n
CVS commit: src/sbin/drvctl
Module Name:src Committed By: wiz Date: Mon Apr 20 22:04:57 UTC 2009 Modified Files: src/sbin/drvctl: drvctl.8 Log Message: Bump date for previous. Remove trailing whitespace. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sbin/drvctl/drvctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/drvctl/drvctl.8 diff -u src/sbin/drvctl/drvctl.8:1.7 src/sbin/drvctl/drvctl.8:1.8 --- src/sbin/drvctl/drvctl.8:1.7 Mon Apr 20 21:40:42 2009 +++ src/sbin/drvctl/drvctl.8 Mon Apr 20 22:04:57 2009 @@ -1,4 +1,4 @@ -.\ $NetBSD: drvctl.8,v 1.7 2009/04/20 21:40:42 dyoung Exp $ +.\ $NetBSD: drvctl.8,v 1.8 2009/04/20 22:04:57 wiz Exp $ .\ .\ Copyright (c) 2004 .\ Matthias Drochner. All rights reserved. @@ -24,7 +24,7 @@ .\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\ SUCH DAMAGE. .\ -.Dd April 4, 2009 +.Dd April 20, 2009 .Dt DRVCTL 8 .Os .Sh NAME @@ -88,7 +88,7 @@ .Dq root if .Ar device -is not specified. +is not specified. The second column is the child. .It Fl p Get the properties for the device specified by the
CVS commit: src/sbin/drvctl
Module Name:src Committed By: wiz Date: Mon Apr 20 22:05:47 UTC 2009 Modified Files: src/sbin/drvctl: drvctl.8 Log Message: Add -n to usage. Now it just needs to be documented. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sbin/drvctl/drvctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/drvctl/drvctl.8 diff -u src/sbin/drvctl/drvctl.8:1.8 src/sbin/drvctl/drvctl.8:1.9 --- src/sbin/drvctl/drvctl.8:1.8 Mon Apr 20 22:04:57 2009 +++ src/sbin/drvctl/drvctl.8 Mon Apr 20 22:05:47 2009 @@ -1,4 +1,4 @@ -.\ $NetBSD: drvctl.8,v 1.8 2009/04/20 22:04:57 wiz Exp $ +.\ $NetBSD: drvctl.8,v 1.9 2009/04/20 22:05:47 wiz Exp $ .\ .\ Copyright (c) 2004 .\ Matthias Drochner. All rights reserved. @@ -40,6 +40,7 @@ .Fl d .Ar device .Nm +.Op Fl n .Fl l .Op Ar device .Nm