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