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
31 static unsigned long nfs_file_mmap_nopage(struct vm_area_struct * area,
32 unsigned long address, int no_share)
33 {
34 struct inode * inode = area->vm_inode;
35 unsigned long page;
36 unsigned int clear;
37 unsigned long tmp;
38 int n;
39 int i;
40 int pos;
41 struct nfs_fattr fattr;
42
43 page = __get_free_page(GFP_KERNEL);
44 if (!page)
45 return page;
46 address &= PAGE_MASK;
47 pos = address - area->vm_start + area->vm_offset;
48
49 clear = 0;
50 if (address + PAGE_SIZE > area->vm_end) {
51 clear = address + PAGE_SIZE - area->vm_end;
52 }
53
54 n = NFS_SERVER(inode)->rsize;
55
56 for (i = 0; i < (PAGE_SIZE - clear); i += n) {
57 int hunk, result;
58
59 hunk = PAGE_SIZE - i;
60 if (hunk > n)
61 hunk = n;
62 result = nfs_proc_read(NFS_SERVER(inode), NFS_FH(inode),
63 pos, hunk, (char *) (page + i), &fattr, 0);
64 if (result < 0)
65 break;
66 pos += result;
67 if (result < n) {
68 i += result;
69 break;
70 }
71 }
72
73 #ifdef doweneedthishere
74 nfs_refresh_inode(inode, &fattr);
75 #endif
76
77 tmp = page + PAGE_SIZE;
78 if (clear > 0){
79 memset ((char*)(tmp-clear),0,clear);
80 }
81
82 return page;
83 }
84
85 struct vm_operations_struct nfs_file_mmap = {
86 NULL,
87 NULL,
88 NULL,
89 NULL,
90 NULL,
91 NULL,
92 nfs_file_mmap_nopage,
93 NULL,
94 NULL,
95 NULL,
96 };
97
98
99
100 int nfs_mmap(struct inode * inode, struct file * file, struct vm_area_struct * vma)
101 {
102 if (vma->vm_flags & VM_SHARED)
103 return -EINVAL;
104 if (!inode->i_sb || !S_ISREG(inode->i_mode))
105 return -EACCES;
106 if (!IS_RDONLY(inode)) {
107 inode->i_atime = CURRENT_TIME;
108 inode->i_dirt = 1;
109 }
110
111 vma->vm_inode = inode;
112 inode->i_count++;
113 vma->vm_ops = &nfs_file_mmap;
114 return 0;
115 }