$ cat >a.c #include <sys/soundcard.h> #include <sys/ioctl.h> #include <fcntl.h> #include <err.h> int main() { int fd = open("/dev/dsp", O_RDWR, 0); audio_errinfo ei; if (ioctl(fd, SNDCTL_DSP_GETERROR, &ei) < 0) err(1, "SNDCTL_DSP_GETERROR"); return 0; } $ cc -o foo a.c $ cc -m32 -o bar a.c $ ./foo $ ./bar bar: SNDCTL_DSP_GETERROR: Invalid argument
The issue is not limited to DSP_GETERROR only; the sys/dev/sound code lacks COMPAT32 shims at all. The task to add them is not technically complicated but requires patience and understanding what to test.
(In reply to Konstantin Belousov from comment #1) It's much easier than it looks: only 5 ioctls and maybe mmap() need COMPAT_FREEBSD32 shims. In sys/sys/soundcard.h only these 9 structs have "long" fields, whose sizes on 32 vs 64 bit FreeBSD will differ (luckily the vast majority of the OSS API uses "int"): Struct | Used in -------------------+------------------------------------- snd_chan_param | AIOGFMT, AIOSFMT snd_sync_parm | AIOSYNC snd_capabilities | AIOGCAP struct patch_info | struct patmgr_info struct sysex_info | unused? struct patmgr_info | SNDCTL_PMGR_ACCESS, SNDCTL_PMGR_IFACE struct synth_info | SNDCTL_SYNTH_INFO struct midi_info | SNDCTL_MIDI_INFO audio_errinfo | SNDCTL_DSP_GETERROR Also this struct uses a pointer: typedef struct buffmem_desc { caddr_t buffer; int size; } buffmem_desc; and is used in SNDCTL_DSP_MAPINBUF, SNDCTL_DSP_MAPOUTBUF. That's a total of 11 ioctls that would have to get COMPAT_FREEBSD32 shims. However FreeBSD doesn't currently implement SNDCTL_PMGR_ACCESS, SNDCTL_PMGR_IFACE, SNDCTL_SYNTH_INFO or SNDCTL_MIDI_INFO in any bitness (in sys/dev/sound/midi/midi.c, midi_ioctl() return ENXIO for everything). FreeBSD doesn't implement SNDCTL_DSP_MAPINBUF or SNDCTL_DSP_MAPOUTBUF either - dsp_ioctl() has a comment saying "undocumented" and returns EINVAL. 11 - 6 = 5 ioctls that needs COMPAT_FREEBSD32 shims: snd_chan_param | AIOGFMT, AIOSFMT snd_sync_parm | AIOSYNC snd_capabilities | AIOGCAP audio_errinfo | SNDCTL_DSP_GETERROR and maybe some mmap() changes. I am going to try implement this.
Created attachment 263756 [details] Testcase I've implemented a patch for this, please see: https://reviews.freebsd.org/D52509 Only the ioctls were necessary - playing audio over mmap() already works. The attached test case tests the 32 bit ioctls and plays a 2100 Hz tone through mmap(): cc oss-compat32-test.c -o oss-compat32-test -lm -m32 ./oss-compat32-test (Ctrl+C to exit)
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=749a9266982b8e012b5ec370b2fdfef11f34c0b2 commit 749a9266982b8e012b5ec370b2fdfef11f34c0b2 Author: Damjan Jovanovic <damjan.jov@gmail.com> AuthorDate: 2025-09-23 18:59:05 +0000 Commit: Christos Margiolis <christos@FreeBSD.org> CommitDate: 2025-09-23 18:59:05 +0000 sound: Implement COMPAT_FREEBSD32 shims PR: 216568 MFC after: 1 week Reviewed by: christos, kib Differential Revision: https://reviews.freebsd.org/D52509 sys/dev/sound/pcm/dsp.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 1 deletion(-)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=782a376911eb61ee59310bfc779363a2a3939c30 commit 782a376911eb61ee59310bfc779363a2a3939c30 Author: Damjan Jovanovic <damjan.jov@gmail.com> AuthorDate: 2025-09-23 18:59:05 +0000 Commit: Christos Margiolis <christos@FreeBSD.org> CommitDate: 2025-09-30 09:17:26 +0000 sound: Implement COMPAT_FREEBSD32 shims PR: 216568 MFC after: 1 week Reviewed by: christos, kib Differential Revision: https://reviews.freebsd.org/D52509 (cherry picked from commit 749a9266982b8e012b5ec370b2fdfef11f34c0b2) sys/dev/sound/pcm/dsp.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 1 deletion(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=d0e8c94631267f07c90465faf5b47dcce0e232be commit d0e8c94631267f07c90465faf5b47dcce0e232be Author: Damjan Jovanovic <damjan.jov@gmail.com> AuthorDate: 2025-09-23 18:59:05 +0000 Commit: Christos Margiolis <christos@FreeBSD.org> CommitDate: 2025-09-30 09:18:07 +0000 sound: Implement COMPAT_FREEBSD32 shims PR: 216568 MFC after: 1 week Reviewed by: christos, kib Differential Revision: https://reviews.freebsd.org/D52509 (cherry picked from commit 749a9266982b8e012b5ec370b2fdfef11f34c0b2) sys/dev/sound/pcm/dsp.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 1 deletion(-)