Skip to contentSkip to conversation

bsd-user: upstream ioctl

PATCH Superseded Warner Losh 2 participants 39 messages Apr 29 – Apr 30

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover bsd-user: upstream ioctl

Again with the help of claude, harvest the ioctl changes from bsd-user blitz branch. These are a bit messy, since ioctls tend to be a bit messy. Ideally, all this would be generated, but that code isn't ready yet, so we go with what we have.

Please note: All style complaints are false positives. The > 80 character ones are fine: these files are semi-generated from upstream and fixing them makes syncing harder. Harder syncing in code that's basically boilerplate is worse than lines that are too long for definitions people are never going to read.

The two errors:
● b64902a56387: bsd-user: Add bsd-ioctl.c infrastructure and termios conversion
● checkpatch.pl: 197: ERROR: Macros with complex values should be enclosed in parenthesis ● checkpatch.pl: 198: ERROR: Macros with complex values should be enclosed in parenthesis
are impossible to fix: they are what they need to be for the macro
tricks that are being used. One cannot add parenthesis and have correct code.

This is largerly unchanged from v1, which didn't get any reviews.

---
Changes in v2:
- rebase forward, minor tweaks for blitz branch evolution
- Link to v1: https://lore.kernel.org/qemu-devel/[email protected]

---
Stacey D. Son (10):
bsd-user: Add FreeBSD tty ioctl definitions
bsd-user: Add FreeBSD file I/O ioctl definitions
bsd-user: Add FreeBSD socket ioctl definitions
bsd-user: Add FreeBSD cryptodev ioctl definitions
bsd-user: Add FreeBSD disk ioctl definitions
bsd-user: Add FreeBSD IPv6 ioctl definitions
bsd-user: Add FreeBSD ioctl type definitions
bsd-user: Add FreeBSD ioctl command table
bsd-user: Add bsd-ioctl.h header
bsd-user: Add target_sockaddr and safe_ioctl to syscall_defs.h

Warner Losh (7):
bsd-user: Add bsd-ioctl.c infrastructure and termios conversion
bsd-user: Add log_unsupported_ioctl function
bsd-user: Add do_ioctl_unsupported function
bsd-user: Add target_to_host_sockaddr_in6 function
bsd-user: Add do_ioctl_in6_ifreq_sockaddr_int function
bsd-user: Add do_bsd_ioctl main function
bsd-user: Add init_bsd_ioctl function

 bsd-user/bsd-ioctl.c                  | 438 ++++++++++++++++++++++++++++++++++
 bsd-user/bsd-ioctl.h                  |  14 ++
 bsd-user/freebsd/os-ioctl-cmds.h      | 151 ++++++++++++
 bsd-user/freebsd/os-ioctl-cryptodev.h |  74 ++++++
 bsd-user/freebsd/os-ioctl-disk.h      |  41 ++++
 bsd-user/freebsd/os-ioctl-filio.h     |  34 +++
 bsd-user/freebsd/os-ioctl-in6_var.h   | 217 +++++++++++++++++
 bsd-user/freebsd/os-ioctl-sockio.h    | 240 +++++++++++++++++++
 bsd-user/freebsd/os-ioctl-ttycom.h    | 237 ++++++++++++++++++
 bsd-user/freebsd/os-ioctl-types.h     | 104 ++++++++
 bsd-user/syscall_defs.h               |  10 +
 11 files changed, 1560 insertions(+)

---
base-commit: becd22fdc2a071783d9e04421526633772b3b98c
change-id: 20260411-ioctl-68c80a77ad32
prerequisite-change-id: 20260312-share-thunk-ab1585477999:v2
prerequisite-patch-id: a048e442d9dda7ee4ed1070ef5eb524e078b9a3b

Best regards,

Signature · 1 line
Warner Losh <[email protected]>
#1 lore raw

PATCH v2 1/17 bsd-user: Add FreeBSD tty ioctl definitions

From: "Stacey D. Son" <[email protected]>

Add os-ioctl-ttycom.h with terminal control ioctl definitions including TARGET_TIOCGETA, TARGET_TIOCSETA, window size ioctls, and the target_termios structure for terminal I/O control.

---
 bsd-user/freebsd/os-ioctl-ttycom.h | 237 +++++++++++++++++++++++++++++++++++++
 1 file changed, 237 insertions(+)
bsd-user/freebsd/os-ioctl-ttycom.h new file +237 -0
new file mode 100644
index 0000000000..94ffa06558
@@ -0,0 +1,237 @@
+/*
+ * FreeBSD ttycom definitions for ioctl(2) emulation
+ *
+ * Copyright (c) 2013 Stacey D. Son
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef BSD_USER_FREEBSD_OS_IOCTL_TTYCOM_H
+#define BSD_USER_FREEBSD_OS_IOCTL_TTYCOM_H
+
+#include "os-ioctl-ioccom.h"
+
+/* From sys/ttycom.h and sys/_termios.h */
+
+#define TARGET_VEOF     0   /* ICANON */
+#define TARGET_VEOL     1   /* ICANON */
+#define TARGET_VEOL2    2   /* ICANON together with IEXTEN */
+#define TARGET_VERASE   3   /* ICANON */
+#define TARGET_VWERASE  4   /* ICANON together with IEXTEN */
+#define TARGET_VKILL    5   /* ICANON */
+#define TARGET_VREPRINT 6   /* ICANON together with IEXTEN */
+#define TARGET_VERASE2  7   /* ICANON */
+#define TARGET_VINTR    8   /* ISIG */
+#define TARGET_VQUIT    9   /* ISIG */
+#define TARGET_VSUSP    10  /* ISIG */
+#define TARGET_VDSUSP   11  /* ISIG together with IEXTEN */
+#define TARGET_VSTART   12  /* IXON, IXOFF */
+#define TARGET_VSTOP    13  /* IXON, IXOFF */
+#define TARGET_VLNEXT   14  /* IEXTEN */
+#define TARGET_VDISCARD 15  /* IEXTEN */
+#define TARGET_VMIN     16  /* !ICANON */
+#define TARGET_VTIME    17  /* !ICANON */
+#define TARGET_VSTATUS  18  /* ICANON together with IEXTEN */
+/*                      19         spare 2 */
+#define TARGET_NCCS     20
+
+/*
+ * Input flags - software input processing
+ */
+#define TARGET_IGNBRK   0x00000001  /* ignore BREAK condition */
+#define TARGET_BRKINT   0x00000002  /* map BREAK to SIGINTR */
+#define TARGET_IGNPAR   0x00000004  /* ignore (discard) parity errors */
+#define TARGET_PARMRK   0x00000008  /* mark parity and framing errors */
+#define TARGET_INPCK    0x00000010  /* enable checking of parity errors */
+#define TARGET_ISTRIP   0x00000020  /* strip 8th bit off chars */
+#define TARGET_INLCR    0x00000040  /* map NL into CR */
+#define TARGET_IGNCR    0x00000080  /* ignore CR */
+#define TARGET_ICRNL    0x00000100  /* map CR to NL (ala CRMOD) */
+#define TARGET_IXON     0x00000200  /* enable output flow control */
+#define TARGET_IXOFF    0x00000400  /* enable input flow control */
+#define TARGET_IXANY    0x00000800  /* any char will restart after stop */
+#define TARGET_IMAXBEL  0x00002000  /* ring bell on input queue full */
+
+/*
+ * Output flags - software output processing
+ */
+#define TARGET_OPOST    0x00000001  /* enable following output processing */
+#define TARGET_ONLCR    0x00000002  /* map NL to CR-NL (ala CRMOD) */
+#define TARGET_TABDLY   0x00000004  /* tab delay mask */
+#define TARGET_TAB0     0x00000000  /* no tab delay and expansion */
+#define TARGET_TAB3     0x00000004  /* expand tabs to spaces */
+#define TARGET_ONOEOT   0x00000008  /* discard EOT's (^D) on output) */
+#define TARGET_OCRNL    0x00000010  /* map CR to NL on output */
+#define TARGET_ONOCR    0x00000020  /* no CR output at column 0 */
+#define TARGET_ONLRET   0x00000040  /* NL performs CR function */
+
+/*
+ * Control flags - hardware control of terminal
+ */
+#define TARGET_CIGNORE      0x00000001  /* ignore control flags */
+#define TARGET_CSIZE        0x00000300  /* character size mask */
+#define     TARGET_CS5      0x00000000  /* 5 bits (pseudo) */
+#define     TARGET_CS6      0x00000100  /* 6 bits */
+#define     TARGET_CS7      0x00000200  /* 7 bits */
+#define     TARGET_CS8      0x00000300  /* 8 bits */
+#define TARGET_CSTOPB       0x00000400  /* send 2 stop bits */
+#define TARGET_CREAD        0x00000800  /* enable receiver */
+#define TARGET_PARENB       0x00001000  /* parity enable */
+#define TARGET_PARODD       0x00002000  /* odd parity, else even */
+#define TARGET_HUPCL        0x00004000  /* hang up on last close */
+#define TARGET_CLOCAL       0x00008000  /* ignore modem status lines */
+#define TARGET_CCTS_OFLOW   0x00010000  /* CTS flow control of output */
+#define TARGET_CRTSCTS      (TARGET_CCTS_OFLOW | TARGET_CRTS_IFLOW)
+#define TARGET_CRTS_IFLOW   0x00020000  /* RTS flow control of input */
+#define TARGET_CDTR_IFLOW   0x00040000  /* DTR flow control of input */
+#define TARGET_CDSR_OFLOW   0x00080000  /* DSR flow control of output */
+#define TARGET_CCAR_OFLOW   0x00100000  /* DCD flow control of output */
+
+/*
+ * "Local" flags - dumping ground for other state
+ */
+#define TARGET_ECHOKE   0x00000001  /* visual erase for line kill */
+#define TARGET_ECHOE    0x00000002  /* visually erase chars */
+#define TARGET_ECHOK    0x00000004  /* echo NL after line kill */
+#define TARGET_ECHO 0x00000008  /* enable echoing */
+#define TARGET_ECHONL   0x00000010  /* echo NL even if ECHO is off */
+#define TARGET_ECHOPRT  0x00000020  /* visual erase mode for hardcopy */
+#define TARGET_ECHOCTL  0x00000040  /* echo control chars as ^(Char) */
+#define TARGET_ISIG 0x00000080  /* enable signals INTR, QUIT, [D]SUSP */
+#define TARGET_ICANON   0x00000100  /* canonicalize input lines */
+#define TARGET_ALTWERASE 0x00000200 /* use alternate WERASE algorithm */
+#define TARGET_IEXTEN   0x00000400  /* enable DISCARD and LNEXT */
+#define TARGET_EXTPROC  0x00000800  /* external processing */
+#define TARGET_TOSTOP   0x00400000  /* stop background jobs from output */
+#define TARGET_FLUSHO   0x00800000  /* output being flushed (state) */
+#define TARGET_NOKERNINFO 0x02000000    /* no kernel output from VSTATUS */
+#define TARGET_PENDIN   0x20000000  /* XXX retype pending input (state) */
+#define TARGET_NOFLSH   0x80000000  /* don't flush after interrupt */
+
+struct target_termios {
+    uint32_t c_iflag;   /* input flags */
+    uint32_t c_oflag;   /* output flags */
+    uint32_t c_cflag;   /* control flags */
+    uint32_t c_lflag;   /* local flags */
+    uint8_t  c_cc[TARGET_NCCS]; /* control chars */
+    uint32_t c_ispeed;  /* input speed */
+    uint32_t c_ospeed;  /* output speed */
+};
+
+
+struct target_winsize {
+    uint16_t ws_row;    /* rows, in characters */
+    uint16_t ws_col;    /* columns, in characters */
+    uint16_t ws_xpixel; /* horizontal size, pixels */
+    uint16_t ws_ypixel; /* vertical size, pixels */
+};
+
+                        /* 0-2 compat */
+                        /* 3-7 unused */
+                        /* 8-10 compat */
+                        /* 11-12 unused */
+#define TARGET_TIOCEXCL  TARGET_IO('t', 13) /* set exclusive use of tty */
+#define TARGET_TIOCNXCL  TARGET_IO('t', 14) /* reset exclusive use of tty */
+#define TARGET_TIOCGPTN  TARGET_IOR('t', 15, int) /* Get pts number. */
+#define TARGET_TIOCFLUSH TARGET_IOW('t', 16, int) /* flush buffers */
+                    /* 17-18 compat */
+/* get termios struct */
+#define TARGET_TIOCGETA TARGET_IOR('t', 19, struct target_termios)
+/* set termios struct */
+#define TARGET_TIOCSETA TARGET_IOW('t', 20, struct target_termios)
+/* drain output, set */
+#define TARGET_TIOCSETAW    TARGET_IOW('t', 21, struct target_termios)
+/* drn out, fls in, set */
+#define TARGET_TIOCSETAF    TARGET_IOW('t', 22, struct target_termios)
+                        /* 23-25 unused */
+#define TARGET_TIOCGETD TARGET_IOR('t', 26, int) /* get line discipline */
+#define TARGET_TIOCSETD TARGET_IOW('t', 27, int) /* set line discipline */
+#define TARGET_TIOCPTMASTER  TARGET_IO('t', 28) /* pts master validation */
+                    /* 29-85 unused */
+/* get ttywait timeout */
+#define TARGET_TIOCGDRAINWAIT   TARGET_IOR('t', 86, int)
+/* set ttywait timeout */
+#define TARGET_TIOCSDRAINWAIT   TARGET_IOW('t', 87, int)
+                    /* 88 unused */
+                    /* 89-91 conflicts: tun and tap */
+/* enable/get timestamp of last input event */
+#define TARGET_TIOCTIMESTAMP    TARGET_IOR('t', 89, struct target_timeval)
+/* modem: get wait on close */
+#define TARGET_TIOCMGDTRWAIT    TARGET_IOR('t', 90, int)
+/* modem: set wait on close */
+#define TARGET_TIOCMSDTRWAIT    TARGET_IOW('t', 91, int)
+                    /* 92-93 tun and tap */
+                    /* 94-97 conflicts: tun and tap */
+/* wait till output drained */
+#define TARGET_TIOCDRAIN     TARGET_IO('t', 94)
+ /* pty: generate signal */
+#define TARGET_TIOCSIG      TARGET_IOWINT('t', 95)
+/* pty: external processing */
+#define TARGET_TIOCEXT      TARGET_IOW('t', 96, int)
+/* become controlling tty */
+#define TARGET_TIOCSCTTY     TARGET_IO('t', 97)
+/* become virtual console */
+#define TARGET_TIOCCONS TARGET_IOW('t', 98, int)
+/* get session id */
+#define TARGET_TIOCGSID TARGET_IOR('t', 99, int)
+                        /* 100 unused */
+/* simulate ^T status message */
+#define TARGET_TIOCSTAT  TARGET_IO('t', 101)
+ /* pty: set/clr usr cntl mode */
+#define TARGET_TIOCUCNTL    TARGET_IOW('t', 102, int)
+/* usr cntl op "n" */
+#define TARGET_TIOCCMD(n)   TARGET_IO('u', n)
+/* set window size */
+#define TARGET_TIOCSWINSZ   TARGET_IOW('t', 103, struct target_winsize)
+/* get window size */
+#define TARGET_TIOCGWINSZ   TARGET_IOR('t', 104, struct target_winsize)
+                        /* 105 unused */
+/* get all modem bits */
+#define TARGET_TIOCMGET TARGET_IOR('t', 106, int)
+#define     TARGET_TIOCM_LE 0001        /* line enable */
+#define     TARGET_TIOCM_DTR    0002    /* data terminal ready */
+#define     TARGET_TIOCM_RTS    0004    /* request to send */
+#define     TARGET_TIOCM_ST 0010        /* secondary transmit */
+#define     TARGET_TIOCM_SR 0020        /* secondary receive */
+#define     TARGET_TIOCM_CTS    0040    /* clear to send */
+#define     TARGET_TIOCM_DCD    0100    /* data carrier detect */
+#define     TARGET_TIOCM_RI     0200    /* ring indicate */
+#define     TARGET_TIOCM_DSR    0400    /* data set ready */
+#define     TARGET_TIOCM_CD TARGET_TIOCM_DCD
+#define     TARGET_TIOCM_CAR    TARGET_TIOCM_DCD
+#define     TARGET_TIOCM_RNG    TARGET_TIOCM_RI
+#define TARGET_TIOCMBIC TARGET_IOW('t', 107, int) /* bic modem bits */
+#define TARGET_TIOCMBIS TARGET_IOW('t', 108, int) /* bis modem bits */
+#define TARGET_TIOCMSET TARGET_IOW('t', 109, int) /* set all modem bits */
+/* start output, like ^Q */
+#define TARGET_TIOCSTART     TARGET_IO('t', 110)
+/* stop output, like ^S */
+#define TARGET_TIOCSTOP  TARGET_IO('t', 111)
+/* pty: set/clear packet mode */
+#define TARGET_TIOCPKT      TARGET_IOW('t', 112, int)
+#define     TARGET_TIOCPKT_DATA     0x00    /* data packet */
+#define     TARGET_TIOCPKT_FLUSHREAD    0x01    /* flush packet */
+#define     TARGET_TIOCPKT_FLUSHWRITE   0x02    /* flush packet */
+#define     TARGET_TIOCPKT_STOP     0x04    /* stop output */
+#define     TARGET_TIOCPKT_START        0x08    /* start output */
+#define     TARGET_TIOCPKT_NOSTOP       0x10    /* no more ^S, ^Q */
+#define     TARGET_TIOCPKT_DOSTOP       0x20    /* now do ^S ^Q */
+#define     TARGET_TIOCPKT_IOCTL        0x40    /* state change of pty driver */
+#define TARGET_TIOCNOTTY TARGET_IO('t', 113)    /* void tty association */
+#define TARGET_TIOCSTI TARGET_IOW('t', 114, char)  /* simulate terminal input */
+#define TARGET_TIOCOUTQ TARGET_IOR('t', 115, int)   /* output queue size */
+                        /* 116-117 compat */
+#define TARGET_TIOCSPGRP    TARGET_IOW('t', 118, int) /* set pgrp of tty */
+#define TARGET_TIOCGPGRP    TARGET_IOR('t', 119, int) /* get pgrp of tty */
+#define TARGET_TIOCCDTR  TARGET_IO('t', 120) /* clear data terminal ready */
+#define TARGET_TIOCSDTR  TARGET_IO('t', 121) /* set data terminal ready */
+#define TARGET_TIOCCBRK  TARGET_IO('t', 122)        /* clear break bit */
+#define TARGET_TIOCSBRK  TARGET_IO('t', 123)        /* set break bit */
+                        /* 124-127 compat */
+
+#define TARGET_TTYDISC      0       /* termios tty line discipline */
+#define TARGET_SLIPDISC     4       /* serial IP discipline */
+#define TARGET_PPPDISC      5       /* PPP discipline */
+#define TARGET_NETGRAPHDISC 6       /* Netgraph tty node discipline */
+#define TARGET_H4DISC       7       /* Netgraph Bluetooth H4 discipline */
+
+#endif /* BSD_USER_FREEBSD_OS_IOCTL_TTYCOM_H */
Signature · 1 line
2.52.0
Reviewed-by on v2 1/17
#2 lore raw

Re: [PATCH v2 01/17] bsd-user: Add FreeBSD tty ioctl definitions

Quoted 6 lines · Warner Losh

From: "Stacey D. Son" <[email protected]>

Add os-ioctl-ttycom.h with terminal control ioctl definitions including TARGET_TIOCGETA, TARGET_TIOCSETA, window size ioctls, and the target_termios structure for terminal I/O control.

Quoted 6 lines
---
 bsd-user/freebsd/os-ioctl-ttycom.h | 237 +++++++++++++++++++++++++++++++++++++
 1 file changed, 237 insertions(+)
#3 lore raw

PATCH v2 2/17 bsd-user: Add FreeBSD file I/O ioctl definitions

In reply to Warner Losh

From: "Stacey D. Son" <[email protected]>

Add os-ioctl-filio.h with file I/O control ioctl definitions including FIONREAD, FIONBIO, FIOASYNC, and FIOSETOWN for file descriptor control.

---
 bsd-user/freebsd/os-ioctl-filio.h | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
bsd-user/freebsd/os-ioctl-filio.h new file +34 -0
new file mode 100644
index 0000000000..79e8f0b83d
@@ -0,0 +1,34 @@
+/*
+ * FreeBSD filio definitions for ioctl(2) emulation
+ *
+ * Copyright (c) 2013 Stacey D. Son
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef BSD_USER_FREEBSD_OS_IOCTL_FILIO_H
+#define BSD_USER_FREEBSD_OS_IOCTL_FILIO_H
+
+/* see sys/filio.h */
+#define TARGET_FIOCLEX      TARGET_IO('f', 1)
+#define TARGET_FIONCLEX     TARGET_IO('f', 2)
+#define TARGET_FIONREAD     TARGET_IOR('f', 127, int)
+#define TARGET_FIONBIO      TARGET_IOW('f', 126, int)
+#define TARGET_FIOASYNC     TARGET_IOW('f', 125, int)
+#define TARGET_FIOSETOWN    TARGET_IOW('f', 124, int)
+#define TARGET_FIOGETOWN    TARGET_IOR('f', 123, int)
+#define TARGET_FIODTYPE     TARGET_IOR('f', 122, int)
+#define TARGET_FIOGETLBA    TARGET_IOR('f', 121, int)
+
+struct target_fiodgname_arg {
+    int32_t     len;
+    abi_ulong   buf;
+};
+
+#define TARGET_FIODGNAME    TARGET_IOW('f', 120,    \
+                struct target_fiodgname_arg)
+#define TARGET_FIONWRITE    TARGET_IOR('f', 119, int)
+#define TARGET_FIONSPACE    TARGET_IOR('f', 118, int)
+#define TARGET_FIOSEEKDATA  TARGET_IOWR('f', 97, off_t)
+#define TARGET_FIOSEEKHOLE  TARGET_IOWR('f', 98, off_t)
+
+#endif /* BSD_USER_FREEBSD_OS_IOCTL_FILIO_H */
Signature · 1 line
2.52.0
Reviewed-by on v2 2/17
#4 lore raw

Re: [PATCH v2 02/17] bsd-user: Add FreeBSD file I/O ioctl definitions

Quoted 11 lines · Warner Losh

From: "Stacey D. Son" <[email protected]>

Add os-ioctl-filio.h with file I/O control ioctl definitions including FIONREAD, FIONBIO, FIOASYNC, and FIOSETOWN for file descriptor control.

---
 bsd-user/freebsd/os-ioctl-filio.h | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
#5 lore raw

PATCH v2 3/17 bsd-user: Add FreeBSD socket ioctl definitions

In reply to Warner Losh

From: "Stacey D. Son" <[email protected]>

Add os-ioctl-sockio.h with network socket and interface control ioctl definitions including SIOCGIFADDR, SIOCSIFADDR, SIOCGIFCONF, and related network interface ioctls with target_ structure definitions.

---
 bsd-user/freebsd/os-ioctl-sockio.h | 240 +++++++++++++++++++++++++++++++++++++
 1 file changed, 240 insertions(+)
bsd-user/freebsd/os-ioctl-sockio.h new file +240 -0
new file mode 100644
index 0000000000..90a9950177
@@ -0,0 +1,240 @@
+/*
+ * FreeBSD sockio.h definitions for ioctl(2) emulation
+ *
+ * Copyright (c) 2015 Stacey D. Son
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef OS_IOCTL_SOCKIO_H
+#define OS_IOCTL_SOCKIO_H
+
+/* See sys/sockio.h */
+#define TARGET_SIOCSHIWAT       TARGET_IOW('s',  0, int32_t)
+#define TARGET_SIOCGHIWAT       TARGET_IOR('s',  1, int32_t)
+#define TARGET_SIOCSLOWAT       TARGET_IOW('s',  2, int32_t)
+#define TARGET_SIOCGLOWAT       TARGET_IOR('s',  3, int32_t)
+#define TARGET_SIOCATMARK       TARGET_IOR('s',  7, int32_t)
+#define TARGET_SIOCSPGRP        TARGET_IOW('s',  8, int32_t)
+#define TARGET_SIOCGPGRP        TARGET_IOR('s',  9, int32_t)
+
+/* See net/if.h */
+struct target_ifreq_buffer {
+    abi_ulong  length;
+    abi_ulong  buffer;
+};
+
+#define TARGET_IFNAMSIZ 16
+
+struct target_ifreq {
+    char    ifr_name[TARGET_IFNAMSIZ];
+    union {
+        struct  target_sockaddr ifru_addr;
+        struct  target_sockaddr ifru_dstaddr;
+        struct  target_sockaddr ifru_broadaddr;
+        struct  target_ifreq_buffer ifru_buffer;
+        int16_t   ifru_flags[2];
+        int16_t   ifru_index;
+        int32_t     ifru_jid;
+        int32_t     ifru_metric;
+        int32_t     ifru_mtu;
+        int32_t     ifru_phys;
+        int32_t     ifru_media;
+        abi_ulong ifru_data;
+        int32_t     ifru_cap[2];
+        uint32_t   ifru_fib;
+    } ifr_ifru;
+};
+
+
+#define TARGET_SIOCSIFADDR      TARGET_IOW('i', 12, struct target_ifreq)
+#define TARGET_SIOCGIFADDR      TARGET_IOWR('i', 33, struct target_ifreq)
+#define TARGET_SIOCSIFDSTADDR   TARGET_IOW('i', 14, struct target_ifreq)
+#define TARGET_SIOCGIFDSTADDR   TARGET_IOWR('i', 34, struct target_ifreq)
+#define TARGET_SIOCSIFFLAGS     TARGET_IOW('i', 16, struct target_ifreq)
+#define TARGET_SIOCGIFFLAGS     TARGET_IOWR('i', 17, struct target_ifreq)
+#define TARGET_SIOCGIFBRDADDR   TARGET_IOWR('i', 35, struct target_ifreq)
+#define TARGET_SIOCSIFBRDADDR   TARGET_IOW('i', 19, struct target_ifreq)
+#define TARGET_SIOCGIFNETMASK   TARGET_IOWR('i', 37, struct target_ifreq)
+#define TARGET_SIOCSIFNETMASK   TARGET_IOW('i', 22, struct target_ifreq)
+#define TARGET_SIOCGIFMETRIC    TARGET_IOWR('i', 23, struct target_ifreq)
+#define TARGET_SIOCSIFMETRIC    TARGET_IOW('i', 24, struct target_ifreq)
+#define TARGET_SIOCDIFADDR      TARGET_IOW('i', 25, struct target_ifreq)
+#define TARGET_SIOCSIFCAP       TARGET_IOW('i', 30, struct target_ifreq)
+#define TARGET_SIOCGIFCAP       TARGET_IOWR('i', 31, struct target_ifreq)
+#define TARGET_SIOCGIFINDEX     TARGET_IOWR('i', 32, struct target_ifreq)
+#define TARGET_SIOCGIFMAC       TARGET_IOWR('i', 38, struct target_ifreq)
+#define TARGET_SIOCSIFMAC       TARGET_IOW('i', 39, struct target_ifreq)
+#define TARGET_SIOCSIFNAME      TARGET_IOW('i', 40, struct target_ifreq)
+#define TARGET_SIOCSIFDESCR     TARGET_IOW('i', 41, struct target_ifreq)
+#define TARGET_SIOCGIFDESCR     TARGET_IOWR('i', 42, struct target_ifreq)
+#define TARGET_SIOCADDMULTI     TARGET_IOW('i', 49, struct target_ifreq)
+#define TARGET_SIOCDELMULTI     TARGET_IOW('i', 50, struct target_ifreq)
+#define TARGET_SIOCGIFMTU       TARGET_IOWR('i', 51, struct target_ifreq)
+#define TARGET_SIOCSIFMTU       TARGET_IOW('i', 52, struct target_ifreq)
+#define TARGET_SIOCGIFPHYS      TARGET_IOWR('i', 53, struct target_ifreq)
+#define TARGET_SIOCSIFPHYS      TARGET_IOW('i', 54, struct target_ifreq)
+#define TARGET_SIOCSIFMEDIA     TARGET_IOWR('i', 55, struct target_ifreq)
+#define TARGET_SIOCSIFGENERIC   TARGET_IOW('i', 57, struct target_ifreq)
+#define TARGET_SIOCGIFGENERIC   TARGET_IOWR('i', 58, struct target_ifreq)
+#define TARGET_SIOCSIFLLADDR    TARGET_IOW('i', 60, struct target_ifreq)
+#define TARGET_SIOCGIFPSRCADDR  TARGET_IOWR('i', 71, struct target_ifreq)
+#define TARGET_SIOCGIFPDSTADDR  TARGET_IOWR('i', 72, struct target_ifreq)
+#define TARGET_SIOCDIFPHYADDR   TARGET_IOW('i', 73, struct target_ifreq)
+#define TARGET_SIOCGPRIVATE_0   TARGET_IOWR('i', 80, struct target_ifreq)
+#define TARGET_SIOCGPRIVATE_1   TARGET_IOWR('i', 81, struct target_ifreq)
+#define TARGET_SIOCSIFVNET      TARGET_IOWR('i', 90, struct target_ifreq)
+#define TARGET_SIOCSIFRVNET     TARGET_IOWR('i', 91, struct target_ifreq)
+#define TARGET_SIOCGIFFIB       TARGET_IOWR('i', 92, struct target_ifreq)
+#define TARGET_SIOCSIFFIB       TARGET_IOW('i', 93, struct target_ifreq)
+#define TARGET_SIOCGTUNFIB      TARGET_IOWR('i', 94, struct target_ifreq)
+#define TARGET_SIOCIFCREATE     TARGET_IOWR('i', 122, struct target_ifreq)
+#define TARGET_SIOCIFCREATE2    TARGET_IOWR('i', 124, struct target_ifreq)
+#define TARGET_SIOCIFDESTROY    TARGET_IOW('i', 121, struct target_ifreq)
+
+/* net/if_gre.h */
+#define TARGET_GREGKEY          TARGET_IOWR('i', 107, struct target_ifreq)
+#define TARGET_GREGOPTS         TARGET_IOWR('i', 109, struct target_ifreq)
+
+/* net/if_gif.h */
+#define TARGET_GIFGOPTS         TARGET_IOWR('i', 150, struct target_ifreq)
+
+/* netinet/ip_carp.h */
+#define TARGET_SIOCGVH          TARGET_IOWR('i', 246, struct target_ifreq)
+
+/* netinet/ip_carp.h */
+#define TARGET_SIOCGVH          TARGET_IOWR('i', 246, struct target_ifreq)
+
+/* net/if_pfsync.h */
+#define TARGET_SIOCGETPFSYNC    TARGET_IOWR('i', 248, struct target_ifreq)
+
+
+/* See net/if.h */
+struct target_ifconf {
+    int32_t ifc_len;
+    union {
+        abi_ulong   ifcu_buf;
+        abi_ulong   ifcu_reg;
+    } ifc_ifcu;
+};
+
+#define TARGET_SIOCGIFCONF     TARGET_IOWR('i', 36, struct target_ifconf)
+
+/* See net/if.h */
+struct  target_ifdrv {
+    char            ifd_name[TARGET_IFNAMSIZ];
+    abi_ulong       ifd_cmd;
+    abi_ulong       ifd_len;
+    abi_ulong       ifd_data;
+};
+
+#define TARGET_SIOCSDRVSPEC    TARGET_IOW('i', 123, struct target_ifdrv)
+#define TARGET_SIOCGDRVSPEC    TARGET_IOWR('i', 123, struct target_ifdrv)
+
+/* See net/if.h */
+struct target_ifg_req {
+    union {
+        char        ifgrqu_group[TARGET_IFNAMSIZ];
+        char        ifgrqu_member[TARGET_IFNAMSIZ];
+    } ifgrq_ifgrqu;
+};
+
+struct target_ifgroupreq {
+    char            ifgr_name[TARGET_IFNAMSIZ];
+    uint32_t        ifgr_len;
+    union {
+        char        ifgru_group[TARGET_IFNAMSIZ];
+        abi_ulong   ifgru_groups;
+    } ifgr_ifgru;
+};
+
+#define TARGET_SIOCGIFGROUP    TARGET_IOWR('i', 136, struct target_ifgroupreq)
+
+struct target_ifmediareq {
+    char        ifm_name[TARGET_IFNAMSIZ];
+    int32_t     ifm_current;
+    int32_t     ifm_mask;
+    int32_t     ifm_status;
+    int32_t     ifm_active;
+    int32_t     ifm_count;
+    abi_ulong   ifm_ulist;
+};
+
+#define TARGET_SIOCGIFMEDIA  TARGET_IOWR('i', 56, struct target_ifmediareq)
+#define TARGET_SIOCGIFXMEDIA  TARGET_IOWR('i', 139, struct target_ifmediareq)
+
+#define TARGET_IFSTATMAX    800
+struct target_ifstat {
+    char    ifs_name[TARGET_IFNAMSIZ];
+    char    ascii[TARGET_IFSTATMAX + 1];
+};
+
+#define TARGET_SIOCGIFSTATUS TARGET_IOWR('i', 59, struct target_ifstat)
+
+/* net80211/ieee80211_ioctl.h */
+struct target_ieee80211req {
+    char            i_name[TARGET_IFNAMSIZ];
+    uint16_t        i_type;
+    int16_t         i_val;
+    uint16_t        i_len;
+    abi_ulong       i_data;
+};
+
+#define TARGET_SIOCG80211 TARGET_IOWR('i', 235, struct target_ieee80211req)
+
+/* net/if_lagg.h */
+struct target_lacp_opreq {
+    uint16_t        actor_prio;
+    uint8_t         actor_mac[ETHER_ADDR_LEN];
+    uint16_t        actor_key;
+    uint16_t        actor_portprio;
+    uint16_t        actor_portno;
+    uint8_t         actor_state;
+    uint16_t        partner_prio;
+    uint8_t         partner_mac[ETHER_ADDR_LEN];
+    uint16_t        partner_key;
+    uint16_t        partner_portprio;
+    uint16_t        partner_portno;
+    uint8_t         partner_state;
+};
+
+struct target_lagg_reqport {
+    char            rp_ifname[TARGET_IFNAMSIZ];
+    char            rp_portname[TARGET_IFNAMSIZ];
+    u_int32_t       rp_prio;
+    u_int32_t       rp_flags;
+    union {
+        struct target_lacp_opreq rpsc_lacp;
+    } rp_psc;
+};
+#define TARGET_SIOCGLAGGPORT TARGET_IOWR('i', 140, struct target_lagg_reqport)
+
+struct target_lagg_reqall {
+    char            ra_ifname[TARGET_IFNAMSIZ];
+    uint32_t        ra_proto;
+
+    abi_ulong       ra_size;
+    abi_ulong       ra_port;
+    int32_t         ra_ports;
+    union {
+        struct target_lacp_opreq rpsc_lacp;
+    } ra_psc;
+};
+#define TARGET_SIOCGLAGG TARGET_IOWR('i', 143, struct target_lagg_reqall)
+
+struct target_lagg_reqflags {
+    char            rf_ifname[TARGET_IFNAMSIZ];
+    uint32_t        rf_flags;
+};
+#define TARGET_SIOCGLAGGFLAGS TARGET_IOWR('i', 145, struct target_lagg_reqflags)
+
+struct target_lagg_reqopts {
+    char            ro_ifname[IFNAMSIZ];
+    int32_t         ro_opts;
+    uint32_t        ro_count;
+    uint32_t        ro_active;
+    uint32_t        ro_flapping;
+    int32_t         ro_flowid_shift;
+};
+#define TARGET_SIOCGLAGGOPTS TARGET_IOWR('i', 152, struct target_lagg_reqopts)
+
+#endif /* OS_IOCTL_SOCKIO_H */
Signature · 1 line
2.52.0
Reviewed-by on v2 3/17
#6 lore raw

Re: [PATCH v2 03/17] bsd-user: Add FreeBSD socket ioctl definitions

Quoted 6 lines · Warner Losh

From: "Stacey D. Son" <[email protected]>

Add os-ioctl-sockio.h with network socket and interface control ioctl definitions including SIOCGIFADDR, SIOCSIFADDR, SIOCGIFCONF, and related network interface ioctls with target_ structure definitions.

Quoted 6 lines
---
 bsd-user/freebsd/os-ioctl-sockio.h | 240 +++++++++++++++++++++++++++++++++++++
 1 file changed, 240 insertions(+)
#7 lore raw

PATCH v2 4/17 bsd-user: Add FreeBSD cryptodev ioctl definitions

In reply to Warner Losh

From: "Stacey D. Son" <[email protected]>

Add os-ioctl-cryptodev.h with /dev/crypto ioctl definitions including CIOCGSESSION, CIOCCRYPT, and related cryptographic device control ioctls.

---
 bsd-user/freebsd/os-ioctl-cryptodev.h | 74 +++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)
bsd-user/freebsd/os-ioctl-cryptodev.h new file +74 -0
new file mode 100644
index 0000000000..dc88521057
@@ -0,0 +1,74 @@
+/*
+ * FreeBSD cryptodev definitions for ioctl(2) emulation
+ *
+ * Copyright (c) 2014 Stacey D. Son
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef BSD_USER_FREEBSD_OS_IOCTL_CRYPTODEV_H
+#define BSD_USER_FREEBSD_OS_IOCTL_CRYPTODEV_H
+
+/* see opencrypto/cryptodev.h */
+
+struct target_session_op {
+        u_int32_t       cipher;
+        u_int32_t       mac;
+
+        u_int32_t       keylen;
+        abi_ulong       key;
+        int32_t         mackeylen;
+        abi_ulong       mackey;
+
+        u_int32_t       ses;
+};
+
+
+struct target_session2_op {
+        u_int32_t       cipher;
+        u_int32_t       mac;
+
+        u_int32_t       keylen;
+        abi_ulong       key;
+        int32_t         mackeylen;
+        abi_ulong       mackey;
+
+        u_int32_t       ses;
+        int32_t         crid;
+        int             pad[4];
+};
+
+struct target_crypt_find_op {
+        int             crid;
+        char            name[32];
+};
+
+struct target_crparam {
+        abi_ulong       crp_p;
+        u_int           crp_nbits;
+};
+
+#define TARGET_CRK_MAXPARAM     8
+
+struct target_crypt_kop {
+        u_int           crk_op;
+        u_int           crk_status;
+        u_short         crk_iparams;
+        u_short         crk_oparams;
+        u_int           crk_crid;
+        struct target_crparam   crk_param[TARGET_CRK_MAXPARAM];
+};
+
+#define TARGET_CRIOGET          TARGET_IOWR('c', 100, u_int32_t)
+#define TARGET_CRIOASYMFEAT     TARGET_CIOCASYMFEAT
+#define TARGET_CRIOFINDDEV      TARGET_CIOCFINDDEV
+
+#define TARGET_CIOCGSESSION     TARGET_IOWR('c', 101, struct target_session_op)
+#define TARGET_CIOCFSESSION     TARGET_IOW('c', 102, u_int32_t)
+#define TARGET_CIOCCRYPT        TARGET_IOWR('c', 103, struct target_crypt_op)
+#define TARGET_CIOCKEY          TARGET_IOWR('c', 104, struct target_crypt_kop)
+#define TARGET_CIOCASYMFEAT     TARGET_IOR('c', 105, u_int32_t)
+#define TARGET_CIOCGSESSION2    TARGET_IOWR('c', 106, struct target_session2_op)
+#define TARGET_CIOCKEY2         TARGET_IOWR('c', 107, struct target_crypt_kop)
+#define TARGET_CIOCFINDDEV TARGET_IOWR('c', 108, struct target_crypt_find_op)
+
+#endif /* BSD_USER_FREEBSD_OS_IOCTL_CRYPTODEV_H */
Signature · 1 line
2.52.0
Reviewed-by on v2 4/17
#8 lore raw

Re: [PATCH v2 04/17] bsd-user: Add FreeBSD cryptodev ioctl definitions

Quoted 6 lines · Warner Losh

From: "Stacey D. Son" <[email protected]>

Add os-ioctl-cryptodev.h with /dev/crypto ioctl definitions including CIOCGSESSION, CIOCCRYPT, and related cryptographic device control ioctls.

Quoted 6 lines
---
 bsd-user/freebsd/os-ioctl-cryptodev.h | 74 +++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)
#9 lore raw

PATCH v2 5/17 bsd-user: Add FreeBSD disk ioctl definitions

In reply to Warner Losh

From: "Stacey D. Son" <[email protected]>

Add os-ioctl-disk.h with disk and storage device ioctl definitions including DIOCGMEDIASIZE, DIOCGSECTORSIZE, and related disk management ioctls.

---
 bsd-user/freebsd/os-ioctl-disk.h | 41 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
bsd-user/freebsd/os-ioctl-disk.h new file +41 -0
new file mode 100644
index 0000000000..9260953dc6
@@ -0,0 +1,41 @@
+/*
+ * FreeBSD disk.h definitions for ioctl(2) emulation
+ *
+ * Copyright (c) 2015 Stacey D. Son
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef OS_IOCTL_DISK_H
+#define OS_IOCTL_DISK_H
+
+/* See sys/disk.h */
+
+#define TARGET_DIOCGSECTORSIZE      TARGET_IOR('d', 128, uint32_t)
+#define TARGET_DIOCGMEDIASIZE       TARGET_IOR('d', 129, int64_t)
+#define TARGET_DIOCGFWSECTORS       TARGET_IOR('d', 130, uint32_t)
+#define TARGET_DIOCGFWHEADS         TARGET_IOR('d', 131, uint32_t)
+#define TARGET_DIOCSKERNELDUMP      TARGET_IOW('d', 133, uint32_t)
+#define TARGET_DIOCGFRONTSTUFF      TARGET_IOR('d', 134, int64_t)
+#define TARGET_DIOCGFLUSH           TARGET_IO('d', 135)
+#define TARGET_DIOCGDELETE          TARGET_IOW('d', 136, int64_t[2])
+#define TARGET_DISK_IDENT_SIZE 256
+#define TARGET_DIOCGIDENT           TARGET_IOR('d', 137,            \
+                                        char[TARGET_DISK_IDENT_SIZE])
+#define TARGET_DIOCGPROVIDERNAME    TARGET_IOR('d', 138, char[MAXPATHLEN])
+#define TARGET_DIOCGSTRIPESIZE      TARGET_IOR('d', 139, int64_t)
+#define TARGET_DIOCGSTRIPEOFFSET    TARGET_IOR('d', 140, int64_t)
+#define TARGET_DIOCGPHYSPATH        TARGET_IOR('d', 141, char[MAXPATHLEN])
+
+struct target_diocgattr_arg {
+        char name[64];
+        int32_t len;
+        union {
+                char str[TARGET_DISK_IDENT_SIZE];
+                int64_t off;
+                int32_t i;
+        } value;
+};
+
+#define TARGET_DIOCGATTR    TARGET_IOWR('d', 142, struct target_diocgattr_arg)
+
+#endif /* OS_IOCTL_DISK_H */
Signature · 1 line
2.52.0
Reviewed-by on v2 5/17
#10 lore raw

Re: [PATCH v2 05/17] bsd-user: Add FreeBSD disk ioctl definitions

Quoted 6 lines · Warner Losh

From: "Stacey D. Son" <[email protected]>

Add os-ioctl-disk.h with disk and storage device ioctl definitions including DIOCGMEDIASIZE, DIOCGSECTORSIZE, and related disk management ioctls.

Quoted 6 lines
---
 bsd-user/freebsd/os-ioctl-disk.h | 41 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
#11 lore raw

PATCH v2 6/17 bsd-user: Add FreeBSD IPv6 ioctl definitions

In reply to Warner Losh

From: "Stacey D. Son" <[email protected]>

Add os-ioctl-in6_var.h with IPv6 network interface ioctl definitions including SIOCAIFADDR_IN6, SIOCDIFADDR_IN6, and related IPv6 configuration ioctls with target_in6_* structure definitions.

---
 bsd-user/freebsd/os-ioctl-in6_var.h | 217 ++++++++++++++++++++++++++++++++++++
 1 file changed, 217 insertions(+)
bsd-user/freebsd/os-ioctl-in6_var.h new file +217 -0
new file mode 100644
index 0000000000..3656b27918
@@ -0,0 +1,217 @@
+/*
+ * FreeBSD in6 definitions for ioctl(2) emulation
+ *
+ * Copyright (c) 2014-2015 Stacey D. Son
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef BSD_USER_FREEBSD_OS_IOCTL_IN6_VAR_H
+#define BSD_USER_FREEBSD_OS_IOCTL_IN6_VAR_H
+
+/*
+ * see netinet6/in6_var.h
+ * and see netinet/in6.h
+ * XXX target_in6_addr and target_sockaddr_in6 should maybe go
+ * somewhere else.
+ */
+struct target_in6_addr {
+        union {
+                uint8_t         __u6_addr8[16];
+                uint16_t        __u6_addr16[8];
+                uint32_t        __u6_addr32[4];
+        } __u6_addr;
+};
+
+struct target_sockaddr_in6 {
+        uint8_t         sin6_len;
+        uint8_t         sin6_family;
+        uint16_t        sin6_port;
+        uint32_t        sin6_flowinfo;
+        struct target_in6_addr sin6_addr;
+        uint32_t        sin6_scope_id;
+};
+
+struct target_in6_addrlifetime {
+        target_time_t ia6t_expire;
+        target_time_t ia6t_preferred;
+        u_int32_t ia6t_vltime;
+        u_int32_t ia6t_pltime;
+};
+
+struct target_in6_ifstat {
+        uint64_t ifs6_in_receive;
+        uint64_t ifs6_in_hdrerr;
+        uint64_t ifs6_in_toobig;
+        uint64_t ifs6_in_noroute;
+        uint64_t ifs6_in_addrerr;
+        uint64_t ifs6_in_protounknown;
+
+        uint64_t ifs6_in_truncated;
+        uint64_t ifs6_in_discard;
+
+        uint64_t ifs6_in_deliver;
+
+        uint64_t ifs6_out_forward;
+
+        uint64_t ifs6_out_request;
+
+        uint64_t ifs6_out_discard;
+        uint64_t ifs6_out_fragok;
+        uint64_t ifs6_out_fragfail;
+        uint64_t ifs6_out_fragcreat;
+
+        uint64_t ifs6_reass_reqd;
+
+        uint64_t ifs6_reass_ok;
+
+        uint64_t ifs6_reass_fail;
+
+        uint64_t ifs6_in_mcast;
+        uint64_t ifs6_out_mcast;
+};
+
+struct target_icmp6_ifstat {
+        uint64_t ifs6_in_msg;
+        uint64_t ifs6_in_error;
+        uint64_t ifs6_in_dstunreach;
+        uint64_t ifs6_in_adminprohib;
+        uint64_t ifs6_in_timeexceed;
+        uint64_t ifs6_in_paramprob;
+        uint64_t ifs6_in_pkttoobig;
+        uint64_t ifs6_in_echo;
+        uint64_t ifs6_in_echoreply;
+        uint64_t ifs6_in_routersolicit;
+        uint64_t ifs6_in_routeradvert;
+        uint64_t ifs6_in_neighborsolicit;
+        uint64_t ifs6_in_neighboradvert;
+        uint64_t ifs6_in_redirect;
+        uint64_t ifs6_in_mldquery;
+        uint64_t ifs6_in_mldreport;
+        uint64_t ifs6_in_mlddone;
+
+        uint64_t ifs6_out_msg;
+        uint64_t ifs6_out_error;
+        uint64_t ifs6_out_dstunreach;
+        uint64_t ifs6_out_adminprohib;
+        uint64_t ifs6_out_timeexceed;
+        uint64_t ifs6_out_paramprob;
+        uint64_t ifs6_out_pkttoobig;
+        uint64_t ifs6_out_echo;
+        uint64_t ifs6_out_echoreply;
+        uint64_t ifs6_out_routersolicit;
+        uint64_t ifs6_out_routeradvert;
+        uint64_t ifs6_out_neighborsolicit;
+        uint64_t ifs6_out_neighboradvert;
+        uint64_t ifs6_out_redirect;
+        uint64_t ifs6_out_mldquery;
+        uint64_t ifs6_out_mldreport;
+        uint64_t ifs6_out_mlddone;
+};
+
+#ifndef TARGET_IFNAMSIZ
+#define TARGET_IFNAMSIZ 16
+#endif
+
+struct target_in6_ifreq {
+        char ifr_name[TARGET_IFNAMSIZ];
+        union {
+                struct  target_sockaddr_in6 ifru_addr;
+                struct  target_sockaddr_in6 ifru_dstaddr;
+                int     ifru_flags;
+                int     ifru_flags6;
+                int     ifru_metric;
+                abi_ulong       ifru_data;
+                struct target_in6_addrlifetime ifru_lifetime;
+                struct target_in6_ifstat ifru_stat;
+                struct target_icmp6_ifstat ifru_icmp6stat;
+                u_int32_t ifru_scope_id[16];
+        } ifr_ifru;
+};
+
+/* netinet6/nd6.h */
+struct target_nd_ifinfo {
+        uint32_t linkmtu;
+        uint32_t maxmtu;
+        uint32_t basereachable;
+        uint32_t reachable;
+        uint32_t retrans;
+        uint32_t flags;
+        int32_t  recalctm;
+        uint8_t  chlim;
+        uint8_t  initialized;
+        uint8_t  randomseed0[8];
+        uint8_t  randomseed1[8];
+        uint8_t  randomid[8];
+};
+
+/* netinet6/nd6.h */
+struct target_in6_ndireq {
+    char ifname[TARGET_IFNAMSIZ];
+    struct target_nd_ifinfo ndi;
+};
+
+struct  target_in6_ndifreq {
+    char ifname[IFNAMSIZ];
+    abi_ulong ifindex;
+};
+
+
+#define TARGET_SIOCGIFDSTADDR_IN6 TARGET_IOWR('i', 34, struct target_in6_ifreq)
+#define TARGET_SIOCGIFNETMASK_IN6 TARGET_IOWR('i', 37, struct target_in6_ifreq)
+
+#define TARGET_SIOCDIFADDR_IN6 TARGET_IOW('i', 25, struct target_in6_ifreq)
+#ifdef notyet
+#define TARGET_OSIOCAIFADDR_IN6 TARGET_IOW('i', 26, struct target_oin6_aliasreq)
+#define TARGET_SIOCAIFADDR_IN6 TARGET_IOW('i', 27, struct target_in6_aliasreq)
+
+#define TARGET_SIOCSIFPHYADDR_IN6 TARGET_IOW('i', 70, struct target_in6_aliasreq)
+#endif
+#define TARGET_SIOCGIFPSRCADDR_IN6 TARGET_IOWR('i', 71, struct target_in6_ifreq)
+#define TARGET_SIOCGIFPDSTADDR_IN6 TARGET_IOWR('i', 72, struct target_in6_ifreq)
+
+#define TARGET_SIOCGIFAFLAG_IN6 TARGET_IOWR('i', 73, struct target_in6_ifreq)
+
+#ifdef notyet
+#define TARGET_SIOCGDRLST_IN6 TARGET_IOWR('i', 74, struct target_in6_drlist)
+#endif
+
+#define TARGET_SIOCGIFINFO_IN6 TARGET_IOWR('i', 108, struct target_in6_ndireq)
+#define TARGET_SIOCSIFINFO_IN6 TARGET_IOWR('i', 109, struct target_in6_ndireq)
+
+#define TARGET_SIOCSNDFLUSH_IN6 TARGET_IOWR('i', 77, struct target_in6_ifreq)
+#ifdef notyet
+#define TARGET_SIOCGNBRINFO_IN6 TARGET_IOWR('i', 78, struct target_in6_nbrinfo)
+#endif
+#define TARGET_SIOCSPFXFLUSH_IN6 TARGET_IOWR('i', 79, struct target_in6_ifreq)
+#define TARGET_SIOCSRTRFLUSH_IN6 TARGET_IOWR('i', 80, struct target_in6_ifreq)
+
+#define TARGET_SIOCGIFALIFETIME_IN6 TARGET_IOWR('i', 81, struct target_in6_ifreq)
+#define TARGET_SIOCSIFALIFETIME_IN6 TARGET_IOWR('i', 82, struct target_in6_ifreq)
+#define TARGET_SIOCGIFSTAT_IN6 TARGET_IOWR('i', 83, struct target_in6_ifreq)
+#define TARGET_SIOCGIFSTAT_ICMP6 TARGET_IOWR('i', 84, struct target_in6_ifreq)
+
+#define TARGET_SIOCSDEFIFACE_IN6 TARGET_IOWR('i', 85, struct target_in6_ndifreq)
+#define TARGET_SIOCGDEFIFACE_IN6 TARGET_IOWR('i', 86, struct target_in6_ndifreq)
+
+#define TARGET_SIOCSIFINFO_FLAGS TARGET_IOWR('i', 87, struct target_in6_ndireq)
+
+#define TARGET_SIOCSSCOPE6 TARGET_IOW('i', 88, struct target_in6_ifreq)
+#define TARGET_SIOCGSCOPE6 TARGET_IOWR('i', 89, struct target_in6_ifreq)
+#define TARGET_SIOCGSCOPE6DEF TARGET_IOWR('i', 90, struct target_in6_ifreq)
+
+#ifdef notyet
+#define TARGET_SIOCSIFPREFIX_IN6 TARGET_IOW('i', 100, struct target_in6_prefixreq)
+#define TARGET_SIOCGIFPREFIX_IN6 TARGET_IOWR('i', 101, struct target_in6_prefixreq)
+#define TARGET_SIOCDIFPREFIX_IN6 TARGET_IOW('i', 102, struct target_in6_prefixreq)
+#define TARGET_SIOCAIFPREFIX_IN6 TARGET_IOW('i', 103, struct target_in6_rrenumreq)
+#define TARGET_SIOCCIFPREFIX_IN6 TARGET_IOW('i', 104, struct target_in6_rrenumreq)
+#define TARGET_SIOCSGIFPREFIX_IN6 TARGET_IOW('i', 105, struct target_in6_rrenumreq)
+
+#define TARGET_SIOCGETSGCNT_IN6 TARGET_IOWR('u', 106, struct target_sioc_sg_req6)
+#define TARGET_SIOCGETMIFCNT_IN6 TARGET_IOWR('u', 107, struct target_sioc_mif_req6)
+
+#define TARGET_SIOCAADDRCTL_POLICY TARGET_IOW('u', 108, struct target_in6_addrpolicy)
+#define TARGET_SIOCDADDRCTL_POLICY TARGET_IOW('u', 109, struct target_in6_addrpolicy)
+#endif
+
+#endif /* BSD_USER_FREEBSD_OS_IOCTL_IN6_VAR_H */
Signature · 1 line
2.52.0
Reviewed-by on v2 6/17
#12 lore raw

Re: [PATCH v2 06/17] bsd-user: Add FreeBSD IPv6 ioctl definitions

Quoted 6 lines · Warner Losh

From: "Stacey D. Son" <[email protected]>

Add os-ioctl-in6_var.h with IPv6 network interface ioctl definitions including SIOCAIFADDR_IN6, SIOCDIFADDR_IN6, and related IPv6 configuration ioctls with target_in6_* structure definitions.

Quoted 6 lines
---
 bsd-user/freebsd/os-ioctl-in6_var.h | 217 ++++++++++++++++++++++++++++++++++++
 1 file changed, 217 insertions(+)
#13 lore raw

PATCH v2 7/17 bsd-user: Add FreeBSD ioctl type definitions

In reply to Warner Losh

From: "Stacey D. Son" <[email protected]>

Add os-ioctl-types.h with STRUCT macro definitions for ioctl type registration. This header uses multiple inclusion with different STRUCT macro definitions to generate both enums and type definitions.

---
 bsd-user/freebsd/os-ioctl-types.h | 104 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)
bsd-user/freebsd/os-ioctl-types.h new file +104 -0
new file mode 100644
index 0000000000..ea0a7b7d92
@@ -0,0 +1,104 @@
+/*
+ * FreeBSD file related system call shims and definitions
+ *
+ * Copyright (c) 2013-2015 Stacey D. Son
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+STRUCT_SPECIAL(termios)
+
+STRUCT(winsize,
+        TYPE_SHORT, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT)
+
+STRUCT(fiodgname_arg,
+        TYPE_INT, TYPE_PTRVOID)
+
+STRUCT(ifconf,
+        TYPE_INT, TYPE_PTRVOID)
+
+STRUCT(sockaddr,
+        TYPE_SHORT, MK_ARRAY(TYPE_CHAR, 14))
+
+STRUCT(_ifreq_buffer,
+        TYPE_PTRVOID, TYPE_PTRVOID)
+
+STRUCT(ifreq_char,
+        MK_ARRAY(TYPE_CHAR, IFNAMSIZ), TYPE_CHAR)
+
+STRUCT(ifreq_short,
+        MK_ARRAY(TYPE_CHAR, IFNAMSIZ), TYPE_SHORT)
+
+STRUCT(ifreq_int,
+        MK_ARRAY(TYPE_CHAR, IFNAMSIZ), TYPE_INT)
+
+STRUCT(ifreq_ptr,
+        MK_ARRAY(TYPE_CHAR, IFNAMSIZ), TYPE_PTRVOID)
+
+STRUCT(ifreq_cap,
+        MK_ARRAY(TYPE_CHAR, IFNAMSIZ), MK_ARRAY(TYPE_INT, 2))
+
+STRUCT(ifreq_sockaddr,
+        MK_ARRAY(TYPE_CHAR, IFNAMSIZ), MK_STRUCT(STRUCT_sockaddr))
+
+STRUCT(ifreq_buf,
+        MK_ARRAY(TYPE_CHAR, IFNAMSIZ), MK_STRUCT(STRUCT__ifreq_buffer))
+
+STRUCT(ifdrv,
+    MK_ARRAY(TYPE_CHAR, IFNAMSIZ), TYPE_PTRVOID, TYPE_PTRVOID, TYPE_PTRVOID)
+
+STRUCT(ifgroupreq_ptr,
+    MK_ARRAY(TYPE_CHAR, IFNAMSIZ), TYPE_INT, TYPE_PTRVOID)
+
+STRUCT(ifmediareq,
+    MK_ARRAY(TYPE_CHAR, IFNAMSIZ), TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
+    TYPE_INT, TYPE_PTRVOID)
+
+STRUCT(ifstat,
+    MK_ARRAY(TYPE_CHAR, IFNAMSIZ), MK_ARRAY(TYPE_CHAR, IFSTATMAX))
+
+STRUCT(ieee80211req,
+    MK_ARRAY(TYPE_CHAR, IFNAMSIZ), TYPE_INT, TYPE_INT, TYPE_INT, TYPE_PTRVOID)
+
+STRUCT(lagg_reqport_lacp_opreq,
+    MK_ARRAY(TYPE_CHAR, IFNAMSIZ), MK_ARRAY(TYPE_CHAR, IFNAMSIZ), TYPE_INT,
+    TYPE_INT,
+    /* struct lacp_opreq */
+    TYPE_SHORT, TYPE_CHAR, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT, TYPE_CHAR,
+    TYPE_SHORT, TYPE_CHAR, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT, TYPE_CHAR)
+
+STRUCT(lagg_reqall_lacp_opreq,
+    MK_ARRAY(TYPE_CHAR, IFNAMSIZ), TYPE_INT, TYPE_PTRVOID, TYPE_PTRVOID,
+    TYPE_INT,
+    /* struct lacp_opreq */
+    TYPE_SHORT, TYPE_CHAR, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT, TYPE_CHAR,
+    TYPE_SHORT, TYPE_CHAR, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT, TYPE_CHAR)
+
+STRUCT(lagg_reqflags,
+    MK_ARRAY(TYPE_CHAR, IFNAMSIZ), TYPE_INT)
+
+STRUCT(lagg_reqopts,
+    MK_ARRAY(TYPE_CHAR, IFNAMSIZ), TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
+    TYPE_INT)
+
+STRUCT(in6_ifreq_int,
+    MK_ARRAY(TYPE_CHAR, IFNAMSIZ), TYPE_INT)
+
+STRUCT(in6_ifreq_ptr,
+    MK_ARRAY(TYPE_CHAR, IFNAMSIZ), TYPE_PTRVOID)
+
+STRUCT(in6_ifreq_sockaddr_in6,
+    MK_ARRAY(TYPE_CHAR, IFNAMSIZ),
+    /* struct sockaddr_in6 */
+    TYPE_CHAR, TYPE_CHAR, TYPE_SHORT, TYPE_INT, MK_ARRAY(TYPE_CHAR, 16),
+    TYPE_INT)
+
+STRUCT(in6_ndireq,
+    MK_ARRAY(TYPE_CHAR, IFNAMSIZ),
+    /* struct nd_ifinfo */
+    TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT, TYPE_INT,
+    TYPE_CHAR, TYPE_CHAR, MK_ARRAY(TYPE_CHAR, 8), MK_ARRAY(TYPE_CHAR, 8),
+    MK_ARRAY(TYPE_CHAR, 8))
+
+STRUCT(in6_ndifreq,
+    MK_ARRAY(TYPE_CHAR, IFNAMSIZ), TYPE_PTRVOID)
Signature · 1 line
2.52.0
Reviewed-by on v2 7/17
#14 lore raw

Re: [PATCH v2 07/17] bsd-user: Add FreeBSD ioctl type definitions

Quoted 6 lines · Warner Losh

From: "Stacey D. Son" <[email protected]>

Add os-ioctl-types.h with STRUCT macro definitions for ioctl type registration. This header uses multiple inclusion with different STRUCT macro definitions to generate both enums and type definitions.

Quoted 6 lines
---
 bsd-user/freebsd/os-ioctl-types.h | 104 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)
#15 lore raw

PATCH v2 8/17 bsd-user: Add FreeBSD ioctl command table

In reply to Warner Losh

From: "Stacey D. Son" <[email protected]>

Add os-ioctl-cmds.h containing the complete ioctl command table mapping TARGET_* ioctl commands to their handlers. Uses IOCTL and IOCTL_SPECIAL macros for table generation.

---
 bsd-user/freebsd/os-ioctl-cmds.h | 151 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 151 insertions(+)
bsd-user/freebsd/os-ioctl-cmds.h new file +151 -0
new file mode 100644
index 0000000000..359e0dbe08
@@ -0,0 +1,151 @@
+/*
+ * FreeBSD file related system call shims and definitions
+ *
+ * Copyright (c) 2014 Stacey D. Son
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+/* sys/ttycom.h tty(4) */
+IOCTL(TIOCSETD, IOC_W, MK_PTR(TYPE_INT))
+IOCTL(TIOCGETD, IOC_R, MK_PTR(TYPE_INT))
+IOCTL(TIOCSBRK, IOC_, TYPE_NULL)
+IOCTL(TIOCCBRK, IOC_, TYPE_NULL)
+IOCTL(TIOCSDTR, IOC_, TYPE_NULL)
+IOCTL(TIOCCDTR, IOC_, TYPE_NULL)
+IOCTL(TIOCGPGRP, IOC_R, MK_PTR(TYPE_INT))
+IOCTL(TIOCSPGRP, IOC_W, MK_PTR(TYPE_INT))
+IOCTL(TIOCGETA, IOC_R, MK_PTR(MK_STRUCT(STRUCT_termios)))
+IOCTL(TIOCSETA, IOC_W, MK_PTR(MK_STRUCT(STRUCT_termios)))
+IOCTL(TIOCSETAW, IOC_W, MK_PTR(MK_STRUCT(STRUCT_termios)))
+IOCTL(TIOCSETAF, IOC_W, MK_PTR(MK_STRUCT(STRUCT_termios)))
+IOCTL(TIOCPTMASTER, IOC_, TYPE_NULL)
+IOCTL(TIOCOUTQ, IOC_R, MK_PTR(TYPE_INT))
+IOCTL(TIOCSTI, IOC_W, MK_PTR(TYPE_CHAR))
+IOCTL(TIOCNOTTY, IOC_, TYPE_NULL)
+IOCTL(TIOCSTOP, IOC_, TYPE_NULL)
+IOCTL(TIOCSTART, IOC_, TYPE_NULL)
+IOCTL(TIOCPKT, IOC_W, MK_PTR(TYPE_INT))
+IOCTL(TIOCSCTTY, IOC_, TYPE_NULL)
+IOCTL(TIOCDRAIN, IOC_, TYPE_NULL)
+IOCTL(TIOCEXCL, IOC_, TYPE_NULL)
+IOCTL(TIOCNXCL, IOC_, TYPE_NULL)
+IOCTL(TIOCFLUSH, IOC_W, MK_PTR(TYPE_INT))
+IOCTL(TIOCGWINSZ, IOC_R, MK_PTR(MK_STRUCT(STRUCT_winsize)))
+IOCTL(TIOCSWINSZ, IOC_W, MK_PTR(MK_STRUCT(STRUCT_winsize)))
+IOCTL(TIOCCONS, IOC_W, MK_PTR(TYPE_INT))
+IOCTL(TIOCMSET, IOC_W, MK_PTR(TYPE_INT))
+IOCTL(TIOCMGET, IOC_R, MK_PTR(TYPE_INT))
+IOCTL(TIOCMBIS, IOC_W, MK_PTR(TYPE_INT))
+IOCTL(TIOCMBIC, IOC_W, MK_PTR(TYPE_INT))
+
+/* sys/filio.h */
+IOCTL(FIOCLEX, IOC_, TYPE_NULL)
+IOCTL(FIONCLEX, IOC_, TYPE_NULL)
+IOCTL(FIONREAD, IOC_R, MK_PTR(TYPE_INT))
+IOCTL(FIONBIO, IOC_W, MK_PTR(TYPE_INT))
+IOCTL(FIOASYNC, IOC_W, MK_PTR(TYPE_INT))
+IOCTL(FIOSETOWN, IOC_W, MK_PTR(TYPE_INT))
+IOCTL(FIOGETOWN, IOC_R, MK_PTR(TYPE_INT))
+IOCTL(FIODTYPE, IOC_R, MK_PTR(TYPE_INT))
+IOCTL(FIOGETLBA, IOC_R, MK_PTR(TYPE_INT))
+IOCTL(FIODGNAME, IOC_W, MK_PTR(MK_STRUCT(STRUCT_fiodgname_arg)))
+IOCTL(FIONWRITE, IOC_R, MK_PTR(TYPE_INT))
+IOCTL(FIONSPACE, IOC_R, MK_PTR(TYPE_INT))
+IOCTL(FIOSEEKDATA, IOC_RW, MK_PTR(TYPE_ULONG))
+IOCTL(FIOSEEKHOLE, IOC_RW, MK_PTR(TYPE_ULONG))
+
+/* crypto/cryptodev.h */
+IOCTL_SPECIAL(CIOCGSESSION, IOC_RW, do_ioctl_unsupported, TYPE_INT)
+IOCTL_SPECIAL_UNIMPL(CRIOGET, IOC_RW, do_ioctl_unsupported, TYPE_INT)
+
+/* netinet6/in6_var.h */
+IOCTL_SPECIAL(SIOCGIFAFLAG_IN6, IOC_RW, do_ioctl_in6_ifreq_sockaddr_int,
+    MK_PTR(MK_STRUCT(STRUCT_in6_ifreq_int)))
+IOCTL_SPECIAL(SIOCGIFALIFETIME_IN6, IOC_RW, do_ioctl_in6_ifreq_sockaddr_int,
+    MK_PTR(MK_STRUCT(STRUCT_in6_ifreq_int)))
+IOCTL(SIOCGIFPSRCADDR_IN6, IOC_RW,
+    MK_PTR(MK_STRUCT(STRUCT_in6_ifreq_sockaddr_in6)))
+IOCTL(SIOCGIFINFO_IN6, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_in6_ndireq)))
+IOCTL(SIOCGDEFIFACE_IN6, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_in6_ndifreq)))
+
+/* sys/disk.h */
+IOCTL(DIOCGSECTORSIZE, IOC_R, MK_PTR(TYPE_INT))
+IOCTL(DIOCGMEDIASIZE, IOC_R, MK_PTR(TYPE_LONGLONG))
+
+/* sys/sockio.h */
+IOCTL_SPECIAL(SIOCGIFMAC, IOC_RW, do_ioctl_unsupported,
+    MK_PTR(MK_STRUCT(STRUCT_ifreq_int)))
+
+IOCTL(SIOCGIFCONF, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_ifconf)))
+
+IOCTL(SIOCGIFFLAGS, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifreq_short)))
+IOCTL(SIOCSIFFLAGS, IOC_W, MK_PTR(MK_STRUCT(STRUCT_ifreq_short)))
+
+IOCTL(SIOCGIFMETRIC, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifreq_int)))
+IOCTL(SIOCSIFMETRIC, IOC_W, MK_PTR(MK_STRUCT(STRUCT_ifreq_int)))
+IOCTL(SIOCGIFMTU, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifreq_int)))
+IOCTL(SIOCSIFMTU, IOC_W, MK_PTR(MK_STRUCT(STRUCT_ifreq_int)))
+IOCTL(SIOCGIFINDEX, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifreq_int)))
+IOCTL(SIOCGIFFIB, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifreq_int)))
+#ifdef SIOCGTUNFIB
+IOCTL(SIOCGTUNFIB, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifreq_int)))
+#endif
+
+IOCTL(SIOCGIFCAP, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifreq_cap)))
+
+IOCTL(SIOCGIFADDR, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifreq_sockaddr)))
+IOCTL(SIOCSIFADDR, IOC_W, MK_PTR(MK_STRUCT(STRUCT_ifreq_sockaddr)))
+IOCTL(SIOCGIFBRDADDR, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifreq_sockaddr)))
+IOCTL(SIOCSIFBRDADDR, IOC_W, MK_PTR(MK_STRUCT(STRUCT_ifreq_sockaddr)))
+IOCTL(SIOCGIFDSTADDR, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifreq_sockaddr)))
+IOCTL(SIOCSIFDSTADDR, IOC_W, MK_PTR(MK_STRUCT(STRUCT_ifreq_sockaddr)))
+IOCTL(SIOCGIFNETMASK, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifreq_sockaddr)))
+IOCTL(SIOCSIFNETMASK, IOC_W, MK_PTR(MK_STRUCT(STRUCT_ifreq_sockaddr)))
+IOCTL(SIOCADDMULTI, IOC_W, MK_PTR(MK_STRUCT(STRUCT_ifreq_sockaddr)))
+IOCTL(SIOCDELMULTI, IOC_W, MK_PTR(MK_STRUCT(STRUCT_ifreq_sockaddr)))
+IOCTL(SIOCGIFPSRCADDR, IOC_W | IOC_R,
+    MK_PTR(MK_STRUCT(STRUCT_ifreq_sockaddr)))
+
+IOCTL(SIOCGIFGENERIC, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifreq_ptr)))
+
+IOCTL(SIOCGIFDESCR, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifreq_buf)))
+
+IOCTL(SIOCGDRVSPEC, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifdrv)))
+
+IOCTL(SIOCGIFGROUP, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifgroupreq_ptr)))
+
+IOCTL(SIOCGIFMEDIA, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifmediareq)))
+#ifdef SIOCGIFXMEDIA
+IOCTL(SIOCGIFXMEDIA, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifmediareq)))
+#endif
+
+IOCTL(SIOCGIFSTATUS, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifstat)))
+
+/* net/if_gre.h */
+IOCTL(GREGKEY, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifreq_ptr)))
+#ifdef GREGOPTS
+IOCTL(GREGOPTS, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifreq_ptr)))
+#endif
+
+/* net/if_gif.h */
+IOCTL(GIFGOPTS, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifreq_ptr)))
+
+/* net/if_pfsync.h */
+#ifdef SIOCGETPFSYNC
+IOCTL(SIOCGETPFSYNC, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ifreq_ptr)))
+#endif
+
+/* net80211/ieee80211_ioctl.h */
+IOCTL(SIOCG80211, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_ieee80211req)))
+
+/* net/if_lagg.h */
+IOCTL(SIOCGLAGGPORT, IOC_W | IOC_R,
+    MK_PTR(MK_STRUCT(STRUCT_lagg_reqport_lacp_opreq)))
+IOCTL(SIOCGLAGG, IOC_W | IOC_R,
+    MK_PTR(MK_STRUCT(STRUCT_lagg_reqall_lacp_opreq)))
+IOCTL(SIOCGLAGGFLAGS, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_lagg_reqflags)))
+#ifdef SIOCGLAGGOPTS
+IOCTL(SIOCGLAGGOPTS, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_lagg_reqopts)))
+#endif
+
Signature · 1 line
2.52.0
Reviewed-by on v2 8/17
#16 lore raw

Re: [PATCH v2 08/17] bsd-user: Add FreeBSD ioctl command table

Quoted 6 lines · Warner Losh

From: "Stacey D. Son" <[email protected]>

Add os-ioctl-cmds.h containing the complete ioctl command table mapping TARGET_* ioctl commands to their handlers. Uses IOCTL and IOCTL_SPECIAL macros for table generation.

Quoted 7 lines
---
 bsd-user/freebsd/os-ioctl-cmds.h | 151 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 151 insertions(+)
#17 lore raw

PATCH v2 9/17 bsd-user: Add bsd-ioctl.h header

In reply to Warner Losh

From: "Stacey D. Son" <[email protected]>

Add bsd-ioctl.h header declaring the public ioctl emulation API:
do_bsd_ioctl() for processing ioctl system calls and init_bsd_ioctl() for initialization.

---
 bsd-user/bsd-ioctl.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
bsd-user/bsd-ioctl.h new file +14 -0
new file mode 100644
index 0000000000..bf9bb72bc9
@@ -0,0 +1,14 @@
+/*
+ * ioctl system call definitions
+ *
+ * Copyright (c) 2013 Stacey D. Son
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef BSD_IOCTL_H
+#define BSD_IOCTL_H
+
+abi_long do_bsd_ioctl(int fd, abi_long cmd, abi_long arg);
+void init_bsd_ioctl(void);
+
+#endif /* BSD_IOCTL_H */
Signature · 1 line
2.52.0
Reviewed-by on v2 9/17
#18 lore raw

Re: [PATCH v2 09/17] bsd-user: Add bsd-ioctl.h header

Quoted 6 lines · Warner Losh

From: "Stacey D. Son" <[email protected]>

Add bsd-ioctl.h header declaring the public ioctl emulation API:
do_bsd_ioctl() for processing ioctl system calls and init_bsd_ioctl() for initialization.

Quoted 6 lines
---
 bsd-user/bsd-ioctl.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
#19 lore raw

PATCH v2 10/17 bsd-user: Add target_sockaddr and safe_ioctl to syscall_defs.h

In reply to Warner Losh

From: "Stacey D. Son" <[email protected]>

Add struct target_sockaddr definition for socket address handling and safe_ioctl macro for safe ioctl system calls. These are required dependencies for the ioctl emulation subsystem.

---
 bsd-user/syscall_defs.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
bsd-user/syscall_defs.h +10 -0
index 4dbd90c2f1..873aea2fdd 100644
@@ -565,6 +565,16 @@ type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
     return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5, arg6); \
 }
 
+/*
+ * sys/socket.h
+ */
+struct target_sockaddr {
+    uint8_t sa_len;
+    uint8_t sa_family;
+    uint8_t sa_data[14];
+} QEMU_PACKED;
+
+#define safe_ioctl(...) safe_syscall(SYS_ioctl, __VA_ARGS__)
 #define safe_fcntl(...) safe_syscall(SYS_fcntl, __VA_ARGS__)
 
 /* So far all target and host bitmasks are the same */
Signature · 1 line
2.52.0
Reviewed-by on v2 10/17
#20 lore raw

Re: [PATCH v2 10/17] bsd-user: Add target_sockaddr and safe_ioctl to syscall_defs.h

Quoted 6 lines · Warner Losh

From: "Stacey D. Son" <[email protected]>

Add struct target_sockaddr definition for socket address handling and safe_ioctl macro for safe ioctl system calls. These are required dependencies for the ioctl emulation subsystem.

Quoted 6 lines
---
 bsd-user/syscall_defs.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
#21 lore raw

PATCH v2 11/17 bsd-user: Add bsd-ioctl.c infrastructure and termios conversion

In reply to Warner Losh

Add initial bsd-ioctl.c file with termios conversion functions, structure type definitions, and ioctl table infrastructure. Includes target_to_host_termios and host_to_target_termios for terminal I/O control conversion, along with the ioctl dispatch table framework.

Style complains about STRUCT and STRUCT_SPECIAL defines:
● checkpatch.pl: 197: ERROR: Macros with complex values should be enclosed in parenthesis ● checkpatch.pl: 198: ERROR: Macros with complex values should be enclosed in parenthesis
but that's fine. We are doing weird things with macros, and it's fine.
We can't put parens or do while (0) around these since they are table building macros for files that are included multiple times.

---
 bsd-user/bsd-ioctl.c | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 221 insertions(+)
bsd-user/bsd-ioctl.c new file +221 -0
new file mode 100644
index 0000000000..32fa9c3d33
@@ -0,0 +1,221 @@
+/*
+ * BSD ioctl(2) emulation
+ *
+ * Copyright (c) 2013-2015 Stacey D. Son
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include "qemu/osdep.h"
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/disk.h>
+#include <sys/ioccom.h>
+#include <sys/ioctl.h>
+#include <sys/sockio.h>
+#include <sys/_termios.h>
+#include <sys/ttycom.h>
+#include <sys/filio.h>
+
+#include <crypto/cryptodev.h>
+
+#include <net/ethernet.h>
+#include <net/if.h>
+#include <net/if_var.h>
+#include <net/if_types.h>
+#include <net/route.h>
+#include <net/if_dl.h>
+#include <net/if_gif.h>
+#include <net/if_gre.h>
+#include <net/if_lagg.h>
+#include <net/if_media.h>
+#include <net/pfvar.h>
+#include <net/if_pfsync.h>
+#include <net/ethernet.h>
+#include <netinet/icmp6.h>
+#include <netinet/in.h>
+#include <netinet/ip_carp.h>
+#include <netinet6/in6_var.h>
+#include <netinet6/nd6.h>
+#include <net80211/ieee80211_ioctl.h>
+
+#include <stdio.h>
+
+#include "qemu.h"
+
+#include "syscall_defs.h"
+#include "bsd-ioctl.h"
+#include "os-ioctl-cryptodev.h"
+#include "os-ioctl-disk.h"
+#include "os-ioctl-filio.h"
+#include "os-ioctl-in6_var.h"
+#include "os-ioctl-sockio.h"
+#include "os-ioctl-ttycom.h"
+
+static void target_to_host_termios(void *dst, const void *src)
+{
+    struct termios *host = dst;
+    const struct target_termios *target = src;
+
+    host->c_iflag = target_to_host_bitmask(tswap32(target->c_iflag), iflag_tbl);
+    host->c_oflag = target_to_host_bitmask(tswap32(target->c_oflag), oflag_tbl);
+    host->c_cflag = target_to_host_bitmask(tswap32(target->c_cflag), cflag_tbl);
+    host->c_lflag = target_to_host_bitmask(tswap32(target->c_lflag), lflag_tbl);
+
+    memset(host->c_cc, 0, sizeof(host->c_cc));
+    host->c_cc[VEOF] = target->c_cc[TARGET_VEOF];
+    host->c_cc[VEOL] = target->c_cc[TARGET_VEOL];
+#ifdef VEOL2
+    host->c_cc[VEOL2] = target->c_cc[TARGET_VEOL2];
+#endif
+    host->c_cc[VERASE] = target->c_cc[TARGET_VERASE];
+#ifdef VWERASE
+    host->c_cc[VWERASE] = target->c_cc[TARGET_VWERASE];
+#endif
+    host->c_cc[VKILL] = target->c_cc[TARGET_VKILL];
+#ifdef VREPRINT
+    host->c_cc[VREPRINT] = target->c_cc[TARGET_VREPRINT];
+#endif
+#ifdef VERASE2
+    host->c_cc[VERASE2] = target->c_cc[TARGET_VERASE2];
+#endif
+    host->c_cc[VINTR] = target->c_cc[TARGET_VINTR];
+    host->c_cc[VQUIT] = target->c_cc[TARGET_VQUIT];
+    host->c_cc[VSUSP] = target->c_cc[TARGET_VSUSP];
+#ifdef VDSUSP
+    host->c_cc[VDSUSP] = target->c_cc[TARGET_VDSUSP];
+#endif
+    host->c_cc[VSTART] = target->c_cc[TARGET_VSTART];
+    host->c_cc[VSTOP] = target->c_cc[TARGET_VSTOP];
+#ifdef VLNEXT
+    host->c_cc[VLNEXT] = target->c_cc[TARGET_VLNEXT];
+#endif
+#ifdef VDISCARD
+    host->c_cc[VDISCARD] = target->c_cc[TARGET_VDISCARD];
+#endif
+    host->c_cc[VMIN] = target->c_cc[TARGET_VMIN];
+    host->c_cc[VTIME] = target->c_cc[TARGET_VTIME];
+#ifdef VSTATUS
+    host->c_cc[VSTATUS] = target->c_cc[TARGET_VSTATUS];
+#endif
+
+    host->c_ispeed = tswap32(target->c_ispeed);
+    host->c_ospeed = tswap32(target->c_ospeed);
+}
+
+static void host_to_target_termios(void *dst, const void *src)
+{
+    struct target_termios *target = dst;
+    const struct termios *host = src;
+
+    target->c_iflag = tswap32(host_to_target_bitmask(host->c_iflag, iflag_tbl));
+    target->c_oflag = tswap32(host_to_target_bitmask(host->c_oflag, oflag_tbl));
+    target->c_cflag = tswap32(host_to_target_bitmask(host->c_cflag, cflag_tbl));
+    target->c_lflag = tswap32(host_to_target_bitmask(host->c_lflag, lflag_tbl));
+
+    memset(target->c_cc, 0, sizeof(target->c_cc));
+    target->c_cc[TARGET_VEOF] = host->c_cc[VEOF];
+    target->c_cc[TARGET_VEOL] = host->c_cc[VEOL];
+#ifdef VEOL2
+    target->c_cc[TARGET_VEOL2] = host->c_cc[VEOL2];
+#endif
+    target->c_cc[TARGET_VERASE] = host->c_cc[VERASE];
+#ifdef VWERASE
+    target->c_cc[TARGET_VWERASE] = host->c_cc[VWERASE];
+#endif
+    target->c_cc[TARGET_VKILL] = host->c_cc[VKILL];
+#ifdef VREPRINT
+    target->c_cc[TARGET_VREPRINT] = host->c_cc[VREPRINT];
+#endif
+#ifdef VERASE2
+    target->c_cc[TARGET_VERASE2] = host->c_cc[VERASE2];
+#endif
+    target->c_cc[TARGET_VINTR] = host->c_cc[VINTR];
+    target->c_cc[TARGET_VQUIT] = host->c_cc[VQUIT];
+    target->c_cc[TARGET_VSUSP] = host->c_cc[VSUSP];
+#ifdef VDSUSP
+    target->c_cc[TARGET_VDSUSP] = host->c_cc[VDSUSP];
+#endif
+    target->c_cc[TARGET_VSTART] = host->c_cc[VSTART];
+    target->c_cc[TARGET_VSTOP] = host->c_cc[VSTOP];
+#ifdef VLNEXT
+    target->c_cc[TARGET_VLNEXT] = host->c_cc[VLNEXT];
+#endif
+#ifdef VDISCARD
+    target->c_cc[TARGET_VDISCARD] = host->c_cc[VDISCARD];
+#endif
+    target->c_cc[TARGET_VMIN] = host->c_cc[VMIN];
+    target->c_cc[TARGET_VTIME] = host->c_cc[VTIME];
+#ifdef VSTATUS
+    target->c_cc[TARGET_VSTATUS] = host->c_cc[VSTATUS];
+#endif
+
+    target->c_ispeed = tswap32(host->c_ispeed);
+    target->c_ospeed = tswap32(host->c_ospeed);
+}
+
+static const StructEntry struct_termios_def = {
+    .convert = { host_to_target_termios, target_to_host_termios },
+    .size = { sizeof(struct target_termios), sizeof(struct termios) },
+    .align = { __alignof__(struct target_termios),
+        __alignof__(struct termios) },
+};
+
+
+/* ioctl structure type definitions */
+#define STRUCT(name, ...) STRUCT_ ## name,
+#define STRUCT_SPECIAL(name) STRUCT_ ## name,
+enum {
+#include "os-ioctl-types.h"
+STRUCT_MAX
+};
+#undef STRUCT
+#undef STRUCT_SPECIAL
+
+#define STRUCT(name, ...) \
+    static const argtype struct_ ## name ## _def[] = { __VA_ARGS__, TYPE_NULL };
+#define STRUCT_SPECIAL(name)
+#include "os-ioctl-types.h"
+#undef STRUCT
+#undef STRUCT_SPECIAL
+
+
+struct IOCTLEntry;
+
+typedef abi_long do_ioctl_fn(const struct IOCTLEntry *ie, uint8_t *buf_temp,
+                int fd, abi_long cmd, abi_long arg);
+
+struct IOCTLEntry {
+    unsigned int target_cmd;
+    unsigned int host_cmd;
+    const char *name;
+    int access;
+    do_ioctl_fn *do_ioctl;
+    const argtype arg_type[5];
+};
+typedef struct IOCTLEntry IOCTLEntry;
+
+#define MAX_STRUCT_SIZE 4096
+
+static abi_long do_ioctl_unsupported(__unused const IOCTLEntry *ie,
+                                     __unused uint8_t *buf_temp,
+                                     __unused int fd, __unused abi_long cmd,
+                                     __unused abi_long arg);
+
+static abi_long do_ioctl_in6_ifreq_sockaddr_int(const IOCTLEntry *ie,
+        uint8_t *buf_temp, int fd, abi_long cmd, abi_long arg);
+
+static IOCTLEntry ioctl_entries[] = {
+#define IOC_    0x0000
+#define IOC_R   0x0001
+#define IOC_W   0x0002
+#define IOC_RW  (IOC_R | IOC_W)
+#define IOCTL(cmd, access, ...) \
+    { TARGET_ ## cmd, cmd, #cmd, access, 0, { __VA_ARGS__ } },
+#define IOCTL_SPECIAL(cmd, access, dofn, ...) \
+    { TARGET_ ## cmd, cmd, #cmd, access, dofn, { __VA_ARGS__ } },
+#define IOCTL_SPECIAL_UNIMPL(cmd, access, dofn, ...) \
+    { TARGET_ ## cmd, 0, #cmd, access, dofn, { __VA_ARGS__ } },
+#include "os-ioctl-cmds.h"
+    { 0, 0 },
+};
Signature · 1 line
2.52.0
Reviewed-by on v2 11/17
#22 lore raw

Re: [PATCH v2 11/17] bsd-user: Add bsd-ioctl.c infrastructure and termios conversion

Quoted 13 lines · Warner Losh

Add initial bsd-ioctl.c file with termios conversion functions, structure type definitions, and ioctl table infrastructure. Includes target_to_host_termios and host_to_target_termios for terminal I/O control conversion, along with the ioctl dispatch table framework.

Style complains about STRUCT and STRUCT_SPECIAL defines:
● checkpatch.pl: 197: ERROR: Macros with complex values should be enclosed in parenthesis ● checkpatch.pl: 198: ERROR: Macros with complex values should be enclosed in parenthesis
but that's fine. We are doing weird things with macros, and it's fine.
We can't put parens or do while (0) around these since they are table building macros for files that are included multiple times.

Quoted 8 lines
---
 bsd-user/bsd-ioctl.c | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 221 insertions(+)
#23 lore raw

PATCH v2 12/17 bsd-user: Add log_unsupported_ioctl function

In reply to Warner Losh

Add helper function to log detailed information about unsupported ioctl commands, including direction, group, and parameter length.

---
 bsd-user/bsd-ioctl.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
bsd-user/bsd-ioctl.c +24 -0
index 32fa9c3d33..049188e5e1 100644
@@ -219,3 +219,27 @@ static IOCTLEntry ioctl_entries[] = {
 #include "os-ioctl-cmds.h"
     { 0, 0 },
 };
+
+static void log_unsupported_ioctl(unsigned long cmd)
+{
+    gemu_log("cmd=0x%08lx dir=", cmd);
+    switch (cmd & IOC_DIRMASK) {
+    case IOC_VOID:
+        gemu_log("VOID ");
+        break;
+    case IOC_OUT:
+        gemu_log("OUT ");
+        break;
+    case IOC_IN:
+        gemu_log("IN  ");
+        break;
+    case IOC_INOUT:
+        gemu_log("INOUT");
+        break;
+    default:
+        gemu_log("%01lx ???", (cmd & IOC_DIRMASK) >> 29);
+        break;
+    }
+    gemu_log(" '%c' %3d %lu\n", (char)IOCGROUP(cmd), (int)(cmd & 0xff),
+             IOCPARM_LEN(cmd));
+}
Signature · 1 line
2.52.0
Reviewed-by on v2 12/17
#24 lore raw

Re: [PATCH v2 12/17] bsd-user: Add log_unsupported_ioctl function

Quoted 9 lines · Warner Losh

Add helper function to log detailed information about unsupported ioctl commands, including direction, group, and parameter length.

---
 bsd-user/bsd-ioctl.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
#25 lore raw

PATCH v2 13/17 bsd-user: Add do_ioctl_unsupported function

In reply to Warner Losh

Add handler function for unsupported ioctl commands that returns TARGET_ENXIO.

---
 bsd-user/bsd-ioctl.c | 8 ++++++++
 1 file changed, 8 insertions(+)
bsd-user/bsd-ioctl.c +8 -0
index 049188e5e1..41f310c734 100644
@@ -243,3 +243,11 @@ static void log_unsupported_ioctl(unsigned long cmd)
     gemu_log(" '%c' %3d %lu\n", (char)IOCGROUP(cmd), (int)(cmd & 0xff),
              IOCPARM_LEN(cmd));
 }
+
+static abi_long do_ioctl_unsupported(__unused const IOCTLEntry *ie,
+                                     __unused uint8_t *buf_temp,
+                                     __unused int fd, __unused abi_long cmd,
+                                     __unused abi_long arg)
+{
+    return -TARGET_ENXIO;
+}
Signature · 1 line
2.52.0
#27 lore raw

PATCH v2 14/17 bsd-user: Add target_to_host_sockaddr_in6 function

In reply to Warner Losh

Add helper function to convert target IPv6 socket address structure to host format, handling all sockaddr_in6 fields including address, port, flow info, and scope ID.

---
 bsd-user/bsd-ioctl.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
bsd-user/bsd-ioctl.c +11 -0
index 41f310c734..2ff37a0817 100644
@@ -251,3 +251,14 @@ static abi_long do_ioctl_unsupported(__unused const IOCTLEntry *ie,
 {
     return -TARGET_ENXIO;
 }
+
+static void target_to_host_sockaddr_in6(struct sockaddr_in6 *hsa_in6,
+        struct target_sockaddr_in6 *tsa_in6)
+{
+    __get_user(hsa_in6->sin6_len, &tsa_in6->sin6_len);
+    __get_user(hsa_in6->sin6_family, &tsa_in6->sin6_family);
+    __get_user(hsa_in6->sin6_port, &tsa_in6->sin6_port);
+    __get_user(hsa_in6->sin6_flowinfo, &tsa_in6->sin6_flowinfo);
+    memcpy(&hsa_in6->sin6_addr, &tsa_in6->sin6_addr, 16);
+    __get_user(hsa_in6->sin6_scope_id, &tsa_in6->sin6_scope_id);
+}
Signature · 1 line
2.52.0
Reviewed-by on v2 14/17
#28 lore raw

Re: [PATCH v2 14/17] bsd-user: Add target_to_host_sockaddr_in6 function

Quoted 10 lines · Warner Losh

Add helper function to convert target IPv6 socket address structure to host format, handling all sockaddr_in6 fields including address, port, flow info, and scope ID.

---
 bsd-user/bsd-ioctl.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
#29 lore raw

PATCH v2 15/17 bsd-user: Add do_ioctl_in6_ifreq_sockaddr_int function

In reply to Warner Losh

Add special handler for IPv6 interface request ioctls that take a sockaddr_in6 structure as input and return an integer flag value, such as SIOCGIFAFLAG_IN6 and SIOCGIFALIFETIME_IN6.

---
 bsd-user/bsd-ioctl.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
bsd-user/bsd-ioctl.c +32 -0
index 2ff37a0817..aa0153bbaa 100644
@@ -262,3 +262,35 @@ static void target_to_host_sockaddr_in6(struct sockaddr_in6 *hsa_in6,
     memcpy(&hsa_in6->sin6_addr, &tsa_in6->sin6_addr, 16);
     __get_user(hsa_in6->sin6_scope_id, &tsa_in6->sin6_scope_id);
 }
+
+/*
+ * For ioctl()'s such as SIOCGIFAFLAG_IN6 and SIOCGIFALIFETIME_IN6 that
+ * passes a struct sockaddr_in6 in and gets an int out using
+ * struct in6_ifreq.
+ */
+static abi_long do_ioctl_in6_ifreq_sockaddr_int(const IOCTLEntry *ie,
+        uint8_t *buf_temp, int fd, abi_long cmd, abi_long arg)
+{
+    abi_long ret;
+    struct target_in6_ifreq *tin6ifreq;
+    struct target_sockaddr_in6 *tsa_in6;
+    struct in6_ifreq hin6ifreq;
+    struct sockaddr_in6 *hsa_in6 = &hin6ifreq.ifr_ifru.ifru_addr;
+
+    tin6ifreq = lock_user(VERIFY_WRITE, arg, sizeof(*tin6ifreq), 0);
+    if (tin6ifreq == NULL) {
+        return -TARGET_EFAULT;
+    }
+    memcpy(hin6ifreq.ifr_name, tin6ifreq->ifr_name, IFNAMSIZ);
+    tsa_in6 = &tin6ifreq->ifr_ifru.ifru_addr;
+    target_to_host_sockaddr_in6(hsa_in6, tsa_in6);
+
+    ret = get_errno(safe_ioctl(fd, ie->host_cmd, &hin6ifreq));
+    if (!is_error(ret)) {
+        put_user_s32(hin6ifreq.ifr_ifru.ifru_flags6,
+                arg + offsetof(struct target_in6_ifreq, ifr_ifru.ifru_flags6));
+    }
+    unlock_user(tin6ifreq, arg, 1);
+
+    return ret;
+}
Signature · 1 line
2.52.0
Reviewed-by on v2 15/17
#30 lore raw

Re: [PATCH v2 15/17] bsd-user: Add do_ioctl_in6_ifreq_sockaddr_int function

Quoted 41 lines · Warner Losh

Add special handler for IPv6 interface request ioctls that take a sockaddr_in6 structure as input and return an integer flag value, such as SIOCGIFAFLAG_IN6 and SIOCGIFALIFETIME_IN6.

---
 bsd-user/bsd-ioctl.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
bsd-user/bsd-ioctl.c +22 -0
index 2ff37a0817..aa0153bbaa 100644
@@ -262,3 +262,35 @@ static void target_to_host_sockaddr_in6(struct sockaddr_in6 *hsa_in6,
     memcpy(&hsa_in6->sin6_addr, &tsa_in6->sin6_addr, 16);
     __get_user(hsa_in6->sin6_scope_id, &tsa_in6->sin6_scope_id);
 }
+
+/*
+ * For ioctl()'s such as SIOCGIFAFLAG_IN6 and SIOCGIFALIFETIME_IN6 that
+ * passes a struct sockaddr_in6 in and gets an int out using
+ * struct in6_ifreq.
+ */
+static abi_long do_ioctl_in6_ifreq_sockaddr_int(const IOCTLEntry *ie,
+        uint8_t *buf_temp, int fd, abi_long cmd, abi_long arg)
+{
+    abi_long ret;
+    struct target_in6_ifreq *tin6ifreq;
+    struct target_sockaddr_in6 *tsa_in6;
+    struct in6_ifreq hin6ifreq;
+    struct sockaddr_in6 *hsa_in6 = &hin6ifreq.ifr_ifru.ifru_addr;
+
+    tin6ifreq = lock_user(VERIFY_WRITE, arg, sizeof(*tin6ifreq), 0);
+    if (tin6ifreq == NULL) {
+        return -TARGET_EFAULT;
+    }
+    memcpy(hin6ifreq.ifr_name, tin6ifreq->ifr_name, IFNAMSIZ);
+    tsa_in6 = &tin6ifreq->ifr_ifru.ifru_addr;
+    target_to_host_sockaddr_in6(hsa_in6, tsa_in6);

bsd-user/bsd-ioctl.c static void target_to_host_sockaddr_in6(struct sockaddr_in6 *hsa_in6, · line 296

Quoted 10 lines
bsd-user/bsd-ioctl.c +10 -0
+
+    ret = get_errno(safe_ioctl(fd, ie->host_cmd, &hin6ifreq));
+    if (!is_error(ret)) {
+        put_user_s32(hin6ifreq.ifr_ifru.ifru_flags6,
+                arg + offsetof(struct target_in6_ifreq, ifr_ifru.ifru_flags6));
+    }
+    unlock_user(tin6ifreq, arg, 1);
+
+    return ret;
+}
#31 lore raw

PATCH v2 16/17 bsd-user: Add do_bsd_ioctl main function

In reply to Warner Losh

Add main ioctl emulation dispatcher that handles table-driven ioctl translation with thunk-based structure conversion. Supports TYPE_NULL, TYPE_INT, and TYPE_PTR argument types with read, write, and read-write access modes.

---
 bsd-user/bsd-ioctl.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 100 insertions(+)
bsd-user/bsd-ioctl.c +100 -0
index aa0153bbaa..ae3ac7ae24 100644
@@ -294,3 +294,103 @@ static abi_long do_ioctl_in6_ifreq_sockaddr_int(const IOCTLEntry *ie,
 
     return ret;
 }
+
+abi_long do_bsd_ioctl(int fd, abi_long cmd, abi_long arg)
+{
+    const IOCTLEntry *ie;
+    const argtype *arg_type;
+    abi_long ret;
+    uint8_t buf_temp[MAX_STRUCT_SIZE];
+    int target_size;
+    void *argptr;
+
+    ie = ioctl_entries;
+    for (;;) {
+        if (ie->target_cmd == 0) {
+            gemu_log("QEMU unsupported ioctl: ");
+            log_unsupported_ioctl(cmd);
+            return -TARGET_ENOSYS;
+        }
+        if (ie->target_cmd == cmd) {
+            break;
+        }
+        ie++;
+    }
+    arg_type = ie->arg_type;
+#if defined(DEBUG)
+    gemu_log("ioctl: cmd=0x%04lx (%s)\n", (long)cmd, ie->name);
+#endif
+    if (ie->do_ioctl) {
+        return ie->do_ioctl(ie, buf_temp, fd, cmd, arg);
+    }
+
+    switch (arg_type[0]) {
+    case TYPE_NULL:
+        /* no argument */
+        ret = get_errno(safe_ioctl(fd, ie->host_cmd));
+        break;
+
+    case TYPE_PTRVOID:
+    case TYPE_INT:
+        /* int argument */
+        ret = get_errno(safe_ioctl(fd, ie->host_cmd, arg));
+        break;
+
+    case TYPE_PTR:
+        arg_type++;
+        target_size = thunk_type_size(arg_type, 0);
+        switch (ie->access) {
+        case IOC_R:
+            ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp));
+            if (!is_error(ret)) {
+                argptr = lock_user(VERIFY_WRITE, arg,
+                    target_size, 0);
+                if (!argptr) {
+                    return -TARGET_EFAULT;
+                }
+                thunk_convert(argptr, buf_temp, arg_type,
+                    THUNK_TARGET);
+                unlock_user(argptr, arg, target_size);
+            }
+            break;
+
+        case IOC_W:
+            argptr = lock_user(VERIFY_READ, arg, target_size, 1);
+            if (!argptr) {
+                return -TARGET_EFAULT;
+            }
+            thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST);
+            unlock_user(argptr, arg, 0);
+            ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp));
+            break;
+
+        case IOC_RW:
+            /* fallthrough */
+        default:
+            argptr = lock_user(VERIFY_READ, arg, target_size, 1);
+            if (!argptr) {
+                return -TARGET_EFAULT;
+            }
+            thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST);
+            unlock_user(argptr, arg, 0);
+            ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp));
+            if (!is_error(ret)) {
+                argptr = lock_user(VERIFY_WRITE, arg, target_size, 0);
+                if (!argptr) {
+                    return -TARGET_EFAULT;
+                }
+                thunk_convert(argptr, buf_temp, arg_type, THUNK_TARGET);
+                unlock_user(argptr, arg, target_size);
+            }
+            break;
+        }
+        break;
+
+    default:
+        gemu_log("QEMU unknown ioctl: type=%d ", arg_type[0]);
+        log_unsupported_ioctl(cmd);
+        ret = -TARGET_ENOSYS;
+        break;
+    }
+    return ret;
+}
Signature · 1 line
2.52.0
Reviewed-by on v2 16/17
#32 lore raw

Re: [PATCH v2 16/17] bsd-user: Add do_bsd_ioctl main function

Quoted 11 lines · Warner Losh

Add main ioctl emulation dispatcher that handles table-driven ioctl translation with thunk-based structure conversion. Supports TYPE_NULL, TYPE_INT, and TYPE_PTR argument types with read, write, and read-write access modes.

---
 bsd-user/bsd-ioctl.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 100 insertions(+)
#33 lore raw

PATCH v2 17/17 bsd-user: Add init_bsd_ioctl function

In reply to Warner Losh

Add initialization function that registers thunk structures and patches ioctl table entries with correct size parameters for target architecture.

---
 bsd-user/bsd-ioctl.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
bsd-user/bsd-ioctl.c +42 -0
index ae3ac7ae24..0b6a0943a2 100644
@@ -394,3 +394,45 @@ abi_long do_bsd_ioctl(int fd, abi_long cmd, abi_long arg)
     }
     return ret;
 }
+
+void init_bsd_ioctl(void)
+{
+    IOCTLEntry *ie;
+    const argtype *arg_type;
+    int size;
+
+    thunk_init(STRUCT_MAX);
+
+#define STRUCT(name, ...) \
+ thunk_register_struct(STRUCT_ ## name, #name, struct_ ## name ## _def);
+#define STRUCT_SPECIAL(name) \
+ thunk_register_struct_direct(STRUCT_ ## name, #name, &struct_ ## name ## _def);
+#include "os-ioctl-types.h"
+#undef STRUCT
+#undef STRUCT_SPECIAL
+
+    /*
+     * Patch the ioctl size if necessary using the fact that no
+     * ioctl has all the bits at '1' in the size field
+     * (IOCPARM_MAX - 1).
+     */
+    ie = ioctl_entries;
+    while (ie->target_cmd != 0) {
+        if (((ie->target_cmd >> TARGET_IOCPARM_SHIFT) &
+                    TARGET_IOCPARM_MASK) == TARGET_IOCPARM_MASK) {
+            arg_type = ie->arg_type;
+            if (arg_type[0] != TYPE_PTR) {
+                fprintf(stderr, "cannot patch size for ioctl 0x%x\n",
+                        ie->target_cmd);
+                exit(1);
+            }
+            arg_type++;
+            size = thunk_type_size(arg_type, 0);
+            ie->target_cmd = (ie->target_cmd &
+                    ~(TARGET_IOCPARM_MASK << TARGET_IOCPARM_SHIFT)) |
+                (size << TARGET_IOCPARM_SHIFT);
+        }
+        ie++;
+    }
+
+}
Signature · 1 line
2.52.0
Reviewed-by on v2 17/17
#34 lore raw

Re: [PATCH v2 17/17] bsd-user: Add init_bsd_ioctl function

Quoted 10 lines · Warner Losh

Add initialization function that registers thunk structures and patches ioctl table entries with correct size parameters for target architecture.

---
 bsd-user/bsd-ioctl.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
#35 lore raw
In reply to Warner Losh
Quoted 61 lines · Warner Losh

Again with the help of claude, harvest the ioctl changes from bsd-user blitz branch. These are a bit messy, since ioctls tend to be a bit messy. Ideally, all this would be generated, but that code isn't ready yet, so we go with what we have.

Please note: All style complaints are false positives. The > 80 character ones are fine: these files are semi-generated from upstream and fixing them makes syncing harder. Harder syncing in code that's basically boilerplate is worse than lines that are too long for definitions people are never going to read.

The two errors:
● b64902a56387: bsd-user: Add bsd-ioctl.c infrastructure and termios conversion
● checkpatch.pl: 197: ERROR: Macros with complex values should be enclosed in parenthesis ● checkpatch.pl: 198: ERROR: Macros with complex values should be enclosed in parenthesis
are impossible to fix: they are what they need to be for the macro
tricks that are being used. One cannot add parenthesis and have correct code.

This is largerly unchanged from v1, which didn't get any reviews.

---
Changes in v2:
- rebase forward, minor tweaks for blitz branch evolution
- Link to v1: https://lore.kernel.org/qemu-devel/[email protected]

---
Stacey D. Son (10):
bsd-user: Add FreeBSD tty ioctl definitions
bsd-user: Add FreeBSD file I/O ioctl definitions
bsd-user: Add FreeBSD socket ioctl definitions
bsd-user: Add FreeBSD cryptodev ioctl definitions
bsd-user: Add FreeBSD disk ioctl definitions
bsd-user: Add FreeBSD IPv6 ioctl definitions
bsd-user: Add FreeBSD ioctl type definitions
bsd-user: Add FreeBSD ioctl command table
bsd-user: Add bsd-ioctl.h header
bsd-user: Add target_sockaddr and safe_ioctl to syscall_defs.h

Warner Losh (7):
bsd-user: Add bsd-ioctl.c infrastructure and termios conversion
bsd-user: Add log_unsupported_ioctl function
bsd-user: Add do_ioctl_unsupported function
bsd-user: Add target_to_host_sockaddr_in6 function
bsd-user: Add do_ioctl_in6_ifreq_sockaddr_int function
bsd-user: Add do_bsd_ioctl main function
bsd-user: Add init_bsd_ioctl function

 bsd-user/bsd-ioctl.c                  | 438 ++++++++++++++++++++++++++++++++++
 bsd-user/bsd-ioctl.h                  |  14 ++
 bsd-user/freebsd/os-ioctl-cmds.h      | 151 ++++++++++++
 bsd-user/freebsd/os-ioctl-cryptodev.h |  74 ++++++
 bsd-user/freebsd/os-ioctl-disk.h      |  41 ++++
 bsd-user/freebsd/os-ioctl-filio.h     |  34 +++
 bsd-user/freebsd/os-ioctl-in6_var.h   | 217 +++++++++++++++++
 bsd-user/freebsd/os-ioctl-sockio.h    | 240 +++++++++++++++++++
 bsd-user/freebsd/os-ioctl-ttycom.h    | 237 ++++++++++++++++++
 bsd-user/freebsd/os-ioctl-types.h     | 104 ++++++++
 bsd-user/syscall_defs.h               |  10 +
 11 files changed, 1560 insertions(+)
Quoted 7 lines

---
base-commit: becd22fdc2a071783d9e04421526633772b3b98c
change-id: 20260411-ioctl-68c80a77ad32
prerequisite-change-id: 20260312-share-thunk-ab1585477999:v2
prerequisite-patch-id: a048e442d9dda7ee4ed1070ef5eb524e078b9a3b

Best regards,

Hi Warner,

a few checkpatch warnings:
https://github.com/p-b-o/qemu-ci/actions/runs/25116258138/job/73604077805

Regards,
Pierrick

#36 lore raw
Quoted 70 lines · Pierrick Bouvier
Quoted 61 lines · Warner Losh

Again with the help of claude, harvest the ioctl changes from bsd-user blitz branch. These are a bit messy, since ioctls tend to be a bit messy. Ideally, all this would be generated, but that code isn't ready yet, so we go with what we have.

Please note: All style complaints are false positives. The > 80 character ones are fine: these files are semi-generated from upstream and fixing them makes syncing harder. Harder syncing in code that's basically boilerplate is worse than lines that are too long for definitions people are never going to read.

The two errors:
● b64902a56387: bsd-user: Add bsd-ioctl.c infrastructure and termios conversion
● checkpatch.pl: 197: ERROR: Macros with complex values should be enclosed in parenthesis ● checkpatch.pl: 198: ERROR: Macros with complex values should be enclosed in parenthesis
are impossible to fix: they are what they need to be for the macro
tricks that are being used. One cannot add parenthesis and have correct code.

This is largerly unchanged from v1, which didn't get any reviews.

---
Changes in v2:
- rebase forward, minor tweaks for blitz branch evolution
- Link to v1: https://lore.kernel.org/qemu-devel/[email protected]

---
Stacey D. Son (10):
bsd-user: Add FreeBSD tty ioctl definitions
bsd-user: Add FreeBSD file I/O ioctl definitions
bsd-user: Add FreeBSD socket ioctl definitions
bsd-user: Add FreeBSD cryptodev ioctl definitions
bsd-user: Add FreeBSD disk ioctl definitions
bsd-user: Add FreeBSD IPv6 ioctl definitions
bsd-user: Add FreeBSD ioctl type definitions
bsd-user: Add FreeBSD ioctl command table
bsd-user: Add bsd-ioctl.h header
bsd-user: Add target_sockaddr and safe_ioctl to syscall_defs.h

Warner Losh (7):
bsd-user: Add bsd-ioctl.c infrastructure and termios conversion
bsd-user: Add log_unsupported_ioctl function
bsd-user: Add do_ioctl_unsupported function
bsd-user: Add target_to_host_sockaddr_in6 function
bsd-user: Add do_ioctl_in6_ifreq_sockaddr_int function
bsd-user: Add do_bsd_ioctl main function
bsd-user: Add init_bsd_ioctl function

 bsd-user/bsd-ioctl.c                  | 438 ++++++++++++++++++++++++++++++++++
 bsd-user/bsd-ioctl.h                  |  14 ++
 bsd-user/freebsd/os-ioctl-cmds.h      | 151 ++++++++++++
 bsd-user/freebsd/os-ioctl-cryptodev.h |  74 ++++++
 bsd-user/freebsd/os-ioctl-disk.h      |  41 ++++
 bsd-user/freebsd/os-ioctl-filio.h     |  34 +++
 bsd-user/freebsd/os-ioctl-in6_var.h   | 217 +++++++++++++++++
 bsd-user/freebsd/os-ioctl-sockio.h    | 240 +++++++++++++++++++
 bsd-user/freebsd/os-ioctl-ttycom.h    | 237 ++++++++++++++++++
 bsd-user/freebsd/os-ioctl-types.h     | 104 ++++++++
 bsd-user/syscall_defs.h               |  10 +
 11 files changed, 1560 insertions(+)
Quoted 7 lines

---
base-commit: becd22fdc2a071783d9e04421526633772b3b98c
change-id: 20260411-ioctl-68c80a77ad32
prerequisite-change-id: 20260312-share-thunk-ab1585477999:v2
prerequisite-patch-id: a048e442d9dda7ee4ed1070ef5eb524e078b9a3b

Best regards,

Quoted 7 lines

Hi Warner,

a few checkpatch warnings:
https://github.com/p-b-o/qemu-ci/actions/runs/25116258138/job/73604077805

Regards,
Pierrick

First commit seems to not belong to this series, but taken from prerequisite-change-id. I didn't know b4 shazam would be follow, but that's great and much more convenient than the custom Based-on tag QEMU devs are used to.

#37 lore raw
In reply to Pierrick Bouvier
Quoted 73 lines · Pierrick Bouvier
Quoted 5 lines · Warner Losh

Again with the help of claude, harvest the ioctl changes from bsd-user blitz branch. These are a bit messy, since ioctls tend to be a bit messy. Ideally, all this would be generated, but that code isn't ready yet, so we go with what we have.

Quoted 8 lines

Please note: All style complaints are false positives. The > 80 character ones are fine: these files are semi-generated from upstream and fixing them makes syncing harder. Harder syncing in code that's basically boilerplate is worse than lines that are too long for definitions people are never going to read.

The two errors:
● b64902a56387: bsd-user: Add bsd-ioctl.c infrastructure and termios

conversion

Quoted 1 line

● checkpatch.pl: 197: ERROR: Macros with complex values should be

enclosed in parenthesis

Quoted 1 line

● checkpatch.pl: 198: ERROR: Macros with complex values should be

enclosed in parenthesis

Quoted 11 lines

are impossible to fix: they are what they need to be for the macro tricks that are being used. One cannot add parenthesis and have correct code.

This is largerly unchanged from v1, which didn't get any reviews.

---
Changes in v2:
- rebase forward, minor tweaks for blitz branch evolution
- Link to v1:

https://lore.kernel.org/qemu-devel/[email protected]

Quoted 23 lines

---
Stacey D. Son (10):
bsd-user: Add FreeBSD tty ioctl definitions
bsd-user: Add FreeBSD file I/O ioctl definitions
bsd-user: Add FreeBSD socket ioctl definitions
bsd-user: Add FreeBSD cryptodev ioctl definitions
bsd-user: Add FreeBSD disk ioctl definitions
bsd-user: Add FreeBSD IPv6 ioctl definitions
bsd-user: Add FreeBSD ioctl type definitions
bsd-user: Add FreeBSD ioctl command table
bsd-user: Add bsd-ioctl.h header
bsd-user: Add target_sockaddr and safe_ioctl to syscall_defs.h

Warner Losh (7):
bsd-user: Add bsd-ioctl.c infrastructure and termios conversion
bsd-user: Add log_unsupported_ioctl function
bsd-user: Add do_ioctl_unsupported function
bsd-user: Add target_to_host_sockaddr_in6 function
bsd-user: Add do_ioctl_in6_ifreq_sockaddr_int function
bsd-user: Add do_bsd_ioctl main function
bsd-user: Add init_bsd_ioctl function

Quoted 1 line
 bsd-user/bsd-ioctl.c                  | 438

++++++++++++++++++++++++++++++++++

Quoted 17 lines
 bsd-user/bsd-ioctl.h                  |  14 ++
 bsd-user/freebsd/os-ioctl-cmds.h      | 151 ++++++++++++
 bsd-user/freebsd/os-ioctl-cryptodev.h |  74 ++++++
 bsd-user/freebsd/os-ioctl-disk.h      |  41 ++++
 bsd-user/freebsd/os-ioctl-filio.h     |  34 +++
 bsd-user/freebsd/os-ioctl-in6_var.h   | 217 +++++++++++++++++
 bsd-user/freebsd/os-ioctl-sockio.h    | 240 +++++++++++++++++++
 bsd-user/freebsd/os-ioctl-ttycom.h    | 237 ++++++++++++++++++
 bsd-user/freebsd/os-ioctl-types.h     | 104 ++++++++
 bsd-user/syscall_defs.h               |  10 +
 11 files changed, 1560 insertions(+)

---
base-commit: becd22fdc2a071783d9e04421526633772b3b98c
change-id: 20260411-ioctl-68c80a77ad32
prerequisite-change-id: 20260312-share-thunk-ab1585477999:v2
prerequisite-patch-id: a048e442d9dda7ee4ed1070ef5eb524e078b9a3b

Quoted 6 lines
Quoted 1 line

Best regards,

Hi Warner,

a few checkpatch warnings:
https://github.com/p-b-o/qemu-ci/actions/runs/25116258138/job/73604077805

There's two sets of warnings. The thunk.c warnings are irrelevant: thunk.c is
a verbaitm copy of linux-user/thunk.c since that was how I was told to share it.
It shows up in the CI as the first commit, but it's an already reviewed patch. Those
won't be fixed because it's inefficnet to reformat code I'm verbatim copying.
The inclusion of this patch is the series is an artifact of b4 and having this
series be based on that prior series I've not put into a pull request yet.

The other warnings are documented in this message and are false positives. The macros can't be written in any way other than how they are written.

Warner

Quoted 4 lines

Regards,
Pierrick

#38 lore raw
Quoted 103 lines · Warner Losh

On Wed, Apr 29, 2026 at 4:52 PM Pierrick Bouvier <[email protected] <mailto:[email protected]>> wrote:

On 4/29/2026 7:45 AM, Warner Losh wrote:
> Again with the help of claude, harvest the ioctl changes from > bsd-user blitz branch. These are a bit messy, since ioctls tend > to be a bit messy. Ideally, all this would be generated, but > that code isn't ready yet, so we go with what we have.
>
> Please note: All style complaints are false positives. The > 80 > character ones are fine: these files are semi-generated from upstream > and fixing them makes syncing harder. Harder syncing in code that's > basically boilerplate is worse than lines that are too long for > definitions people are never going to read.
>
> The two errors:
> ● b64902a56387: bsd-user: Add bsd-ioctl.c infrastructure and termios conversion
>   ● checkpatch.pl <http://checkpatch.pl>: 197: ERROR: Macros with complex values should be enclosed in parenthesis
>   ● checkpatch.pl <http://checkpatch.pl>: 198: ERROR: Macros with complex values should be enclosed in parenthesis
> are impossible to fix: they are what they need to be for the macro > tricks that are being used. One cannot add parenthesis and have correct
> code.
>
> This is largerly unchanged from v1, which didn't get any reviews. >
> Signed-off-by: Warner Losh <[email protected] <mailto:[email protected]>> > ---
> Changes in v2:
> - rebase forward, minor tweaks for blitz branch evolution > - Link to v1: https://lore.kernel.org/qemu-devel/20260412-ioctl-
[email protected] <https://lore.kernel.org/qemu-
devel/[email protected]>
>
> ---
> Stacey D. Son (10):
>       bsd-user: Add FreeBSD tty ioctl definitions
>       bsd-user: Add FreeBSD file I/O ioctl definitions
>       bsd-user: Add FreeBSD socket ioctl definitions
>       bsd-user: Add FreeBSD cryptodev ioctl definitions
>       bsd-user: Add FreeBSD disk ioctl definitions
>       bsd-user: Add FreeBSD IPv6 ioctl definitions
>       bsd-user: Add FreeBSD ioctl type definitions
>       bsd-user: Add FreeBSD ioctl command table
>       bsd-user: Add bsd-ioctl.h header
>       bsd-user: Add target_sockaddr and safe_ioctl to syscall_defs.h >
> Warner Losh (7):
>       bsd-user: Add bsd-ioctl.c infrastructure and termios conversion >       bsd-user: Add log_unsupported_ioctl function
>       bsd-user: Add do_ioctl_unsupported function
>       bsd-user: Add target_to_host_sockaddr_in6 function >       bsd-user: Add do_ioctl_in6_ifreq_sockaddr_int function >       bsd-user: Add do_bsd_ioctl main function
>       bsd-user: Add init_bsd_ioctl function
>
>  bsd-user/bsd-ioctl.c                  | 438 +++++++++++++++++++++
+++++++++++++
>  bsd-user/bsd-ioctl.h                  |  14 ++
>  bsd-user/freebsd/os-ioctl-cmds.h      | 151 ++++++++++++ >  bsd-user/freebsd/os-ioctl-cryptodev.h |  74 ++++++
>  bsd-user/freebsd/os-ioctl-disk.h      |  41 ++++
>  bsd-user/freebsd/os-ioctl-filio.h     |  34 +++
>  bsd-user/freebsd/os-ioctl-in6_var.h   | 217 +++++++++++++++++ >  bsd-user/freebsd/os-ioctl-sockio.h    | 240 +++++++++++++++++++ >  bsd-user/freebsd/os-ioctl-ttycom.h    | 237 ++++++++++++++++++ >  bsd-user/freebsd/os-ioctl-types.h     | 104 ++++++++
>  bsd-user/syscall_defs.h               |  10 +
>  11 files changed, 1560 insertions(+)
> ---
> base-commit: becd22fdc2a071783d9e04421526633772b3b98c
> change-id: 20260411-ioctl-68c80a77ad32
> prerequisite-change-id: 20260312-share-thunk-ab1585477999:v2 > prerequisite-patch-id: a048e442d9dda7ee4ed1070ef5eb524e078b9a3b >
> Best regards,

Hi Warner,

a few checkpatch warnings:
https://github.com/p-b-o/qemu-ci/actions/runs/25116258138/
job/73604077805 <https://github.com/p-b-o/qemu-ci/actions/
runs/25116258138/job/73604077805>

There's two sets of warnings. The thunk.c warnings are irrelevant:
thunk.c is
a verbaitm copy of linux-user/thunk.c since that was how I was told to share it.
It shows up in the CI as the first commit, but it's an already reviewed patch. Those
won't be fixed because it's inefficnet to reformat code I'm verbatim copying.
The inclusion of this patch is the series is an artifact of b4 and having this
series be based on that prior series I've not put into a pull request yet.

Quoted 3 lines

The other warnings are documented in this message and are false positives. The macros can't be written in any way other than how they are written.

Yep, I noted that.
And saw *after* that first commit was not from this series.

Quoted 7 lines

Warner

Regards,
Pierrick