@samitouri / QOSamiQemu / commits / 0d4b76adb7

bsd-user: Add FreeBSD disk ioctl definitions

Add os-ioctl-disk.h with disk and storage device ioctl definitions including DIOCGMEDIASIZE, DIOCGSECTORSIZE, and related disk management ioctls. Signed-off-by: Stacey Son <sson@FreeBSD.org> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> Signed-off-by: Warner Losh <imp@bsdimp.com>

Stacey Son committed Mar 13, 2026 at 22:12 UTC 0d4b76adb7123db04c6c8925dfcc473883986532
1 file changed +52
bsd-user/freebsd/os-ioctl-disk.h new
+52
@@ -0,0 +1,52 @@
1 +/*
2 + * FreeBSD disk.h definitions for ioctl(2) emulation
3 + *
4 + * Copyright (c) 2015 Stacey D. Son
5 + *
6 + * SPDX-License-Identifier: GPL-2.0-or-later
7 + */
8 +#ifndef OS_IOCTL_DISK_H
9 +#define OS_IOCTL_DISK_H
10 +
11 +/* See sys/disk.h */
12 +
13 +#define TARGET_MAXPATHLEN 1024
14 +
15 +#define TARGET_DIOCGSECTORSIZE TARGET_IOR('d', 128, uint32_t)
16 +#define TARGET_DIOCGMEDIASIZE TARGET_IOR('d', 129, int64_t)
17 +#define TARGET_DIOCGFWSECTORS TARGET_IOR('d', 130, uint32_t)
18 +#define TARGET_DIOCGFWHEADS TARGET_IOR('d', 131, uint32_t)
19 +#define TARGET_DIOCGFLUSH TARGET_IO('d', 135)
20 +#define TARGET_DIOCGDELETE TARGET_IOW('d', 136, int64_t[2])
21 +#define TARGET_DISK_IDENT_SIZE 256
22 +#define TARGET_DIOCGIDENT TARGET_IOR('d', 137, \
23 + char[TARGET_DISK_IDENT_SIZE])
24 +#define TARGET_DIOCGPROVIDERNAME TARGET_IOR('d', 138, \
25 + char[TARGET_MAXPATHLEN])
26 +#define TARGET_DIOCGSTRIPESIZE TARGET_IOR('d', 139, int64_t)
27 +#define TARGET_DIOCGSTRIPEOFFSET TARGET_IOR('d', 140, int64_t)
28 +#define TARGET_DIOCGPHYSPATH TARGET_IOR('d', 141, \
29 + char[TARGET_MAXPATHLEN])
30 +
31 +struct target_diocgattr_arg {
32 + char name[64];
33 + abi_int len;
34 + union {
35 + char str[TARGET_DISK_IDENT_SIZE];
36 + int64_t off; /* Want abioff, but this will do */
37 + abi_int i;
38 + abi_short u16;
39 + } value;
40 +};
41 +
42 +#define TARGET_DIOCGATTR TARGET_IOWR('d', 142, struct target_diocgattr_arg)
43 +
44 +/* Unsupported, target_disk_zone_args is complicated */
45 +/* #define DIOCZONECMD _IOWR('d', 143, struct target_disk_zone_args) */
46 +
47 +/* Enable/Disable the device for kernel core dumps. */
48 +/* #define DIOCSKERNELDUMP _IOW('d', 145, struct diocskerneldump_arg) */
49 +/* Get current kernel netdump configuration details for a given index. */
50 +/* #define DIOCGKERNELDUMP _IOWR('d', 146, struct diocskerneldump_arg) */
51 +
52 +#endif /* OS_IOCTL_DISK_H */