bsd-user: upstream ioctl
v3 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 v3:
- Fix numerous small errors in types found by claude code review:
- remove duplicate net/ethernet.h include
- remove duplicate TARGET_SIOCGVH definition
- fix lock_user issue in do_ioctl_in6_ifreq_sockaddr_int to copy it
- fix unlock_user issue in do_ioctl_in6_ifreq_sockaddr_int to use correct size
- remove duplicate TARGET_IFNAMSIZ definition
- Provide struct target_crypto_op
- Use abi types not native in several places (same size though)
- Fix logical error in ioctl encoding using TARGET_ forms if IF* constants
- Fix ieee80211req definition for ioctls to use SHROT instead of INT for int16 types
- fix lagg_reqport_lacp_opreq and lagg_reqall_lacp_opreq thunks to match structure def
- sync to latest freebsd and delete obsolete crypto
- Use abi_ types more consistently
- sync to latest disk ioctls
- Somehow foled all that into the same number of patches (since it just reflect blitz fixes and we don't need that history in qemu-project master).
- Link to v2: https://lore.kernel.org/qemu-devel/[email protected]
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
Stacey Son (1):
bsd-user: ioctl: add common definitions
Warner Losh (8):
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: Add call to do_bsd_ioctl and add bsd-ioctl.c to the build
bsd-user/bsd-ioctl.c | 436 ++++++++++++++++++++++++++++++++++ bsd-user/bsd-ioctl.h | 14 ++ bsd-user/freebsd/os-ioctl-cmds.h | 149 ++++++++++++ bsd-user/freebsd/os-ioctl-cryptodev.h | 84 +++++++ bsd-user/freebsd/os-ioctl-disk.h | 52 ++++ bsd-user/freebsd/os-ioctl-filio.h | 34 +++ bsd-user/freebsd/os-ioctl-in6_var.h | 226 ++++++++++++++++++ bsd-user/freebsd/os-ioctl-ioccom.h | 43 ++++ bsd-user/freebsd/os-ioctl-sockio.h | 246 +++++++++++++++++++ bsd-user/freebsd/os-ioctl-ttycom.h | 239 +++++++++++++++++++ bsd-user/freebsd/os-ioctl-types.h | 109 +++++++++ bsd-user/freebsd/os-syscall.c | 9 + bsd-user/meson.build | 1 + bsd-user/syscall_defs.h | 14 ++ 14 files changed, 1656 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]>
PATCH v3 1/19 bsd-user: ioctl: add common definitions
From: Stacey Son <[email protected]>
Modeled on sys/ioccom.h.
--- bsd-user/freebsd/os-ioctl-ioccom.h | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
bsd-user/freebsd/os-ioctl-ioccom.h new file +43 -0
@@ -0,0 +1,43 @@ +/* +* FreeBSD ioccom 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_IOCCOM_H +#define BSD_USER_FREEBSD_OS_IOCTL_IOCCOM_H + +/* +* Ioctl's have the command encoded in the lower word, and the size of +* any in or out parameters in the upper word. The high 3 bits of the +* upper word are used to encode the in/out status of the parameter. +*/ +/* number of bits for ioctl size */ +#define TARGET_IOCPARM_SHIFT 13 + +/* parameter length mask */ +#define TARGET_IOCPARM_MASK ((1 << TARGET_IOCPARM_SHIFT) - 1) + +#define TARGET_IOCPARM_LEN (x) (((x) >> 16) & TARGET_IOCPARM_MASK) +#define TARGET_IOCBASECMD (x) ((x) & ~(TARGET_IOCPARM_MASK << 16)) +#define TARGET_IOCGROUP (x) (((x) >> 8) & 0xff) + +#define TARGET_IOCPARM_MAX (1 << TARGET_IOCPARM_SHIFT)/* max size of ioctl */ +#define TARGET_IOC_VOID 0x20000000/* no parameters */ +#define TARGET_IOC_OUT 0x40000000/* copy out parameters */ +#define TARGET_IOC_IN 0x80000000/* copy in parameters */ +#define TARGET_IOC_INOUT (TARGET_IOC_IN | TARGET_IOC_OUT) +#define TARGET_IOC_DIRMASK (TARGET_IOC_VOID | TARGET_IOC_OUT | TARGET_IOC_IN) + +#define TARGET_IOC (inout, group, num, len) ((abi_ulong) \ + ((inout) | (((len) & TARGET_IOCPARM_MASK) << 16) | ((group) << 8) \ + | (num))) +#define TARGET_IO (g, n) TARGET_IOC(TARGET_IOC_VOID, (g), (n), 0) +#define TARGET_IOWINT (g, n) TARGET_IOC(TARGET_IOC_VOID, (g), (n), sizeof(int)) +#define TARGET_IOR (g, n, t) TARGET_IOC(TARGET_IOC_OUT, (g), (n), sizeof(t)) +#define TARGET_IOW (g, n, t) TARGET_IOC(TARGET_IOC_IN, (g), (n), sizeof(t)) +/* this should be _IORW, but stdio got there first */ +#define TARGET_IOWR (g, n, t) TARGET_IOC(TARGET_IOC_INOUT, (g), (n), sizeof(t)) + +#endif /* BSD_USER_FREEBSD_OS_IOCTL_IOCCOM_H */
Signature · 1 line
2.52.0
Re: [PATCH v3 01/19] bsd-user: ioctl: add common definitions
Quoted 10 lines · Warner Losh
From: Stacey Son <[email protected]>
Modeled on
sys/ioccom.h.Signed-off-by Stacey Son <[email protected]>Signed-off-by Warner Losh <[email protected]>--- bsd-user/freebsd/os-ioctl-ioccom.h | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
PATCH v3 2/19 bsd-user: Add FreeBSD tty ioctl definitions
In reply to Warner LoshFrom: "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 | 239 +++++++++++++++++++++++++++++++++++++ 1 file changed, 239 insertions(+)
bsd-user/freebsd/os-ioctl-ttycom.h new file +239 -0
@@ -0,0 +1,239 @@ +/* +* 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 */ +#define TARGET_IUTF8 0x00004000/* assume input is utf-8 encoded */ + +/* +* 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 */ +#define TARGET_CNO_RTSDTR 0x00200000/* Do not assert RTS or DTR automatically */ + +/* +* "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
PATCH v3 3/19 bsd-user: Add FreeBSD file I/O ioctl definitions
In reply to Warner LoshFrom: "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
@@ -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
PATCH v3 4/19 bsd-user: Add FreeBSD socket ioctl definitions
In reply to Warner LoshFrom: "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 | 246 +++++++++++++++++++++++++++++++++++++ 1 file changed, 246 insertions(+)
bsd-user/freebsd/os-ioctl-sockio.h new file +246 -0
@@ -0,0 +1,246 @@ +/* +* 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; +}; + +struct target_ifreq_nv_req { +abi_uint buf_length;/* Total size of buffer */ +abi_uint length;/* Length of the filled part */ +abi_ulong buffer;/* Buffer itself, containing packed nv */ +}; + +#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; +abi_short ifru_flags[2 ]; +abi_short ifru_index; +abi_int ifru_jid; +abi_int ifru_metric; +abi_int ifru_mtu; +abi_int ifru_phys; +abi_int ifru_media; +abi_ulong ifru_data; +abi_int ifru_cap[2 ]; +uint32_t ifru_fib; +uint8_t ifru_vlan_pcp; +struct target_ifreq_nv_req ifru_nv; + } 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) + +/* 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_req; + } 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 ]; +abi_uint ra_proto; + +abi_ulong ra_size; +abi_ulong ra_port; +abi_int 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[TARGET_IFNAMSIZ ]; +abi_int ro_opts; +abi_uint ro_count; +abi_uint ro_active; +abi_uint ro_flapping; +abi_int ro_flowid_shift; +uint32_t ro_bkt; +}; +#define TARGET_SIOCGLAGGOPTS TARGET_IOWR('i', 152, struct target_lagg_reqopts) + +#endif /* OS_IOCTL_SOCKIO_H */
Signature · 1 line
2.52.0
PATCH v3 5/19 bsd-user: Add FreeBSD cryptodev ioctl definitions
In reply to Warner LoshFrom: "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 | 84 +++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+)
bsd-user/freebsd/os-ioctl-cryptodev.h new file +84 -0
@@ -0,0 +1,84 @@ +/* +* 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; +abi_int ivlen; +abi_int maclen; +abi_int pad[2 ]; +}; + +struct target_crypt_op { +uint32_t ses; +uint16_t op;/* i.e. COP_ENCRYPT */ +#define TARGET_COP_ENCRYPT 1 +#define TARGET_COP_DECRYPT 2 +uint16_t flags; +#define TARGET_COP_F_CIPHER_FIRST 0x0001/* Cipher before MAC. */ +#define TARGET_COP_F_BATCH 0x0008/* Batch op if possible */ +abi_uint len; +abi_ulong src;/* become iov[] inside kernel */ +abi_ulong dst; +abi_ulong mac;/* must be big enough for chosen MAC */ +abi_ulong iv; +}; + +/* op and flags the same as crypt_op */ +struct target_crypt_aead { +uint32_t ses; +uint16_t op;/* i.e. COP_ENCRYPT */ +uint16_t flags; +abi_uint len; +abi_uint aadlen; +abi_uint ivlen; +abi_ulong src;/* become iov[] inside kernel */ +abi_ulong dst; +abi_ulong aad;/* additional authenticated data */ +abi_ulong tag;/* must fit for chosen TAG length */ +abi_ulong iv; +}; + +struct target_crypt_find_op { +abi_int crid; +char name[32 ]; +}; + +#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_CIOCGSESSION2 TARGET_IOWR('c', 106, struct target_session2_op) +#define TARGET_CIOCFINDDEV TARGET_IOWR('c', 108, struct target_crypt_find_op) +#define TARGET_CIOCCRYPTAEAD TARGET_IOWR('c', 109, struct target_crypt_aead) + +#endif /* BSD_USER_FREEBSD_OS_IOCTL_CRYPTODEV_H */
Signature · 1 line
2.52.0
PATCH v3 6/19 bsd-user: Add FreeBSD disk ioctl definitions
In reply to Warner LoshFrom: "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 | 52 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
bsd-user/freebsd/os-ioctl-disk.h new file +52 -0
@@ -0,0 +1,52 @@ +/* +* 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_MAXPATHLEN 1024 + +#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_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[TARGET_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[TARGET_MAXPATHLEN]) + +struct target_diocgattr_arg { +char name[64 ]; +abi_int len; +union { +char str[TARGET_DISK_IDENT_SIZE ]; +int64_t off;/* Want abioff, but this will do */ +abi_int i; +abi_short u16; + } value; +}; + +#define TARGET_DIOCGATTR TARGET_IOWR('d', 142, struct target_diocgattr_arg) + +/* Unsupported, target_disk_zone_args is complicated */ +/* #define DIOCZONECMD _IOWR('d', 143, struct target_disk_zone_args) */ + +/* Enable/Disable the device for kernel core dumps. */ +/* #define DIOCSKERNELDUMP _IOW('d', 145, struct diocskerneldump_arg) */ +/* Get current kernel netdump configuration details for a given index. */ +/* #define DIOCGKERNELDUMP _IOWR('d', 146, struct diocskerneldump_arg) */ + +#endif /* OS_IOCTL_DISK_H */
Signature · 1 line
2.52.0
PATCH v3 7/19 bsd-user: Add FreeBSD IPv6 ioctl definitions
In reply to Warner LoshFrom: "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 | 226 ++++++++++++++++++++++++++++++++++++ 1 file changed, 226 insertions(+)
bsd-user/freebsd/os-ioctl-in6_var.h new file +226 -0
@@ -0,0 +1,226 @@ +/* +* 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 + +#include "os-ioctl-sockio.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; +}; + +struct target_in6_ifreq { +char ifr_name[TARGET_IFNAMSIZ ]; +union { +struct target_sockaddr_in6 ifru_addr; +struct target_sockaddr_in6 ifru_dstaddr; +abi_int ifru_flags; +abi_int ifru_flags6; +abi_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[TARGET_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_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
PATCH v3 8/19 bsd-user: Add FreeBSD ioctl type definitions
In reply to Warner LoshFrom: "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 | 109 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+)
bsd-user/freebsd/os-ioctl-types.h new file +109 -0
@@ -0,0 +1,109 @@ +/* +* 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, TARGET_IFNAMSIZ), TYPE_CHAR) + +STRUCT(ifreq_short, + MK_ARRAY(TYPE_CHAR, TARGET_IFNAMSIZ), MK_ARRAY(TYPE_SHORT, 2)) + +STRUCT(ifreq_int, + MK_ARRAY(TYPE_CHAR, TARGET_IFNAMSIZ), TYPE_INT) + +STRUCT(ifreq_ptr, + MK_ARRAY(TYPE_CHAR, TARGET_IFNAMSIZ), TYPE_PTRVOID) + +STRUCT(ifreq_cap, + MK_ARRAY(TYPE_CHAR, TARGET_IFNAMSIZ), MK_ARRAY(TYPE_INT, 2)) + +STRUCT(ifreq_sockaddr, + MK_ARRAY(TYPE_CHAR, TARGET_IFNAMSIZ), MK_STRUCT(STRUCT_sockaddr)) + +STRUCT(ifreq_buf, + MK_ARRAY(TYPE_CHAR, TARGET_IFNAMSIZ), MK_STRUCT(STRUCT__ifreq_buffer)) + +STRUCT(ifdrv, + MK_ARRAY(TYPE_CHAR, TARGET_IFNAMSIZ), TYPE_PTRVOID, TYPE_PTRVOID, + TYPE_PTRVOID) + +STRUCT(ifgroupreq_ptr, + MK_ARRAY(TYPE_CHAR, TARGET_IFNAMSIZ), TYPE_INT, TYPE_PTRVOID) + +STRUCT(ifmediareq, + MK_ARRAY(TYPE_CHAR, TARGET_IFNAMSIZ), TYPE_INT, TYPE_INT, TYPE_INT, + TYPE_INT, TYPE_INT, TYPE_PTRVOID) + +STRUCT(ifstat, + MK_ARRAY(TYPE_CHAR, TARGET_IFNAMSIZ), + MK_ARRAY(TYPE_CHAR, TARGET_IFSTATMAX + 1)) + +STRUCT(ieee80211req, + MK_ARRAY(TYPE_CHAR, TARGET_IFNAMSIZ), TYPE_SHORT, TYPE_SHORT, TYPE_SHORT, + TYPE_PTRVOID) + +STRUCT(lagg_reqport_lacp_opreq, + MK_ARRAY(TYPE_CHAR, TARGET_IFNAMSIZ), MK_ARRAY(TYPE_CHAR, TARGET_IFNAMSIZ), + TYPE_INT, TYPE_INT, + /* struct lacp_opreq */ + TYPE_SHORT, MK_ARRAY(TYPE_CHAR, ETHER_ADDR_LEN), TYPE_SHORT, TYPE_SHORT, + TYPE_SHORT, TYPE_CHAR, TYPE_SHORT, MK_ARRAY(TYPE_CHAR, ETHER_ADDR_LEN), + TYPE_SHORT, TYPE_SHORT, TYPE_SHORT, TYPE_CHAR) + +STRUCT(lagg_reqall_lacp_opreq, + MK_ARRAY(TYPE_CHAR, TARGET_IFNAMSIZ), TYPE_INT, TYPE_PTRVOID, TYPE_PTRVOID, + TYPE_INT, + /* struct lacp_opreq */ + TYPE_SHORT, MK_ARRAY(TYPE_CHAR, ETHER_ADDR_LEN), TYPE_SHORT, TYPE_SHORT, + TYPE_SHORT, TYPE_CHAR, TYPE_SHORT, MK_ARRAY(TYPE_CHAR, ETHER_ADDR_LEN), + TYPE_SHORT, TYPE_SHORT, TYPE_SHORT, TYPE_CHAR) + +STRUCT(lagg_reqflags, + MK_ARRAY(TYPE_CHAR, TARGET_IFNAMSIZ), TYPE_INT) + +STRUCT(lagg_reqopts, + MK_ARRAY(TYPE_CHAR, TARGET_IFNAMSIZ), TYPE_INT, TYPE_INT, TYPE_INT, + TYPE_INT, TYPE_INT, TYPE_INT) + +STRUCT(in6_ifreq_int, + MK_ARRAY(TYPE_CHAR, TARGET_IFNAMSIZ), TYPE_INT) + +STRUCT(in6_ifreq_ptr, + MK_ARRAY(TYPE_CHAR, TARGET_IFNAMSIZ), TYPE_PTRVOID) + +STRUCT(in6_ifreq_sockaddr_in6, + MK_ARRAY(TYPE_CHAR, TARGET_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, TARGET_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, TARGET_IFNAMSIZ), TYPE_PTRVOID)
Signature · 1 line
2.52.0
PATCH v3 9/19 bsd-user: Add FreeBSD ioctl command table
In reply to Warner LoshFrom: "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 | 149 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+)
bsd-user/freebsd/os-ioctl-cmds.h new file +149 -0
@@ -0,0 +1,149 @@ +/* +* 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 ) + +/* 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
PATCH v3 10/19 bsd-user: Add bsd-ioctl.h header
In reply to Warner LoshFrom: "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
@@ -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
PATCH v3 11/19 bsd-user: Add target_sockaddr and safe_ioctl to syscall_defs.h
In reply to Warner LoshFrom: "Stacey D. Son" <[email protected]>
Add struct target_sockaddr and target_in_addr definitions for socket address handling and safe_ioctl macro for safe ioctl system calls.
--- bsd-user/syscall_defs.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
bsd-user/syscall_defs.h +14 -0
@@ -565,6 +565,20 @@ 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 ; + +struct target_in_addr { +uint32_t s_addr;/* big endian */ +}; + +#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
PATCH v3 12/19 bsd-user: Add bsd-ioctl.c infrastructure and termios conversion
In reply to Warner LoshAdd 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 | 219 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 219 insertions(+)
bsd-user/bsd-ioctl.c new file +219 -0
@@ -0,0 +1,219 @@ +/* +* 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 <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-filio.h" +#include "os-ioctl-in6_var.h" +#include "os-ioctl-sockio.h" +#include "os-ioctl-ttycom.h" +#include "os-ioctl-disk.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
PATCH v3 13/19 bsd-user: Add log_unsupported_ioctl function
In reply to Warner LoshAdd 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
@@ -217,3 +217,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
PATCH v3 14/19 bsd-user: Add do_ioctl_unsupported function
In reply to Warner LoshAdd 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
@@ -241,3 +241,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
PATCH v3 15/19 bsd-user: Add target_to_host_sockaddr_in6 function
In reply to Warner LoshAdd 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
@@ -249,3 +249,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
PATCH v3 16/19 bsd-user: Add do_ioctl_in6_ifreq_sockaddr_int function
In reply to Warner LoshAdd 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
@@ -260,3 +260,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),1 ); +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,sizeof (*tin6ifreq)); + +return ret; +}
Signature · 1 line
2.52.0
PATCH v3 17/19 bsd-user: Add do_bsd_ioctl main function
In reply to Warner LoshAdd 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
@@ -292,3 +292,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
PATCH v3 18/19 bsd-user: Add init_bsd_ioctl function
In reply to Warner LoshAdd 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
@@ -392,3 +392,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
PATCH v3 19/19 bsd-user: Add call to do_bsd_ioctl and add bsd-ioctl.c to the build
In reply to Warner LoshFinally, connect do_bsd_ioctl to the build. Call bsd_ioctl_init() from syscall_init()
--- bsd-user/freebsd/os-syscall.c | 9 +++++++++ bsd-user/meson.build | 1 + 2 files changed, 10 insertions(+)
bsd-user/freebsd/os-syscall.c +9 -0
@@ -34,6 +34,7 @@/* BSD independent syscall shims */ #include "bsd-file.h" +#include "bsd-ioctl.h" #include "bsd-mem.h" #include "bsd-proc.h" #include "bsd-misc.h"
@@ -689,6 +690,13 @@ static abi_long freebsd_syscall(void *cpu_env, int num, abi_long arg1, ret =do_bsd_undelete (arg1);break ; +/* +* ioctl(2) +*/ +case TARGET_FREEBSD_NR_ioctl:/* ioctl(2) */ + ret =do_bsd_ioctl (arg1, arg2, arg3); +break ; +/* * stat system calls */
@@ -1001,4 +1009,5 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,void syscall_init (void ) { +init_bsd_ioctl (); }
bsd-user/meson.build +1 -0
@@ -7,6 +7,7 @@ bsd_user_ss = ss.source_set() common_user_inc += include_directories('include') bsd_user_ss.add(files( + 'bsd-ioctl.c', 'bsd-mem.c', 'bsd-misc.c', 'bsd-proc.c',
Signature · 1 line
2.52.0
Re: [PATCH v3 19/19] bsd-user: Add call to do_bsd_ioctl and add bsd-ioctl.c to the build
Quoted 10 lines · Warner Losh
Finally, connect
do_bsd_ioctlto the build. Callbsd_ioctl_init()fromsyscall_init()Signed-off-by Stacey D. Son <[email protected]>Signed-off-by Warner Losh <[email protected]>--- bsd-user/freebsd/os-syscall.c | 9 +++++++++ bsd-user/meson.build | 1 + 2 files changed, 10 insertions(+)