git: 40d340acb931 - main - stand: Implement ofw disk print routine
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 30 Nov 2022 22:31:28 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=40d340acb9316db5771fe777e279776b903336d4 commit 40d340acb9316db5771fe777e279776b903336d4 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2022-11-30 22:09:56 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2022-11-30 22:30:33 +0000 stand: Implement ofw disk print routine Have lsdev show openfirmware devices. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D37555 --- stand/libofw/ofw_disk.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/stand/libofw/ofw_disk.c b/stand/libofw/ofw_disk.c index 8f4c0162d32b..67da8cbeb310 100644 --- a/stand/libofw/ofw_disk.c +++ b/stand/libofw/ofw_disk.c @@ -184,6 +184,30 @@ ofwd_ioctl(struct open_file *f, u_long cmd, void *data) static int ofwd_print(int verbose __unused) { + uintmax_t block_size, n; + int ret; + char line[80]; + + /* + * We don't have a list of devices since we don't parse the whole OFW + * tree to find them. Instead, if we have an open device print info + * about it. Otherwise say we can't. Makes lsdev nicer. + */ + if ((ret = pager_output("block devices:\n")) != 0) + return (ret); + if (kdp != NULL) { + block_size = OF_block_size(kdp->d_handle); + n = OF_blocks(kdp->d_handle); + snprintf(line, sizeof(line), + " %s: OFW block device (%ju X %ju): %ju bytes\n", + kdp->d_path, n, block_size, n * block_size); + if ((ret = pager_output(line)) != 0) + return (ret); + } else { + if ((ret = pager_output(" none are open, so no info\n")) != 0) + return (ret); + } + return (0); } static char *