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