Re: aarch64 lib32 vs. armv7 mdconfig behavior: "mdconfig: ioctl(/dev/mdctl): Inappropriate ioctl for device"

Mark Millard <[email protected]>
Newsgroups gmane.os.freebsd.devel.arm,gmane.os.freebsd.current
Message-ID <[email protected]>
On Jul 31, 2023, at 23:22, Mark Millard <[email protected]> wrote:

> Not via a chroot'd context, but using the files from a
> directory tree that allows an armv7 chroot:
> 
> # /usr/obj/DESTDIRs/main-CA7-chroot/sbin/mdconfig -s40m
> mdconfig: ioctl(/dev/mdctl): Inappropriate ioctl for device
> 
> This sort of thing messes up the operation of the likes
> of the /usr/tests/sbin/growfs/legacy_test logic:
> 
> #! /usr/local/bin/perl
> # $FreeBSD$
> 
> use strict;
> use warnings;
> use POSIX;
> use Test::More tests => 19;
> use Fcntl qw(:DEFAULT :seek);
> . . .
> SKIP: {
>    skip "Cannot test without UID 0", 19 if $<;
> 
>    chomp(my $md = `mdconfig -s40m`);
>    like($md, qr/^md\d+$/, "Created $md with size 40m") or die;
>    $unit = substr $md, 2;
> . . .
> 
> 
> Other ioctl complaints:
> 
> sys/aio/aio_test:md_kq  ->  failed: ioctl MDIOCATTACH failed: Inappropriate ioctl for device
> sys/aio/aio_test:md_poll  ->  failed: ioctl MDIOCATTACH failed: Inappropriate ioctl for device
> sys/aio/aio_test:md_signal  ->  failed: ioctl MDIOCATTACH failed: Inappropriate ioctl for device
> sys/aio/aio_test:md_suspend  ->  failed: ioctl MDIOCATTACH failed: Inappropriate ioctl for device
> sys/aio/aio_test:md_thread  ->  failed: ioctl MDIOCATTACH failed: Inappropriate ioctl for device
> sys/aio/aio_test:md_waitcomplete  ->  failed: ioctl MDIOCATTACH failed: Inappropriate ioctl for device
> sys/aio/aio_test:vectored_md_poll  ->  failed: ioctl MDIOCATTACH failed: Inappropriate ioctl for device
> 
> 
> For reference:
> 
> # uname -apKU
> FreeBSD CA78C-WDK23-ZFS 14.0-CURRENT FreeBSD 14.0-CURRENT aarch64 1400093 #5 main-n264334-215bab7924f6-dirty: Wed Jul 26 02:13:44 PDT 2023     root@CA78C-WDK23-ZFS:/usr/obj/BUILDs/main-CA78C-nodbg-clang/usr/main-src/arm64.aarch64/sys/GENERIC-NODBG-CA78C arm64 aarch64 1400093 1400093


Adding more examples of ioctl failure contexts . . .

sys/netpfil/pf/ioctl/validation:clrtstats  ->  failed: Request with size -1 failed 

is actually at least associated with a ioctl use:

ATF_TC_BODY(clrtstats, tc)
{
        struct pfioc_table io;
        struct pfr_table tbl;
        int flags;
                 COMMON_HEAD();
                 flags = 0;
                 common_init_tbl(&tbl);

        bzero(&io, sizeof(io));
        io.pfrio_flags = flags;
        io.pfrio_buffer = &tbl;
        io.pfrio_esize = sizeof(tbl);
                         /* Negative size. This will succeed, because the kernel will not copy
         * tables than it has. */
        io.pfrio_size = -1;
        if (ioctl(dev, DIOCRCLRTSTATS, &io) != 0)
                atf_tc_fail("Request with size -1 failed ");

DIOCGETSRCNODES, DIOCRGETTABLES, DIOCRGETTSTATS, and DIOCRSETTFLAGS
are similar and get the notice as well.

The earlier aio_test examples are from:

static int
aio_md_setup(void)
{
        int error, fd, mdctl_fd, unit;
        char pathname[PATH_MAX];
        struct md_ioctl mdio;
        char buf[80];
 
        ATF_REQUIRE_KERNEL_MODULE("aio");
 
        mdctl_fd = open("/dev/" MDCTL_NAME, O_RDWR, 0);
        ATF_REQUIRE_MSG(mdctl_fd != -1,
            "opening /dev/%s failed: %s", MDCTL_NAME, strerror(errno));
 
        bzero(&mdio, sizeof(mdio));
        mdio.md_version = MDIOVERSION;
        mdio.md_type = MD_MALLOC;
        mdio.md_options = MD_AUTOUNIT | MD_COMPRESS;
        mdio.md_mediasize = GLOBAL_MAX;
        mdio.md_sectorsize = 512;
        strlcpy(buf, __func__, sizeof(buf));
        mdio.md_label = buf;

        if (ioctl(mdctl_fd, MDIOCATTACH, &mdio) < 0) {
                error = errno;
                errno = error;
                atf_tc_fail("ioctl MDIOCATTACH failed: %s", strerror(errno));
        }
. . .


===
Mark Millard
marklmi at yahoo.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.