Advertisement
Guest User

Untitled

a guest
May 20th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. printk("Create surface");
  2. struct doomdev_ioctl_create_surface surf_arg;
  3. if (copy_from_user(&surf_arg, (const void __user *) arg, sizeof(struct doomdev_ioctl_create_surface))) {
  4. return -1;
  5. }
  6. printk("Create surface %d x %d", surf_arg.width, surf_arg.height);
  7.  
  8. struct surface* mem_for_surface = kmalloc(sizeof(struct surface), GFP_KERNEL);
  9.  
  10. if (IS_ERR_OR_NULL(mem_for_surface))
  11. return -1;
  12.  
  13. if (create_surface(dev, mem_for_surface, surf_arg.width, surf_arg.height))
  14. {
  15. kfree(mem_for_surface);
  16. return -1;
  17. }
  18.  
  19. struct file* surface_file = anon_inode_getfile("/doom/surface", &surface_fops, mem_for_surface, 0);
  20.  
  21. surface_file->f_mode |= FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE;
  22.  
  23. int fd = get_unused_fd_flags(O_CLOEXEC);
  24.  
  25. fd_install(fd, surface_file);
  26.  
  27. return fd;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement