Date: Fri, 5 May 2023 16:20:54 GMT From: Doug Ambrisko <ambrisko@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 7e0f8b79b773 - main - Add mrsasutil(8) as alias to mfiutil(8) Message-ID: <202305051620.345GKsNh005252@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by ambrisko: URL: https://cgit.FreeBSD.org/src/commit/?id=7e0f8b79b773276712234421f140c8c6ebc0f780 commit 7e0f8b79b773276712234421f140c8c6ebc0f780 Author: Doug Ambrisko <ambrisko@FreeBSD.org> AuthorDate: 2022-08-24 22:38:43 +0000 Commit: Doug Ambrisko <ambrisko@FreeBSD.org> CommitDate: 2023-05-05 16:20:48 +0000 Add mrsasutil(8) as alias to mfiutil(8) mfiutil(8) in theory can work on devices attached to mrsas(4) but mrsas(4) is missing the FreeBSD mfi(4) ioctl support. Once that support is added to mrsas(4) then mrsasutil(8) can manage mrsas(4) attached devices. So this commit depends on that. When mrsasutil(8) is run it automatically opens /dev/mrsas0 instead of /dev/mfi0. Add -D <device> and -t <type> flag to optionally specify mrsas or mfi to work with the existing -u <unit>. Device is the device node with or without /dev/ PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=265794 Differential Revision: https://reviews.freebsd.org/D36343 Tested by: Dan Mahoney <freebsd@gushi.org> Reviewed by: jhb --- usr.sbin/mfiutil/Makefile | 2 + usr.sbin/mfiutil/mfi_bbu.c | 4 +- usr.sbin/mfiutil/mfi_cmd.c | 29 +++++++---- usr.sbin/mfiutil/mfi_config.c | 91 ++++++++++++++++----------------- usr.sbin/mfiutil/mfi_drive.c | 14 ++--- usr.sbin/mfiutil/mfi_evt.c | 10 ++-- usr.sbin/mfiutil/mfi_flash.c | 4 +- usr.sbin/mfiutil/mfi_foreign.c | 58 ++++++++++----------- usr.sbin/mfiutil/mfi_patrol.c | 8 +-- usr.sbin/mfiutil/mfi_properties.c | 12 ++--- usr.sbin/mfiutil/mfi_show.c | 37 +++++++------- usr.sbin/mfiutil/mfi_volume.c | 10 ++-- usr.sbin/mfiutil/mfiutil.8 | 104 ++++++++++++++++++++++++++++++++++++-- usr.sbin/mfiutil/mfiutil.c | 43 ++++++++++++++-- usr.sbin/mfiutil/mfiutil.h | 11 ++-- 15 files changed, 294 insertions(+), 143 deletions(-) diff --git a/usr.sbin/mfiutil/Makefile b/usr.sbin/mfiutil/Makefile index dc6f3e481593..139e31d6c41d 100644 --- a/usr.sbin/mfiutil/Makefile +++ b/usr.sbin/mfiutil/Makefile @@ -1,10 +1,12 @@ # $FreeBSD$ PROG= mfiutil +LINKS= ${BINDIR}/mfiutil ${BINDIR}/mrsasutil SRCS= mfiutil.c mfi_bbu.c mfi_cmd.c mfi_config.c mfi_drive.c mfi_evt.c \ mfi_flash.c mfi_patrol.c mfi_show.c mfi_volume.c mfi_foreign.c \ mfi_properties.c MAN8= mfiutil.8 +MLINKS= mfiutil.8 mrsasutil.8 CFLAGS.gcc+= -fno-builtin-strftime diff --git a/usr.sbin/mfiutil/mfi_bbu.c b/usr.sbin/mfiutil/mfi_bbu.c index 343d101661da..6c1a76aeacc3 100644 --- a/usr.sbin/mfiutil/mfi_bbu.c +++ b/usr.sbin/mfiutil/mfi_bbu.c @@ -134,7 +134,7 @@ start_bbu_learn(int ac, char **av __unused) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -171,7 +171,7 @@ update_bbu_props(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); diff --git a/usr.sbin/mfiutil/mfi_cmd.c b/usr.sbin/mfiutil/mfi_cmd.c index 094c9017348b..d0df65ecb937 100644 --- a/usr.sbin/mfiutil/mfi_cmd.c +++ b/usr.sbin/mfiutil/mfi_cmd.c @@ -44,6 +44,7 @@ #include <string.h> #include <time.h> #include <unistd.h> +#include <paths.h> #include "mfiutil.h" #include <dev/mfi/mfi_ioctl.h> @@ -209,15 +210,23 @@ mfi_volume_busy(int fd, uint8_t target_id) * configuration of the mfi controller. */ int -mfi_reconfig_supported(void) +mfi_reconfig_supported(const char *dev) { char mibname[64]; + const char *cp; size_t len; - int dummy; + int dummy, mfi_unit; + + cp = dev + strlen(_PATH_DEV); + if (strncmp(cp, MRSAS_TYPE, strlen(MRSAS_TYPE)) == 0) + return (1); + + cp += strlen(MFI_TYPE); + mfi_unit = strtol(cp, NULL, 10);; len = sizeof(dummy); - snprintf(mibname, sizeof(mibname), "dev.mfi.%d.delete_busy_volumes", - mfi_unit); + snprintf(mibname, sizeof(mibname), + "dev.mfi.%d.delete_busy_volumes", mfi_unit); return (sysctlbyname(mibname, &dummy, &len, NULL, 0) == 0); } @@ -239,7 +248,7 @@ mfi_lookup_volume(int fd, const char *name, uint8_t *target_id) if (mfi_dcmd_command(fd, MFI_DCMD_LD_GET_LIST, &list, sizeof(list), NULL, 0, NULL) < 0) - return (-1); + return (-1); for (i = 0; i < list.ld_count; i++) { if (mfi_query_disk(fd, list.ld_list[i].ld.v.target_id, @@ -304,12 +313,14 @@ mfi_ctrl_get_info(int fd, struct mfi_ctrl_info *info, uint8_t *statusp) } int -mfi_open(int unit, int acs) +mfi_open(char *dev, int acs) { - char path[MAXPATHLEN]; + int ret; - snprintf(path, sizeof(path), "/dev/mfi%d", unit); - return (open(path, acs)); + ret = open(dev, acs); + if (ret < 0) + warn("Couldn't open %s", dev); + return (ret); } static void diff --git a/usr.sbin/mfiutil/mfi_config.c b/usr.sbin/mfiutil/mfi_config.c index 0ee78fca0613..e2afbe52e0c3 100644 --- a/usr.sbin/mfiutil/mfi_config.c +++ b/usr.sbin/mfiutil/mfi_config.c @@ -35,6 +35,7 @@ #ifdef DEBUG #include <sys/sysctl.h> #endif +#include <ctype.h> #include <err.h> #include <errno.h> #include <fcntl.h> @@ -52,30 +53,30 @@ static int remove_spare(int ac, char **av); static long dehumanize(const char *value) { - char *vtp; - long iv; - - if (value == NULL) - return (0); - iv = strtoq(value, &vtp, 0); - if (vtp == value || (vtp[0] != '\0' && vtp[1] != '\0')) { - return (0); - } - switch (vtp[0]) { - case 't': case 'T': - iv *= 1024; - case 'g': case 'G': - iv *= 1024; - case 'm': case 'M': - iv *= 1024; - case 'k': case 'K': - iv *= 1024; - case '\0': - break; - default: - return (0); - } - return (iv); + char *vtp; + long iv; + + if (value == NULL) + return (0); + iv = strtoq(value, &vtp, 0); + if (vtp == value || (vtp[0] != '\0' && vtp[1] != '\0')) { + return (0); + } + switch (vtp[0]) { + case 't': case 'T': + iv *= 1024; + case 'g': case 'G': + iv *= 1024; + case 'm': case 'M': + iv *= 1024; + case 'k': case 'K': + iv *= 1024; + case '\0': + break; + default: + return (0); + } + return (iv); } int @@ -162,16 +163,16 @@ clear_config(int ac __unused, char **av __unused) int ch, error, fd; u_int i; - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); return (error); } - if (!mfi_reconfig_supported()) { - warnx("The current mfi(4) driver does not support " - "configuration changes."); + if (!mfi_reconfig_supported(mfi_device)) { + warnx("The current %s driver does not support " + "configuration changes.", mfi_device); close(fd); return (EOPNOTSUPP); } @@ -193,8 +194,8 @@ clear_config(int ac __unused, char **av __unused) } printf( - "Are you sure you wish to clear the configuration on mfi%u? [y/N] ", - mfi_unit); + "Are you sure you wish to clear the configuration on %s? [y/N] ", + mfi_device); ch = getchar(); if (ch != 'y' && ch != 'Y') { printf("\nAborting\n"); @@ -209,7 +210,7 @@ clear_config(int ac __unused, char **av __unused) return (error); } - printf("mfi%d: Configuration cleared\n", mfi_unit); + printf("%s: Configuration cleared\n", mfi_device); close(fd); return (0); @@ -587,16 +588,16 @@ create_volume(int ac, char **av) narrays = 0; error = 0; - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); return (error); } - if (!mfi_reconfig_supported()) { - warnx("The current mfi(4) driver does not support " - "configuration changes."); + if (!mfi_reconfig_supported(mfi_device)) { + warnx("The current %s(4) driver does not support " + "configuration changes.", mfi_device); error = EOPNOTSUPP; goto error; } @@ -869,16 +870,16 @@ delete_volume(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); return (error); } - if (!mfi_reconfig_supported()) { - warnx("The current mfi(4) driver does not support " - "configuration changes."); + if (!mfi_reconfig_supported(mfi_device)) { + warnx("The current %s(4) driver does not support " + "configuration changes.", mfi_device); close(fd); return (EOPNOTSUPP); } @@ -937,7 +938,7 @@ add_spare(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -1027,7 +1028,7 @@ add_spare(int ac, char **av) ar->array_ref); error = EINVAL; goto error; - } + } spare->array_ref[i] = ar->array_ref; } } @@ -1062,7 +1063,7 @@ remove_spare(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -1120,7 +1121,7 @@ dump_config(int fd, struct mfi_config_data *config, const char *msg_prefix) msg_prefix = "Configuration (Debug)"; printf( - "mfi%d %s: %d arrays, %d volumes, %d spares\n", mfi_unit, + "%s %s: %d arrays, %d volumes, %d spares\n", mfi_device, msg_prefix, config->array_count, config->log_drv_count, config->spares_count); printf(" array size: %u\n", config->array_size); @@ -1211,7 +1212,7 @@ debug_config(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -1248,7 +1249,7 @@ dump(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); diff --git a/usr.sbin/mfiutil/mfi_drive.c b/usr.sbin/mfiutil/mfi_drive.c index 4fd8fb93dd4c..17231af13fb0 100644 --- a/usr.sbin/mfiutil/mfi_drive.c +++ b/usr.sbin/mfiutil/mfi_drive.c @@ -74,7 +74,7 @@ mfi_drive_name(struct mfi_pd_info *pinfo, uint16_t device_id, uint32_t def) else snprintf(buf, sizeof(buf), "%2u", device_id); - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { warn("mfi_open"); return (buf); @@ -388,7 +388,7 @@ drive_set_state(char *drive, uint16_t new_state) uint8_t mbox[6]; int error, fd; - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -503,7 +503,7 @@ start_rebuild(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -560,7 +560,7 @@ abort_rebuild(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -616,7 +616,7 @@ drive_progress(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -682,7 +682,7 @@ drive_clear(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -742,7 +742,7 @@ drive_locate(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); diff --git a/usr.sbin/mfiutil/mfi_evt.c b/usr.sbin/mfiutil/mfi_evt.c index 915fbb7125bf..68b78ea6bfa9 100644 --- a/usr.sbin/mfiutil/mfi_evt.c +++ b/usr.sbin/mfiutil/mfi_evt.c @@ -77,7 +77,7 @@ show_logstate(int ac, char **av __unused) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -91,13 +91,13 @@ show_logstate(int ac, char **av __unused) return (error); } - printf("mfi%d Event Log Sequence Numbers:\n", mfi_unit); + printf("%s Event Log Sequence Numbers:\n", mfi_device); printf(" Newest Seq #: %u\n", info.newest_seq_num); printf(" Oldest Seq #: %u\n", info.oldest_seq_num); printf(" Clear Seq #: %u\n", info.clear_seq_num); printf("Shutdown Seq #: %u\n", info.shutdown_seq_num); printf(" Boot Seq #: %u\n", info.boot_seq_num); - + close(fd); return (0); @@ -547,7 +547,7 @@ show_events(int ac, char **av) int ch, error, fd, num_events, verbose; u_int i; - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -691,7 +691,7 @@ show_events(int ac, char **av) * need to know the size of the buffer somehow. */ seq = list->event[list->count - 1].seq + 1; - + } finish: if (first) diff --git a/usr.sbin/mfiutil/mfi_flash.c b/usr.sbin/mfiutil/mfi_flash.c index 239390acf7b5..fe2ccbd3d80f 100644 --- a/usr.sbin/mfiutil/mfi_flash.c +++ b/usr.sbin/mfiutil/mfi_flash.c @@ -58,7 +58,7 @@ display_pending_firmware(int fd) return (error); } - printf("mfi%d Pending Firmware Images:\n", mfi_unit); + printf("%s Pending Firmware Images:\n", mfi_device); strcpy(header.name, "Name"); strcpy(header.version, "Version"); strcpy(header.build_date, "Date"); @@ -122,7 +122,7 @@ flash_adapter(int ac, char **av) goto error; } - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); diff --git a/usr.sbin/mfiutil/mfi_foreign.c b/usr.sbin/mfiutil/mfi_foreign.c index ce4b8a704bea..f2662cb9de7a 100644 --- a/usr.sbin/mfiutil/mfi_foreign.c +++ b/usr.sbin/mfiutil/mfi_foreign.c @@ -48,7 +48,7 @@ foreign_clear(__unused int ac, __unused char **av) { int ch, error, fd; - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -57,7 +57,7 @@ foreign_clear(__unused int ac, __unused char **av) printf( "Are you sure you wish to clear ALL foreign configurations" - " on mfi%u? [y/N] ", mfi_unit); + " on %s? [y/N] ", mfi_device); ch = getchar(); if (ch != 'y' && ch != 'Y') { @@ -74,7 +74,7 @@ foreign_clear(__unused int ac, __unused char **av) return (error); } - printf("mfi%d: Foreign configuration cleared\n", mfi_unit); + printf("%s: Foreign configuration cleared\n", mfi_device); close(fd); return (0); } @@ -86,7 +86,7 @@ foreign_scan(__unused int ac, __unused char **av) struct mfi_foreign_scan_info info; int error, fd; - fd = mfi_open(mfi_unit, O_RDONLY); + fd = mfi_open(mfi_device, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -101,7 +101,7 @@ foreign_scan(__unused int ac, __unused char **av) return (error); } - printf("mfi%d: Found %d foreign configurations\n", mfi_unit, + printf("%s: Found %d foreign configurations\n", mfi_device, info.count); close(fd); return (0); @@ -143,7 +143,7 @@ foreign_show_cfg(int fd, uint32_t opcode, uint8_t cfgidx, int diagnostic) ld_list = (char *)(config->array); - printf("%s: %d arrays, %d volumes, %d spares\n", prefix, + printf("%s: %d arrays, %d volumes, %d spares\n", prefix, config->array_count, config->log_drv_count, config->spares_count); @@ -152,28 +152,28 @@ foreign_show_cfg(int fd, uint32_t opcode, uint8_t cfgidx, int diagnostic) ld_list += config->array_size; for (i = 0; i < config->log_drv_count; i++) { - const char *level; - char size[6], stripe[5]; + const char *level; + char size[6], stripe[5]; struct mfi_ld_config *ld; ld = (struct mfi_ld_config *)ld_list; - format_stripe(stripe, sizeof(stripe), - ld->params.stripe_size); + format_stripe(stripe, sizeof(stripe), + ld->params.stripe_size); /* * foreign configs don't seem to have a secondary raid level * but, we can use span depth here as if a LD spans multiple * arrays of disks (2 raid 1 sets for example), we will have an * indication based on the spam depth. swb - */ - level = mfi_raid_level(ld->params.primary_raid_level, - (ld->params.span_depth - 1)); + */ + level = mfi_raid_level(ld->params.primary_raid_level, + (ld->params.span_depth - 1)); - humanize_number(size, sizeof(size), ld->span[0].num_blocks * 512, - "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); + humanize_number(size, sizeof(size), ld->span[0].num_blocks * 512, + "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); printf(" ID%d ", i); - printf("(%6s) %-8s |", + printf("(%6s) %-8s |", size, level); printf("volume spans %d %s\n", ld->params.span_depth, (ld->params.span_depth > 1) ? "arrays" : "array"); @@ -183,9 +183,9 @@ foreign_show_cfg(int fd, uint32_t opcode, uint8_t cfgidx, int diagnostic) uint16_t device_id; printf(" array %u @ ", ld->span[j].array_ref); - humanize_number(size, sizeof(size), ld->span[j].num_blocks * 512, - "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); - + humanize_number(size, sizeof(size), ld->span[j].num_blocks * 512, + "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); + printf("(%6s)\n",size); ar_list = (char *)config->array + (ld->span[j].array_ref * config->array_size); @@ -196,7 +196,7 @@ foreign_show_cfg(int fd, uint32_t opcode, uint8_t cfgidx, int diagnostic) printf(" drive MISSING\n"); else { printf(" drive %u %s\n", device_id, - mfi_pdstate(ar->pd[k].fw_state)); + mfi_pdstate(ar->pd[k].fw_state)); } } @@ -222,7 +222,7 @@ display_format(int ac, char **av, int diagnostic, mfi_dcmd_t display_cmd) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDONLY); + fd = mfi_open(mfi_device, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -262,7 +262,7 @@ display_format(int ac, char **av, int diagnostic, mfi_dcmd_t display_cmd) return (error); } } - + close(fd); return (0); } @@ -294,7 +294,7 @@ foreign_import(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -318,7 +318,7 @@ foreign_import(int ac, char **av) if (ac == 1) { cfgidx = 0xff; printf("Are you sure you wish to import ALL foreign " - "configurations on mfi%u? [y/N] ", mfi_unit); + "configurations on %s? [y/N] ", mfi_device); } else { /* * While this is docmmented for MegaCli this failed with @@ -334,7 +334,7 @@ foreign_import(int ac, char **av) return (EINVAL); } printf("Are you sure you wish to import the foreign " - "configuration %d on mfi%u? [y/N] ", cfgidx, mfi_unit); + "configuration %d on %s? [y/N] ", cfgidx, mfi_device); } ch = getchar(); @@ -355,11 +355,11 @@ foreign_import(int ac, char **av) } if (ac == 1) - printf("mfi%d: All foreign configurations imported\n", - mfi_unit); + printf("%s: All foreign configurations imported\n", + mfi_device); else - printf("mfi%d: Foreign configuration %d imported\n", mfi_unit, - cfgidx); + printf("%s: Foreign configuration %d imported\n", + mfi_device, cfgidx); close(fd); return (0); } diff --git a/usr.sbin/mfiutil/mfi_patrol.c b/usr.sbin/mfiutil/mfi_patrol.c index a1dbb1336f1b..3071fa0a8ace 100644 --- a/usr.sbin/mfiutil/mfi_patrol.c +++ b/usr.sbin/mfiutil/mfi_patrol.c @@ -89,7 +89,7 @@ show_patrol(int ac __unused, char **av __unused) int error, fd; u_int i; - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -199,7 +199,7 @@ start_patrol(int ac __unused, char **av __unused) { int error, fd; - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -225,7 +225,7 @@ stop_patrol(int ac __unused, char **av __unused) { int error, fd; - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -295,7 +295,7 @@ patrol_config(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); diff --git a/usr.sbin/mfiutil/mfi_properties.c b/usr.sbin/mfiutil/mfi_properties.c index f5affe14bd50..2e49312d7867 100644 --- a/usr.sbin/mfiutil/mfi_properties.c +++ b/usr.sbin/mfiutil/mfi_properties.c @@ -3,7 +3,7 @@ * * Copyright (c) 2013 Yahoo!, Inc. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -64,7 +64,7 @@ mfi_ctrl_set_properties(int fd, struct mfi_ctrl_props *info) } /* - * aquite the controller properties data structure modify the + * aquire the controller properties data structure modify the * rebuild rate if requested and then retun */ static int @@ -77,8 +77,8 @@ mfi_ctrl_rebuild_rate(int ac, char **av) warn("mfi_ctrl_set_rebuild_rate"); return(-1); } - - fd = mfi_open(mfi_unit, O_RDWR); + + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -129,8 +129,8 @@ mfi_ctrl_alarm_enable(int ac, char **av) warn("mfi_ctrl_alarm_enable"); return(-1); } - - fd = mfi_open(mfi_unit, O_RDWR); + + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); diff --git a/usr.sbin/mfiutil/mfi_show.c b/usr.sbin/mfiutil/mfi_show.c index 17c967762963..d1ab70cf641b 100644 --- a/usr.sbin/mfiutil/mfi_show.c +++ b/usr.sbin/mfiutil/mfi_show.c @@ -50,7 +50,7 @@ void format_stripe(char *buf, size_t buflen, uint8_t stripe) { - humanize_number(buf, buflen, (1 << stripe) * 512, "", HN_AUTOSCALE, + humanize_number(buf, buflen, (1 << stripe) * 512, "", HN_AUTOSCALE, HN_B | HN_NOSPACE); } @@ -66,7 +66,7 @@ show_adapter(int ac, char **av __unused) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDONLY); + fd = mfi_open(mfi_device, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -79,7 +79,7 @@ show_adapter(int ac, char **av __unused) close(fd); return (error); } - printf("mfi%d Adapter:\n", mfi_unit); + printf("%s Adapter:\n", mfi_device); printf(" Product Name: %.80s\n", info.product_name); printf(" Serial Number: %.32s\n", info.serial_number); if (info.package_version[0] != '\0') @@ -155,7 +155,7 @@ show_battery(int ac, char **av __unused) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDONLY); + fd = mfi_open(mfi_device, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -170,7 +170,7 @@ show_battery(int ac, char **av __unused) return (error); } if (status == MFI_STAT_NO_HW_PRESENT) { - printf("mfi%d: No battery present\n", mfi_unit); + printf("%s: No battery present\n", mfi_device); close(fd); return (0); } @@ -200,7 +200,7 @@ show_battery(int ac, char **av __unused) } show_props = (status == MFI_STAT_OK); - printf("mfi%d: Battery State:\n", mfi_unit); + printf("%s: Battery State:\n", mfi_device); printf(" Manufacture Date: %d/%d/%d\n", design.mfg_date >> 5 & 0x0f, design.mfg_date & 0x1f, design.mfg_date >> 9 & 0xffff); printf(" Serial Number: %d\n", design.serial_number); @@ -357,7 +357,7 @@ show_config(int ac, char **av __unused) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDONLY); + fd = mfi_open(mfi_device, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -373,8 +373,8 @@ show_config(int ac, char **av __unused) } /* Dump out the configuration. */ - printf("mfi%d Configuration: %d arrays, %d volumes, %d spares\n", - mfi_unit, config->array_count, config->log_drv_count, + printf("%s Configuration: %d arrays, %d volumes, %d spares\n", + mfi_device, config->array_count, config->log_drv_count, config->spares_count); p = (char *)config->array; @@ -458,7 +458,7 @@ show_volumes(int ac, char **av __unused) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDONLY); + fd = mfi_open(mfi_device, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -474,7 +474,7 @@ show_volumes(int ac, char **av __unused) } /* List the volumes. */ - printf("mfi%d Volumes:\n", mfi_unit); + printf("%s Volumes:\n", mfi_device); state_len = strlen("State"); for (i = 0; i < list.ld_count; i++) { len = strlen(mfi_ldstate(list.ld_list[i].state)); @@ -541,7 +541,7 @@ show_drives(int ac, char **av __unused) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDONLY); + fd = mfi_open(mfi_device, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -576,7 +576,7 @@ show_drives(int ac, char **av __unused) } /* List the drives. */ - printf("mfi%d Physical Drives:\n", mfi_unit); + printf("%s Physical Drives:\n", mfi_device); for (i = 0; i < list->count; i++) { /* Skip non-hard disks. */ @@ -621,7 +621,7 @@ show_firmware(int ac, char **av __unused) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDONLY); + fd = mfi_open(mfi_device, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -636,9 +636,9 @@ show_firmware(int ac, char **av __unused) } if (info.package_version[0] != '\0') - printf("mfi%d Firmware Package Version: %s\n", mfi_unit, + printf("%s Firmware Package Version: %s\n", mfi_device, info.package_version); - printf("mfi%d Firmware Images:\n", mfi_unit); + printf("%s Firmware Images:\n", mfi_device); strcpy(header.name, "Name"); strcpy(header.version, "Version"); strcpy(header.build_date, "Date"); @@ -681,7 +681,7 @@ show_progress(int ac, char **av __unused) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDONLY); + fd = mfi_open(mfi_device, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); @@ -776,7 +776,8 @@ show_progress(int ac, char **av __unused) close(fd); if (!busy) - printf("No activity in progress for adapter mfi%d\n", mfi_unit); + printf("No activity in progress for adapter %s\n", + mfi_device); return (0); } diff --git a/usr.sbin/mfiutil/mfi_volume.c b/usr.sbin/mfiutil/mfi_volume.c index 2bc913374b86..8a0e911155c0 100644 --- a/usr.sbin/mfiutil/mfi_volume.c +++ b/usr.sbin/mfiutil/mfi_volume.c @@ -297,7 +297,7 @@ volume_cache(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -319,7 +319,7 @@ volume_cache(int ac, char **av) } if (ac == 2) { - printf("mfi%u volume %s cache settings:\n", mfi_unit, + printf("%s volume %s cache settings:\n", mfi_device, mfi_volume_name(fd, target_id)); printf(" I/O caching: "); switch (props.default_cache_policy & @@ -406,7 +406,7 @@ volume_name(int ac, char **av) return (ENOSPC); } - fd = mfi_open(mfi_unit, O_RDWR); + fd = mfi_open(mfi_device, O_RDWR); if (fd < 0) { error = errno; warn("mfi_open"); @@ -427,7 +427,7 @@ volume_name(int ac, char **av) return (error); } - printf("mfi%u volume %s name changed from \"%s\" to \"%s\"\n", mfi_unit, + printf("%s volume %s name changed from \"%s\" to \"%s\"\n", mfi_device, mfi_volume_name(fd, target_id), props.name, av[2]); bzero(props.name, sizeof(props.name)); strcpy(props.name, av[2]); @@ -457,7 +457,7 @@ volume_progress(int ac, char **av) return (EINVAL); } - fd = mfi_open(mfi_unit, O_RDONLY); + fd = mfi_open(mfi_device, O_RDONLY); if (fd < 0) { error = errno; warn("mfi_open"); diff --git a/usr.sbin/mfiutil/mfiutil.8 b/usr.sbin/mfiutil/mfiutil.8 index 29409ad53e46..6b92ce049b86 100644 --- a/usr.sbin/mfiutil/mfiutil.8 +++ b/usr.sbin/mfiutil/mfiutil.8 @@ -31,26 +31,37 @@ .Dt MFIUTIL 8 .Os .Sh NAME -.Nm mfiutil +.Nm mfiutil , +.Nm mrsasutil .Nd Utility for managing LSI MegaRAID SAS controllers .Sh SYNOPSIS .Nm .Cm version .Nm +.Op Fl D Ar device +.Op Fl t Ar type .Op Fl u Ar unit .Cm show adapter .Nm +.Op Fl D Ar device +.Op Fl t Ar type .Op Fl u Ar unit .Cm show battery .Nm .Op Fl d .Op Fl e +.Op Fl D Ar device +.Op Fl t Ar type *** 383 LINES SKIPPED ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202305051620.345GKsNh005252>