Page MenuHomeFreeBSD

Add mrsasutil(8) as alias to mfiutil(8)
ClosedPublic

Authored by ambrisko on Aug 24 2022, 10:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 16, 10:50 AM
Unknown Object (File)
Jan 9 2024, 5:18 PM
Unknown Object (File)
Jan 9 2024, 5:18 PM
Unknown Object (File)
Jan 9 2024, 5:18 PM
Unknown Object (File)
Jan 9 2024, 5:17 PM
Unknown Object (File)
Jan 9 2024, 5:17 PM
Unknown Object (File)
Jan 1 2024, 8:48 AM
Unknown Object (File)
Dec 29 2023, 1:20 AM

Details

Summary

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.
Also a -t <type> flag to optionally specify mrsas or mfi to work
with the existing -u <unit>.

PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=265794
Tested by: Dan Mahoney <freebsd@gushi.org>

Test Plan

This depends on https://reviews.freebsd.org/D36342 to provide the FreeBSD mfi(4) ioctl in mrsas(4) so this tool can run with mrsas(4). Tested on some random mrsas(4) attached controlled as mrsasutil and a long time ago mfiutuil -t mrsas. Other people have found this useful so adding to FreeBSD src.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ambrisko added reviewers: imp, emaste, jhb.

I wonder if we want some kind of '-D mfi0' type option (either with or without leading /dev) that specifies the device name as well as -t? If you went this route then maybe what would happen is '-D' would set a char *mfi_device variable, and after parsing the options in main(), mfi_device would be constructed from mfi_type and mfi_unit if it isn't already set.

usr.sbin/mfiutil/mfiutil.c
133

Using strdup would seem simpler? Plus, why do you need it allocated vs just assigning to the constant? That is, I would make mfi_type a const char * and have this code just do:

if (strcmp(pn, "mrsasutil") == 0)
    mfi_type = MRSAS_TYPE;
else
    mfi_type = MFI_TYPE;

Address feedback on malloc. I thought I ran into type conflicts before.
I'll look at the -D suggestion.

This change looks pretty mechanical, but one of the sorts of changes that if it compiles it looks like it would work :)

This revision is now accepted and ready to land.Aug 30 2022, 1:46 AM

Add the mfi_device and get rid of mfi_type and mfi_unit.
-D <device> will be made of -t <type> and -u <unit> if not
specified. -t <type> will come from the program name if neither
are specified. Fix up a couple of "mfi" messages and fix unit in the
-t man page description.

This revision now requires review to proceed.Aug 30 2022, 11:42 PM

Fix white space in mfiutil.c.

Thanks for using the mfi_device approach. A few more comments.

usr.sbin/mfiutil/mfi_cmd.c
213

Maybe pass in const char *mfi_device here instead? That avoids having to deal with allocating the type name and freeing that out in the callers.

230–231

This could then become something like:

const char *cp;
int mfi_unit;

cp = mfi_device + strlen("/dev/");
if (strncmp(cp, MRSAS_TYPE, strlen(MRSAS_TYPE)) == 0)
    return (1);

cp += strlen("mfi");
mfi_unit = strtol(cp, , NULL, 10);
len = sizeof(dummy);
...
usr.sbin/mfiutil/mfi_config.c
56–79

Maybe do the whitespace fixes as a separate commit before the content changes to use mfi_device?

usr.sbin/mfiutil/mfiutil.c
162
163–172

It is probably simpler to just use asprintf(3) here. That is, something like:

if (asprintf(&mfi_device, "/dev/%s%d", mfi_type, mfi_unit) == -1)
    errx(1, "Can't allocate memory for device name");
174

Maybe #include <paths.h> and use _PATH_DEV?

176

I would use asprintf() + errx() here as well.

Address jhb's latest round of comments.

ambrisko added inline comments.
usr.sbin/mfiutil/mfi_cmd.c
213

Changed it to address the initial issue so sort of done.

usr.sbin/mfiutil/mfiutil.8
271

three options are supported?

ambrisko marked an inline comment as done.

Address global count and make plural.

Yes, three options and make plural.

One thing that does occur to me is that now a few messages will say things like "/dev/mfi0: <blah blah>" instead of "mfi0: <blah blah>", but that's probably ok. If you wanted you could maybe make a little const char *mfi_name(const char *mfi_device) that just returned mfi_device + strlen(_PATH_DEV) or some such.

That said, I'm fine with you committing regardless.

usr.sbin/mfiutil/mfi_config.c
174

Nit: might want to drop (4) here as it would now say something like "The current mfi0(4) driver"

usr.sbin/mfiutil/mfi_properties.c
67

An old typo, but maybe fix it since you are changing the line anyway?

This revision is now accepted and ready to land.Jan 20 2023, 12:06 AM
yuri_aetern.org added inline comments.
usr.sbin/mfiutil/mfiutil.8
34–35

Or at least add whitespace between mfiutil and comma so the latter isn't parsed as part of the macro.

275

New sentence, new line.

281

Punctuation and links.

820–821

Add mrsas to "see also"

Updated based on man page comments.

This revision now requires review to proceed.Apr 14 2023, 10:36 PM

Missed a couple of changes to man page.

ambrisko marked 4 inline comments as done.

Missing a couple of comments from jhb.

This revision is now accepted and ready to land.Apr 18 2023, 8:24 PM
This revision was automatically updated to reflect the committed changes.