#include <linux/anon_inodes.h>
#include <linux/fs.h>
+#include <linux/sched/mm.h>
#include <linux/syscalls.h>
+int mshare_release(struct inode *inode, struct file *file)
+{
+ struct mm_struct *mm = file->private_data;
+
+ mmput(mm);
+
+ return 0;
+}
+
static const struct file_operations mshare_fops = {
+ .release = mshare_release,
};
SYSCALL_DEFINE3(mshare, unsigned long, addr, unsigned long, len,
unsigned long, flags)
{
+ struct mm_struct *mm;
int fd;
if ((addr | len) & (PGDIR_SIZE - 1))
return -EINVAL;
- fd = anon_inode_getfd("mshare", &mshare_fops, NULL, O_RDWR);
+ mm = mm_alloc();
+ if (!mm)
+ return -ENOMEM;
+
+ fd = anon_inode_getfd("mshare", &mshare_fops, mm, O_RDWR);
return fd;
}