Send proper flags to userspace

This commit is contained in:
Godzil 2019-07-24 16:01:28 +01:00
parent 095ac4569a
commit a54adc616d
2 changed files with 17 additions and 2 deletions

View File

@ -110,6 +110,11 @@ typedef struct {
unsigned long offset; unsigned long offset;
unsigned int cmd; /* ioctl cmd, poll_diff cached_state */ unsigned int cmd; /* ioctl cmd, poll_diff cached_state */
/* mmap parameters */
unsigned long mmprot;
unsigned long mmflags;
unsigned long mmoffset;
union { union {
unsigned long arg; /* ioctl */ unsigned long arg; /* ioctl */
void *ptr_arg; void *ptr_arg;

View File

@ -65,6 +65,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/mman.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/poll.h> #include <linux/poll.h>
@ -1663,8 +1664,17 @@ static int fusd_client_mmap(struct file *file, struct vm_area_struct *vma)
/* send the message */ /* send the message */
init_fusd_msg(&fusd_msg); init_fusd_msg(&fusd_msg);
fusd_msg.subcmd = FUSD_MMAP; fusd_msg.subcmd = FUSD_MMAP;
fusd_msg.parm.fops_msg.offset = vma->vm_pgoff << PAGE_SHIFT; fusd_msg.parm.fops_msg.mmoffset = vma->vm_pgoff << PAGE_SHIFT;
fusd_msg.parm.fops_msg.flags = vma->vm_flags;
fusd_msg.parm.fops_msg.mmprot = ((vma->vm_flags & VM_READ) ? PROT_READ : 0) |
((vma->vm_flags & VM_WRITE) ? PROT_WRITE : 0) |
((vma->vm_flags & VM_EXEC) ? PROT_EXEC : 0);
fusd_msg.parm.fops_msg.mmflags = ((vma->vm_flags & VM_SHARED) ? MAP_SHARED : 0 ) |
((vma->vm_flags & VM_GROWSDOWN) ? MAP_GROWSDOWN : 0) |
((vma->vm_flags & VM_DENYWRITE) ? MAP_DENYWRITE : 0) |
((vma->vm_flags & VM_EXEC) ? MAP_EXECUTABLE : 0) |
((vma->vm_flags & VM_LOCKED) ? MAP_LOCKED : 0);
fusd_msg.parm.fops_msg.length = vma->vm_end - vma->vm_start; fusd_msg.parm.fops_msg.length = vma->vm_end - vma->vm_start;
/* send message to userspace */ /* send message to userspace */