git: 08939ccadc25 - stable/13 - stand: Add devformat to return formatted string for a device
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 24 Jan 2023 22:11:56 UTC
The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=08939ccadc253933d6cbff55f6d9b1b82707bc8e commit 08939ccadc253933d6cbff55f6d9b1b82707bc8e Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2022-08-11 15:06:09 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2023-01-24 21:49:30 +0000 stand: Add devformat to return formatted string for a device Use dv_fmtdev to return a formatted string for a device. If this is a null pointer, return the device name and unit followed by a colon (eg disk3:). Sponsored by: Netflix Reviewed by: tsoome (prior version) Differential Revision: https://reviews.freebsd.org/D35916 (cherry picked from commit dc472f67021320309ced970d3d26d30a04da0ef2) --- stand/libsa/dev.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/stand/libsa/dev.c b/stand/libsa/dev.c index 1d1dd075580e..2ccdce22d596 100644 --- a/stand/libsa/dev.c +++ b/stand/libsa/dev.c @@ -56,3 +56,14 @@ noioctl(struct open_file *f __unused, u_long cmd __unused, void *data __unused) { return (EINVAL); } + +char * +devformat(struct devdesc *d) +{ + static char name[DEV_DEVLEN]; + + if (d->d_dev->dv_fmtdev != NULL) + return (d->d_dev->dv_fmtdev(d)); + snprintf(name, sizeof(name), "%s%d:", d->d_dev->dv_name, d->d_unit); + return (name); +}