diff --git a/sys/alpha/linux/linux_ioctl.h b/sys/alpha/linux/linux_ioctl.h index fd637b49b951..1ed49012547f 100644 --- a/sys/alpha/linux/linux_ioctl.h +++ b/sys/alpha/linux/linux_ioctl.h @@ -31,6 +31,25 @@ #ifndef _LINUX_IOCTL_H_ #define _LINUX_IOCTL_H_ +/* + * disk + */ +#define LINUX_BLKROSET 0x125d +#define LINUX_BLKROGET 0x125e +#define LINUX_BLKRRPART 0x125f +#define LINUX_BLKGETSIZE 0x1260 +#define LINUX_BLKFLSBUF 0x1261 +#define LINUX_BLKRASET 0x1262 +#define LINUX_BLKRAGET 0x1263 +#define LINUX_BLKFRASET 0x1264 +#define LINUX_BLKFRAGET 0x1265 +#define LINUX_BLKSECTSET 0x1266 +#define LINUX_BLKSECTGET 0x1267 +#define LINUX_BLKSSZGET 0x1268 + +#define LINUX_IOCTL_DISK_MIN LINUX_BLKROSET +#define LINUX_IOCTL_DISK_MAX LINUX_BLKSSZGET + /* * cdrom */ diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c index a4747c686861..cd532e601099 100644 --- a/sys/compat/linux/linux_ioctl.c +++ b/sys/compat/linux/linux_ioctl.c @@ -46,6 +46,7 @@ #include #include #include +#include #include @@ -55,12 +56,15 @@ #include #include +static linux_ioctl_function_t linux_ioctl_disk; static linux_ioctl_function_t linux_ioctl_cdrom; static linux_ioctl_function_t linux_ioctl_console; static linux_ioctl_function_t linux_ioctl_socket; static linux_ioctl_function_t linux_ioctl_sound; static linux_ioctl_function_t linux_ioctl_termio; +static struct linux_ioctl_handler disk_handler = +{ linux_ioctl_disk, LINUX_IOCTL_DISK_MIN, LINUX_IOCTL_DISK_MAX }; static struct linux_ioctl_handler cdrom_handler = { linux_ioctl_cdrom, LINUX_IOCTL_CDROM_MIN, LINUX_IOCTL_CDROM_MAX }; static struct linux_ioctl_handler console_handler = @@ -72,6 +76,7 @@ static struct linux_ioctl_handler sound_handler = static struct linux_ioctl_handler termio_handler = { linux_ioctl_termio, LINUX_IOCTL_TERMIO_MIN, LINUX_IOCTL_TERMIO_MAX }; +DATA_SET(linux_ioctl_handler_set, disk_handler); DATA_SET(linux_ioctl_handler_set, cdrom_handler); DATA_SET(linux_ioctl_handler_set, console_handler); DATA_SET(linux_ioctl_handler_set, socket_handler); @@ -88,6 +93,24 @@ struct handler_element static TAILQ_HEAD(, handler_element) handlers = TAILQ_HEAD_INITIALIZER(handlers); +static int +linux_ioctl_disk(struct proc *p, struct linux_ioctl_args *args) +{ + struct file *fp = p->p_fd->fd_ofiles[args->fd]; + int error; + struct disklabel dl; + + switch (args->cmd & 0xffff) { + case LINUX_BLKGETSIZE: + error = fo_ioctl(fp, DIOCGDINFO, (caddr_t)&dl, p); + if (error) + return (error); + return copyout(&(dl.d_secperunit), (caddr_t)args->arg, sizeof(dl.d_secperunit)); + break; + } + return (ENOIOCTL); +} + /* * termio related ioctls */ diff --git a/sys/compat/linux/linux_ioctl.h b/sys/compat/linux/linux_ioctl.h index fd637b49b951..1ed49012547f 100644 --- a/sys/compat/linux/linux_ioctl.h +++ b/sys/compat/linux/linux_ioctl.h @@ -31,6 +31,25 @@ #ifndef _LINUX_IOCTL_H_ #define _LINUX_IOCTL_H_ +/* + * disk + */ +#define LINUX_BLKROSET 0x125d +#define LINUX_BLKROGET 0x125e +#define LINUX_BLKRRPART 0x125f +#define LINUX_BLKGETSIZE 0x1260 +#define LINUX_BLKFLSBUF 0x1261 +#define LINUX_BLKRASET 0x1262 +#define LINUX_BLKRAGET 0x1263 +#define LINUX_BLKFRASET 0x1264 +#define LINUX_BLKFRAGET 0x1265 +#define LINUX_BLKSECTSET 0x1266 +#define LINUX_BLKSECTGET 0x1267 +#define LINUX_BLKSSZGET 0x1268 + +#define LINUX_IOCTL_DISK_MIN LINUX_BLKROSET +#define LINUX_IOCTL_DISK_MAX LINUX_BLKSSZGET + /* * cdrom */ diff --git a/sys/i386/linux/linux_ioctl.c b/sys/i386/linux/linux_ioctl.c index a4747c686861..cd532e601099 100644 --- a/sys/i386/linux/linux_ioctl.c +++ b/sys/i386/linux/linux_ioctl.c @@ -46,6 +46,7 @@ #include #include #include +#include #include @@ -55,12 +56,15 @@ #include #include +static linux_ioctl_function_t linux_ioctl_disk; static linux_ioctl_function_t linux_ioctl_cdrom; static linux_ioctl_function_t linux_ioctl_console; static linux_ioctl_function_t linux_ioctl_socket; static linux_ioctl_function_t linux_ioctl_sound; static linux_ioctl_function_t linux_ioctl_termio; +static struct linux_ioctl_handler disk_handler = +{ linux_ioctl_disk, LINUX_IOCTL_DISK_MIN, LINUX_IOCTL_DISK_MAX }; static struct linux_ioctl_handler cdrom_handler = { linux_ioctl_cdrom, LINUX_IOCTL_CDROM_MIN, LINUX_IOCTL_CDROM_MAX }; static struct linux_ioctl_handler console_handler = @@ -72,6 +76,7 @@ static struct linux_ioctl_handler sound_handler = static struct linux_ioctl_handler termio_handler = { linux_ioctl_termio, LINUX_IOCTL_TERMIO_MIN, LINUX_IOCTL_TERMIO_MAX }; +DATA_SET(linux_ioctl_handler_set, disk_handler); DATA_SET(linux_ioctl_handler_set, cdrom_handler); DATA_SET(linux_ioctl_handler_set, console_handler); DATA_SET(linux_ioctl_handler_set, socket_handler); @@ -88,6 +93,24 @@ struct handler_element static TAILQ_HEAD(, handler_element) handlers = TAILQ_HEAD_INITIALIZER(handlers); +static int +linux_ioctl_disk(struct proc *p, struct linux_ioctl_args *args) +{ + struct file *fp = p->p_fd->fd_ofiles[args->fd]; + int error; + struct disklabel dl; + + switch (args->cmd & 0xffff) { + case LINUX_BLKGETSIZE: + error = fo_ioctl(fp, DIOCGDINFO, (caddr_t)&dl, p); + if (error) + return (error); + return copyout(&(dl.d_secperunit), (caddr_t)args->arg, sizeof(dl.d_secperunit)); + break; + } + return (ENOIOCTL); +} + /* * termio related ioctls */ diff --git a/sys/i386/linux/linux_ioctl.h b/sys/i386/linux/linux_ioctl.h index fd637b49b951..1ed49012547f 100644 --- a/sys/i386/linux/linux_ioctl.h +++ b/sys/i386/linux/linux_ioctl.h @@ -31,6 +31,25 @@ #ifndef _LINUX_IOCTL_H_ #define _LINUX_IOCTL_H_ +/* + * disk + */ +#define LINUX_BLKROSET 0x125d +#define LINUX_BLKROGET 0x125e +#define LINUX_BLKRRPART 0x125f +#define LINUX_BLKGETSIZE 0x1260 +#define LINUX_BLKFLSBUF 0x1261 +#define LINUX_BLKRASET 0x1262 +#define LINUX_BLKRAGET 0x1263 +#define LINUX_BLKFRASET 0x1264 +#define LINUX_BLKFRAGET 0x1265 +#define LINUX_BLKSECTSET 0x1266 +#define LINUX_BLKSECTGET 0x1267 +#define LINUX_BLKSSZGET 0x1268 + +#define LINUX_IOCTL_DISK_MIN LINUX_BLKROSET +#define LINUX_IOCTL_DISK_MAX LINUX_BLKSSZGET + /* * cdrom */