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