This source file includes following definitions.
- nfs_file_mmap_nopage
- nfs_mmap
1
2
3
4
5
6
7
8
9
10
11
12 #ifdef MODULE
13 #include <linux/module.h>
14 #endif
15
16 #include <linux/stat.h>
17 #include <linux/sched.h>
18 #include <linux/kernel.h>
19 #include <linux/mm.h>
20 #include <linux/shm.h>
21 #include <linux/errno.h>
22 #include <linux/mman.h>
23 #include <linux/string.h>
24 #include <linux/malloc.h>
25 #include <linux/nfs_fs.h>
26
27 #include <asm/segment.h>
28 #include <asm/system.h>
29
30
31
32
33 static unsigned long nfs_file_mmap_nopage(struct vm_area_struct * area,
34 unsigned long address, unsigned long page, int no_share)
35 {
36 struct inode * inode = area->vm_inode;
37 unsigned int clear;
38 unsigned long tmp;
39 int n;
40 int i;
41 int pos;
42 struct nfs_fattr fattr;
43
44 address &= PAGE_MASK;
45 pos = address - area->vm_start + area->vm_offset;
46
47 clear = 0;
48 if (address + PAGE_SIZE > area->vm_end) {
49 clear = address + PAGE_SIZE - area->vm_end;
50 }
51
52 n = NFS_SERVER(inode)->rsize;
53
54 for (i = 0; i < (PAGE_SIZE - clear); i += n) {
55 int hunk, result;
56
57 hunk = PAGE_SIZE - i;
58 if (hunk > n)
59 hunk = n;
60 result = nfs_proc_read(NFS_SERVER(inode), NFS_FH(inode),
61 pos, hunk, (char *) (page + i), &fattr, 0);
62 if (result < 0)
63 break;
64 pos += result;
65 if (result < n) {
66 i += result;
67 break;
68 }
69 }
70
71 #ifdef doweneedthishere
72 nfs_refresh_inode(inode, &fattr);
73 #endif
74
75 tmp = page + PAGE_SIZE;
76 if (clear > 0){
77 memset ((char*)(tmp-clear),0,clear);
78 }
79
80 return page;
81 }
82
83 struct vm_operations_struct nfs_file_mmap = {
84 NULL,
85 NULL,
86 NULL,
87 NULL,
88 NULL,
89 NULL,
90 nfs_file_mmap_nopage,
91 NULL,
92 NULL,
93 NULL,
94 };
95
96
97
98 int nfs_mmap(struct inode * inode, struct file * file, struct vm_area_struct * vma)
99 {
100 if (vma->vm_flags & VM_SHARED)
101 return -EINVAL;
102 if (!inode->i_sb || !S_ISREG(inode->i_mode))
103 return -EACCES;
104 if (!IS_RDONLY(inode)) {
105 inode->i_atime = CURRENT_TIME;
106 inode->i_dirt = 1;
107 }
108
109 vma->vm_inode = inode;
110 inode->i_count++;
111 vma->vm_ops = &nfs_file_mmap;
112 return 0;
113 }