mmap in module: remap_page_range - why not?

Roman Pozlevich (roma@botik.yaroslavl.su)
Tue, 22 Aug 95 14:06 +0400


I'm writing a library for some device with shared memory and interrupts.
I want to write a char device driver module with mmap ability. I don't like
using of /dev/mmap. All I need is a library. I don't want to give
suid-root ability to other application developers working with this device
because of security.

I've written code like this:
(based on /usr/src/linux/drivers/char/mem.c)

...

static int dev_mmap(struct inode * inode, struct file * file,
struct vm_area_struct * vma)
{
if (vma->vm_offset & ~PAGE_MASK)
return -ENXIO;
...
if (remap_page_range(vma->vm_start, vma->vm_offset + board_mem,
vma->vm_end - vma->vm_start, vma->vm_page_prot))
return -EAGAIN;
vma->vm_inode = inode;
inode->i_count++;
return 0;
}

static struct file_operations dev_fops = {
...
dev_mmap, /* mmap */
...
};


This code can be compiled as built-in driver only but not as module.
The problem is that remap_page_range is not exported for modules.

Here is a part of /usr/src/linux/kernel/ksyms.c (linux v1.2.13)

...
/* process memory management */
X(verify_area),
X(do_mmap),
X(do_munmap),
X(zeromap_page_range),
X(unmap_page_range),
X(insert_vm_struct),
X(merge_segments),
...

Why remap_page_range is not in this list?

zeromap_page_range, unmap_page_range, remap_page_range are defined
in /usr/src/linux/mm/memory.c. I don't understand why remap_page_range
is not exported. Is it intentionally or accidentally?

Maybe there is another way to make module with mmap feature?

-- 
  Roman Pozlevich                      e-mail: roma@botik.ru
                                       http://www.botik.ru/~roma/
                                       tel: +7 (08535) 98121