This source file includes following definitions.
- sysv_file_mmap_nopage
- sysv_mmap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <asm/segment.h>
20
21 #include <linux/fs.h>
22 #include <linux/sysv_fs.h>
23 #include <linux/mm.h>
24 #include <linux/string.h>
25 #include <linux/stat.h>
26 #include <linux/sched.h>
27 #include <linux/errno.h>
28 #include <linux/malloc.h>
29
30
31
32
33 static unsigned long sysv_file_mmap_nopage (struct vm_area_struct * area,
34 unsigned long address, unsigned long page, int no_share)
35 {
36 int remaining, count, old_fs;
37 struct file filp;
38
39 address &= PAGE_MASK;
40
41 filp.f_pos = address - area->vm_start + area->vm_offset;
42 filp.f_reada = 0;
43 remaining = area->vm_end - address;
44 if (remaining > PAGE_SIZE)
45 remaining = PAGE_SIZE;
46
47 old_fs = get_fs(); set_fs(get_ds());
48 count = sysv_file_read (area->vm_inode, &filp, (char *)page, remaining);
49 set_fs(old_fs);
50 if (count < 0)
51 count = 0;
52 else
53 remaining -= count;
54 if (remaining > 0)
55 memset((char *)page + count, 0, remaining);
56 return page;
57 }
58
59 static struct vm_operations_struct sysv_file_mmap = {
60 NULL,
61 NULL,
62 sysv_file_mmap_nopage,
63 NULL,
64 NULL,
65 NULL,
66 };
67
68 int sysv_mmap(struct inode * inode, struct file * file, struct vm_area_struct * vma)
69 {
70 if (vma->vm_page_prot & PAGE_RW)
71 return -EINVAL;
72 if (vma->vm_offset & (inode->i_sb->s_blocksize - 1))
73 return -EINVAL;
74 if (!inode->i_sb || !S_ISREG(inode->i_mode))
75 return -EACCES;
76 if (!IS_RDONLY(inode)) {
77 inode->i_atime = CURRENT_TIME;
78 inode->i_dirt = 1;
79 }
80
81 vma->vm_inode = inode;
82 inode->i_count++;
83 vma->vm_ops = &sysv_file_mmap;
84 return 0;
85 }