diff options
-rw-r--r-- | char.c | 85 |
1 files changed, 76 insertions, 9 deletions
@@ -17,24 +17,91 @@ dev_t first; int major; -int next_minor = 0; +bool minors[DOOMDEV_COUNT]; +long do_new_surface(struct file *filp, unsigned long arg) +{ + struct doomdev_ioctl_create_surface param; + int not_copied; + int err; + + not_copied = copy_from_user(¶m, (void __iomem *) arg, sizeof(param)); + if (not_copied) { + err = -EFAULT; + goto error_param; + } + + err = new_surface(filp, ¶m); + +error_param: + return err; +} + +long do_new_texture(struct file *filp, unsigned long arg) +{ + struct doomdev_ioctl_create_texture param; + int not_copied; + int err; + + not_copied = copy_from_user(¶m, (void __iomem *) arg, sizeof(param)); + if (not_copied) { + err = -EFAULT; + goto error_param; + } + + err = new_texture(filp, ¶m); + +error_param: + return err; +} + +long do_new_flat(struct file *filp, unsigned long arg) +{ + struct doomdev_ioctl_create_flat param; + int not_copied; + int err; + + not_copied = copy_from_user(¶m, (void __iomem *) arg, sizeof(param)); + if (not_copied) { + err = -EFAULT; + goto error_param; + } + + err = new_flat(filp, ¶m); + +error_param: + return err; +} + +long do_new_colors(struct file *filp, unsigned long arg) +{ + struct doomdev_ioctl_create_colormaps param; + int not_copied; + int err; + + not_copied = copy_from_user(¶m, (void __iomem *) arg, sizeof(param)); + if (not_copied) { + err = -EFAULT; + goto error_param; + } + + err = new_colors(filp, ¶m); + +error_param: + return err; +} long doom_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { switch (cmd) { case DOOMDEV_IOCTL_CREATE_SURFACE: - return new_surface(filp, - (struct doomdev_ioctl_create_surface *) arg); + return do_new_surface(filp, arg); case DOOMDEV_IOCTL_CREATE_TEXTURE: - return new_texture(filp, - (struct doomdev_ioctl_create_texture *) arg); + return do_new_texture(filp, arg); case DOOMDEV_IOCTL_CREATE_FLAT: - return new_flat(filp, - (struct doomdev_ioctl_create_flat *) arg); + return do_new_flat(filp, arg); case DOOMDEV_IOCTL_CREATE_COLORMAPS: - return new_colors(filp, - (struct doomdev_ioctl_create_colormaps *) arg); + return do_new_colors(filp, arg); default: return -ENOTTY; } |