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