This source file includes following definitions.
- msdos_file_mmap_nopage
- msdos_mmap
1
2
3
4
5
6
7
8
9
10 #include <linux/stat.h>
11 #include <linux/sched.h>
12 #include <linux/kernel.h>
13 #include <linux/mm.h>
14 #include <linux/shm.h>
15 #include <linux/errno.h>
16 #include <linux/mman.h>
17 #include <linux/string.h>
18 #include <linux/malloc.h>
19 #include <linux/msdos_fs.h>
20
21 #include <asm/segment.h>
22 #include <asm/system.h>
23
24
25
26
27 static unsigned long msdos_file_mmap_nopage(
28 struct vm_area_struct * area,
29 unsigned long address,
30 unsigned long page,
31 int error_code)
32 {
33 struct inode * inode = area->vm_inode;
34 unsigned int clear;
35 int pos;
36 long gap;
37
38 address &= PAGE_MASK;
39 pos = address - area->vm_start + area->vm_offset;
40
41 clear = 0;
42 gap = inode->i_size - pos;
43 if (gap <= 0){
44
45 clear = PAGE_SIZE;
46 }else{
47 int cur_read;
48 int need_read;
49 struct file filp;
50 if (gap < PAGE_SIZE){
51 clear = PAGE_SIZE - gap;
52 }
53 filp.f_reada = 0;
54 filp.f_pos = pos;
55 need_read = PAGE_SIZE - clear;
56 {
57 unsigned long cur_fs = get_fs();
58 set_fs (KERNEL_DS);
59 cur_read = msdos_file_read (inode,&filp,(char*)page
60 ,need_read);
61 set_fs (cur_fs);
62 }
63 if (cur_read != need_read){
64 printk ("MSDOS: Error while reading an mmap file %d <> %d\n"
65 ,cur_read,need_read);
66 }
67 }
68 if (clear > 0){
69 memset ((char*)page+PAGE_SIZE-clear,0,clear);
70 }
71 return page;
72 }
73
74 struct vm_operations_struct msdos_file_mmap = {
75 NULL,
76 NULL,
77 NULL,
78 NULL,
79 NULL,
80 NULL,
81 msdos_file_mmap_nopage,
82 NULL,
83 NULL,
84 NULL,
85 };
86
87
88
89
90
91 int msdos_mmap(struct inode * inode, struct file * file, struct vm_area_struct * vma)
92 {
93 if (vma->vm_flags & VM_SHARED)
94 return -EINVAL;
95 if (vma->vm_offset & (inode->i_sb->s_blocksize - 1))
96 return -EINVAL;
97 if (!inode->i_sb || !S_ISREG(inode->i_mode))
98 return -EACCES;
99 if (!IS_RDONLY(inode)) {
100 inode->i_atime = CURRENT_TIME;
101 inode->i_dirt = 1;
102 }
103
104 vma->vm_inode = inode;
105 inode->i_count++;
106 vma->vm_ops = &msdos_file_mmap;
107 return 0;
108 }
109
110