This source file includes following definitions.
- smb_file_mmap_nopage
- smb_mmap
1
2
3
4
5
6
7
8 #include <linux/module.h>
9
10 #include <linux/stat.h>
11 #include <linux/sched.h>
12 #include <linux/kernel.h>
13 #include <linux/mm.h>
14 #include <linux/shm.h>
15 #include <linux/errno.h>
16 #include <linux/mman.h>
17 #include <linux/string.h>
18 #include <linux/malloc.h>
19 #include <linux/smb_fs.h>
20 #include <linux/fcntl.h>
21
22 #include <asm/segment.h>
23 #include <asm/system.h>
24
25
26
27
28 static unsigned long
29 smb_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
39 address &= PAGE_MASK;
40 pos = address - area->vm_start + area->vm_offset;
41
42 clear = 0;
43 if (address + PAGE_SIZE > area->vm_end) {
44 clear = address + PAGE_SIZE - area->vm_end;
45 }
46
47
48 n = SMB_SERVER(inode)->max_xmit - SMB_HEADER_LEN - 5 * 2 - 3 - 10;
49
50 if (smb_make_open(inode, O_RDONLY) < 0) {
51 clear = PAGE_SIZE;
52 }
53 else
54 {
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
63 DDPRINTK("smb_file_mmap_nopage: reading\n");
64 DDPRINTK("smb_file_mmap_nopage: pos = %d\n", pos);
65 result = smb_proc_read(SMB_SERVER(inode),
66 SMB_FINFO(inode), pos, hunk,
67 (char *) (page + i), 0);
68 DDPRINTK("smb_file_mmap_nopage: result= %d\n", result);
69 if (result < 0)
70 break;
71 pos += result;
72 if (result < n) {
73 i += result;
74 break;
75 }
76 }
77 }
78
79 tmp = page + PAGE_SIZE;
80 while (clear--) {
81 *(char *)--tmp = 0;
82 }
83 return page;
84 }
85
86 struct vm_operations_struct smb_file_mmap = {
87 NULL,
88 NULL,
89 NULL,
90 NULL,
91 NULL,
92 NULL,
93 smb_file_mmap_nopage,
94 NULL,
95 NULL,
96 NULL,
97 };
98
99
100
101 int
102 smb_mmap(struct inode * inode, struct file * file, struct vm_area_struct * vma)
103 {
104 DPRINTK("smb_mmap: called\n");
105
106
107 if (vma->vm_flags & VM_SHARED)
108 return -EINVAL;
109 if (!inode->i_sb || !S_ISREG(inode->i_mode))
110 return -EACCES;
111 if (!IS_RDONLY(inode)) {
112 inode->i_atime = CURRENT_TIME;
113 inode->i_dirt = 1;
114 }
115
116 vma->vm_inode = inode;
117 inode->i_count++;
118 vma->vm_ops = &smb_file_mmap;
119 return 0;
120 }
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137