diff options
| author | ktullavik <ktullavik@gmail.com> | 2024-10-17 19:01:51 +0000 |
|---|---|---|
| committer | Warner Losh <imp@FreeBSD.org> | 2025-05-06 22:01:46 +0000 |
| commit | c73b33f85a4d34d221c125780a059d86a8351f0b (patch) | |
| tree | 84c4f8bf1852e5f2b78863154f52e04bd6e7265c | |
| parent | 471cff3eba5318ea5800a22ba0de547fa7da601a (diff) | |
devinfo: Add helper function
This is prep for libxo.
No functional change intended.
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1480
| -rw-r--r-- | usr.sbin/devinfo/devinfo.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/usr.sbin/devinfo/devinfo.c b/usr.sbin/devinfo/devinfo.c index d12f9d4ec331..04809323ec70 100644 --- a/usr.sbin/devinfo/devinfo.c +++ b/usr.sbin/devinfo/devinfo.c @@ -52,6 +52,7 @@ static int print_device(struct devinfo_dev *, void *); static int print_rman_resource(struct devinfo_res *, void *); static int print_rman(struct devinfo_rman *, void *); static int print_device_path(struct devinfo_dev *, void *); +static void print_path(struct devinfo_dev *, char *); struct indent_arg { @@ -286,6 +287,15 @@ print_device_path(struct devinfo_dev *dev, void *xname) return (rv); } +static void +print_path(struct devinfo_dev *root, char *path) +{ + if (devinfo_foreach_device_child(root, print_device_path, (void *)path) == 0) + errx(1, "%s: Not found", path); + if (!vflag) + printf("\n"); +} + static void __dead2 usage(void) { @@ -336,10 +346,7 @@ main(int argc, char *argv[]) errx(1, "can't find root device"); if (path) { - if (devinfo_foreach_device_child(root, print_device_path, (void *)path) == 0) - errx(1, "%s: Not found", path); - if (!vflag) - printf("\n"); + print_path(root, path); } else if (uflag) { /* print resource usage? */ devinfo_foreach_rman(print_rman, NULL); |
