This source file includes following definitions.
- nfs_file_mmap_nopage
- nfs_mmap
1
2
3
4
5
6
7
8
9
10
11
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 <linux/nfs_fs.h>
23
24 #include <asm/segment.h>
25 #include <asm/system.h>
26
27
28
29
30 static unsigned long nfs_file_mmap_nopage(struct vm_area_struct * area,
31 unsigned long address, unsigned long page, int no_share)
32 {
33 struct inode * inode = area->vm_inode;
34 unsigned int clear;
35 unsigned long tmp;
36 int n;
37 int i;
38 int pos;
39 struct nfs_fattr fattr;
40
41 address &= PAGE_MASK;
42 pos = address - area->vm_start + area->vm_offset;
43
44 clear = 0;
45 if (address + PAGE_SIZE > area->vm_end) {
46 clear = address + PAGE_SIZE - area->vm_end;
47 }
48
49 n = NFS_SERVER(inode)->rsize;
50
51 for (i = 0; i < (PAGE_SIZE - clear); i += n) {
52 int hunk, result;
53
54 hunk = PAGE_SIZE - i;
55 if (hunk > n)
56 hunk = n;
57 result = nfs_proc_read(NFS_SERVER(inode), NFS_FH(inode),
58 pos, hunk, (char *) (page + i), &fattr, 0);
59 if (result < 0)
60 break;
61 pos += result;
62 if (result < n) {
63 i += result;
64 break;
65 }
66 }
67
68 #ifdef doweneedthishere
69 nfs_refresh_inode(inode, &fattr);
70 #endif
71
72 tmp = page + PAGE_SIZE;
73 if (clear > 0){
74 memset ((char*)(tmp-clear),0,clear);
75 }
76
77 return page;
78 }
79
80 struct vm_operations_struct nfs_file_mmap = {
81 NULL,
82 NULL,
83 NULL,
84 NULL,
85 NULL,
86 NULL,
87 nfs_file_mmap_nopage,
88 NULL,
89 NULL,
90 NULL,
91 };
92
93
94
95 int nfs_mmap(struct inode * inode, struct file * file, struct vm_area_struct * vma)
96 {
97 if (vma->vm_flags & VM_SHARED)
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 = &nfs_file_mmap;
109 return 0;
110 }