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 while (clear--) {
77 *(char *)--tmp = 0;
78 }
79 return page;
80 }
81
82 struct vm_operations_struct nfs_file_mmap = {
83 NULL,
84 NULL,
85 NULL,
86 NULL,
87 NULL,
88 NULL,
89 nfs_file_mmap_nopage,
90 NULL,
91 NULL,
92 NULL,
93 };
94
95
96
97 int nfs_mmap(struct inode * inode, struct file * file, struct vm_area_struct * vma)
98 {
99 if (vma->vm_flags & VM_SHARED)
100 return -EINVAL;
101 if (!inode->i_sb || !S_ISREG(inode->i_mode))
102 return -EACCES;
103 if (!IS_RDONLY(inode)) {
104 inode->i_atime = CURRENT_TIME;
105 inode->i_dirt = 1;
106 }
107
108 vma->vm_inode = inode;
109 inode->i_count++;
110 vma->vm_ops = &nfs_file_mmap;
111 return 0;
112 }