m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--char.c85
1 files changed, 76 insertions, 9 deletions
diff --git a/char.c b/char.c
index ae718c6..90bd16c 100644
--- a/char.c
+++ b/char.c
@@ -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(&param, (void __iomem *) arg, sizeof(param));
+ if (not_copied) {
+ err = -EFAULT;
+ goto error_param;
+ }
+
+ err = new_surface(filp, &param);
+
+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(&param, (void __iomem *) arg, sizeof(param));
+ if (not_copied) {
+ err = -EFAULT;
+ goto error_param;
+ }
+
+ err = new_texture(filp, &param);
+
+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(&param, (void __iomem *) arg, sizeof(param));
+ if (not_copied) {
+ err = -EFAULT;
+ goto error_param;
+ }
+
+ err = new_flat(filp, &param);
+
+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(&param, (void __iomem *) arg, sizeof(param));
+ if (not_copied) {
+ err = -EFAULT;
+ goto error_param;
+ }
+
+ err = new_colors(filp, &param);
+
+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;
}