]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Improve unit parsing of mpsutil.
authorjmallett <jmallett@FreeBSD.org>
Tue, 16 Jun 2020 19:21:28 +0000 (19:21 +0000)
committerjmallett <jmallett@FreeBSD.org>
Tue, 16 Jun 2020 19:21:28 +0000 (19:21 +0000)
commitcf128a57977e88cc5f79eb6b1d7f95248ec60101
tree1b7de7cc290dc6f3c8a2044adc6deaba0f363b97
parent9ea76245ef98a4dd6fb31f6348a30d3aa8a95f20
Improve unit parsing of mpsutil.

Previously, it used atoi(3) to parse the unit parameter, which would silently
yield a unit of 0 in the presence of an invalid unit number.  As most users of
mpsutil(8) are likely to have at least a unit 0, this is could have confusing
results.

This behaviour was particularly unintuitive if one incorrectly passed an
adapter device name, or a device path, instead of a unit number.  In addition
to using strtoumax(3) instead of atoi(3) to parse unit numbers, support
stripping a device name (e.g. mps1) or path (e.g. /dev/mps2) to just its unit
number.

Reviewed by: scottl (earlier version)
usr.sbin/mpsutil/mpsutil.c