/[kernel]/trunk/kernel-2.4/source/kernel-source-2.4.26-2.4.26/debian/patches/patch-2.4.26-6
ViewVC logotype

Contents of /trunk/kernel-2.4/source/kernel-source-2.4.26-2.4.26/debian/patches/patch-2.4.26-6

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1134 - (show annotations) (download)
Mon Aug 16 01:03:14 2004 UTC (8 years, 9 months ago) by horms
File size: 598496 byte(s)
Fix symbol problems in xfrm update
1 #ChangeSet 1.1465
2 # This is a BitKeeper generated diff -Nru style patch.
3 #
4 # ChangeSet
5 # 2004/08/03 19:15:49-03:00 marcelo@logos.cnet
6 # Al Viro and others: Fix file offset handling races in several drivers
7 #
8 # BitKeeper/deleted/.del-error_log.c~5cdf26cd9a8325fd
9 # 2004/08/03 19:14:57-03:00 marcelo@logos.cnet +0 -0
10 # Delete: arch/ppc/platforms/error_log.c
11 # *** Updated to create a dummy file as dpk-source does not ***
12 # *** handle file deletion Horms 2004/08/12 ***
13 #
14 # BitKeeper/deleted/.del-error_log.h~76c5c9436b7dffbc
15 # 2004/08/03 19:14:57-03:00 marcelo@logos.cnet +0 -0
16 # Delete: arch/ppc/platforms/error_log.h
17 # *** Updated to create a dummy file as dpk-source does not ***
18 # *** handle file deletion Horms 2004/08/12 ***
19 #
20 # BitKeeper/deleted/.del-proc_rtas.c~ca8a566ec73bac30
21 # 2004/08/03 19:14:57-03:00 marcelo@logos.cnet +0 -0
22 # Delete: arch/ppc/platforms/proc_rtas.c
23 # *** Updated to create a dummy file as dpk-source does not ***
24 # *** handle file deletion Horms 2004/08/12 ***
25 #
26 # arch/cris/drivers/eeprom.c
27 # 2004/07/30 10:29:18-03:00 marcelo@logos.cnet +6 -6
28 # Import patch 2.4.27-ppos5.patch
29 #
30 # arch/i386/kernel/mtrr.c
31 # 2004/07/30 10:29:18-03:00 marcelo@logos.cnet +11 -5
32 # Import patch 2.4.27-ppos5.patch
33 #
34 # arch/ia64/kernel/efivars.c
35 # 2004/07/30 10:29:18-03:00 marcelo@logos.cnet +5 -4
36 # Import patch 2.4.27-ppos5.patch
37 #
38 # arch/ia64/kernel/salinfo.c
39 # 2004/07/30 10:29:18-03:00 marcelo@logos.cnet +5 -4
40 # Import patch 2.4.27-ppos5.patch
41 #
42 # arch/mips/sibyte/sb1250/bcm1250_tbprof.c
43 # 2004/07/30 10:29:18-03:00 marcelo@logos.cnet +3 -0
44 # Import patch 2.4.27-ppos5.patch
45 #
46 # arch/ppc/config.in
47 # 2004/07/30 10:29:18-03:00 marcelo@logos.cnet +0 -1
48 # Import patch 2.4.27-ppos5.patch
49 #
50 # arch/ppc/kernel/ppc_htab.c
51 # 2004/07/30 10:29:18-03:00 marcelo@logos.cnet +6 -5
52 # Import patch 2.4.27-ppos5.patch
53 #
54 # arch/ppc/platforms/Makefile
55 # 2004/07/30 10:29:18-03:00 marcelo@logos.cnet +0 -1
56 # Import patch 2.4.27-ppos5.patch
57 #
58 # arch/ppc64/kernel/lparcfg.c
59 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +1 -1
60 # Import patch 2.4.27-ppos5.patch
61 #
62 # arch/ppc64/kernel/nvram.c
63 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +9 -5
64 # Import patch 2.4.27-ppos5.patch
65 #
66 # arch/ppc64/kernel/proc_pmc.c
67 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +7 -10
68 # Import patch 2.4.27-ppos5.patch
69 #
70 # arch/ppc64/kernel/rtas-proc.c
71 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +36 -30
72 # Import patch 2.4.27-ppos5.patch
73 #
74 # arch/s390/kernel/debug.c
75 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +4 -4
76 # Import patch 2.4.27-ppos5.patch
77 #
78 # arch/s390x/kernel/debug.c
79 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +3 -3
80 # Import patch 2.4.27-ppos5.patch
81 #
82 # arch/x86_64/kernel/mtrr.c
83 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +8 -5
84 # Import patch 2.4.27-ppos5.patch
85 #
86 # drivers/block/acsi_slm.c
87 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +7 -6
88 # Import patch 2.4.27-ppos5.patch
89 #
90 # drivers/block/rd.c
91 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +9 -4
92 # Import patch 2.4.27-ppos5.patch
93 #
94 # drivers/char/i8k.c
95 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +5 -4
96 # Import patch 2.4.27-ppos5.patch
97 #
98 # drivers/char/istallion.c
99 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +14 -10
100 # Import patch 2.4.27-ppos5.patch
101 #
102 # drivers/char/mem.c
103 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +2 -2
104 # Import patch 2.4.27-ppos5.patch
105 #
106 # drivers/char/nvram.c
107 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +10 -2
108 # Import patch 2.4.27-ppos5.patch
109 #
110 # drivers/char/nwflash.c
111 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +8 -6
112 # Import patch 2.4.27-ppos5.patch
113 #
114 # drivers/char/raw.c
115 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +5 -4
116 # Import patch 2.4.27-ppos5.patch
117 #
118 # drivers/char/tpqic02.c
119 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +3 -1
120 # Import patch 2.4.27-ppos5.patch
121 #
122 # drivers/char/vc_screen.c
123 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +34 -20
124 # Import patch 2.4.27-ppos5.patch
125 #
126 # drivers/gsc/eisa_eeprom.c
127 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +11 -5
128 # Import patch 2.4.27-ppos5.patch
129 #
130 # drivers/hotplug/pci_hotplug_core.c
131 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +26 -21
132 # Import patch 2.4.27-ppos5.patch
133 # *** Updated version to patch against 2.6.26 - Horms 2004/08/12 ***
134 #
135 # drivers/ieee1394/pcilynx.c
136 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +25 -16
137 # Import patch 2.4.27-ppos5.patch
138 #
139 # drivers/isdn/divert/divert_procfs.c
140 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +2 -1
141 # Import patch 2.4.27-ppos5.patch
142 #
143 # drivers/isdn/hysdn/hysdn_procconf.c
144 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +14 -16
145 # Import patch 2.4.27-ppos5.patch
146 #
147 # drivers/isdn/hysdn/hysdn_proclog.c
148 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +2 -1
149 # Import patch 2.4.27-ppos5.patch
150 #
151 # drivers/isdn/isdn_common.c
152 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +7 -3
153 # Import patch 2.4.27-ppos5.patch
154 #
155 # drivers/macintosh/ans-lcd.c
156 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +4 -5
157 # Import patch 2.4.27-ppos5.patch
158 #
159 # drivers/macintosh/nvram.c
160 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +8 -6
161 # Import patch 2.4.27-ppos5.patch
162 #
163 # drivers/mtd/mtdchar.c
164 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +18 -10
165 # Import patch 2.4.27-ppos5.patch
166 #
167 # drivers/pci/proc.c
168 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +6 -4
169 # Import patch 2.4.27-ppos5.patch
170 #
171 # drivers/pnp/isapnp_proc.c
172 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +17 -14
173 # Import patch 2.4.27-ppos5.patch
174 #
175 # drivers/s390/block/dasd.c
176 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +6 -4
177 # Import patch 2.4.27-ppos5.patch
178 #
179 # drivers/s390/char/tapechar.c
180 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +8 -3
181 # Import patch 2.4.27-ppos5.patch
182 #
183 # drivers/s390/net/ctcmain.c
184 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +17 -12
185 # Import patch 2.4.27-ppos5.patch
186 #
187 # drivers/s390/net/netiucv.c
188 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +19 -12
189 # Import patch 2.4.27-ppos5.patch
190 #
191 # drivers/s390/net/qeth.c
192 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +9 -7
193 # Import patch 2.4.27-ppos5.patch
194 #
195 # drivers/s390/s390io.c
196 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +21 -16
197 # Import patch 2.4.27-ppos5.patch
198 #
199 # drivers/sbus/char/flash.c
200 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +8 -2
201 # Import patch 2.4.27-ppos5.patch
202 #
203 # drivers/scsi/osst.c
204 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +9 -4
205 # Import patch 2.4.27-ppos5.patch
206 #
207 # drivers/scsi/st.c
208 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +9 -4
209 # Import patch 2.4.27-ppos5.patch
210 #
211 # drivers/usb/brlvger.c
212 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +3 -0
213 # Import patch 2.4.27-ppos5.patch
214 #
215 # drivers/usb/devio.c
216 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +9 -8
217 # Import patch 2.4.27-ppos5.patch
218 #
219 # drivers/usb/drivers.c
220 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +4 -4
221 # Import patch 2.4.27-ppos5.patch
222 #
223 # drivers/usb/host/uhci-debug.h
224 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +5 -7
225 # Import patch 2.4.27-ppos5.patch
226 #
227 # drivers/video/fbmem.c
228 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +12 -10
229 # Import patch 2.4.27-ppos5.patch
230 #
231 # drivers/zorro/proc.c
232 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +3 -5
233 # Import patch 2.4.27-ppos5.patch
234 #
235 # fs/devfs/base.c
236 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +9 -8
237 # Import patch 2.4.27-ppos5.patch
238 #
239 # fs/hfs/file.c
240 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +5 -5
241 # Import patch 2.4.27-ppos5.patch
242 #
243 # fs/hfs/file_cap.c
244 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +7 -6
245 # Import patch 2.4.27-ppos5.patch
246 #
247 # fs/hfs/file_hdr.c
248 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +3 -3
249 # Import patch 2.4.27-ppos5.patch
250 #
251 # fs/openpromfs/inode.c
252 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +35 -28
253 # Import patch 2.4.27-ppos5.patch
254 #
255 # fs/proc/base.c
256 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +6 -5
257 # Import patch 2.4.27-ppos5.patch
258 #
259 # fs/proc/generic.c
260 # 2004/07/30 10:31:20-03:00 marcelo@logos.cnet +9 -5
261 # Import patch 2.4.27-ppos5.patch
262 #
263 # fs/proc/kcore.c
264 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +2 -1
265 # Import patch 2.4.27-ppos5.patch
266 #
267 # fs/proc/proc_misc.c
268 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +4 -3
269 # Import patch 2.4.27-ppos5.patch
270 #
271 # fs/udf/file.c
272 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +7 -3
273 # Import patch 2.4.27-ppos5.patch
274 #
275 # mm/shmem.c
276 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +6 -2
277 # Import patch 2.4.27-ppos5.patch
278 #
279 # net/8021q/vlanproc.c
280 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +5 -4
281 # Import patch 2.4.27-ppos5.patch
282 #
283 # net/atm/br2684.c
284 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +4 -2
285 # Import patch 2.4.27-ppos5.patch
286 # *** Updated patch to include ChangeSet 1.1469 - Horms 2004/08/12 ***
287 # *** Updated patch to include ChangeSet 1.1458.1.11 - Horms 2004/08/14 ***
288 #
289 # net/atm/mpoa_proc.c
290 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +4 -3
291 # Import patch 2.4.27-ppos5.patch
292 #
293 # net/wanrouter/wanproc.c
294 # 2004/07/30 10:29:39-03:00 marcelo@logos.cnet +5 -4
295 # Import patch 2.4.27-ppos5.patch
296 #
297 diff -Nru a/arch/cris/drivers/eeprom.c b/arch/cris/drivers/eeprom.c
298 --- a/arch/cris/drivers/eeprom.c 2004-08-11 19:29:57 -07:00
299 +++ b/arch/cris/drivers/eeprom.c 2004-08-11 19:29:57 -07:00
300 @@ -506,7 +506,7 @@
301 static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t *off)
302 {
303 int read=0;
304 - unsigned long p = file->f_pos;
305 + unsigned long p = *off;
306
307 unsigned char page;
308
309 @@ -540,7 +540,7 @@
310 return -EFAULT;
311 }
312
313 - if( (p + count) > eeprom.size)
314 + if(count > eeprom.size - p)
315 {
316 /* truncate count */
317 count = eeprom.size - p;
318 @@ -560,7 +560,7 @@
319
320 if(read > 0)
321 {
322 - file->f_pos += read;
323 + *off = p + read;
324 }
325
326 eeprom.busy--;
327 @@ -605,7 +605,7 @@
328 {
329 restart = 0;
330 written = 0;
331 - p = file->f_pos;
332 + p = *off;
333
334
335 while( (written < count) && (p < eeprom.size))
336 @@ -733,10 +733,10 @@
337
338 eeprom.busy--;
339 wake_up_interruptible(&eeprom.wait_q);
340 - if (written == 0 && file->f_pos >= eeprom.size){
341 + if (written == 0 && p >= eeprom.size){
342 return -ENOSPC;
343 }
344 - file->f_pos += written;
345 + *off = p;
346 return written;
347 }
348
349 diff -Nru a/arch/i386/kernel/mtrr.c b/arch/i386/kernel/mtrr.c
350 --- a/arch/i386/kernel/mtrr.c 2004-08-11 19:29:57 -07:00
351 +++ b/arch/i386/kernel/mtrr.c 2004-08-11 19:29:57 -07:00
352 @@ -1648,11 +1648,17 @@
353 static ssize_t mtrr_read (struct file *file, char *buf, size_t len,
354 loff_t *ppos)
355 {
356 - if (*ppos >= ascii_buf_bytes) return 0;
357 - if (*ppos + len > ascii_buf_bytes) len = ascii_buf_bytes - *ppos;
358 - if ( copy_to_user (buf, ascii_buffer + *ppos, len) ) return -EFAULT;
359 - *ppos += len;
360 - return len;
361 + loff_t pos = *ppos;
362 + if (pos < 0 || pos >= ascii_buf_bytes)
363 + return 0;
364 + if (len > ascii_buf_bytes - pos)
365 + len = ascii_buf_bytes - pos;
366 + if (copy_to_user(buf, ascii_buffer + pos, len))
367 + return -EFAULT;
368 + pos += len;
369 + *ppos = pos;
370 +
371 + return len;
372 } /* End Function mtrr_read */
373
374 static ssize_t mtrr_write (struct file *file, const char *buf, size_t len,
375 diff -Nru a/arch/ia64/kernel/efivars.c b/arch/ia64/kernel/efivars.c
376 --- a/arch/ia64/kernel/efivars.c 2004-08-11 19:29:57 -07:00
377 +++ b/arch/ia64/kernel/efivars.c 2004-08-11 19:29:57 -07:00
378 @@ -364,6 +364,7 @@
379 int ret;
380 const int max_nr_entries = 7; /* num ptrs to tables we could expose */
381 const int max_line_len = 80;
382 + loff_t pos = *ppos;
383
384 if (!efi.systab)
385 return 0;
386 @@ -388,13 +389,13 @@
387 if (efi.boot_info)
388 length += sprintf(proc_buffer + length, "BOOTINFO=0x%lx\n", __pa(efi.boot_info));
389
390 - if (*ppos >= length) {
391 + if (pos != (unsigned) pos || pos >= length) {
392 ret = 0;
393 goto out;
394 }
395
396 - data = proc_buffer + file->f_pos;
397 - size = length - file->f_pos;
398 + data = proc_buffer + pos;
399 + size = length - pos;
400 if (size > count)
401 size = count;
402 if (copy_to_user(buffer, data, size)) {
403 @@ -402,7 +403,7 @@
404 goto out;
405 }
406
407 - *ppos += size;
408 + *ppos = pos + size;
409 ret = size;
410
411 out:
412 diff -Nru a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
413 --- a/arch/ia64/kernel/salinfo.c 2004-08-11 19:29:57 -07:00
414 +++ b/arch/ia64/kernel/salinfo.c 2004-08-11 19:29:57 -07:00
415 @@ -451,6 +451,7 @@
416 size_t size;
417 u8 *buf;
418 u64 bufsize;
419 + loff_t pos = *ppos;
420
421 if (data->state == STATE_LOG_RECORD) {
422 buf = data->log_buffer;
423 @@ -462,17 +463,17 @@
424 buf = NULL;
425 bufsize = 0;
426 }
427 - if (*ppos >= bufsize)
428 + if (pos != (unsigned)pos || pos >= bufsize)
429 return 0;
430
431 - saldata = buf + file->f_pos;
432 - size = bufsize - file->f_pos;
433 + saldata = buf + pos;
434 + size = bufsize - pos;
435 if (size > count)
436 size = count;
437 if (copy_to_user(buffer, saldata, size))
438 return -EFAULT;
439
440 - *ppos += size;
441 + *ppos = pos + size;
442 return size;
443 }
444
445 diff -Nru a/arch/mips/sibyte/sb1250/bcm1250_tbprof.c b/arch/mips/sibyte/sb1250/bcm1250_tbprof.c
446 --- a/arch/mips/sibyte/sb1250/bcm1250_tbprof.c 2004-08-11 19:29:57 -07:00
447 +++ b/arch/mips/sibyte/sb1250/bcm1250_tbprof.c 2004-08-11 19:29:57 -07:00
448 @@ -300,6 +300,9 @@
449 char *dest = buf;
450 long cur_off = *offp;
451
452 + if (cur_off < 0)
453 + return -EINVAL;
454 +
455 count = 0;
456 cur_sample = cur_off / TB_SAMPLE_SIZE;
457 sample_off = cur_off % TB_SAMPLE_SIZE;
458 diff -Nru a/arch/ppc/config.in b/arch/ppc/config.in
459 --- a/arch/ppc/config.in 2004-08-11 19:29:57 -07:00
460 +++ b/arch/ppc/config.in 2004-08-11 19:29:57 -07:00
461 @@ -410,7 +410,6 @@
462
463 if [ "$CONFIG_ALL_PPC" = "y" ]; then
464 bool 'Support for Open Firmware device tree in /proc' CONFIG_PROC_DEVICETREE
465 - bool 'Support for RTAS (RunTime Abstraction Services) in /proc' CONFIG_PPC_RTAS
466 bool 'Support for PReP Residual Data' CONFIG_PREP_RESIDUAL
467 dep_bool ' Support for reading of PReP Residual Data in /proc' CONFIG_PROC_PREPRESIDUAL $CONFIG_PREP_RESIDUAL
468 define_bool CONFIG_PPCBUG_NVRAM y
469 diff -Nru a/arch/ppc/kernel/ppc_htab.c b/arch/ppc/kernel/ppc_htab.c
470 --- a/arch/ppc/kernel/ppc_htab.c 2004-08-11 19:29:57 -07:00
471 +++ b/arch/ppc/kernel/ppc_htab.c 2004-08-11 19:29:57 -07:00
472 @@ -112,6 +112,7 @@
473 size_t count, loff_t *ppos)
474 {
475 unsigned long mmcr0 = 0, pmc1 = 0, pmc2 = 0;
476 + loff_t pos = *ppos;
477 int n = 0;
478 #if defined(CONFIG_PPC_STD_MMU) && !defined(CONFIG_PPC64BRIDGE)
479 int valid;
480 @@ -219,14 +220,14 @@
481 "Non-error misses: %lu\n"
482 "Error misses\t: %lu\n",
483 pte_misses, pte_errors);
484 - if (*ppos >= strlen(buffer))
485 + if (pos != (unsigned)pos || pos >= strlen(buffer))
486 return 0;
487 - if (n > strlen(buffer) - *ppos)
488 - n = strlen(buffer) - *ppos;
489 + if (n > strlen(buffer) - pos)
490 + n = strlen(buffer) - pos;
491 if (n > count)
492 n = count;
493 - copy_to_user(buf, buffer + *ppos, n);
494 - *ppos += n;
495 + copy_to_user(buf, buffer + pos, n);
496 + *ppos = pos + n;
497 return n;
498 }
499
500 diff -Nru a/arch/ppc/platforms/Makefile b/arch/ppc/platforms/Makefile
501 --- a/arch/ppc/platforms/Makefile 2004-08-11 19:29:57 -07:00
502 +++ b/arch/ppc/platforms/Makefile 2004-08-11 19:29:57 -07:00
503 @@ -51,7 +51,6 @@
504 prep_time.o prep_setup.o pmac_sleep.o \
505 pmac_nvram.o
506 obj-$(CONFIG_PMAC_BACKLIGHT) += pmac_backlight.o
507 -obj-$(CONFIG_PPC_RTAS) += error_log.o proc_rtas.o
508 obj-$(CONFIG_PREP_RESIDUAL) += residual.o
509 obj-$(CONFIG_GEMINI) += gemini_pci.o gemini_setup.o gemini_prom.o
510 obj-$(CONFIG_LOPEC) += lopec_setup.o lopec_pci.o
511 --- a/arch/ppc/platforms/error_log.h 2004-08-12 16:56:06.000000000 +0900
512 +++ b/arch/ppc/platforms/error_log.h 2004-08-12 16:56:18.000000000 +0900
513 @@ -1,95 +1 @@
514 -#ifndef __ERROR_LOG_H__
515 -#define __ERROR_LOG_H__
516 -
517 -#define VERBOSE_ERRORS 1 /* Maybe I enlarge the kernel too much */
518 -#undef VERBOSE_ERRORS
519 -
520 -/* Event classes */
521 -/* XXX: Endianess correct? NOW*/
522 -#define INTERNAL_ERROR 0x80000000 /* set bit 0 */
523 -#define EPOW_WARNING 0x40000000 /* set bit 1 */
524 -#define POWERMGM_EVENTS 0x20000000 /* set bit 2 */
525 -
526 -/* event-scan returns */
527 -#define SEVERITY_FATAL 0x5
528 -#define SEVERITY_ERROR 0x4
529 -#define SEVERITY_ERROR_SYNC 0x3
530 -#define SEVERITY_WARNING 0x2
531 -#define SEVERITY_EVENT 0x1
532 -#define SEVERITY_NO_ERROR 0x0
533 -#define DISP_FULLY_RECOVERED 0x0
534 -#define DISP_LIMITED_RECOVERY 0x1
535 -#define DISP_NOT_RECOVERED 0x2
536 -#define PART_PRESENT 0x0
537 -#define PART_NOT_PRESENT 0x1
538 -#define INITIATOR_UNKNOWN 0x0
539 -#define INITIATOR_CPU 0x1
540 -#define INITIATOR_PCI 0x2
541 -#define INITIATOR_ISA 0x3
542 -#define INITIATOR_MEMORY 0x4
543 -#define INITIATOR_POWERMGM 0x5
544 -#define TARGET_UNKNOWN 0x0
545 -#define TARGET_CPU 0x1
546 -#define TARGET_PCI 0x2
547 -#define TARGET_ISA 0x3
548 -#define TARGET_MEMORY 0x4
549 -#define TARGET_POWERMGM 0x5
550 -#define TYPE_RETRY 0x01
551 -#define TYPE_TCE_ERR 0x02
552 -#define TYPE_INTERN_DEV_FAIL 0x03
553 -#define TYPE_TIMEOUT 0x04
554 -#define TYPE_DATA_PARITY 0x05
555 -#define TYPE_ADDR_PARITY 0x06
556 -#define TYPE_CACHE_PARITY 0x07
557 -#define TYPE_ADDR_INVALID 0x08
558 -#define TYPE_ECC_UNCORR 0x09
559 -#define TYPE_ECC_CORR 0x0a
560 -#define TYPE_EPOW 0x40
561 -/* I don't add PowerMGM events right now, this is a different topic */
562 -#define TYPE_PMGM_POWER_SW_ON 0x60
563 -#define TYPE_PMGM_POWER_SW_OFF 0x61
564 -#define TYPE_PMGM_LID_OPEN 0x62
565 -#define TYPE_PMGM_LID_CLOSE 0x63
566 -#define TYPE_PMGM_SLEEP_BTN 0x64
567 -#define TYPE_PMGM_WAKE_BTN 0x65
568 -#define TYPE_PMGM_BATTERY_WARN 0x66
569 -#define TYPE_PMGM_BATTERY_CRIT 0x67
570 -#define TYPE_PMGM_SWITCH_TO_BAT 0x68
571 -#define TYPE_PMGM_SWITCH_TO_AC 0x69
572 -#define TYPE_PMGM_KBD_OR_MOUSE 0x6a
573 -#define TYPE_PMGM_ENCLOS_OPEN 0x6b
574 -#define TYPE_PMGM_ENCLOS_CLOSED 0x6c
575 -#define TYPE_PMGM_RING_INDICATE 0x6d
576 -#define TYPE_PMGM_LAN_ATTENTION 0x6e
577 -#define TYPE_PMGM_TIME_ALARM 0x6f
578 -#define TYPE_PMGM_CONFIG_CHANGE 0x70
579 -#define TYPE_PMGM_SERVICE_PROC 0x71
580 -
581 -typedef struct _rtas_error_log {
582 - unsigned long version:8; /* Architectural version */
583 - unsigned long severity:3; /* Severity level of error */
584 - unsigned long disposition:2; /* Degree of recovery */
585 - unsigned long extended:1; /* extended log present? */
586 - unsigned long /* reserved */ :2; /* Reserved for future use */
587 - unsigned long initiator:4; /* Initiator of event */
588 - unsigned long target:4; /* Target of failed operation */
589 - unsigned long type:8; /* General event or error*/
590 - unsigned long extended_log_length:32; /* length in bytes */
591 -} rtas_error_log;
592 -
593 -/* ****************************************************************** */
594 -#define ppc_rtas_errorlog_check_severity(x) \
595 - (_errlog_severity[x.severity])
596 -#define ppc_rtas_errorlog_check_target(x) \
597 - (_errlog_target[x.target])
598 -#define ppc_rtas_errorlog_check_initiator(x) \
599 - (_errlog_initiator[x.initiator])
600 -#define ppc_rtas_errorlog_check_extended(x) \
601 - (_errlog_extended[x.extended])
602 -#define ppc_rtas_errorlog_disect_extended(x) \
603 - do { /* implement me */ } while(0)
604 -extern const char * ppc_rtas_errorlog_check_type (rtas_error_log error_log);
605 -extern int ppc_rtas_errorlog_scan(void);
606 -
607 -
608 -#endif /* __ERROR_LOG_H__ */
609 +/* Dummy File as dpkg-source does not handle file deletion */
610 --- a/arch/ppc/platforms/error_log.c 2004-08-12 16:55:49.000000000 +0900
611 +++ b/arch/ppc/platforms/error_log.c 2004-08-12 16:55:54.000000000 +0900
612 @@ -1,183 +1 @@
613 -/*
614 - * arch/ppc/kernel/error_log.c
615 - *
616 - * Copyright (c) 2000 Tilmann Bitterberg
617 - * (tilmann@bitterberg.de)
618 - *
619 - * Error processing of errors found by rtas even-scan routine
620 - * which is done with every heartbeat. (chrp_setup.c)
621 - */
622 -
623 -#include <linux/sched.h>
624 -
625 -#include <asm/prom.h>
626 -
627 -#include "error_log.h"
628 -
629 -/* ****************************************************************** */
630 -/*
631 - * EVENT-SCAN
632 - * The whole stuff below here doesn't take any action when it found
633 - * an error, it just prints as much information as possible and
634 - * then its up to the user to decide what to do.
635 - *
636 - * Returns 0 if no errors were found
637 - * Returns 1 if there may be more errors
638 - */
639 -int ppc_rtas_errorlog_scan(void)
640 -{
641 -const char *_errlog_severity[] = {
642 -#ifdef VERBOSE_ERRORS
643 - "No Error\n\t\
644 -Should require no further information",
645 - "Event\n\t\
646 -This is not really an error, it is an event. I use events\n\t\
647 -to communicate with RTAS back and forth.",
648 - "Warning\n\t\
649 -Indicates a non-state-losing error, either fully recovered\n\t\
650 -by RTAS or not needing recovery. Ignore it.",
651 - "Error sync\n\t\
652 -May only be fatal to a certain program or thread. Recovery\n\t\
653 -and continuation is possible, if I only had a handler for\n\t\
654 -this. Less serious",
655 - "Error\n\t\
656 -Less serious, but still causing a loss of data and state.\n\t\
657 -I can't tell you exactly what to do, You have to decide\n\t\
658 -with help from the target and initiator field, what kind\n\t\
659 -of further actions may take place.",
660 - "Fatal\n\t\
661 -Represent a permanent hardware failure and I believe this\n\t\
662 -affects my overall performance and behaviour. I would not\n\t\
663 -attempt to continue normal operation."
664 -#else
665 - "No Error",
666 - "Event",
667 - "Warning",
668 - "Error sync",
669 - "Error",
670 - "Fatal"
671 -#endif /* VERBOSE_ERRORS */
672 -};
673 -
674 -#if 0 /* unused?? */
675 -const char *_errlog_disposition[] = {
676 -#ifdef VERBOSE_ERRORS
677 - "Fully recovered\n\t\
678 -There was an error, but it is fully recovered by RTAS.",
679 - "Limited recovery\n\t\
680 -RTAS was able to recover the state of the machine, but some\n\t\
681 -feature of the machine has been disabled or lost (for example\n\t\
682 -error checking) or performance may suffer.",
683 - "Not recovered\n\t\
684 -Whether RTAS did not try to recover anything or recovery failed:\n\t\
685 -HOUSTON, WE HAVE A PROBLEM!"
686 -#else
687 - "Fully recovered",
688 - "Limited recovery",
689 - "Not recovered"
690 -#endif /* VERBOSE_ERRORS */
691 -};
692 -#endif
693 -
694 -const char *_errlog_extended[] = {
695 -#ifdef VERBOSE_ERRORS
696 - "Not present\n\t\
697 -Sad, the RTAS call didn't return an extended error log.",
698 - "Present\n\t\
699 -The extended log is present and hopefully it contains a lot of\n\t\
700 -useful information, which leads to the solution of the problem."
701 -#else
702 - "Not present",
703 - "Present"
704 -#endif /* VERBOSE_ERRORS */
705 -};
706 -
707 -const char *_errlog_initiator[] = {
708 - "Unknown or not applicable",
709 - "CPU",
710 - "PCI",
711 - "ISA",
712 - "Memory",
713 - "Power management"
714 -};
715 -
716 -const char *_errlog_target[] = {
717 - "Unknown or not applicable",
718 - "CPU",
719 - "PCI",
720 - "ISA",
721 - "Memory",
722 - "Power management"
723 -};
724 - rtas_error_log error_log;
725 - char logdata[1024];
726 - int error;
727 -#if 0 /* unused?? */
728 - int retries = 0; /* if HW error, try 10 times */
729 -#endif
730 -
731 - error = call_rtas ("event-scan", 4, 1, (unsigned long *)&error_log,
732 - INTERNAL_ERROR | EPOW_WARNING,
733 - 0, __pa(logdata), 1024);
734 -
735 - if (error == 1) /* no errors found */
736 - return 0;
737 -
738 - if (error == -1) {
739 - printk(KERN_ERR "Unable to get errors. Do you a favor and throw this box away\n");
740 - return 0;
741 - }
742 - if (error_log.version != 1)
743 - printk(KERN_WARNING "Unknown version (%d), please implement me\n",
744 - error_log.version);
745 -
746 - switch (error_log.disposition) {
747 - case DISP_FULLY_RECOVERED:
748 - /* there was an error, but everything is fine now */
749 - return 0;
750 - case DISP_NOT_RECOVERED:
751 - printk("We have a really serious Problem!\n");
752 - case DISP_LIMITED_RECOVERY:
753 - printk("Error classification\n");
754 - printk("Severity : %s\n",
755 - ppc_rtas_errorlog_check_severity (error_log));
756 - printk("Initiator : %s\n",
757 - ppc_rtas_errorlog_check_initiator (error_log));
758 - printk("Target : %s\n",
759 - ppc_rtas_errorlog_check_target (error_log));
760 - printk("Type : %s\n",
761 - ppc_rtas_errorlog_check_type (error_log));
762 - printk("Ext. log : %s\n",
763 - ppc_rtas_errorlog_check_extended (error_log));
764 - if (error_log.extended)
765 - ppc_rtas_errorlog_disect_extended (logdata);
766 - return 1;
767 - default:
768 - /* nothing */
769 - break;
770 - }
771 - return 0;
772 -}
773 -/* ****************************************************************** */
774 -const char * ppc_rtas_errorlog_check_type (rtas_error_log error_log)
775 -{
776 - const char *_errlog_type[] = {
777 - "unknown type",
778 - "too many tries failed",
779 - "TCE error",
780 - "RTAS device failed",
781 - "target timed out",
782 - "parity error on data", /* 5 */
783 - "parity error on address",
784 - "parity error on external cache",
785 - "access to invalid address",
786 - "uncorrectable ECC error",
787 - "corrected ECC error" /* 10 */
788 - };
789 - if (error_log.type == TYPE_EPOW)
790 - return "EPOW";
791 - if (error_log.type >= TYPE_PMGM_POWER_SW_ON)
792 - return "PowerMGM Event (not handled right now)";
793 - return _errlog_type[error_log.type];
794 -}
795 -
796 +/* Dummy File as dpkg-source does not handle file deletion */
797 --- a/arch/ppc/platforms/proc_rtas.c 2004-08-12 16:56:33.000000000 +0900
798 +++ b/arch/ppc/platforms/proc_rtas.c 2004-08-12 16:56:42.000000000 +0900
799 @@ -1,784 +1 @@
800 -/*
801 - * arch/ppc/kernel/proc_rtas.c
802 - * Copyright (C) 2000 Tilmann Bitterberg
803 - * (tilmann@bitterberg.de)
804 - *
805 - * RTAS (Runtime Abstraction Services) stuff
806 - * Intention is to provide a clean user interface
807 - * to use the RTAS.
808 - *
809 - * TODO:
810 - * Split off a header file and maybe move it to a different
811 - * location. Write Documentation on what the /proc/rtas/ entries
812 - * actually do.
813 - */
814 -
815 -#include <linux/errno.h>
816 -#include <linux/sched.h>
817 -#include <linux/proc_fs.h>
818 -#include <linux/stat.h>
819 -#include <linux/ctype.h>
820 -#include <linux/time.h>
821 -#include <linux/string.h>
822 -
823 -#include <asm/uaccess.h>
824 -#include <asm/bitops.h>
825 -#include <asm/processor.h>
826 -#include <asm/io.h>
827 -#include <asm/prom.h>
828 -#include <asm/machdep.h> /* for ppc_md */
829 -#include <asm/time.h>
830 -
831 -/* Token for Sensors */
832 -#define KEY_SWITCH 0x0001
833 -#define ENCLOSURE_SWITCH 0x0002
834 -#define THERMAL_SENSOR 0x0003
835 -#define LID_STATUS 0x0004
836 -#define POWER_SOURCE 0x0005
837 -#define BATTERY_VOLTAGE 0x0006
838 -#define BATTERY_REMAINING 0x0007
839 -#define BATTERY_PERCENTAGE 0x0008
840 -#define EPOW_SENSOR 0x0009
841 -#define BATTERY_CYCLESTATE 0x000a
842 -#define BATTERY_CHARGING 0x000b
843 -
844 -/* IBM specific sensors */
845 -#define IBM_SURVEILLANCE 0x2328 /* 9000 */
846 -#define IBM_FANRPM 0x2329 /* 9001 */
847 -#define IBM_VOLTAGE 0x232a /* 9002 */
848 -#define IBM_DRCONNECTOR 0x232b /* 9003 */
849 -#define IBM_POWERSUPPLY 0x232c /* 9004 */
850 -#define IBM_INTQUEUE 0x232d /* 9005 */
851 -
852 -/* Status return values */
853 -#define SENSOR_CRITICAL_HIGH 13
854 -#define SENSOR_WARNING_HIGH 12
855 -#define SENSOR_NORMAL 11
856 -#define SENSOR_WARNING_LOW 10
857 -#define SENSOR_CRITICAL_LOW 9
858 -#define SENSOR_SUCCESS 0
859 -#define SENSOR_HW_ERROR -1
860 -#define SENSOR_BUSY -2
861 -#define SENSOR_NOT_EXIST -3
862 -#define SENSOR_DR_ENTITY -9000
863 -
864 -/* Location Codes */
865 -#define LOC_SCSI_DEV_ADDR 'A'
866 -#define LOC_SCSI_DEV_LOC 'B'
867 -#define LOC_CPU 'C'
868 -#define LOC_DISKETTE 'D'
869 -#define LOC_ETHERNET 'E'
870 -#define LOC_FAN 'F'
871 -#define LOC_GRAPHICS 'G'
872 -/* reserved / not used 'H' */
873 -#define LOC_IO_ADAPTER 'I'
874 -/* reserved / not used 'J' */
875 -#define LOC_KEYBOARD 'K'
876 -#define LOC_LCD 'L'
877 -#define LOC_MEMORY 'M'
878 -#define LOC_NV_MEMORY 'N'
879 -#define LOC_MOUSE 'O'
880 -#define LOC_PLANAR 'P'
881 -#define LOC_OTHER_IO 'Q'
882 -#define LOC_PARALLEL 'R'
883 -#define LOC_SERIAL 'S'
884 -#define LOC_DEAD_RING 'T'
885 -#define LOC_RACKMOUNTED 'U' /* for _u_nit is rack mounted */
886 -#define LOC_VOLTAGE 'V'
887 -#define LOC_SWITCH_ADAPTER 'W'
888 -#define LOC_OTHER 'X'
889 -#define LOC_FIRMWARE 'Y'
890 -#define LOC_SCSI 'Z'
891 -
892 -/* Tokens for indicators */
893 -#define TONE_FREQUENCY 0x0001 /* 0 - 1000 (HZ)*/
894 -#define TONE_VOLUME 0x0002 /* 0 - 100 (%) */
895 -#define SYSTEM_POWER_STATE 0x0003
896 -#define WARNING_LIGHT 0x0004
897 -#define DISK_ACTIVITY_LIGHT 0x0005
898 -#define HEX_DISPLAY_UNIT 0x0006
899 -#define BATTERY_WARNING_TIME 0x0007
900 -#define CONDITION_CYCLE_REQUEST 0x0008
901 -#define SURVEILLANCE_INDICATOR 0x2328 /* 9000 */
902 -#define DR_ACTION 0x2329 /* 9001 */
903 -#define DR_INDICATOR 0x232a /* 9002 */
904 -/* 9003 - 9004: Vendor specific */
905 -#define GLOBAL_INTERRUPT_QUEUE 0x232d /* 9005 */
906 -/* 9006 - 9999: Vendor specific */
907 -
908 -/* other */
909 -#define MAX_SENSORS 17 /* I only know of 17 sensors */
910 -#define MAX_LINELENGTH 256
911 -#define SENSOR_PREFIX "ibm,sensor-"
912 -#define cel_to_fahr(x) ((x*9/5)+32)
913 -
914 -
915 -/* Globals */
916 -static struct proc_dir_entry *proc_rtas;
917 -static struct rtas_sensors sensors;
918 -static struct device_node *rtas;
919 -static unsigned long power_on_time = 0; /* Save the time the user set */
920 -static char progress_led[MAX_LINELENGTH];
921 -
922 -static unsigned long rtas_tone_frequency = 1000;
923 -static unsigned long rtas_tone_volume = 0;
924 -
925 -/* ****************STRUCTS******************************************* */
926 -struct individual_sensor {
927 - unsigned int token;
928 - unsigned int quant;
929 -};
930 -
931 -struct rtas_sensors {
932 - struct individual_sensor sensor[MAX_SENSORS];
933 - unsigned int quant;
934 -};
935 -
936 -/* ****************************************************************** */
937 -/* Declarations */
938 -static int ppc_rtas_sensor_read(char * buf, char ** start, off_t off,
939 - int count, int *eof, void *data);
940 -static ssize_t ppc_rtas_clock_read(struct file * file, char * buf,
941 - size_t count, loff_t *ppos);
942 -static ssize_t ppc_rtas_clock_write(struct file * file, const char * buf,
943 - size_t count, loff_t *ppos);
944 -static ssize_t ppc_rtas_progress_read(struct file * file, char * buf,
945 - size_t count, loff_t *ppos);
946 -static ssize_t ppc_rtas_progress_write(struct file * file, const char * buf,
947 - size_t count, loff_t *ppos);
948 -static ssize_t ppc_rtas_poweron_read(struct file * file, char * buf,
949 - size_t count, loff_t *ppos);
950 -static ssize_t ppc_rtas_poweron_write(struct file * file, const char * buf,
951 - size_t count, loff_t *ppos);
952 -
953 -static ssize_t ppc_rtas_tone_freq_write(struct file * file, const char * buf,
954 - size_t count, loff_t *ppos);
955 -static ssize_t ppc_rtas_tone_freq_read(struct file * file, char * buf,
956 - size_t count, loff_t *ppos);
957 -static ssize_t ppc_rtas_tone_volume_write(struct file * file, const char * buf,
958 - size_t count, loff_t *ppos);
959 -static ssize_t ppc_rtas_tone_volume_read(struct file * file, char * buf,
960 - size_t count, loff_t *ppos);
961 -
962 -struct file_operations ppc_rtas_poweron_operations = {
963 - read: ppc_rtas_poweron_read,
964 - write: ppc_rtas_poweron_write
965 -};
966 -struct file_operations ppc_rtas_progress_operations = {
967 - read: ppc_rtas_progress_read,
968 - write: ppc_rtas_progress_write
969 -};
970 -
971 -struct file_operations ppc_rtas_clock_operations = {
972 - read: ppc_rtas_clock_read,
973 - write: ppc_rtas_clock_write
974 -};
975 -
976 -struct file_operations ppc_rtas_tone_freq_operations = {
977 - read: ppc_rtas_tone_freq_read,
978 - write: ppc_rtas_tone_freq_write
979 -};
980 -struct file_operations ppc_rtas_tone_volume_operations = {
981 - read: ppc_rtas_tone_volume_read,
982 - write: ppc_rtas_tone_volume_write
983 -};
984 -
985 -int ppc_rtas_find_all_sensors (void);
986 -int ppc_rtas_process_sensor(struct individual_sensor s, int state,
987 - int error, char * buf);
988 -char * ppc_rtas_process_error(int error);
989 -int get_location_code(struct individual_sensor s, char * buf);
990 -int check_location_string (char *c, char * buf);
991 -int check_location (char *c, int idx, char * buf);
992 -
993 -/* ****************************************************************** */
994 -/* MAIN */
995 -/* ****************************************************************** */
996 -void proc_rtas_init(void)
997 -{
998 - struct proc_dir_entry *entry;
999 -
1000 - rtas = find_devices("rtas");
1001 - if ((rtas == 0) || (_machine != _MACH_chrp)) {
1002 - return;
1003 - }
1004 -
1005 - proc_rtas = proc_mkdir("rtas", 0);
1006 - if (proc_rtas == 0)
1007 - return;
1008 -
1009 - /* /proc/rtas entries */
1010 -
1011 - entry = create_proc_entry("progress", S_IRUGO|S_IWUSR, proc_rtas);
1012 - if (entry) entry->proc_fops = &ppc_rtas_progress_operations;
1013 -
1014 - entry = create_proc_entry("clock", S_IRUGO|S_IWUSR, proc_rtas);
1015 - if (entry) entry->proc_fops = &ppc_rtas_clock_operations;
1016 -
1017 - entry = create_proc_entry("poweron", S_IWUSR|S_IRUGO, proc_rtas);
1018 - if (entry) entry->proc_fops = &ppc_rtas_poweron_operations;
1019 -
1020 - create_proc_read_entry("sensors", S_IRUGO, proc_rtas,
1021 - ppc_rtas_sensor_read, NULL);
1022 -
1023 - entry = create_proc_entry("frequency", S_IWUSR|S_IRUGO, proc_rtas);
1024 - if (entry) entry->proc_fops = &ppc_rtas_tone_freq_operations;
1025 -
1026 - entry = create_proc_entry("volume", S_IWUSR|S_IRUGO, proc_rtas);
1027 - if (entry) entry->proc_fops = &ppc_rtas_tone_volume_operations;
1028 -}
1029 -
1030 -/* ****************************************************************** */
1031 -/* POWER-ON-TIME */
1032 -/* ****************************************************************** */
1033 -static ssize_t ppc_rtas_poweron_write(struct file * file, const char * buf,
1034 - size_t count, loff_t *ppos)
1035 -{
1036 - struct rtc_time tm;
1037 - unsigned long nowtime;
1038 - char *dest;
1039 - int error;
1040 -
1041 - nowtime = simple_strtoul(buf, &dest, 10);
1042 - if (*dest != '\0' && *dest != '\n') {
1043 - printk("ppc_rtas_poweron_write: Invalid time\n");
1044 - return count;
1045 - }
1046 - power_on_time = nowtime; /* save the time */
1047 -
1048 - to_tm(nowtime, &tm);
1049 -
1050 - error = call_rtas("set-time-for-power-on", 7, 1, NULL,
1051 - tm.tm_year, tm.tm_mon, tm.tm_mday,
1052 - tm.tm_hour, tm.tm_min, tm.tm_sec, 0 /* nano */);
1053 - if (error != 0)
1054 - printk(KERN_WARNING "error: setting poweron time returned: %s\n",
1055 - ppc_rtas_process_error(error));
1056 - return count;
1057 -}
1058 -/* ****************************************************************** */
1059 -static ssize_t ppc_rtas_poweron_read(struct file * file, char * buf,
1060 - size_t count, loff_t *ppos)
1061 -{
1062 - int n;
1063 - if (power_on_time == 0)
1064 - n = sprintf(buf, "Power on time not set\n");
1065 - else
1066 - n = sprintf(buf, "%lu\n", power_on_time);
1067 -
1068 - if (*ppos >= strlen(buf))
1069 - return 0;
1070 - if (n > strlen(buf) - *ppos)
1071 - n = strlen(buf) - *ppos;
1072 - if (n > count)
1073 - n = count;
1074 - *ppos += n;
1075 - return n;
1076 -}
1077 -
1078 -/* ****************************************************************** */
1079 -/* PROGRESS */
1080 -/* ****************************************************************** */
1081 -static ssize_t ppc_rtas_progress_write(struct file * file, const char * buf,
1082 - size_t count, loff_t *ppos)
1083 -{
1084 - unsigned long hex;
1085 -
1086 - strcpy(progress_led, buf); /* save the string */
1087 - /* Lets see if the user passed hexdigits */
1088 - hex = simple_strtoul(buf, NULL, 10);
1089 -
1090 - ppc_md.progress ((char *)buf, hex);
1091 - return count;
1092 -
1093 - /* clear the line */ /* ppc_md.progress(" ", 0xffff);*/
1094 -}
1095 -/* ****************************************************************** */
1096 -static ssize_t ppc_rtas_progress_read(struct file * file, char * buf,
1097 - size_t count, loff_t *ppos)
1098 -{
1099 - int n = 0;
1100 - if (progress_led != NULL)
1101 - n = sprintf (buf, "%s\n", progress_led);
1102 - if (*ppos >= strlen(buf))
1103 - return 0;
1104 - if (n > strlen(buf) - *ppos)
1105 - n = strlen(buf) - *ppos;
1106 - if (n > count)
1107 - n = count;
1108 - *ppos += n;
1109 - return n;
1110 -}
1111 -
1112 -/* ****************************************************************** */
1113 -/* CLOCK */
1114 -/* ****************************************************************** */
1115 -static ssize_t ppc_rtas_clock_write(struct file * file, const char * buf,
1116 - size_t count, loff_t *ppos)
1117 -{
1118 - struct rtc_time tm;
1119 - unsigned long nowtime;
1120 - char *dest;
1121 - int error;
1122 -
1123 - nowtime = simple_strtoul(buf, &dest, 10);
1124 - if (*dest != '\0' && *dest != '\n') {
1125 - printk("ppc_rtas_clock_write: Invalid time\n");
1126 - return count;
1127 - }
1128 -
1129 - to_tm(nowtime, &tm);
1130 - error = call_rtas("set-time-of-day", 7, 1, NULL,
1131 - tm.tm_year, tm.tm_mon, tm.tm_mday,
1132 - tm.tm_hour, tm.tm_min, tm.tm_sec, 0);
1133 - if (error != 0)
1134 - printk(KERN_WARNING "error: setting the clock returned: %s\n",
1135 - ppc_rtas_process_error(error));
1136 - return count;
1137 -}
1138 -/* ****************************************************************** */
1139 -static ssize_t ppc_rtas_clock_read(struct file * file, char * buf,
1140 - size_t count, loff_t *ppos)
1141 -{
1142 - unsigned int year, mon, day, hour, min, sec;
1143 - unsigned long *ret = kmalloc(4*8, GFP_KERNEL);
1144 - int n, error;
1145 -
1146 - error = call_rtas("get-time-of-day", 0, 8, ret);
1147 -
1148 - year = ret[0]; mon = ret[1]; day = ret[2];
1149 - hour = ret[3]; min = ret[4]; sec = ret[5];
1150 -
1151 - if (error != 0){
1152 - printk(KERN_WARNING "error: reading the clock returned: %s\n",
1153 - ppc_rtas_process_error(error));
1154 - n = sprintf (buf, "0");
1155 - } else {
1156 - n = sprintf (buf, "%lu\n", mktime(year, mon, day, hour, min, sec));
1157 - }
1158 - kfree(ret);
1159 -
1160 - if (*ppos >= strlen(buf))
1161 - return 0;
1162 - if (n > strlen(buf) - *ppos)
1163 - n = strlen(buf) - *ppos;
1164 - if (n > count)
1165 - n = count;
1166 - *ppos += n;
1167 - return n;
1168 -}
1169 -
1170 -/* ****************************************************************** */
1171 -/* SENSOR STUFF */
1172 -/* ****************************************************************** */
1173 -static int ppc_rtas_sensor_read(char * buf, char ** start, off_t off,
1174 - int count, int *eof, void *data)
1175 -{
1176 - int i,j,n;
1177 - unsigned long ret;
1178 - int state, error;
1179 - char buffer[MAX_LINELENGTH*MAX_SENSORS]; /* May not be enough */
1180 -
1181 - if (count < 0)
1182 - return -EINVAL;
1183 -
1184 - n = sprintf ( buffer , "RTAS (RunTime Abstraction Services) Sensor Information\n");
1185 - n += sprintf ( buffer+n, "Sensor\t\tValue\t\tCondition\tLocation\n");
1186 - n += sprintf ( buffer+n, "********************************************************\n");
1187 -
1188 - if (ppc_rtas_find_all_sensors() != 0) {
1189 - n += sprintf ( buffer+n, "\nNo sensors are available\n");
1190 - goto return_string;
1191 - }
1192 -
1193 - for (i=0; i<sensors.quant; i++) {
1194 - j = sensors.sensor[i].quant;
1195 - /* A sensor may have multiple instances */
1196 - while (j >= 0) {
1197 - error = call_rtas("get-sensor-state", 2, 2, &ret,
1198 - sensors.sensor[i].token, sensors.sensor[i].quant-j);
1199 - state = (int) ret;
1200 - n += ppc_rtas_process_sensor(sensors.sensor[i], state, error, buffer+n );
1201 - n += sprintf (buffer+n, "\n");
1202 - j--;
1203 - } /* while */
1204 - } /* for */
1205 -
1206 -return_string:
1207 - if (off >= strlen(buffer)) {
1208 - *eof = 1;
1209 - return 0;
1210 - }
1211 - if (n > strlen(buffer) - off)
1212 - n = strlen(buffer) - off;
1213 - if (n > count)
1214 - n = count;
1215 - else
1216 - *eof = 1;
1217 - memcpy(buf, buffer + off, n);
1218 - *start = buf;
1219 - return n;
1220 -}
1221 -
1222 -/* ****************************************************************** */
1223 -
1224 -int ppc_rtas_find_all_sensors (void)
1225 -{
1226 - unsigned long *utmp;
1227 - int len, i, j;
1228 -
1229 - utmp = (unsigned long *) get_property(rtas, "rtas-sensors", &len);
1230 - if (utmp == NULL) {
1231 - printk (KERN_ERR "error: could not get rtas-sensors\n");
1232 - return 1;
1233 - }
1234 -
1235 - sensors.quant = len / 8; /* int + int */
1236 -
1237 - for (i=0, j=0; j<sensors.quant; i+=2, j++) {
1238 - sensors.sensor[j].token = utmp[i];
1239 - sensors.sensor[j].quant = utmp[i+1];
1240 - }
1241 - return 0;
1242 -}
1243 -
1244 -/* ****************************************************************** */
1245 -/*
1246 - * Builds a string of what rtas returned
1247 - */
1248 -char * ppc_rtas_process_error(int error)
1249 -{
1250 - switch (error) {
1251 - case SENSOR_CRITICAL_HIGH:
1252 - return "(critical high)";
1253 - case SENSOR_WARNING_HIGH:
1254 - return "(warning high)";
1255 - case SENSOR_NORMAL:
1256 - return "(normal)";
1257 - case SENSOR_WARNING_LOW:
1258 - return "(warning low)";
1259 - case SENSOR_CRITICAL_LOW:
1260 - return "(critical low)";
1261 - case SENSOR_SUCCESS:
1262 - return "(read ok)";
1263 - case SENSOR_HW_ERROR:
1264 - return "(hardware error)";
1265 - case SENSOR_BUSY:
1266 - return "(busy)";
1267 - case SENSOR_NOT_EXIST:
1268 - return "(non existant)";
1269 - case SENSOR_DR_ENTITY:
1270 - return "(dr entity removed)";
1271 - default:
1272 - return "(UNKNOWN)";
1273 - }
1274 -}
1275 -
1276 -/* ****************************************************************** */
1277 -/*
1278 - * Builds a string out of what the sensor said
1279 - */
1280 -
1281 -int ppc_rtas_process_sensor(struct individual_sensor s, int state,
1282 - int error, char * buf)
1283 -{
1284 - /* Defined return vales */
1285 - const char * key_switch[] = { "Off\t", "Normal\t", "Secure\t", "Mainenance" };
1286 - const char * enclosure_switch[] = { "Closed", "Open" };
1287 - const char * lid_status[] = { " ", "Open", "Closed" };
1288 - const char * power_source[] = { "AC\t", "Battery", "AC & Battery" };
1289 - const char * battery_remaining[] = { "Very Low", "Low", "Mid", "High" };
1290 - const char * epow_sensor[] = {
1291 - "EPOW Reset", "Cooling warning", "Power warning",
1292 - "System shutdown", "System halt", "EPOW main enclosure",
1293 - "EPOW power off" };
1294 - const char * battery_cyclestate[] = { "None", "In progress", "Requested" };
1295 - const char * battery_charging[] = { "Charging", "Discharching", "No current flow" };
1296 - const char * ibm_drconnector[] = { "Empty", "Present" };
1297 - const char * ibm_intqueue[] = { "Disabled", "Enabled" };
1298 -
1299 - int have_strings = 0;
1300 - int temperature = 0;
1301 - int unknown = 0;
1302 - int n = 0;
1303 -
1304 - /* What kind of sensor do we have here? */
1305 - switch (s.token) {
1306 - case KEY_SWITCH:
1307 - n += sprintf(buf+n, "Key switch:\t");
1308 - n += sprintf(buf+n, "%s\t", key_switch[state]);
1309 - have_strings = 1;
1310 - break;
1311 - case ENCLOSURE_SWITCH:
1312 - n += sprintf(buf+n, "Enclosure switch:\t");
1313 - n += sprintf(buf+n, "%s\t", enclosure_switch[state]);
1314 - have_strings = 1;
1315 - break;
1316 - case THERMAL_SENSOR:
1317 - n += sprintf(buf+n, "Temp. (°C/°F):\t");
1318 - temperature = 1;
1319 - break;
1320 - case LID_STATUS:
1321 - n += sprintf(buf+n, "Lid status:\t");
1322 - n += sprintf(buf+n, "%s\t", lid_status[state]);
1323 - have_strings = 1;
1324 - break;
1325 - case POWER_SOURCE:
1326 - n += sprintf(buf+n, "Power source:\t");
1327 - n += sprintf(buf+n, "%s\t", power_source[state]);
1328 - have_strings = 1;
1329 - break;
1330 - case BATTERY_VOLTAGE:
1331 - n += sprintf(buf+n, "Battery voltage:\t");
1332 - break;
1333 - case BATTERY_REMAINING:
1334 - n += sprintf(buf+n, "Battery remaining:\t");
1335 - n += sprintf(buf+n, "%s\t", battery_remaining[state]);
1336 - have_strings = 1;
1337 - break;
1338 - case BATTERY_PERCENTAGE:
1339 - n += sprintf(buf+n, "Battery percentage:\t");
1340 - break;
1341 - case EPOW_SENSOR:
1342 - n += sprintf(buf+n, "EPOW Sensor:\t");
1343 - n += sprintf(buf+n, "%s\t", epow_sensor[state]);
1344 - have_strings = 1;
1345 - break;
1346 - case BATTERY_CYCLESTATE:
1347 - n += sprintf(buf+n, "Battery cyclestate:\t");
1348 - n += sprintf(buf+n, "%s\t", battery_cyclestate[state]);
1349 - have_strings = 1;
1350 - break;
1351 - case BATTERY_CHARGING:
1352 - n += sprintf(buf+n, "Battery Charging:\t");
1353 - n += sprintf(buf+n, "%s\t", battery_charging[state]);
1354 - have_strings = 1;
1355 - break;
1356 - case IBM_SURVEILLANCE:
1357 - n += sprintf(buf+n, "Surveillance:\t");
1358 - break;
1359 - case IBM_FANRPM:
1360 - n += sprintf(buf+n, "Fan (rpm):\t");
1361 - break;
1362 - case IBM_VOLTAGE:
1363 - n += sprintf(buf+n, "Voltage (mv):\t");
1364 - break;
1365 - case IBM_DRCONNECTOR:
1366 - n += sprintf(buf+n, "DR connector:\t");
1367 - n += sprintf(buf+n, "%s\t", ibm_drconnector[state]);
1368 - have_strings = 1;
1369 - break;
1370 - case IBM_POWERSUPPLY:
1371 - n += sprintf(buf+n, "Powersupply:\t");
1372 - break;
1373 - case IBM_INTQUEUE:
1374 - n += sprintf(buf+n, "Interrupt queue:\t");
1375 - n += sprintf(buf+n, "%s\t", ibm_intqueue[state]);
1376 - have_strings = 1;
1377 - break;
1378 - default:
1379 - n += sprintf(buf+n, "Unkown sensor (type %d), ignoring it\n",
1380 - s.token);
1381 - unknown = 1;
1382 - have_strings = 1;
1383 - break;
1384 - }
1385 - if (have_strings == 0) {
1386 - if (temperature) {
1387 - n += sprintf(buf+n, "%4d /%4d\t", state, cel_to_fahr(state));
1388 - } else
1389 - n += sprintf(buf+n, "%10d\t", state);
1390 - }
1391 - if (unknown == 0) {
1392 - n += sprintf ( buf+n, "%s\t", ppc_rtas_process_error(error));
1393 - n += get_location_code(s, buf+n);
1394 - }
1395 - return n;
1396 -}
1397 -
1398 -/* ****************************************************************** */
1399 -
1400 -int check_location (char *c, int idx, char * buf)
1401 -{
1402 - int n = 0;
1403 -
1404 - switch (*(c+idx)) {
1405 - case LOC_PLANAR:
1406 - n += sprintf ( buf, "Planar #%c", *(c+idx+1));
1407 - break;
1408 - case LOC_CPU:
1409 - n += sprintf ( buf, "CPU #%c", *(c+idx+1));
1410 - break;
1411 - case LOC_FAN:
1412 - n += sprintf ( buf, "Fan #%c", *(c+idx+1));
1413 - break;
1414 - case LOC_RACKMOUNTED:
1415 - n += sprintf ( buf, "Rack #%c", *(c+idx+1));
1416 - break;
1417 - case LOC_VOLTAGE:
1418 - n += sprintf ( buf, "Voltage #%c", *(c+idx+1));
1419 - break;
1420 - case LOC_LCD:
1421 - n += sprintf ( buf, "LCD #%c", *(c+idx+1));
1422 - break;
1423 - case '.':
1424 - n += sprintf ( buf, "- %c", *(c+idx+1));
1425 - default:
1426 - n += sprintf ( buf, "Unknown location");
1427 - break;
1428 - }
1429 - return n;
1430 -}
1431 -
1432 -
1433 -/* ****************************************************************** */
1434 -/*
1435 - * Format:
1436 - * ${LETTER}${NUMBER}[[-/]${LETTER}${NUMBER} [ ... ] ]
1437 - * the '.' may be an abbrevation
1438 - */
1439 -int check_location_string (char *c, char *buf)
1440 -{
1441 - int n=0,i=0;
1442 -
1443 - while (c[i]) {
1444 - if (isalpha(c[i]) || c[i] == '.') {
1445 - n += check_location(c, i, buf+n);
1446 - }
1447 - else if (c[i] == '/' || c[i] == '-')
1448 - n += sprintf(buf+n, " at ");
1449 - i++;
1450 - }
1451 - return n;
1452 -}
1453 -
1454 -
1455 -/* ****************************************************************** */
1456 -
1457 -int get_location_code(struct individual_sensor s, char * buffer)
1458 -{
1459 - char rstr[512], tmp[10], tmp2[10];
1460 - int n=0, i=0, llen, len;
1461 - /* char *buf = kmalloc(MAX_LINELENGTH, GFP_KERNEL); */
1462 - char *ret;
1463 -
1464 - static int pos = 0; /* remember position where buffer was */
1465 -
1466 - /* construct the sensor number like 0003 */
1467 - /* fill with zeros */
1468 - n = sprintf(tmp, "%d", s.token);
1469 - len = strlen(tmp);
1470 - while (strlen(tmp) < 4)
1471 - n += sprintf (tmp+n, "0");
1472 -
1473 - /* invert the string */
1474 - while (tmp[i]) {
1475 - if (i<len)
1476 - tmp2[4-len+i] = tmp[i];
1477 - else
1478 - tmp2[3-i] = tmp[i];
1479 - i++;
1480 - }
1481 - tmp2[4] = '\0';
1482 -
1483 - sprintf (rstr, SENSOR_PREFIX"%s", tmp2);
1484 -
1485 - ret = (char *) get_property(rtas, rstr, &llen);
1486 -
1487 - n=0;
1488 - if (ret[0] == '\0')
1489 - n += sprintf ( buffer+n, "--- ");/* does not have a location */
1490 - else {
1491 - char t[50];
1492 - ret += pos;
1493 -
1494 - n += check_location_string(ret, buffer + n);
1495 - n += sprintf ( buffer+n, " ");
1496 - /* see how many characters we have printed */
1497 - sprintf ( t, "%s ", ret);
1498 -
1499 - pos += strlen(t);
1500 - if (pos >= llen) pos=0;
1501 - }
1502 - return n;
1503 -}
1504 -/* ****************************************************************** */
1505 -/* INDICATORS - Tone Frequency */
1506 -/* ****************************************************************** */
1507 -static ssize_t ppc_rtas_tone_freq_write(struct file * file, const char * buf,
1508 - size_t count, loff_t *ppos)
1509 -{
1510 - unsigned long freq;
1511 - char *dest;
1512 - int error;
1513 - freq = simple_strtoul(buf, &dest, 10);
1514 - if (*dest != '\0' && *dest != '\n') {
1515 - printk("ppc_rtas_tone_freq_write: Invalid tone freqency\n");
1516 - return count;
1517 - }
1518 - if (freq < 0) freq = 0;
1519 - rtas_tone_frequency = freq; /* save it for later */
1520 - error = call_rtas("set-indicator", 3, 1, NULL,
1521 - TONE_FREQUENCY, 0, freq);
1522 - if (error != 0)
1523 - printk(KERN_WARNING "error: setting tone frequency returned: %s\n",
1524 - ppc_rtas_process_error(error));
1525 - return count;
1526 -}
1527 -/* ****************************************************************** */
1528 -static ssize_t ppc_rtas_tone_freq_read(struct file * file, char * buf,
1529 - size_t count, loff_t *ppos)
1530 -{
1531 - int n;
1532 - n = sprintf(buf, "%lu\n", rtas_tone_frequency);
1533 -
1534 - if (*ppos >= strlen(buf))
1535 - return 0;
1536 - if (n > strlen(buf) - *ppos)
1537 - n = strlen(buf) - *ppos;
1538 - if (n > count)
1539 - n = count;
1540 - *ppos += n;
1541 - return n;
1542 -}
1543 -/* ****************************************************************** */
1544 -/* INDICATORS - Tone Volume */
1545 -/* ****************************************************************** */
1546 -static ssize_t ppc_rtas_tone_volume_write(struct file * file, const char * buf,
1547 - size_t count, loff_t *ppos)
1548 -{
1549 - unsigned long volume;
1550 - char *dest;
1551 - int error;
1552 - volume = simple_strtoul(buf, &dest, 10);
1553 - if (*dest != '\0' && *dest != '\n') {
1554 - printk("ppc_rtas_tone_volume_write: Invalid tone volume\n");
1555 - return count;
1556 - }
1557 - if (volume < 0) volume = 0;
1558 - if (volume > 100) volume = 100;
1559 -
1560 - rtas_tone_volume = volume; /* save it for later */
1561 - error = call_rtas("set-indicator", 3, 1, NULL,
1562 - TONE_VOLUME, 0, volume);
1563 - if (error != 0)
1564 - printk(KERN_WARNING "error: setting tone volume returned: %s\n",
1565 - ppc_rtas_process_error(error));
1566 - return count;
1567 -}
1568 -/* ****************************************************************** */
1569 -static ssize_t ppc_rtas_tone_volume_read(struct file * file, char * buf,
1570 - size_t count, loff_t *ppos)
1571 -{
1572 - int n;
1573 - n = sprintf(buf, "%lu\n", rtas_tone_volume);
1574 -
1575 - if (*ppos >= strlen(buf))
1576 - return 0;
1577 - if (n > strlen(buf) - *ppos)
1578 - n = strlen(buf) - *ppos;
1579 - if (n > count)
1580 - n = count;
1581 - *ppos += n;
1582 - return n;
1583 -}
1584 +/* Dummy File as dpkg-source does not handle file deletion */
1585 diff -Nru a/arch/ppc64/kernel/lparcfg.c b/arch/ppc64/kernel/lparcfg.c
1586 --- a/arch/ppc64/kernel/lparcfg.c 2004-08-11 19:29:57 -07:00
1587 +++ b/arch/ppc64/kernel/lparcfg.c 2004-08-11 19:29:57 -07:00
1588 @@ -415,7 +415,7 @@
1589 pnt = (char *)(data) + p;
1590 copy_to_user(buf, (void *)pnt, count);
1591 read += count;
1592 - *ppos += read;
1593 + *ppos = p + read;
1594 return read;
1595 }
1596
1597 diff -Nru a/arch/ppc64/kernel/nvram.c b/arch/ppc64/kernel/nvram.c
1598 --- a/arch/ppc64/kernel/nvram.c 2004-08-11 19:29:57 -07:00
1599 +++ b/arch/ppc64/kernel/nvram.c 2004-08-11 19:29:57 -07:00
1600 @@ -78,11 +78,12 @@
1601 size_t count, loff_t *ppos)
1602 {
1603 unsigned long len;
1604 - char *tmp_buffer;
1605 + char *tmp_buffer;
1606 + loff_t pos = *ppos;
1607
1608 if (verify_area(VERIFY_WRITE, buf, count))
1609 return -EFAULT;
1610 - if (*ppos >= rtas_nvram_size)
1611 + if ((unsigned)pos != pos || pos >= rtas_nvram_size)
1612 return 0;
1613 if (count > rtas_nvram_size)
1614 count = rtas_nvram_size;
1615 @@ -93,7 +94,7 @@
1616 return 0;
1617 }
1618
1619 - len = read_nvram(tmp_buffer, count, ppos);
1620 + len = read_nvram(tmp_buffer, count, &pos);
1621 if ((long)len <= 0) {
1622 kfree(tmp_buffer);
1623 return len;
1624 @@ -105,6 +106,7 @@
1625 }
1626
1627 kfree(tmp_buffer);
1628 + *ppos = pos;
1629 return len;
1630
1631 }
1632 @@ -114,10 +116,11 @@
1633 {
1634 unsigned long len;
1635 char * tmp_buffer;
1636 + loff_t pos = *ppos;
1637
1638 if (verify_area(VERIFY_READ, buf, count))
1639 return -EFAULT;
1640 - if (*ppos >= rtas_nvram_size)
1641 + if (pos != (unsigned) pos || pos >= rtas_nvram_size)
1642 return 0;
1643 if (count > rtas_nvram_size)
1644 count = rtas_nvram_size;
1645 @@ -133,7 +136,8 @@
1646 return -EFAULT;
1647 }
1648
1649 - len = write_nvram(tmp_buffer, count, ppos);
1650 + len = write_nvram(tmp_buffer, count, &pos);
1651 + *ppos = pos;
1652
1653 kfree(tmp_buffer);
1654 return len;
1655 diff -Nru a/arch/ppc64/kernel/proc_pmc.c b/arch/ppc64/kernel/proc_pmc.c
1656 --- a/arch/ppc64/kernel/proc_pmc.c 2004-08-11 19:29:57 -07:00
1657 +++ b/arch/ppc64/kernel/proc_pmc.c 2004-08-11 19:29:57 -07:00
1658 @@ -445,8 +445,9 @@
1659 }
1660 pnt = (char *)(perfmon_base.profile_buffer) + p - sizeof(unsigned int);
1661 copy_to_user(buf,(void *)pnt,count);
1662 + p += count;
1663 read += count;
1664 - *ppos += read;
1665 + *ppos = p;
1666 return read;
1667 }
1668
1669 @@ -460,19 +461,17 @@
1670 size_t count, loff_t *ppos)
1671 {
1672 unsigned long p = *ppos;
1673 - ssize_t read;
1674 char * pnt;
1675
1676 if (p >= (perfmon_base.trace_length)) return 0;
1677 if (count > (perfmon_base.trace_length) - p)
1678 count = (perfmon_base.trace_length) - p;
1679 - read = 0;
1680
1681 pnt = (char *)(perfmon_base.trace_buffer) + p;
1682 copy_to_user(buf,(void *)pnt,count);
1683 - read += count;
1684 - *ppos += read;
1685 - return read;
1686 + p += count;
1687 + *ppos = p;
1688 + return count;
1689 }
1690
1691 static ssize_t write_trace(struct file * file, const char * buf,
1692 @@ -491,13 +490,11 @@
1693 if (p >= (perfmon_base.timeslice_length)) return 0;
1694 if (count > (perfmon_base.timeslice_length) - p)
1695 count = (perfmon_base.timeslice_length) - p;
1696 - read = 0;
1697
1698 pnt = (char *)(perfmon_base.timeslice_buffer) + p;
1699 copy_to_user(buf,(void *)pnt,count);
1700 - read += count;
1701 - *ppos += read;
1702 - return read;
1703 + *ppos = p + count;
1704 + return count;
1705 }
1706
1707 static ssize_t write_timeslice(struct file * file, const char * buf,
1708 diff -Nru a/arch/ppc64/kernel/rtas-proc.c b/arch/ppc64/kernel/rtas-proc.c
1709 --- a/arch/ppc64/kernel/rtas-proc.c 2004-08-11 19:29:57 -07:00
1710 +++ b/arch/ppc64/kernel/rtas-proc.c 2004-08-11 19:29:57 -07:00
1711 @@ -337,6 +337,7 @@
1712 {
1713 char stkbuf[40]; /* its small, its on stack */
1714 int n;
1715 + loff_t pos = *ppos;
1716
1717 if (power_on_time == 0)
1718 n = snprintf(stkbuf, 40, "Power on time not set\n");
1719 @@ -344,15 +345,15 @@
1720 n = snprintf(stkbuf, 40, "%lu\n", power_on_time);
1721
1722 int sn = strlen(stkbuf) +1;
1723 - if (*ppos >= sn)
1724 + if (pos != (unsigned)pos || pos >= sn)
1725 return 0;
1726 - if (n > sn - *ppos)
1727 - n = sn - *ppos;
1728 + if (n > sn - pos)
1729 + n = sn - pos;
1730 if (n > count)
1731 n = count;
1732 - if (copy_to_user(buf, stkbuf + (*ppos), n))
1733 + if (copy_to_user(buf, stkbuf + pos, n))
1734 return -EFAULT;
1735 - *ppos += n;
1736 + *ppos = pos + n;
1737 return n;
1738 }
1739
1740 @@ -384,6 +385,7 @@
1741 size_t count, loff_t *ppos)
1742 {
1743 int n = 0, sn;
1744 + loff_t pos = *ppos;
1745
1746 if (progress_led == NULL)
1747 return 0;
1748 @@ -396,20 +398,20 @@
1749 n = sprintf (tmpbuf, "%s\n", progress_led);
1750
1751 sn = strlen (tmpbuf) +1;
1752 - if (*ppos >= sn) {
1753 + if (pos != (unsigned)pos || pos >= sn) {
1754 kfree(tmpbuf);
1755 return 0;
1756 }
1757 - if (n > sn - *ppos)
1758 - n = sn - *ppos;
1759 + if (n > sn - pos)
1760 + n = sn - pos;
1761 if (n > count)
1762 n = count;
1763 - if (copy_to_user(buf, tmpbuf + (*ppos), n)) {
1764 + if (copy_to_user(buf, tmpbuf + pos), n) {
1765 kfree(tmpbuf);
1766 return -EFAULT;
1767 }
1768 kfree(tmpbuf);
1769 - *ppos += n;
1770 + *ppos = pos + n;
1771 return n;
1772 }
1773
1774 @@ -453,6 +455,7 @@
1775 unsigned int year, mon, day, hour, min, sec;
1776 unsigned long *ret = kmalloc(4*8, GFP_KERNEL);
1777 int n, error;
1778 + loff_t pos = *ppos;
1779
1780 error = rtas_call(rtas_token("get-time-of-day"), 0, 8, ret);
1781
1782 @@ -471,16 +474,16 @@
1783 kfree(ret);
1784
1785 int sn = strlen(stkbuf) +1;
1786 - if (*ppos >= sn)
1787 + if (pos != (unsigned)pos || pos >= sn)
1788 return 0;
1789 - if (n > sn - *ppos)
1790 - n = sn - *ppos;
1791 + if (n > sn - pos)
1792 + n = sn - pos;
1793 if (n > count)
1794 n = count;
1795 - if (copy_to_user(buf, stkbuf + (*ppos), n))
1796 + if (copy_to_user(buf, stkbuf + pos, n))
1797 return -EFAULT;
1798
1799 - *ppos += n;
1800 + *ppos = pos + n;
1801 return n;
1802 }
1803
1804 @@ -878,20 +881,21 @@
1805 {
1806 int n, sn;
1807 char stkbuf[40]; /* its small, its on stack */
1808 + loff_t pos = *ppos;
1809
1810 n = snprintf(stkbuf, 40, "%lu\n", rtas_tone_frequency);
1811
1812 sn = strlen(stkbuf) +1;
1813 - if (*ppos >= sn)
1814 + if (pos != (unsigned)pos || pos >= sn)
1815 return 0;
1816 - if (n > sn - *ppos)
1817 - n = sn - *ppos;
1818 + if (n > sn - pos)
1819 + n = sn - pos;
1820 if (n > count)
1821 n = count;
1822 - if (copy_to_user(buf, stkbuf + (*ppos), n))
1823 + if (copy_to_user(buf, stkbuf + pos, n))
1824 return -EFAULT;
1825
1826 - *ppos += n;
1827 + *ppos = pos + n;
1828 return n;
1829 }
1830 /* ****************************************************************** */
1831 @@ -933,19 +937,20 @@
1832 {
1833 int n, sn;
1834 char stkbuf[40]; /* its small, its on stack */
1835 + loff_t pos = *ppos;
1836
1837 n = snprintf(stkbuf, 40, "%lu\n", rtas_tone_volume);
1838 sn = strlen(stkbuf) +1;
1839 - if (*ppos >= sn)
1840 + if (pos != (unsigned)pos || pos >= sn)
1841 return 0;
1842 - if (n > sn - *ppos)
1843 - n = sn - *ppos;
1844 + if (n > sn - pos)
1845 + n = sn - pos;
1846 if (n > count)
1847 n = count;
1848 - if (copy_to_user(buf, stkbuf + (*ppos), n))
1849 + if (copy_to_user(buf, stkbuf + pos, n))
1850 return -EFAULT;
1851
1852 - *ppos += n;
1853 + *ppos = pos + n;
1854 return n;
1855 }
1856
1857 @@ -1064,6 +1069,7 @@
1858 char * buffer;
1859 int i, sn;
1860 int n = 0;
1861 + loff_t pos = *ppos;
1862
1863 int m = MAX_ERRINJCT_TOKENS * (ERRINJCT_TOKEN_LEN+1);
1864 buffer = (char *)kmalloc(m, GFP_KERNEL);
1865 @@ -1078,22 +1084,22 @@
1866 }
1867
1868 sn = strlen(buffer) +1;
1869 - if (*ppos >= sn) {
1870 + if (pos != (unsigned)pos || pos >= sn) {
1871 kfree(buffer);
1872 return 0;
1873 }
1874 - if (n > sn - *ppos)
1875 - n = sn - *ppos;
1876 + if (n > sn - pos)
1877 + n = sn - pos;
1878
1879 if (n > count)
1880 n = count;
1881
1882 - if (copy_to_user(buf, buffer + *ppos, n)) {
1883 + if (copy_to_user(buf, buffer + pos, n)) {
1884 kfree(buffer);
1885 return -EFAULT;
1886 }
1887
1888 - *ppos += n;
1889 + *ppos = pos + n;
1890
1891 kfree(buffer);
1892 return n;
1893 diff -Nru a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
1894 --- a/arch/s390/kernel/debug.c 2004-08-11 19:29:57 -07:00
1895 +++ b/arch/s390/kernel/debug.c 2004-08-11 19:29:57 -07:00
1896 @@ -470,8 +470,8 @@
1897 goto out;
1898 }
1899 out:
1900 - p_info->offset = *offset + count;
1901 - p_info->act_entry_offset = size;
1902 + p_info->offset += count;
1903 + p_info->act_entry_offset = size;
1904 *offset = p_info->offset;
1905 return count;
1906 }
1907 @@ -1068,7 +1068,7 @@
1908 input_buf[0]);
1909 }
1910 out:
1911 - *offset += in_buf_size;
1912 + *offset = in_buf_size;
1913 return rc; /* number of input characters */
1914 }
1915
1916 @@ -1135,7 +1135,7 @@
1917 printk(KERN_INFO "debug: area `%c` is not valid\n", input_buf[0]);
1918
1919 out:
1920 - *offset += in_buf_size;
1921 + *offset = in_buf_size;
1922 return rc; /* number of input characters */
1923 }
1924
1925 diff -Nru a/arch/s390x/kernel/debug.c b/arch/s390x/kernel/debug.c
1926 --- a/arch/s390x/kernel/debug.c 2004-08-11 19:29:57 -07:00
1927 +++ b/arch/s390x/kernel/debug.c 2004-08-11 19:29:57 -07:00
1928 @@ -470,7 +470,7 @@
1929 goto out;
1930 }
1931 out:
1932 - p_info->offset = *offset + count;
1933 + p_info->offset += count;
1934 p_info->act_entry_offset = size;
1935 *offset = p_info->offset;
1936 return count;
1937 @@ -1068,7 +1068,7 @@
1938 input_buf[0]);
1939 }
1940 out:
1941 - *offset += in_buf_size;
1942 + *offset = in_buf_size;
1943 return rc; /* number of input characters */
1944 }
1945
1946 @@ -1135,7 +1135,7 @@
1947 printk(KERN_INFO "debug: area `%c` is not valid\n", input_buf[0]);
1948
1949 out:
1950 - *offset += in_buf_size;
1951 + *offset = in_buf_size;
1952 return rc; /* number of input characters */
1953 }
1954
1955 diff -Nru a/arch/x86_64/kernel/mtrr.c b/arch/x86_64/kernel/mtrr.c
1956 --- a/arch/x86_64/kernel/mtrr.c 2004-08-11 19:29:57 -07:00
1957 +++ b/arch/x86_64/kernel/mtrr.c 2004-08-11 19:29:57 -07:00
1958 @@ -961,16 +961,19 @@
1959 static ssize_t mtrr_read (struct file *file, char *buf, size_t len,
1960 loff_t * ppos)
1961 {
1962 - if (*ppos >= ascii_buf_bytes)
1963 + loff_t n = *ppos;
1964 + unsigned pos = n;
1965 +
1966 + if (pos != n || pos >= ascii_buf_bytes)
1967 return 0;
1968
1969 - if (*ppos + len > ascii_buf_bytes)
1970 - len = ascii_buf_bytes - *ppos;
1971 + if (len > ascii_buf_bytes - pos)
1972 + len = ascii_buf_bytes - pos;
1973
1974 - if (copy_to_user (buf, ascii_buffer + *ppos, len))
1975 + if (copy_to_user (buf, ascii_buffer + pos, len))
1976 return -EFAULT;
1977
1978 - *ppos += len;
1979 + *ppos = pos + len;
1980 return len;
1981 }
1982
1983 diff -Nru a/drivers/block/acsi_slm.c b/drivers/block/acsi_slm.c
1984 --- a/drivers/block/acsi_slm.c 2004-08-11 19:29:57 -07:00
1985 +++ b/drivers/block/acsi_slm.c 2004-08-11 19:29:57 -07:00
1986 @@ -367,6 +367,7 @@
1987
1988 {
1989 struct inode *node = file->f_dentry->d_inode;
1990 + loff_t pos = *ppos;
1991 unsigned long page;
1992 int length;
1993 int end;
1994 @@ -381,18 +382,18 @@
1995 count = length;
1996 goto out;
1997 }
1998 - if (file->f_pos >= length) {
1999 + if (pos != (unsigned) pos || pos >= length) {
2000 count = 0;
2001 goto out;
2002 }
2003 - if (count + file->f_pos > length)
2004 - count = length - file->f_pos;
2005 - end = count + file->f_pos;
2006 - if (copy_to_user(buf, (char *)page + file->f_pos, count)) {
2007 + if (count > length - pos)
2008 + count = length - pos;
2009 + end = count + pos;
2010 + if (copy_to_user(buf, (char *)page + pos, count)) {
2011 count = -EFAULT;
2012 goto out;
2013 }
2014 - file->f_pos = end;
2015 + *ppos = end;
2016 out: free_page( page );
2017 return( count );
2018 }
2019 diff -Nru a/drivers/block/rd.c b/drivers/block/rd.c
2020 --- a/drivers/block/rd.c 2004-08-11 19:29:57 -07:00
2021 +++ b/drivers/block/rd.c 2004-08-11 19:29:57 -07:00
2022 @@ -320,14 +320,19 @@
2023 static ssize_t initrd_read(struct file *file, char *buf,
2024 size_t count, loff_t *ppos)
2025 {
2026 - int left;
2027 + loff_t n = *ppos;
2028 + unsigned pos = n;
2029 + unsigned left = initrd_end - initrd_start;
2030
2031 - left = initrd_end - initrd_start - *ppos;
2032 + if (pos != n || pos >= left)
2033 + return 0;
2034 +
2035 + left -= pos;
2036 if (count > left) count = left;
2037 if (count == 0) return 0;
2038 - if (copy_to_user(buf, (char *)initrd_start + *ppos, count))
2039 + if (copy_to_user(buf, (char *)initrd_start + pos, count))
2040 return -EFAULT;
2041 - *ppos += count;
2042 + *ppos = pos + count;
2043 return count;
2044 }
2045
2046 diff -Nru a/drivers/char/i8k.c b/drivers/char/i8k.c
2047 --- a/drivers/char/i8k.c 2004-08-11 19:29:57 -07:00
2048 +++ b/drivers/char/i8k.c 2004-08-11 19:29:57 -07:00
2049 @@ -493,6 +493,7 @@
2050
2051 static ssize_t i8k_read(struct file *f, char *buffer, size_t len, loff_t *fpos)
2052 {
2053 + loff_t pos = *fpos;
2054 int n;
2055 char info[128];
2056
2057 @@ -501,19 +502,19 @@
2058 return n;
2059 }
2060
2061 - if (*fpos >= n) {
2062 + if (pos != (unsigned)pos || pos >= n) {
2063 return 0;
2064 }
2065
2066 - if ((*fpos + len) >= n) {
2067 - len = n - *fpos;
2068 + if (len >= n - pos) {
2069 + len = n - pos;
2070 }
2071
2072 if (copy_to_user(buffer, info, len) != 0) {
2073 return -EFAULT;
2074 }
2075
2076 - *fpos += len;
2077 + *fpos = pos + len;
2078 return len;
2079 }
2080
2081 diff -Nru a/drivers/char/istallion.c b/drivers/char/istallion.c
2082 --- a/drivers/char/istallion.c 2004-08-11 19:29:57 -07:00
2083 +++ b/drivers/char/istallion.c 2004-08-11 19:29:57 -07:00
2084 @@ -4854,6 +4854,7 @@
2085 void *memptr;
2086 stlibrd_t *brdp;
2087 int brdnr, size, n;
2088 + loff_t pos = *offp;
2089
2090 #if DEBUG
2091 printk(KERN_DEBUG "stli_memread(fp=%x,buf=%x,count=%x,offp=%x)\n",
2092 @@ -4868,25 +4869,26 @@
2093 return(-ENODEV);
2094 if (brdp->state == 0)
2095 return(-ENODEV);
2096 - if (fp->f_pos >= brdp->memsize)
2097 + if (pos != (unsigned)pos || pos >= brdp->memsize)
2098 return(0);
2099
2100 - size = MIN(count, (brdp->memsize - fp->f_pos));
2101 + size = MIN(count, (brdp->memsize - pos));
2102
2103 save_flags(flags);
2104 cli();
2105 EBRDENABLE(brdp);
2106 while (size > 0) {
2107 - memptr = (void *) EBRDGETMEMPTR(brdp, fp->f_pos);
2108 - n = MIN(size, (brdp->pagesize - (((unsigned long) fp->f_pos) % brdp->pagesize)));
2109 + memptr = (void *) EBRDGETMEMPTR(brdp, pos);
2110 + n = MIN(size, (brdp->pagesize - (((unsigned long) pos) % brdp->pagesize)));
2111 if (copy_to_user(buf, memptr, n)) {
2112 count = -EFAULT;
2113 goto out;
2114 }
2115 - fp->f_pos += n;
2116 + pos += n;
2117 buf += n;
2118 size -= n;
2119 }
2120 + *offp = pos;
2121 out:
2122 EBRDDISABLE(brdp);
2123 restore_flags(flags);
2124 @@ -4909,6 +4911,7 @@
2125 stlibrd_t *brdp;
2126 char *chbuf;
2127 int brdnr, size, n;
2128 + loff_t pos = *offp;
2129
2130 #if DEBUG
2131 printk(KERN_DEBUG "stli_memwrite(fp=%x,buf=%x,count=%x,offp=%x)\n",
2132 @@ -4923,26 +4926,27 @@
2133 return(-ENODEV);
2134 if (brdp->state == 0)
2135 return(-ENODEV);
2136 - if (fp->f_pos >= brdp->memsize)
2137 + if (pos != (unsigned)pos || pos >= brdp->memsize)
2138 return(0);
2139
2140 chbuf = (char *) buf;
2141 - size = MIN(count, (brdp->memsize - fp->f_pos));
2142 + size = MIN(count, (brdp->memsize - pos));
2143
2144 save_flags(flags);
2145 cli();
2146 EBRDENABLE(brdp);
2147 while (size > 0) {
2148 - memptr = (void *) EBRDGETMEMPTR(brdp, fp->f_pos);
2149 - n = MIN(size, (brdp->pagesize - (((unsigned long) fp->f_pos) % brdp->pagesize)));
2150 + memptr = (void *) EBRDGETMEMPTR(brdp, pos);
2151 + n = MIN(size, (brdp->pagesize - (((unsigned long) pos) % brdp->pagesize)));
2152 if (copy_from_user(memptr, chbuf, n)) {
2153 count = -EFAULT;
2154 goto out;
2155 }
2156 - fp->f_pos += n;
2157 + pos += n;
2158 chbuf += n;
2159 size -= n;
2160 }
2161 + *offp = pos;
2162 out:
2163 EBRDDISABLE(brdp);
2164 restore_flags(flags);
2165 diff -Nru a/drivers/char/mem.c b/drivers/char/mem.c
2166 --- a/drivers/char/mem.c 2004-08-11 19:29:57 -07:00
2167 +++ b/drivers/char/mem.c 2004-08-11 19:29:57 -07:00
2168 @@ -64,7 +64,7 @@
2169 if (copy_from_user(p, buf, count))
2170 return -EFAULT;
2171 written += count;
2172 - *ppos += written;
2173 + *ppos = realp + written;
2174 return written;
2175 }
2176
2177 @@ -105,7 +105,7 @@
2178 if (copy_to_user(buf, __va(p), count))
2179 return -EFAULT;
2180 read += count;
2181 - *ppos += read;
2182 + *ppos = p + read;
2183 return read;
2184 }
2185
2186 diff -Nru a/drivers/char/nvram.c b/drivers/char/nvram.c
2187 --- a/drivers/char/nvram.c 2004-08-11 19:29:57 -07:00
2188 +++ b/drivers/char/nvram.c 2004-08-11 19:29:57 -07:00
2189 @@ -252,9 +252,13 @@
2190 nvram_read(struct file *file, char *buf, size_t count, loff_t *ppos)
2191 {
2192 unsigned char contents[NVRAM_BYTES];
2193 - unsigned i = *ppos;
2194 + loff_t n = *ppos;
2195 + unsigned i = n;
2196 unsigned char *tmp;
2197
2198 + if (i != n || i >= NVRAM_BYTES)
2199 + return 0;
2200 +
2201 spin_lock_irq(&rtc_lock);
2202
2203 if (!__nvram_check_checksum())
2204 @@ -281,9 +285,13 @@
2205 nvram_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
2206 {
2207 unsigned char contents[NVRAM_BYTES];
2208 - unsigned i = *ppos;
2209 + loff_t n = *ppos;
2210 + unsigned i = n;
2211 unsigned char *tmp;
2212 int len;
2213 +
2214 + if (i != n || i >= NVRAM_BYTES)
2215 + return 0;
2216
2217 len = (NVRAM_BYTES - i) < count ? (NVRAM_BYTES - i) : count;
2218 if (copy_from_user(contents, buf, len))
2219 diff -Nru a/drivers/char/nwflash.c b/drivers/char/nwflash.c
2220 --- a/drivers/char/nwflash.c 2004-08-11 19:29:57 -07:00
2221 +++ b/drivers/char/nwflash.c 2004-08-11 19:29:57 -07:00
2222 @@ -133,7 +133,8 @@
2223
2224 static ssize_t flash_read(struct file *file, char *buf, size_t size, loff_t * ppos)
2225 {
2226 - unsigned long p = *ppos;
2227 + loff_t n = *ppos;
2228 + unsigned long p = n;
2229 unsigned int count = size;
2230 int ret = 0;
2231
2232 @@ -144,7 +145,7 @@
2233 if (count)
2234 ret = -ENXIO;
2235
2236 - if (p < gbFlashSize) {
2237 + if (n == p && p < gbFlashSize) {
2238 if (count > gbFlashSize - p)
2239 count = gbFlashSize - p;
2240
2241 @@ -157,7 +158,7 @@
2242 ret = copy_to_user(buf, (void *)(FLASH_BASE + p), count);
2243 if (ret == 0) {
2244 ret = count;
2245 - *ppos += count;
2246 + *ppos = p + count;
2247 }
2248 up(&nwflash_sem);
2249 }
2250 @@ -166,7 +167,8 @@
2251
2252 static ssize_t flash_write(struct file *file, const char *buf, size_t size, loff_t * ppos)
2253 {
2254 - unsigned long p = *ppos;
2255 + loff_t n = *ppos;
2256 + unsigned long p = n;
2257 unsigned int count = size;
2258 int written;
2259 int nBlock, temp, rc;
2260 @@ -185,7 +187,7 @@
2261 /*
2262 * check for out of range pos or count
2263 */
2264 - if (p >= gbFlashSize)
2265 + if (p != n || p >= gbFlashSize)
2266 return count ? -ENXIO : 0;
2267
2268 if (count > gbFlashSize - p)
2269 @@ -274,7 +276,7 @@
2270 p += rc;
2271 buf += rc;
2272 written += rc;
2273 - *ppos += rc;
2274 + *ppos = p;
2275
2276 if (flashdebug)
2277 printk(KERN_DEBUG "flash_write: written 0x%X bytes OK.\n", written);
2278 diff -Nru a/drivers/char/raw.c b/drivers/char/raw.c
2279 --- a/drivers/char/raw.c 2004-08-11 19:29:57 -07:00
2280 +++ b/drivers/char/raw.c 2004-08-11 19:29:57 -07:00
2281 @@ -301,6 +301,7 @@
2282 int minor;
2283 kdev_t dev;
2284 unsigned long limit;
2285 + loff_t off = *offp;
2286
2287 int sector_size, sector_bits, sector_mask;
2288 int max_sectors;
2289 @@ -338,12 +339,12 @@
2290 MAJOR(dev), MINOR(dev), limit);
2291
2292 err = -EINVAL;
2293 - if ((*offp & sector_mask) || (size & sector_mask))
2294 + if ((off & sector_mask) || (size & sector_mask))
2295 goto out_free;
2296 err = 0;
2297 if (size)
2298 err = -ENXIO;
2299 - if ((*offp >> sector_bits) >= limit)
2300 + if ((off >> sector_bits) >= limit)
2301 goto out_free;
2302
2303 /*
2304 @@ -353,7 +354,7 @@
2305 */
2306
2307 transferred = 0;
2308 - blocknr = *offp >> sector_bits;
2309 + blocknr = off >> sector_bits;
2310 while (size > 0) {
2311 blocks = size >> sector_bits;
2312 if (blocks > max_sectors)
2313 @@ -390,7 +391,7 @@
2314 }
2315
2316 if (transferred) {
2317 - *offp += transferred;
2318 + *offp = off + transferred;
2319 err = transferred;
2320 }
2321
2322 diff -Nru a/drivers/char/tpqic02.c b/drivers/char/tpqic02.c
2323 --- a/drivers/char/tpqic02.c 2004-08-11 19:29:57 -07:00
2324 +++ b/drivers/char/tpqic02.c 2004-08-11 19:29:57 -07:00
2325 @@ -1818,6 +1818,7 @@
2326 kdev_t dev = filp->f_dentry->d_inode->i_rdev;
2327 unsigned short flags = filp->f_flags;
2328 unsigned long bytes_todo, bytes_done, total_bytes_done = 0;
2329 + loff_t pos = *ppos;
2330 int stat;
2331
2332 if (status_zombie == YES) {
2333 @@ -1898,6 +1899,7 @@
2334
2335 /*****************************/
2336 if (bytes_todo == 0) {
2337 + *ppos = pos;
2338 return total_bytes_done;
2339 }
2340
2341 @@ -1966,7 +1968,7 @@
2342 if (bytes_done > 0) {
2343 status_bytes_rd = YES;
2344 buf += bytes_done;
2345 - *ppos += bytes_done;
2346 + pos += bytes_done;
2347 total_bytes_done += bytes_done;
2348 count -= bytes_done;
2349 }
2350 diff -Nru a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
2351 --- a/drivers/char/vc_screen.c 2004-08-11 19:29:57 -07:00
2352 +++ b/drivers/char/vc_screen.c 2004-08-11 19:29:57 -07:00
2353 @@ -64,12 +64,25 @@
2354 return size;
2355 }
2356
2357 +/* We share this temporary buffer with the console write code
2358 + * so that we can easily avoid touching user space while holding the
2359 + * console spinlock.
2360 + */
2361 +extern char con_buf[PAGE_SIZE];
2362 +#define CON_BUF_SIZE PAGE_SIZE
2363 +extern struct semaphore con_buf_sem;
2364 +
2365 static loff_t vcs_lseek(struct file *file, loff_t offset, int orig)
2366 {
2367 - int size = vcs_size(file->f_dentry->d_inode);
2368 + int size;
2369 +
2370 + down(&con_buf_sem);
2371 +
2372 + size = vcs_size(file->f_dentry->d_inode);
2373
2374 switch (orig) {
2375 default:
2376 + up(&con_buf_sem);
2377 return -EINVAL;
2378 case 2:
2379 offset += size;
2380 @@ -79,26 +92,22 @@
2381 case 0:
2382 break;
2383 }
2384 - if (offset < 0 || offset > size)
2385 + if (offset < 0 || offset > size) {
2386 + up(&con_buf_sem);
2387 return -EINVAL;
2388 + }
2389 file->f_pos = offset;
2390 + up (&con_buf_sem);
2391 return file->f_pos;
2392 }
2393
2394 -/* We share this temporary buffer with the console write code
2395 - * so that we can easily avoid touching user space while holding the
2396 - * console spinlock.
2397 - */
2398 -extern char con_buf[PAGE_SIZE];
2399 -#define CON_BUF_SIZE PAGE_SIZE
2400 -extern struct semaphore con_buf_sem;
2401 -
2402 static ssize_t
2403 vcs_read(struct file *file, char *buf, size_t count, loff_t *ppos)
2404 {
2405 struct inode *inode = file->f_dentry->d_inode;
2406 unsigned int currcons = MINOR(inode->i_rdev);
2407 - long pos = *ppos;
2408 + loff_t n;
2409 + unsigned pos;
2410 long viewed, attr, read;
2411 int col, maxcol;
2412 unsigned short *org = NULL;
2413 @@ -106,6 +115,9 @@
2414
2415 down(&con_buf_sem);
2416
2417 + n = *ppos;
2418 + pos = n;
2419 +
2420 /* Select the proper current console and verify
2421 * sanity of the situation under the console lock.
2422 */
2423 @@ -124,11 +136,10 @@
2424 if (!vc_cons_allocated(currcons))
2425 goto unlock_out;
2426
2427 - ret = -EINVAL;
2428 - if (pos < 0)
2429 - goto unlock_out;
2430 read = 0;
2431 ret = 0;
2432 + if (pos != n)
2433 + goto unlock_out;
2434 while (count) {
2435 char *con_buf0, *con_buf_start;
2436 long this_round, size;
2437 @@ -244,16 +255,15 @@
2438 acquire_console_sem();
2439
2440 if (ret) {
2441 - read += (orig_count - ret);
2442 ret = -EFAULT;
2443 - break;
2444 + goto unlock_out;
2445 }
2446 buf += orig_count;
2447 pos += orig_count;
2448 read += orig_count;
2449 count -= orig_count;
2450 }
2451 - *ppos += read;
2452 + *ppos = pos;
2453 if (read)
2454 ret = read;
2455 unlock_out:
2456 @@ -267,7 +277,8 @@
2457 {
2458 struct inode *inode = file->f_dentry->d_inode;
2459 unsigned int currcons = MINOR(inode->i_rdev);
2460 - long pos = *ppos;
2461 + loff_t n;
2462 + unsigned pos;
2463 long viewed, attr, size, written;
2464 char *con_buf0;
2465 int col, maxcol;
2466 @@ -276,6 +287,9 @@
2467
2468 down(&con_buf_sem);
2469
2470 + n = *ppos;
2471 + pos = n;
2472 +
2473 /* Select the proper current console and verify
2474 * sanity of the situation under the console lock.
2475 */
2476 @@ -297,7 +311,7 @@
2477
2478 size = vcs_size(inode);
2479 ret = -EINVAL;
2480 - if (pos < 0 || pos > size)
2481 + if (pos != n || pos > size)
2482 goto unlock_out;
2483 if (count > size - pos)
2484 count = size - pos;
2485 @@ -435,7 +449,7 @@
2486 if (org0)
2487 update_region(currcons, (unsigned long)(org0), org-org0);
2488 }
2489 - *ppos += written;
2490 + *ppos = pos;
2491 ret = written;
2492
2493 unlock_out:
2494 diff -Nru a/drivers/gsc/eisa_eeprom.c b/drivers/gsc/eisa_eeprom.c
2495 --- a/drivers/gsc/eisa_eeprom.c 2004-08-11 19:29:57 -07:00
2496 +++ b/drivers/gsc/eisa_eeprom.c 2004-08-11 19:29:57 -07:00
2497 @@ -34,24 +34,30 @@
2498 unsigned char *tmp;
2499 ssize_t ret;
2500 int i;
2501 + loff_t n = *ppos;
2502 + unsigned pos = n;
2503
2504 - if (*ppos >= HPEE_MAX_LENGTH)
2505 + if (n != pos || pos >= HPEE_MAX_LENGTH)
2506 return 0;
2507
2508 - count = *ppos + count < HPEE_MAX_LENGTH ? count : HPEE_MAX_LENGTH - *ppos;
2509 + if (count > HPEE_MAX_LENGTH - pos)
2510 + count = HPEE_MAX_LENGTH - pos;
2511 +
2512 tmp = kmalloc(count, GFP_KERNEL);
2513 if (tmp) {
2514 for (i = 0; i < count; i++)
2515 - tmp[i] = gsc_readb(eeprom_addr+(*ppos)++);
2516 + tmp[i] = gsc_readb(eeprom_addr+(pos)++);
2517
2518 if (copy_to_user (buf, tmp, count))
2519 ret = -EFAULT;
2520 - else
2521 + else {
2522 ret = count;
2523 + *ppos = pos;
2524 + }
2525 kfree (tmp);
2526 } else
2527 ret = -ENOMEM;
2528 -
2529 +
2530 return ret;
2531 }
2532
2533 --- a/drivers/ieee1394/pcilynx.c 2004-08-11 19:29:57 -07:00
2534 +++ b/drivers/ieee1394/pcilynx.c 2004-08-11 19:29:57 -07:00
2535 @@ -1065,12 +1065,15 @@
2536 ssize_t retval;
2537 void *membase;
2538
2539 - if ((off + count) > PCILYNX_MAX_MEMORY+1) {
2540 - count = PCILYNX_MAX_MEMORY+1 - off;
2541 - }
2542 - if (count == 0 || off > PCILYNX_MAX_MEMORY) {
2543 + if (!count)
2544 + return 0;
2545 + if (off < 0)
2546 + return -EINVAL;
2547 + if (off > PCILYNX_MAX_MEMORY)
2548 return -ENOSPC;
2549 - }
2550 +
2551 + if (count > PCILYNX_MAX_MEMORY + 1 - off)
2552 + count = PCILYNX_MAX_MEMORY + 1 - off;
2553
2554 switch (md->type) {
2555 case rom:
2556 @@ -1091,6 +1094,7 @@
2557
2558 if (count < mem_mindma) {
2559 memcpy_fromio(md->lynx->mem_dma_buffer, membase+off, count);
2560 + off += count;
2561 goto out;
2562 }
2563
2564 @@ -1121,6 +1125,7 @@
2565 if (bcount) {
2566 memcpy_fromio(md->lynx->mem_dma_buffer + count - bcount,
2567 membase+off, bcount);
2568 + off += bcount;
2569 }
2570
2571 out:
2572 @@ -1128,7 +1133,7 @@
2573 up(&md->lynx->mem_dma_mutex);
2574
2575 if (retval) return -EFAULT;
2576 - *offset += count;
2577 + *offset = off;
2578 return count;
2579 }
2580
2581 @@ -1137,32 +1142,36 @@
2582 loff_t *offset)
2583 {
2584 struct memdata *md = (struct memdata *)file->private_data;
2585 + loff_t off = *offset;
2586
2587 - if (((*offset) + count) > PCILYNX_MAX_MEMORY+1) {
2588 - count = PCILYNX_MAX_MEMORY+1 - *offset;
2589 - }
2590 - if (count == 0 || *offset > PCILYNX_MAX_MEMORY) {
2591 - return -ENOSPC;
2592 - }
2593 + if (!count)
2594 + return 0;
2595 + if (off < 0)
2596 + return -EINVAL;
2597 + if (off > PCILYNX_MAX_MEMORY)
2598 + return -ENOSPC;
2599 +
2600 + if (count > PCILYNX_MAX_MEMORY + 1 - off)
2601 + count = PCILYNX_MAX_MEMORY + 1 - off;
2602
2603 /* FIXME: dereferencing pointers to PCI mem doesn't work everywhere */
2604 switch (md->type) {
2605 case aux:
2606 - if (copy_from_user(md->lynx->aux_port+(*offset), buffer, count))
2607 + if (copy_from_user(md->lynx->aux_port+off, buffer, count))
2608 return -EFAULT;
2609 break;
2610 case ram:
2611 - if (copy_from_user(md->lynx->local_ram+(*offset), buffer, count))
2612 + if (copy_from_user(md->lynx->local_ram+off, buffer, count))
2613 return -EFAULT;
2614 break;
2615 case rom:
2616 /* the ROM may be writeable */
2617 - if (copy_from_user(md->lynx->local_rom+(*offset), buffer, count))
2618 + if (copy_from_user(md->lynx->local_rom+off, buffer, count))
2619 return -EFAULT;
2620 break;
2621 }
2622
2623 - file->f_pos += count;
2624 + *offset = off + count;
2625 return count;
2626 }
2627 #endif /* CONFIG_IEEE1394_PCILYNX_PORTS */
2628 --- a/drivers/hotplug/pci_hotplug_core.c Sat Nov 29 03:26:20 2003
2629 +++ b/drivers/hotplug/pci_hotplug_core.c Thu Aug 12 11:42:03 2004
2630 @@ -604,7 +604,7 @@
2631 retval = -EFAULT;
2632 goto exit;
2633 }
2634 - *offset += len;
2635 + *offset = len;
2636 retval = len;
2637
2638 exit:
2639 @@ -715,7 +715,7 @@
2640 retval = -EFAULT;
2641 goto exit;
2642 }
2643 - *offset += len;
2644 + *offset = len;
2645 retval = len;
2646
2647 exit:
2648 @@ -780,14 +780,15 @@
2649 int retval;
2650 int len;
2651 u8 value;
2652 + loff_t off = *offset;
2653
2654 - dbg("count = %d, offset = %lld\n", count, *offset);
2655 + dbg("count = %d, offset = %lld\n", count, off);
2656
2657 - if (*offset < 0)
2658 + if (off < 0)
2659 return -EINVAL;
2660 if (count <= 0)
2661 return 0;
2662 - if (*offset != 0)
2663 + if (off != 0)
2664 return 0;
2665
2666 if (slot == NULL) {
2667 @@ -808,7 +809,7 @@
2668 retval = -EFAULT;
2669 goto exit;
2670 }
2671 - *offset += len;
2672 + *offset = off + len;
2673 retval = len;
2674
2675 exit:
2676 @@ -823,14 +824,15 @@
2677 int retval;
2678 int len;
2679 u8 value;
2680 + loff_t off = *offset;
2681
2682 dbg("count = %d, offset = %lld\n", count, *offset);
2683
2684 - if (*offset < 0)
2685 + if (off < 0)
2686 return -EINVAL;
2687 if (count <= 0)
2688 return 0;
2689 - if (*offset != 0)
2690 + if (off != 0)
2691 return 0;
2692
2693 if (slot == NULL) {
2694 @@ -851,7 +853,7 @@
2695 retval = -EFAULT;
2696 goto exit;
2697 }
2698 - *offset += len;
2699 + *offset = off + len;
2700 retval = len;
2701
2702 exit:
2703 @@ -869,14 +871,15 @@
2704 int retval;
2705 int len = 0;
2706 enum pci_bus_speed value;
2707 + loff_t off = *offset;
2708
2709 - dbg ("count = %d, offset = %lld\n", count, *offset);
2710 + dbg ("count = %d, offset = %lld\n", count, off);
2711
2712 - if (*offset < 0)
2713 + if (off < 0)
2714 return -EINVAL;
2715 if (count <= 0)
2716 return 0;
2717 - if (*offset != 0)
2718 + if (off != 0)
2719 return 0;
2720
2721 if (slot == NULL) {
2722 @@ -903,7 +906,7 @@
2723 retval = -EFAULT;
2724 goto exit;
2725 }
2726 - *offset += len;
2727 + *offset = off + len;
2728 retval = len;
2729
2730 exit:
2731 @@ -919,14 +922,15 @@
2732 int retval;
2733 int len = 0;
2734 enum pci_bus_speed value;
2735 + loff_t off = *offset;
2736
2737 - dbg ("count = %d, offset = %lld\n", count, *offset);
2738 + dbg ("count = %d, offset = %lld\n", count, off);
2739
2740 - if (*offset < 0)
2741 + if (off < 0)
2742 return -EINVAL;
2743 if (count <= 0)
2744 return 0;
2745 - if (*offset != 0)
2746 + if (off != 0)
2747 return 0;
2748
2749 if (slot == NULL) {
2750 @@ -953,7 +957,7 @@
2751 retval = -EFAULT;
2752 goto exit;
2753 }
2754 - *offset += len;
2755 + *offset = off + len;
2756 retval = len;
2757
2758 exit:
2759 @@ -968,12 +972,15 @@
2760 unsigned long ltest;
2761 u32 test;
2762 int retval = 0;
2763 + loff_t off = *offset;
2764
2765 - if (*offset < 0)
2766 + dbg ("count = %d, offset = %lld\n", count, off);
2767 +
2768 + if (off < 0)
2769 return -EINVAL;
2770 if (count == 0 || count > 16384)
2771 return 0;
2772 - if (*offset != 0)
2773 + if (off != 0)
2774 return 0;
2775
2776 if (slot == NULL) {
2777 diff -Nru a/drivers/isdn/divert/divert_procfs.c b/drivers/isdn/divert/divert_procfs.c
2778 --- a/drivers/isdn/divert/divert_procfs.c 2004-08-11 19:29:57 -07:00
2779 +++ b/drivers/isdn/divert/divert_procfs.c 2004-08-11 19:29:57 -07:00
2780 @@ -80,6 +80,7 @@
2781 isdn_divert_read(struct file *file, char *buf, size_t count, loff_t * off)
2782 {
2783 struct divert_info *inf;
2784 + loff_t pos = *off;
2785 int len;
2786
2787 if (!*((struct divert_info **) file->private_data)) {
2788 @@ -95,7 +96,7 @@
2789 if ((len = strlen(inf->info_start)) <= count) {
2790 if (copy_to_user(buf, inf->info_start, len))
2791 return -EFAULT;
2792 - file->f_pos += len;
2793 + *off = pos + len;
2794 return (len);
2795 }
2796 return (0);
2797 diff -Nru a/drivers/isdn/hysdn/hysdn_procconf.c b/drivers/isdn/hysdn/hysdn_procconf.c
2798 --- a/drivers/isdn/hysdn/hysdn_procconf.c 2004-08-11 19:29:57 -07:00
2799 +++ b/drivers/isdn/hysdn/hysdn_procconf.c 2004-08-11 19:29:57 -07:00
2800 @@ -212,29 +212,27 @@
2801 static ssize_t
2802 hysdn_conf_read(struct file *file, char *buf, size_t count, loff_t * off)
2803 {
2804 + loff_t pos = *off;
2805 char *cp;
2806 int i;
2807
2808 if (off != &file->f_pos) /* fs error check */
2809 return -ESPIPE;
2810
2811 - if (file->f_mode & FMODE_READ) {
2812 - if (!(cp = file->private_data))
2813 - return (-EFAULT); /* should never happen */
2814 - i = strlen(cp); /* get total string length */
2815 - if (*off < i) {
2816 - /* still bytes to transfer */
2817 - cp += *off; /* point to desired data offset */
2818 - i -= *off; /* remaining length */
2819 - if (i > count)
2820 - i = count; /* limit length to transfer */
2821 - if (copy_to_user(buf, cp, i))
2822 - return (-EFAULT); /* copy error */
2823 - *off += i; /* adjust offset */
2824 - } else
2825 - return (0);
2826 + if (!(cp = file->private_data))
2827 + return (-EFAULT); /* should never happen */
2828 + i = strlen(cp); /* get total string length */
2829 + if (pos == (unsigned)pos && pos < i) {
2830 + /* still bytes to transfer */
2831 + cp += pos; /* point to desired data offset */
2832 + i -= pos; /* remaining length */
2833 + if (i > count)
2834 + i = count; /* limit length to transfer */
2835 + if (copy_to_user(buf, cp, i))
2836 + return (-EFAULT); /* copy error */
2837 + *off = pos + i; /* adjust offset */
2838 } else
2839 - return (-EPERM); /* no permission to read */
2840 + return (0);
2841
2842 return (i);
2843 } /* hysdn_conf_read */
2844 diff -Nru a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c
2845 --- a/drivers/isdn/hysdn/hysdn_proclog.c 2004-08-11 19:29:57 -07:00
2846 +++ b/drivers/isdn/hysdn/hysdn_proclog.c 2004-08-11 19:29:57 -07:00
2847 @@ -210,6 +210,7 @@
2848 word ino;
2849 struct procdata *pd = NULL;
2850 hysdn_card *card;
2851 + loff_t pos = *off;
2852
2853 if (!*((struct log_data **) file->private_data)) {
2854 if (file->f_flags & O_NONBLOCK)
2855 @@ -238,7 +239,7 @@
2856 if ((len = strlen(inf->log_start)) <= count) {
2857 if (copy_to_user(buf, inf->log_start, len))
2858 return -EFAULT;
2859 - file->f_pos += len;
2860 + *off = pos + len;
2861 return (len);
2862 }
2863 return (0);
2864 diff -Nru a/drivers/isdn/isdn_common.c b/drivers/isdn/isdn_common.c
2865 --- a/drivers/isdn/isdn_common.c 2004-08-11 19:29:57 -07:00
2866 +++ b/drivers/isdn/isdn_common.c 2004-08-11 19:29:57 -07:00
2867 @@ -976,10 +976,14 @@
2868 int chidx;
2869 int retval;
2870 char *p;
2871 + loff_t pos = *off;
2872
2873 if (off != &file->f_pos)
2874 return -ESPIPE;
2875
2876 + if (pos != (unsigned) pos)
2877 + return -EINVAL;
2878 +
2879 lock_kernel();
2880 if (minor == ISDN_MINOR_STATUS) {
2881 if (!file->private_data) {
2882 @@ -996,7 +1000,7 @@
2883 retval = -EFAULT;
2884 goto out;
2885 }
2886 - *off += len;
2887 + *off = pos + len;
2888 retval = len;
2889 goto out;
2890 }
2891 @@ -1027,7 +1031,7 @@
2892 cli();
2893 len = isdn_readbchan(drvidx, chidx, p, 0, count,
2894 &dev->drv[drvidx]->rcv_waitq[chidx]);
2895 - *off += len;
2896 + *off = pos + len;
2897 restore_flags(flags);
2898 if (copy_to_user(buf,p,len))
2899 len = -EFAULT;
2900 @@ -1064,7 +1068,7 @@
2901 else
2902 dev->drv[drvidx]->stavail = 0;
2903 restore_flags(flags);
2904 - *off += len;
2905 + *off = pos + len;
2906 retval = len;
2907 goto out;
2908 }
2909 diff -Nru a/drivers/macintosh/ans-lcd.c b/drivers/macintosh/ans-lcd.c
2910 --- a/drivers/macintosh/ans-lcd.c 2004-08-11 19:29:57 -07:00
2911 +++ b/drivers/macintosh/ans-lcd.c 2004-08-11 19:29:57 -07:00
2912 @@ -53,7 +53,6 @@
2913 size_t count, loff_t *ppos )
2914 {
2915 const char * p = buf;
2916 - int i;
2917
2918 #ifdef DEBUG
2919 printk(KERN_DEBUG "LCD: write\n");
2920 @@ -61,13 +60,13 @@
2921
2922 if ( verify_area(VERIFY_READ, buf, count) )
2923 return -EFAULT;
2924 - for ( i = *ppos; count > 0; ++i, ++p, --count )
2925 - {
2926 + while (count--) {
2927 char c;
2928 - __get_user(c, p);
2929 + if (__get_user(c, p++))
2930 + return -EFAULT;
2931 anslcd_write_byte_data( c );
2932 }
2933 - *ppos = i;
2934 + *ppos = p - buf;
2935 return p - buf;
2936 }
2937
2938 diff -Nru a/drivers/macintosh/nvram.c b/drivers/macintosh/nvram.c
2939 --- a/drivers/macintosh/nvram.c 2004-08-11 19:29:57 -07:00
2940 +++ b/drivers/macintosh/nvram.c 2004-08-11 19:29:57 -07:00
2941 @@ -37,14 +37,15 @@
2942 static ssize_t read_nvram(struct file *file, char *buf,
2943 size_t count, loff_t *ppos)
2944 {
2945 - unsigned int i;
2946 + loff_t n = *ppos
2947 + unsigned int i = n;
2948 char *p = buf;
2949
2950 if (verify_area(VERIFY_WRITE, buf, count))
2951 return -EFAULT;
2952 - if (*ppos >= NVRAM_SIZE)
2953 + if (i != n || i >= NVRAM_SIZE)
2954 return 0;
2955 - for (i = *ppos; count > 0 && i < NVRAM_SIZE; ++i, ++p, --count)
2956 + for (; count > 0 && i < NVRAM_SIZE; ++i, ++p, --count)
2957 if (__put_user(nvram_read_byte(i), p))
2958 return -EFAULT;
2959 *ppos = i;
2960 @@ -54,15 +55,16 @@
2961 static ssize_t write_nvram(struct file *file, const char *buf,
2962 size_t count, loff_t *ppos)
2963 {
2964 - unsigned int i;
2965 + loff_t n = *ppos;
2966 + unsigned int i = n;
2967 const char *p = buf;
2968 char c;
2969
2970 if (verify_area(VERIFY_READ, buf, count))
2971 return -EFAULT;
2972 - if (*ppos >= NVRAM_SIZE)
2973 + if (i != n || i >= NVRAM_SIZE)
2974 return 0;
2975 - for (i = *ppos; count > 0 && i < NVRAM_SIZE; ++i, ++p, --count) {
2976 + for (; count > 0 && i < NVRAM_SIZE; ++i, ++p, --count) {
2977 if (__get_user(c, p))
2978 return -EFAULT;
2979 nvram_write_byte(c, i);
2980 diff -Nru a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
2981 --- a/drivers/mtd/mtdchar.c 2004-08-11 19:29:57 -07:00
2982 +++ b/drivers/mtd/mtdchar.c 2004-08-11 19:29:57 -07:00
2983 @@ -125,11 +125,15 @@
2984 int ret=0;
2985 int len;
2986 char *kbuf;
2987 + loff_t pos = *ppos;
2988
2989 DEBUG(MTD_DEBUG_LEVEL0,"MTD_read\n");
2990
2991 - if (*ppos + count > mtd->size)
2992 - count = mtd->size - *ppos;
2993 + if (pos < 0 || pos > mtd->size)
2994 + return 0;
2995 +
2996 + if (count > mtd->size - pos)
2997 + count = mtd->size - pos;
2998
2999 if (!count)
3000 return 0;
3001 @@ -146,9 +150,9 @@
3002 if (!kbuf)
3003 return -ENOMEM;
3004
3005 - ret = MTD_READ(mtd, *ppos, len, &retlen, kbuf);
3006 + ret = MTD_READ(mtd, pos, len, &retlen, kbuf);
3007 if (!ret) {
3008 - *ppos += retlen;
3009 + pos += retlen;
3010 if (copy_to_user(buf, kbuf, retlen)) {
3011 kfree(kbuf);
3012 return -EFAULT;
3013 @@ -167,6 +171,8 @@
3014 kfree(kbuf);
3015 }
3016
3017 + *ppos = pos;
3018 +
3019 return total_retlen;
3020 } /* mtd_read */
3021
3022 @@ -176,17 +182,18 @@
3023 char *kbuf;
3024 size_t retlen;
3025 size_t total_retlen=0;
3026 + loff_t pos = *ppos;
3027 int ret=0;
3028 int len;
3029
3030 DEBUG(MTD_DEBUG_LEVEL0,"MTD_write\n");
3031
3032 - if (*ppos == mtd->size)
3033 + if (pos < 0 || pos >= mtd->size)
3034 return -ENOSPC;
3035 -
3036 - if (*ppos + count > mtd->size)
3037 - count = mtd->size - *ppos;
3038
3039 + if (count > mtd->size - pos)
3040 + count = mtd->size - pos;
3041 +
3042 if (!count)
3043 return 0;
3044
3045 @@ -207,9 +214,9 @@
3046 return -EFAULT;
3047 }
3048
3049 - ret = (*(mtd->write))(mtd, *ppos, len, &retlen, kbuf);
3050 + ret = (*(mtd->write))(mtd, pos, len, &retlen, kbuf);
3051 if (!ret) {
3052 - *ppos += retlen;
3053 + pos += retlen;
3054 total_retlen += retlen;
3055 count -= retlen;
3056 buf += retlen;
3057 @@ -221,6 +228,7 @@
3058
3059 kfree(kbuf);
3060 }
3061 + *ppos = pos;
3062
3063 return total_retlen;
3064 } /* mtd_write */
3065 diff -Nru a/drivers/pci/proc.c b/drivers/pci/proc.c
3066 --- a/drivers/pci/proc.c 2004-08-11 19:29:57 -07:00
3067 +++ b/drivers/pci/proc.c 2004-08-11 19:29:57 -07:00
3068 @@ -47,7 +47,8 @@
3069 const struct inode *ino = file->f_dentry->d_inode;
3070 const struct proc_dir_entry *dp = ino->u.generic_ip;
3071 struct pci_dev *dev = dp->data;
3072 - unsigned int pos = *ppos;
3073 + loff_t n = *ppos;
3074 + unsigned pos = n;
3075 unsigned int cnt, size;
3076
3077 /*
3078 @@ -63,7 +64,7 @@
3079 else
3080 size = 64;
3081
3082 - if (pos >= size)
3083 + if (pos != n || pos >= size)
3084 return 0;
3085 if (nbytes >= size)
3086 nbytes = size;
3087 @@ -129,10 +130,11 @@
3088 const struct inode *ino = file->f_dentry->d_inode;
3089 const struct proc_dir_entry *dp = ino->u.generic_ip;
3090 struct pci_dev *dev = dp->data;
3091 - int pos = *ppos;
3092 + loff_t n = *ppos;
3093 + unsigned pos = n;
3094 int cnt;
3095
3096 - if (pos >= PCI_CFG_SPACE_SIZE)
3097 + if (pos != n || pos >= PCI_CFG_SPACE_SIZE)
3098 return 0;
3099 if (nbytes >= PCI_CFG_SPACE_SIZE)
3100 nbytes = PCI_CFG_SPACE_SIZE;
3101 diff -Nru a/drivers/pnp/isapnp_proc.c b/drivers/pnp/isapnp_proc.c
3102 --- a/drivers/pnp/isapnp_proc.c 2004-08-11 19:29:57 -07:00
3103 +++ b/drivers/pnp/isapnp_proc.c 2004-08-11 19:29:57 -07:00
3104 @@ -102,6 +102,7 @@
3105 size_t count, loff_t * offset)
3106 {
3107 isapnp_info_buffer_t *buf;
3108 + loff_t pos = *offset;
3109 long size = 0, size1;
3110 int mode;
3111
3112 @@ -111,15 +112,15 @@
3113 buf = (isapnp_info_buffer_t *) file->private_data;
3114 if (!buf)
3115 return -EIO;
3116 - if (file->f_pos >= buf->size)
3117 + if (pos != (unsigned) pos || pos >= buf->size)
3118 return 0;
3119 size = buf->size < count ? buf->size : count;
3120 - size1 = buf->size - file->f_pos;
3121 + size1 = buf->size - pos;
3122 if (size1 < size)
3123 size = size1;
3124 - if (copy_to_user(buffer, buf->buffer + file->f_pos, size))
3125 + if (copy_to_user(buffer, buf->buffer + pos, size))
3126 return -EFAULT;
3127 - file->f_pos += size;
3128 + *offset = pos + size;
3129 return size;
3130 }
3131
3132 @@ -128,6 +129,7 @@
3133 {
3134 isapnp_info_buffer_t *buf;
3135 long size = 0, size1;
3136 + loff_t pos = *offset;
3137 int mode;
3138
3139 mode = file->f_flags & O_ACCMODE;
3140 @@ -136,19 +138,19 @@
3141 buf = (isapnp_info_buffer_t *) file->private_data;
3142 if (!buf)
3143 return -EIO;
3144 - if (file->f_pos < 0)
3145 + if (pos < 0)
3146 return -EINVAL;
3147 - if (file->f_pos >= buf->len)
3148 + if (pos >= buf->len)
3149 return -ENOMEM;
3150 size = buf->len < count ? buf->len : count;
3151 - size1 = buf->len - file->f_pos;
3152 + size1 = buf->len - pos;
3153 if (size1 < size)
3154 size = size1;
3155 - if (copy_from_user(buf->buffer + file->f_pos, buffer, size))
3156 + if (copy_from_user(buf->buffer + pos, buffer, size))
3157 return -EFAULT;
3158 - if (buf->size < file->f_pos + size)
3159 - buf->size = file->f_pos + size;
3160 - file->f_pos += size;
3161 + if (buf->size < pos + size)
3162 + buf->size = pos + size;
3163 + *offset = pos + size;
3164 return size;
3165 }
3166
3167 @@ -240,14 +242,15 @@
3168 struct inode *ino = file->f_dentry->d_inode;
3169 struct proc_dir_entry *dp = ino->u.generic_ip;
3170 struct pci_dev *dev = dp->data;
3171 - int pos = *ppos;
3172 + loff_t n = *ppos;
3173 + unsigned pos = n;
3174 int cnt, size = 256;
3175
3176 - if (pos >= size)
3177 + if (pos != n || pos >= size)
3178 return 0;
3179 if (nbytes >= size)
3180 nbytes = size;
3181 - if (pos + nbytes > size)
3182 + if (nbytes > size - pos)
3183 nbytes = size - pos;
3184 cnt = nbytes;
3185
3186 diff -Nru a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
3187 --- a/drivers/s390/block/dasd.c 2004-08-11 19:29:57 -07:00
3188 +++ b/drivers/s390/block/dasd.c 2004-08-11 19:29:57 -07:00
3189 @@ -4655,15 +4655,17 @@
3190 loff_t * offset)
3191 {
3192 loff_t len;
3193 + loff_t n = *offset;
3194 + unsigned pos = n;
3195 tempinfo_t *p_info = (tempinfo_t *) file->private_data;
3196
3197 - if (*offset >= p_info->len) {
3198 + if (n != pos || pos >= p_info->len) {
3199 return 0; /* EOF */
3200 } else {
3201 - len = MIN (user_len, (p_info->len - *offset));
3202 - if (copy_to_user (user_buf, &(p_info->data[*offset]), len))
3203 + len = MIN (user_len, (p_info->len - pos));
3204 + if (copy_to_user (user_buf, &(p_info->data[pos]), len))
3205 return -EFAULT;
3206 - (*offset) += len;
3207 + *offset = pos + len;
3208 return len; /* number of bytes "read" */
3209 }
3210 }
3211 diff -Nru a/drivers/s390/char/tapechar.c b/drivers/s390/char/tapechar.c
3212 --- a/drivers/s390/char/tapechar.c 2004-08-11 19:29:57 -07:00
3213 +++ b/drivers/s390/char/tapechar.c 2004-08-11 19:29:57 -07:00
3214 @@ -161,6 +161,7 @@
3215 size_t block_size;
3216 ccw_req_t *cqr;
3217 int rc;
3218 + loff_t pos = *ppos;
3219 #ifdef TAPE_DEBUG
3220 debug_text_event (tape_debug_area,6,"c:read");
3221 #endif /* TAPE_DEBUG */
3222 @@ -230,7 +231,7 @@
3223 debug_text_event (tape_debug_area,6,"c:rbytes:");
3224 debug_int_event (tape_debug_area,6,block_size - ti->devstat.rescnt);
3225 #endif /* TAPE_DEBUG */
3226 - filp->f_pos += block_size - ti->devstat.rescnt;
3227 + *ppos = pos + (block_size - ti->devstat.rescnt);
3228 return block_size - ti->devstat.rescnt;
3229 }
3230
3231 @@ -246,6 +247,8 @@
3232 ccw_req_t *cqr;
3233 int nblocks, i, rc;
3234 size_t written = 0;
3235 + loff_t pos = *ppos;
3236 +
3237 #ifdef TAPE_DEBUG
3238 debug_text_event (tape_debug_area,6,"c:write");
3239 #endif
3240 @@ -318,15 +321,17 @@
3241 debug_text_event (tape_debug_area,6,"c:wbytes:");
3242 debug_int_event (tape_debug_area,6,block_size - ti->devstat.rescnt);
3243 #endif
3244 - filp->f_pos += block_size - ti->devstat.rescnt;
3245 written += block_size - ti->devstat.rescnt;
3246 - if (ti->devstat.rescnt > 0)
3247 + if (ti->devstat.rescnt > 0) {
3248 + *ppos = pos + written;
3249 return written;
3250 + }
3251 }
3252 #ifdef TAPE_DEBUG
3253 debug_text_event (tape_debug_area,6,"c:wtotal:");
3254 debug_int_event (tape_debug_area,6,written);
3255 #endif
3256 + *ppos = pos + written;
3257 return written;
3258 }
3259
3260 diff -Nru a/drivers/s390/net/ctcmain.c b/drivers/s390/net/ctcmain.c
3261 --- a/drivers/s390/net/ctcmain.c 2004-08-11 19:29:57 -07:00
3262 +++ b/drivers/s390/net/ctcmain.c 2004-08-11 19:29:57 -07:00
3263 @@ -2934,6 +2934,7 @@
3264 file->private_data = kmalloc(CTRL_BUFSIZE, GFP_KERNEL);
3265 if (file->private_data == NULL)
3266 return -ENOMEM;
3267 + *(char *)file->private_data = '\0';
3268 MOD_INC_USE_COUNT;
3269 return 0;
3270 }
3271 @@ -2999,6 +3000,7 @@
3272 ctc_priv *privptr;
3273 ssize_t ret = 0;
3274 char *p = sbuf;
3275 + loff_t pos = *off;
3276 int l;
3277
3278 if (!(dev = find_netdev_by_ino(ino)))
3279 @@ -3008,19 +3010,19 @@
3280
3281 privptr = (ctc_priv *)dev->priv;
3282
3283 - if (file->f_pos == 0)
3284 + if (!*sbuf || pos == 0)
3285 sprintf(sbuf, "%d\n", privptr->channel[READ]->max_bufsize);
3286
3287 l = strlen(sbuf);
3288 p = sbuf;
3289 - if (file->f_pos < l) {
3290 - p += file->f_pos;
3291 + if (pos == (unsigned)pos && pos < l) {
3292 + p += pos;
3293 l = strlen(p);
3294 ret = (count > l) ? l : count;
3295 if (copy_to_user(buf, p, ret))
3296 return -EFAULT;
3297 + *off = pos + ret;
3298 }
3299 - file->f_pos += ret;
3300 return ret;
3301 }
3302
3303 @@ -3084,6 +3086,7 @@
3304 ctc_priv *privptr;
3305 ssize_t ret = 0;
3306 char *p = sbuf;
3307 + loff_t pos = *off;
3308 int l;
3309
3310 if (!(dev = find_netdev_by_ino(ino)))
3311 @@ -3093,19 +3096,19 @@
3312
3313 privptr = (ctc_priv *)dev->priv;
3314
3315 - if (file->f_pos == 0)
3316 + if (!*sbus || pos == 0)
3317 sprintf(sbuf, "0x%02x\n", loglevel);
3318
3319 l = strlen(sbuf);
3320 p = sbuf;
3321 - if (file->f_pos < l) {
3322 - p += file->f_pos;
3323 + if (pos == (unsigned)pos && pos < l) {
3324 + p += pos;
3325 l = strlen(p);
3326 ret = (count > l) ? l : count;
3327 if (copy_to_user(buf, p, ret))
3328 return -EFAULT;
3329 + *off = pos + ret;
3330 }
3331 - file->f_pos += ret;
3332 return ret;
3333 }
3334
3335 @@ -3116,6 +3119,7 @@
3336 file->private_data = kmalloc(STATS_BUFSIZE, GFP_KERNEL);
3337 if (file->private_data == NULL)
3338 return -ENOMEM;
3339 + *(char *)file->private_data = '\0';
3340 MOD_INC_USE_COUNT;
3341 return 0;
3342 }
3343 @@ -3155,6 +3159,7 @@
3344 ctc_priv *privptr;
3345 ssize_t ret = 0;
3346 char *p = sbuf;
3347 + loff_t pos = *off;
3348 int l;
3349
3350 if (!(dev = find_netdev_by_ino(ino)))
3351 @@ -3164,7 +3169,7 @@
3352
3353 privptr = (ctc_priv *)dev->priv;
3354
3355 - if (file->f_pos == 0) {
3356 + if (!*sbus || pos == 0) {
3357 p += sprintf(p, "Device FSM state: %s\n",
3358 fsm_getstate_str(privptr->fsm));
3359 p += sprintf(p, "RX channel FSM state: %s\n",
3360 @@ -3186,14 +3191,14 @@
3361 }
3362 l = strlen(sbuf);
3363 p = sbuf;
3364 - if (file->f_pos < l) {
3365 - p += file->f_pos;
3366 + if (pos == (unsigned)pos && pos < l) {
3367 + p += pos;
3368 l = strlen(p);
3369 ret = (count > l) ? l : count;
3370 if (copy_to_user(buf, p, ret))
3371 return -EFAULT;
3372 + *off = pos + ret;
3373 }
3374 - file->f_pos += ret;
3375 return ret;
3376 }
3377
3378 diff -Nru a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
3379 --- a/drivers/s390/net/netiucv.c 2004-08-11 19:29:57 -07:00
3380 +++ b/drivers/s390/net/netiucv.c 2004-08-11 19:29:57 -07:00
3381 @@ -1375,6 +1375,7 @@
3382 file->private_data = kmalloc(CTRL_BUFSIZE, GFP_KERNEL);
3383 if (file->private_data == NULL)
3384 return -ENOMEM;
3385 + *(char *)file->private_data = '\0';
3386 MOD_INC_USE_COUNT;
3387 return 0;
3388 }
3389 @@ -1440,6 +1441,7 @@
3390 netiucv_priv *privptr;
3391 ssize_t ret = 0;
3392 char *p = sbuf;
3393 + loff_t pos = *ppos;
3394 int l;
3395
3396 if (!(dev = find_netdev_by_ino(ino)))
3397 @@ -1449,19 +1451,20 @@
3398
3399 privptr = (netiucv_priv *)dev->priv;
3400
3401 - if (file->f_pos == 0)
3402 + if (!*sbuf || pos == 0)
3403 sprintf(sbuf, "%d\n", privptr->conn->max_buffsize);
3404
3405 l = strlen(sbuf);
3406 p = sbuf;
3407 - if (file->f_pos < l) {
3408 - p += file->f_pos;
3409 + if (pos == (unsigned)pos && pos < l) {
3410 + p += pos;
3411 l = strlen(p);
3412 ret = (count > l) ? l : count;
3413 if (copy_to_user(buf, p, ret))
3414 return -EFAULT;
3415 }
3416 - file->f_pos += ret;
3417 + pos += ret;
3418 + *ppos = pos;
3419 return ret;
3420 }
3421
3422 @@ -1471,6 +1474,7 @@
3423 file->private_data = kmalloc(CTRL_BUFSIZE, GFP_KERNEL);
3424 if (file->private_data == NULL)
3425 return -ENOMEM;
3426 + *(char *)file->private_data = '\0';
3427 MOD_INC_USE_COUNT;
3428 return 0;
3429 }
3430 @@ -1535,6 +1539,7 @@
3431 netiucv_priv *privptr;
3432 ssize_t ret = 0;
3433 char *p = sbuf;
3434 + loff_t pos = *ppos;
3435 int l;
3436
3437 if (!(dev = find_netdev_by_ino(ino)))
3438 @@ -1545,20 +1550,20 @@
3439 privptr = (netiucv_priv *)dev->priv;
3440
3441
3442 - if (file->f_pos == 0)
3443 + if (!*sbuf || pos == 0)
3444 sprintf(sbuf, "%s\n",
3445 netiucv_printname(privptr->conn->userid));
3446
3447 l = strlen(sbuf);
3448 p = sbuf;
3449 - if (file->f_pos < l) {
3450 - p += file->f_pos;
3451 + if (pos == (unsigned)pos && pos < l) {
3452 + p += pos;
3453 l = strlen(p);
3454 ret = (count > l) ? l : count;
3455 if (copy_to_user(buf, p, ret))
3456 return -EFAULT;
3457 + *ppos = pos + ret;
3458 }
3459 - file->f_pos += ret;
3460 return ret;
3461 }
3462
3463 @@ -1570,6 +1575,7 @@
3464 file->private_data = kmalloc(STATS_BUFSIZE, GFP_KERNEL);
3465 if (file->private_data == NULL)
3466 return -ENOMEM;
3467 + *(char *)file->private_data = '\0';
3468 MOD_INC_USE_COUNT;
3469 return 0;
3470 }
3471 @@ -1600,6 +1606,7 @@
3472 netiucv_stat_read(struct file *file, char *buf, size_t count, loff_t *off)
3473 {
3474 unsigned int ino = ((struct inode *)file->f_dentry->d_inode)->i_ino;
3475 + loff_t pos = *ppos;
3476 char *sbuf = (char *)file->private_data;
3477 net_device *dev;
3478 netiucv_priv *privptr;
3479 @@ -1614,7 +1621,7 @@
3480
3481 privptr = (netiucv_priv *)dev->priv;
3482
3483 - if (file->f_pos == 0) {
3484 + if (!*sbuf || pos == 0) {
3485 p += sprintf(p, "Device FSM state: %s\n",
3486 fsm_getstate_str(privptr->fsm));
3487 p += sprintf(p, "Connection FSM state: %s\n",
3488 @@ -1638,14 +1645,14 @@
3489 }
3490 l = strlen(sbuf);
3491 p = sbuf;
3492 - if (file->f_pos < l) {
3493 - p += file->f_pos;
3494 + if (pos == (unsigned)pos && pos < l) {
3495 + p += pos;
3496 l = strlen(p);
3497 ret = (count > l) ? l : count;
3498 if (copy_to_user(buf, p, ret))
3499 return -EFAULT;
3500 + *ppos = pos + ret;
3501 }
3502 - file->f_pos += ret;
3503 return ret;
3504 }
3505
3506 diff -Nru a/drivers/s390/net/qeth.c b/drivers/s390/net/qeth.c
3507 --- a/drivers/s390/net/qeth.c 2004-08-11 19:29:57 -07:00
3508 +++ b/drivers/s390/net/qeth.c 2004-08-11 19:29:57 -07:00
3509 @@ -9792,7 +9792,7 @@
3510 int pos=0,end_pos;
3511 char dbf_text[15];
3512
3513 - if (*offset>0) return user_len;
3514 + if (*offset) return user_len;
3515 buffer=vmalloc(__max(user_len+1,QETH_DBF_MISC_LEN));
3516 if (buffer == NULL)
3517 return -ENOMEM;
3518 @@ -10308,14 +10308,16 @@
3519 {
3520 loff_t len;
3521 tempinfo_t *p_info = (tempinfo_t *) file->private_data;
3522 + loff_t n = *offset;
3523 + unsigned long pos = n;
3524
3525 - if (*offset >= p_info->len) {
3526 + if (pos != n || pos >= p_info->len) {
3527 return 0;
3528 } else {
3529 - len = __min(user_len, (p_info->len - *offset));
3530 - if (copy_to_user (user_buf, &(p_info->data[*offset]), len))
3531 + len = __min(user_len, (p_info->len - pos));
3532 + if (copy_to_user (user_buf, &(p_info->data[pos]), len))
3533 return -EFAULT;
3534 - (*offset) += len;
3535 + *offset = pos + len;
3536 return len;
3537 }
3538 }
3539 @@ -10350,7 +10352,7 @@
3540 qeth_card_t *card;
3541 #define BUFFER_LEN (10+32+1+5+1+DEV_NAME_LEN+1)
3542
3543 - if (*offset>0) return user_len;
3544 + if (*offset) return user_len;
3545 buffer=vmalloc(__max(__max(user_len+1,BUFFER_LEN),QETH_DBF_MISC_LEN));
3546
3547 if (buffer == NULL)
3548 @@ -10474,7 +10476,7 @@
3549 PRINT_ERR("unknown ipato information command\n");
3550 out:
3551 vfree(buffer);
3552 - *offset = *offset + user_len;
3553 + *offset = user_len;
3554 #undef BUFFER_LEN
3555 return user_len;
3556 }
3557 diff -Nru a/drivers/s390/s390io.c b/drivers/s390/s390io.c
3558 --- a/drivers/s390/s390io.c 2004-08-11 19:29:57 -07:00
3559 +++ b/drivers/s390/s390io.c 2004-08-11 19:29:57 -07:00
3560 @@ -8328,14 +8328,15 @@
3561 {
3562 loff_t len;
3563 tempinfo_t *p_info = (tempinfo_t *) file->private_data;
3564 + loff_t pos = *offset;
3565
3566 - if (*offset >= p_info->len) {
3567 + if (pos < 0 || pos >= p_info->len) {
3568 return 0;
3569 } else {
3570 - len = MIN (user_len, (p_info->len - *offset));
3571 - if (copy_to_user (user_buf, &(p_info->data[*offset]), len))
3572 + len = MIN (user_len, (p_info->len - pos));
3573 + if (copy_to_user (user_buf, &(p_info->data[pos]), len))
3574 return -EFAULT;
3575 - (*offset) += len;
3576 + *offset = pos + len;
3577 return len;
3578 }
3579 }
3580 @@ -8410,14 +8411,15 @@
3581 {
3582 loff_t len;
3583 tempinfo_t *p_info = (tempinfo_t *) file->private_data;
3584 + loff_t pos = *offset;
3585
3586 - if (*offset >= p_info->len) {
3587 + if (pos < 0 || pos >= p_info->len) {
3588 return 0;
3589 } else {
3590 - len = MIN (user_len, (p_info->len - *offset));
3591 - if (copy_to_user (user_buf, &(p_info->data[*offset]), len))
3592 + len = MIN (user_len, (p_info->len - pos));
3593 + if (copy_to_user (user_buf, &(p_info->data[pos]), len))
3594 return -EFAULT;
3595 - (*offset) += len;
3596 + *offset = pos + len;
3597 return len;
3598 }
3599 }
3600 @@ -8874,14 +8876,15 @@
3601 {
3602 loff_t len;
3603 tempinfo_t *p_info = (tempinfo_t *) file->private_data;
3604 + loff_t pos = *offset;
3605
3606 - if (*offset >= p_info->len) {
3607 + if (pos < 0 || pos >= p_info->len) {
3608 return 0;
3609 } else {
3610 len = MIN (user_len, (p_info->len - *offset));
3611 if (copy_to_user (user_buf, &(p_info->data[*offset]), len))
3612 return -EFAULT;
3613 - (*offset) += len;
3614 + (*offset) = pos + len;
3615 return len;
3616 }
3617 }
3618 @@ -8994,14 +8997,15 @@
3619 {
3620 loff_t len;
3621 tempinfo_t *p_info = (tempinfo_t *) file->private_data;
3622 + loff_t pos = *offset;
3623
3624 - if (*offset >= p_info->len) {
3625 + if (pos < 0 || pos >= p_info->len) {
3626 return 0;
3627 } else {
3628 len = MIN (user_len, (p_info->len - *offset));
3629 if (copy_to_user (user_buf, &(p_info->data[*offset]), len))
3630 return -EFAULT;
3631 - (*offset) += len;
3632 + (*offset) = pos + len;
3633 return len;
3634 }
3635 }
3636 @@ -9123,14 +9127,15 @@
3637 {
3638 loff_t len;
3639 tempinfo_t *p_info = (tempinfo_t *) file->private_data;
3640 + loff_t pos = *offset;
3641
3642 - if ( *offset>=p_info->len) {
3643 + if (pos < 0 || pos >= p_info->len) {
3644 return 0;
3645 } else {
3646 - len = MIN(user_len, (p_info->len - *offset));
3647 - if (copy_to_user( user_buf, &(p_info->data[*offset]), len))
3648 + len = MIN(user_len, (p_info->len - pos));
3649 + if (copy_to_user( user_buf, &(p_info->data[pos]), len))
3650 return -EFAULT;
3651 - (* offset) += len;
3652 + *offset = pos + len;
3653 return len;
3654 }
3655 }
3656 diff -Nru a/drivers/sbus/char/flash.c b/drivers/sbus/char/flash.c
3657 --- a/drivers/sbus/char/flash.c 2004-08-11 19:29:57 -07:00
3658 +++ b/drivers/sbus/char/flash.c 2004-08-11 19:29:57 -07:00
3659 @@ -105,9 +105,15 @@
3660 flash_read(struct file * file, char * buf,
3661 size_t count, loff_t *ppos)
3662 {
3663 - unsigned long p = file->f_pos;
3664 + loff_t p = *ppos;
3665 int i;
3666
3667 + if (p > flash.read_size)
3668 + return 0;
3669 +
3670 + if (p < 0)
3671 + return -EINVAL;
3672 +
3673 if (count > flash.read_size - p)
3674 count = flash.read_size - p;
3675
3676 @@ -118,7 +124,7 @@
3677 buf++;
3678 }
3679
3680 - file->f_pos += count;
3681 + *ppos = p + count;
3682 return count;
3683 }
3684
3685 diff -Nru a/drivers/scsi/osst.c b/drivers/scsi/osst.c
3686 --- a/drivers/scsi/osst.c 2004-08-11 19:29:57 -07:00
3687 +++ b/drivers/scsi/osst.c 2004-08-11 19:29:57 -07:00
3688 @@ -3148,6 +3148,7 @@
3689 ST_mode * STm;
3690 ST_partstat * STps;
3691 int dev = TAPE_NR(inode->i_rdev);
3692 + loff_t pos = *ppos;
3693
3694 STp = os_scsi_tapes[dev];
3695
3696 @@ -3369,7 +3370,7 @@
3697 if (i == (-ENOSPC)) {
3698 transfer = STp->buffer->writing; /* FIXME -- check this logic */
3699 if (transfer <= do_count) {
3700 - filp->f_pos += do_count - transfer;
3701 + pos += do_count - transfer;
3702 count -= do_count - transfer;
3703 if (STps->drv_block >= 0) {
3704 STps->drv_block += (do_count - transfer) / STp->block_size;
3705 @@ -3407,7 +3408,7 @@
3706 goto out;
3707 }
3708
3709 - filp->f_pos += do_count;
3710 + pos += do_count;
3711 b_point += do_count;
3712 count -= do_count;
3713 if (STps->drv_block >= 0) {
3714 @@ -3429,7 +3430,7 @@
3715 if (STps->drv_block >= 0) {
3716 STps->drv_block += blks;
3717 }
3718 - filp->f_pos += count;
3719 + pos += count;
3720 count = 0;
3721 }
3722
3723 @@ -3459,6 +3460,7 @@
3724 retval = total;
3725
3726 out:
3727 + *ppos = pos;
3728 if (SRpnt != NULL) scsi_release_request(SRpnt);
3729
3730 up(&STp->lock);
3731 @@ -3479,6 +3481,7 @@
3732 ST_partstat * STps;
3733 Scsi_Request *SRpnt = NULL;
3734 int dev = TAPE_NR(inode->i_rdev);
3735 + loff_t pos = *ppos;
3736
3737 STp = os_scsi_tapes[dev];
3738
3739 @@ -3614,7 +3617,7 @@
3740 }
3741 STp->logical_blk_num += transfer / STp->block_size;
3742 STps->drv_block += transfer / STp->block_size;
3743 - filp->f_pos += transfer;
3744 + pos += transfer;
3745 buf += transfer;
3746 total += transfer;
3747 }
3748 @@ -3653,6 +3656,7 @@
3749 retval = total;
3750
3751 out:
3752 + *ppos = pos;
3753 if (SRpnt != NULL) scsi_release_request(SRpnt);
3754
3755 up(&STp->lock);
3756 @@ -5501,6 +5505,7 @@
3757 read: osst_read,
3758 write: osst_write,
3759 ioctl: osst_ioctl,
3760 + llseek: no_llseek,
3761 open: os_scsi_tape_open,
3762 flush: os_scsi_tape_flush,
3763 release: os_scsi_tape_close,
3764 diff -Nru a/drivers/scsi/st.c b/drivers/scsi/st.c
3765 --- a/drivers/scsi/st.c 2004-08-11 19:29:57 -07:00
3766 +++ b/drivers/scsi/st.c 2004-08-11 19:29:57 -07:00
3767 @@ -1202,6 +1202,7 @@
3768 ST_mode *STm;
3769 ST_partstat *STps;
3770 int dev = TAPE_NR(inode->i_rdev);
3771 + loff_t pos = *ppos;
3772
3773 read_lock(&st_dev_arr_lock);
3774 STp = scsi_tapes[dev];
3775 @@ -1433,7 +1434,7 @@
3776 residual *= STp->block_size;
3777 if (residual <= do_count) {
3778 /* Within the data in this write() */
3779 - filp->f_pos += do_count - residual;
3780 + pos += do_count - residual;
3781 count -= do_count - residual;
3782 if (STps->drv_block >= 0) {
3783 if (STp->block_size == 0 &&
3784 @@ -1489,7 +1490,7 @@
3785 retval = total - count;
3786 goto out;
3787 }
3788 - filp->f_pos += do_count;
3789 + pos += do_count;
3790 b_point += do_count;
3791 count -= do_count;
3792 if (STps->drv_block >= 0) {
3793 @@ -1508,7 +1509,7 @@
3794 retval = i;
3795 goto out;
3796 }
3797 - filp->f_pos += count;
3798 + pos += count;
3799 count = 0;
3800 }
3801
3802 @@ -1543,6 +1544,7 @@
3803 retval = total - count;
3804
3805 out:
3806 + *ppos = pos;
3807 if (SRpnt != NULL)
3808 scsi_release_request(SRpnt);
3809 up(&STp->lock);
3810 @@ -1743,6 +1745,7 @@
3811 ST_mode *STm;
3812 ST_partstat *STps;
3813 int dev = TAPE_NR(inode->i_rdev);
3814 + loff_t pos = *ppos;
3815
3816 read_lock(&st_dev_arr_lock);
3817 STp = scsi_tapes[dev];
3818 @@ -1887,7 +1890,7 @@
3819 retval = i;
3820 goto out;
3821 }
3822 - filp->f_pos += transfer;
3823 + pos += transfer;
3824 buf += transfer;
3825 total += transfer;
3826 }
3827 @@ -1917,6 +1920,7 @@
3828 retval = total;
3829
3830 out:
3831 + *ppos = pos;
3832 if (SRpnt != NULL) {
3833 scsi_release_request(SRpnt);
3834 SRpnt = NULL;
3835 @@ -3774,6 +3778,7 @@
3836 read: st_read,
3837 write: st_write,
3838 ioctl: st_ioctl,
3839 + llseek: no_llseek,
3840 open: st_open,
3841 flush: st_flush,
3842 release: st_release,
3843 diff -Nru a/drivers/usb/brlvger.c b/drivers/usb/brlvger.c
3844 --- a/drivers/usb/brlvger.c 2004-08-11 19:29:57 -07:00
3845 +++ b/drivers/usb/brlvger.c 2004-08-11 19:29:57 -07:00
3846 @@ -596,6 +596,9 @@
3847
3848 off = *pos;
3849
3850 + if (off < 0)
3851 + return -EINVAL;
3852 +
3853 if(off > priv->plength)
3854 return -ESPIPE;;
3855
3856 diff -Nru a/drivers/usb/devio.c b/drivers/usb/devio.c
3857 --- a/drivers/usb/devio.c 2004-08-11 19:29:57 -07:00
3858 +++ b/drivers/usb/devio.c 2004-08-11 19:29:57 -07:00
3859 @@ -80,7 +80,7 @@
3860 struct dev_state *ps = (struct dev_state *)file->private_data;
3861 ssize_t ret = 0;
3862 unsigned len;
3863 - loff_t pos;
3864 + loff_t pos, last;
3865 int i;
3866
3867 pos = *ppos;
3868 @@ -102,37 +102,38 @@
3869 goto err;
3870 }
3871
3872 - *ppos += len;
3873 + pos += len;
3874 buf += len;
3875 nbytes -= len;
3876 ret += len;
3877 }
3878
3879 - pos = sizeof(struct usb_device_descriptor);
3880 + last = sizeof(struct usb_device_descriptor);
3881 for (i = 0; nbytes && i < ps->dev->descriptor.bNumConfigurations; i++) {
3882 struct usb_config_descriptor *config =
3883 (struct usb_config_descriptor *)ps->dev->rawdescriptors[i];
3884 unsigned int length = le16_to_cpu(config->wTotalLength);
3885
3886 - if (*ppos < pos + length) {
3887 - len = length - (*ppos - pos);
3888 + if (pos < last + length) {
3889 + len = length - (pos - last);
3890 if (len > nbytes)
3891 len = nbytes;
3892
3893 if (copy_to_user(buf,
3894 - ps->dev->rawdescriptors[i] + (*ppos - pos), len)) {
3895 + ps->dev->rawdescriptors[i] + (pos - last), len)) {
3896 ret = -EFAULT;
3897 goto err;
3898 }
3899
3900 - *ppos += len;
3901 + pos += len;
3902 buf += len;
3903 nbytes -= len;
3904 ret += len;
3905 }
3906
3907 - pos += length;
3908 + last += length;
3909 }
3910 + *ppos = pos;
3911
3912 err:
3913 up_read(&ps->devsem);
3914 diff -Nru a/drivers/usb/drivers.c b/drivers/usb/drivers.c
3915 --- a/drivers/usb/drivers.c 2004-08-11 19:29:57 -07:00
3916 +++ b/drivers/usb/drivers.c 2004-08-11 19:29:57 -07:00
3917 @@ -52,9 +52,10 @@
3918 struct list_head *tmp = usb_driver_list.next;
3919 char *page, *start, *end;
3920 ssize_t ret = 0;
3921 - unsigned int pos, len;
3922 + loff_t n = *ppos;
3923 + unsigned int pos = n, len;
3924
3925 - if (*ppos < 0)
3926 + if (pos != n)
3927 return -EINVAL;
3928 if (nbytes <= 0)
3929 return 0;
3930 @@ -64,7 +65,6 @@
3931 return -ENOMEM;
3932 start = page;
3933 end = page + (PAGE_SIZE - 100);
3934 - pos = *ppos;
3935 for (; tmp != &usb_driver_list; tmp = tmp->next) {
3936 struct usb_driver *driver = list_entry(tmp, struct usb_driver, driver_list);
3937 int minor = driver->fops ? driver->minor : -1;
3938 @@ -88,7 +88,7 @@
3939 if (copy_to_user(buf, page + pos, len))
3940 ret = -EFAULT;
3941 else
3942 - *ppos += len;
3943 + *ppos = pos + len;
3944 }
3945 free_page((unsigned long)page);
3946 return ret;
3947 diff -Nru a/drivers/usb/host/uhci-debug.h b/drivers/usb/host/uhci-debug.h
3948 --- a/drivers/usb/host/uhci-debug.h 2004-08-11 19:29:57 -07:00
3949 +++ b/drivers/usb/host/uhci-debug.h 2004-08-11 19:29:57 -07:00
3950 @@ -530,16 +530,14 @@
3951 loff_t *ppos)
3952 {
3953 struct uhci_proc *up = file->private_data;
3954 - unsigned int pos;
3955 + loff_t n = *ppos;
3956 + unsigned int pos = n;
3957 unsigned int size;
3958
3959 - pos = *ppos;
3960 size = up->size;
3961 - if (pos >= size)
3962 + if (pos != n || pos >= size)
3963 return 0;
3964 - if (nbytes >= size)
3965 - nbytes = size;
3966 - if (pos + nbytes > size)
3967 + if (nbytes > size - pos)
3968 nbytes = size - pos;
3969
3970 if (!access_ok(VERIFY_WRITE, buf, nbytes))
3971 @@ -548,7 +546,7 @@
3972 if (copy_to_user(buf, up->data + pos, nbytes))
3973 return -EFAULT;
3974
3975 - *ppos += nbytes;
3976 + *ppos = pos + nbytes;
3977
3978 return nbytes;
3979 }
3980 diff -Nru a/drivers/video/fbmem.c b/drivers/video/fbmem.c
3981 --- a/drivers/video/fbmem.c 2004-08-11 19:29:57 -07:00
3982 +++ b/drivers/video/fbmem.c 2004-08-11 19:29:57 -07:00
3983 @@ -404,7 +404,7 @@
3984 static ssize_t
3985 fb_read(struct file *file, char *buf, size_t count, loff_t *ppos)
3986 {
3987 - unsigned long p = *ppos;
3988 + loff_t p = *ppos;
3989 struct inode *inode = file->f_dentry->d_inode;
3990 int fbidx = GET_FB_IDX(inode->i_rdev);
3991 struct fb_info *info = registered_fb[fbidx];
3992 @@ -414,12 +414,13 @@
3993 if (! fb || ! info->disp)
3994 return -ENODEV;
3995
3996 + if (p < 0)
3997 + return -EINVAL;
3998 +
3999 fb->fb_get_fix(&fix,PROC_CONSOLE(info), info);
4000 if (p >= fix.smem_len)
4001 return 0;
4002 - if (count >= fix.smem_len)
4003 - count = fix.smem_len;
4004 - if (count + p > fix.smem_len)
4005 + if (count > fix.smem_len - p)
4006 count = fix.smem_len - p;
4007 if (count) {
4008 char *base_addr;
4009 @@ -428,7 +429,7 @@
4010 count -= copy_to_user(buf, base_addr+p, count);
4011 if (!count)
4012 return -EFAULT;
4013 - *ppos += count;
4014 + *ppos = p + count;
4015 }
4016 return count;
4017 }
4018 @@ -436,7 +437,7 @@
4019 static ssize_t
4020 fb_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
4021 {
4022 - unsigned long p = *ppos;
4023 + loff_t p = *ppos;
4024 struct inode *inode = file->f_dentry->d_inode;
4025 int fbidx = GET_FB_IDX(inode->i_rdev);
4026 struct fb_info *info = registered_fb[fbidx];
4027 @@ -447,13 +448,14 @@
4028 if (! fb || ! info->disp)
4029 return -ENODEV;
4030
4031 + if (p < 0)
4032 + return -EINVAL;
4033 +
4034 fb->fb_get_fix(&fix, PROC_CONSOLE(info), info);
4035 if (p > fix.smem_len)
4036 return -ENOSPC;
4037 - if (count >= fix.smem_len)
4038 - count = fix.smem_len;
4039 err = 0;
4040 - if (count + p > fix.smem_len) {
4041 + if (count > fix.smem_len - p) {
4042 count = fix.smem_len - p;
4043 err = -ENOSPC;
4044 }
4045 @@ -462,7 +464,7 @@
4046
4047 base_addr = info->disp->screen_base;
4048 count -= copy_from_user(base_addr+p, buf, count);
4049 - *ppos += count;
4050 + *ppos = p + count;
4051 err = -EFAULT;
4052 }
4053 if (count)
4054 diff -Nru a/drivers/zorro/proc.c b/drivers/zorro/proc.c
4055 --- a/drivers/zorro/proc.c 2004-08-11 19:29:57 -07:00
4056 +++ b/drivers/zorro/proc.c 2004-08-11 19:29:57 -07:00
4057 @@ -50,11 +50,9 @@
4058 struct ConfigDev cd;
4059 loff_t pos = *ppos;
4060
4061 - if (pos >= sizeof(struct ConfigDev))
4062 + if (pos < 0 || pos >= sizeof(struct ConfigDev))
4063 return 0;
4064 - if (nbytes >= sizeof(struct ConfigDev))
4065 - nbytes = sizeof(struct ConfigDev);
4066 - if (pos + nbytes > sizeof(struct ConfigDev))
4067 + if (nbytes > sizeof(struct ConfigDev) - pos)
4068 nbytes = sizeof(struct ConfigDev) - pos;
4069
4070 /* Construct a ConfigDev */
4071 @@ -67,7 +65,7 @@
4072
4073 if (copy_to_user(buf, &cd, nbytes))
4074 return -EFAULT;
4075 - *ppos += nbytes;
4076 + *ppos = pos + nbytes;
4077
4078 return nbytes;
4079 }
4080 diff -Nru a/fs/devfs/base.c b/fs/devfs/base.c
4081 --- a/fs/devfs/base.c 2004-08-11 19:29:57 -07:00
4082 +++ b/fs/devfs/base.c 2004-08-11 19:29:57 -07:00
4083 @@ -3312,7 +3312,7 @@
4084 {
4085 int done = FALSE;
4086 int ival;
4087 - loff_t pos, devname_offset, tlen, rpos;
4088 + loff_t pos, devname_offset, tlen, rpos, old_pos;
4089 devfs_handle_t de;
4090 struct devfsd_buf_entry *entry;
4091 struct fs_info *fs_info = file->f_dentry->d_inode->i_sb->u.generic_sbp;
4092 @@ -3363,8 +3363,8 @@
4093 info->namelen = DEVFS_PATHLEN - pos - 1;
4094 if (info->mode == 0) info->mode = de->mode;
4095 devname_offset = info->devname - (char *) info;
4096 - rpos = *ppos;
4097 - if (rpos < devname_offset)
4098 + old_pos = rpos = *ppos;
4099 + if (rpos >= 0 && rpos < devname_offset)
4100 {
4101 /* Copy parts of the header */
4102 tlen = devname_offset - rpos;
4103 @@ -3390,7 +3390,7 @@
4104 }
4105 rpos += tlen;
4106 }
4107 - tlen = rpos - *ppos;
4108 + tlen = rpos - old_pos;
4109 if (done)
4110 {
4111 devfs_handle_t parent;
4112 @@ -3504,16 +3504,17 @@
4113 loff_t *ppos)
4114 {
4115 ssize_t num;
4116 + loff_t n = *ppos;
4117 char txt[80];
4118
4119 num = sprintf (txt, "Number of entries: %u number of bytes: %u\n",
4120 stat_num_entries, stat_num_bytes) + 1;
4121 /* Can't seek (pread) on this device */
4122 if (ppos != &file->f_pos) return -ESPIPE;
4123 - if (*ppos >= num) return 0;
4124 - if (*ppos + len > num) len = num - *ppos;
4125 - if ( copy_to_user (buf, txt + *ppos, len) ) return -EFAULT;
4126 - *ppos += len;
4127 + if (n != (unsigned)n || n >= num) return 0;
4128 + if (len > num - n) len = num - n;
4129 + if ( copy_to_user (buf, txt + n, len) ) return -EFAULT;
4130 + *ppos = n + len;
4131 return len;
4132 } /* End Function stat_read */
4133 #endif
4134 diff -Nru a/fs/hfs/file.c b/fs/hfs/file.c
4135 --- a/fs/hfs/file.c 2004-08-11 19:29:57 -07:00
4136 +++ b/fs/hfs/file.c 2004-08-11 19:29:57 -07:00
4137 @@ -150,7 +150,7 @@
4138 return -EINVAL;
4139 }
4140 pos = *ppos;
4141 - if (pos >= HFS_FORK_MAX) {
4142 + if (pos < 0 || pos >= HFS_FORK_MAX) {
4143 return 0;
4144 }
4145 size = inode->i_size;
4146 @@ -167,7 +167,7 @@
4147 }
4148 if ((read = hfs_do_read(inode, HFS_I(inode)->fork, pos,
4149 buf, left, filp->f_reada != 0)) > 0) {
4150 - *ppos += read;
4151 + *ppos = pos + read;
4152 filp->f_reada = 1;
4153 }
4154
4155 @@ -197,7 +197,7 @@
4156
4157 pos = (filp->f_flags & O_APPEND) ? inode->i_size : *ppos;
4158
4159 - if (pos >= HFS_FORK_MAX) {
4160 + if (pos < 0 || pos >= HFS_FORK_MAX) {
4161 return 0;
4162 }
4163 if (count > HFS_FORK_MAX) {
4164 @@ -207,8 +207,8 @@
4165 pos += written;
4166
4167 *ppos = pos;
4168 - if (*ppos > inode->i_size) {
4169 - inode->i_size = *ppos;
4170 + if (pos > inode->i_size) {
4171 + inode->i_size = pos;
4172 mark_inode_dirty(inode);
4173 }
4174
4175 diff -Nru a/fs/hfs/file_cap.c b/fs/hfs/file_cap.c
4176 --- a/fs/hfs/file_cap.c 2004-08-11 19:29:57 -07:00
4177 +++ b/fs/hfs/file_cap.c 2004-08-11 19:29:57 -07:00
4178 @@ -191,7 +191,7 @@
4179 hfs_rwarg_t count, loff_t *ppos)
4180 {
4181 struct inode *inode = filp->f_dentry->d_inode;
4182 - hfs_u32 pos;
4183 + hfs_u32 pos, last;
4184
4185 if (!S_ISREG(inode->i_mode)) {
4186 hfs_warn("hfs_file_write: mode = %07o\n", inode->i_mode);
4187 @@ -207,14 +207,14 @@
4188 return 0;
4189 }
4190
4191 - *ppos += count;
4192 - if (*ppos > HFS_FORK_MAX) {
4193 - *ppos = HFS_FORK_MAX;
4194 + last = pos + count;
4195 + if (last > HFS_FORK_MAX) {
4196 + last = HFS_FORK_MAX;
4197 count = HFS_FORK_MAX - pos;
4198 }
4199
4200 - if (*ppos > inode->i_size)
4201 - inode->i_size = *ppos;
4202 + if (last > inode->i_size)
4203 + inode->i_size = last;
4204
4205 /* Only deal with the part we store in memory */
4206 if (pos < sizeof(struct hfs_cap_info)) {
4207 @@ -272,6 +272,7 @@
4208 }
4209 }
4210
4211 + *ppos = last;
4212 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
4213 mark_inode_dirty(inode);
4214 return count;
4215 diff -Nru a/fs/hfs/file_hdr.c b/fs/hfs/file_hdr.c
4216 --- a/fs/hfs/file_hdr.c 2004-08-11 19:29:57 -07:00
4217 +++ b/fs/hfs/file_hdr.c 2004-08-11 19:29:57 -07:00
4218 @@ -384,7 +384,7 @@
4219 struct hfs_cat_entry *entry = HFS_I(inode)->entry;
4220 const struct hfs_hdr_layout *layout;
4221 off_t start, length, offset;
4222 - off_t pos = *ppos;
4223 + loff_t pos = *ppos;
4224 int left, lcv, read = 0;
4225
4226 if (!S_ISREG(inode->i_mode)) {
4227 @@ -399,7 +399,7 @@
4228 }
4229
4230 /* Adjust count to fit within the bounds of the file */
4231 - if ((pos >= inode->i_size) || (count <= 0)) {
4232 + if (pos != (unsigned)pos || pos >= inode->i_size || count <= 0) {
4233 return 0;
4234 } else if (count > inode->i_size - pos) {
4235 count = inode->i_size - pos;
4236 @@ -646,7 +646,7 @@
4237 hfs_warn("hfs_hdr_write: mode = %07o\n", inode->i_mode);
4238 return -EINVAL;
4239 }
4240 - if (count <= 0) {
4241 + if (count <= 0 || pos != (unsigned)pos) {
4242 return 0;
4243 }
4244
4245 diff -Nru a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
4246 --- a/fs/openpromfs/inode.c 2004-08-11 19:29:57 -07:00
4247 +++ b/fs/openpromfs/inode.c 2004-08-11 19:29:57 -07:00
4248 @@ -69,17 +69,18 @@
4249 size_t count, loff_t *ppos)
4250 {
4251 struct inode *inode = file->f_dentry->d_inode;
4252 + loff_t pos = *ppos;
4253 char buffer[10];
4254
4255 if (count < 0 || !inode->u.generic_ip)
4256 return -EINVAL;
4257 sprintf (buffer, "%8.8x\n", (u32)(long)(inode->u.generic_ip));
4258 - if (file->f_pos >= 9)
4259 + if (pos != (unsigned)pos || pos >= 9)
4260 return 0;
4261 - if (count > 9 - file->f_pos)
4262 - count = 9 - file->f_pos;
4263 - copy_to_user(buf, buffer + file->f_pos, count);
4264 - file->f_pos += count;
4265 + if (count > 9 - pos)
4266 + count = 9 - pos;
4267 + copy_to_user(buf, buffer + pos, count);
4268 + *ppos = pos + count;
4269 return count;
4270 }
4271
4272 @@ -87,6 +88,7 @@
4273 size_t count, loff_t *ppos)
4274 {
4275 struct inode *inode = filp->f_dentry->d_inode;
4276 + loff_t pos = *ppos;
4277 int i, j, k;
4278 u32 node;
4279 char *p, *s;
4280 @@ -94,7 +96,7 @@
4281 openprom_property *op;
4282 char buffer[64];
4283
4284 - if (filp->f_pos >= 0xffffff)
4285 + if (pos < 0 || pos >= 0xffffff)
4286 return -EINVAL;
4287 if (!filp->private_data) {
4288 node = nodes[(u16)((long)inode->u.generic_ip)].node;
4289 @@ -180,7 +182,7 @@
4290 } else {
4291 i = (op->len << 1) + 1;
4292 }
4293 - k = filp->f_pos;
4294 + k = pos;
4295 if (k >= i) return 0;
4296 if (count > i - k) count = i - k;
4297 if (op->flag & OPP_STRING) {
4298 @@ -196,16 +198,16 @@
4299 j = count;
4300
4301 if (j >= 0) {
4302 - copy_to_user(buf + k - filp->f_pos,
4303 + copy_to_user(buf + k - pos,
4304 op->value + k - 1, j);
4305 count -= j;
4306 k += j;
4307 }
4308
4309 if (count)
4310 - __put_user('\'', &buf [k++ - filp->f_pos]);
4311 + __put_user('\'', &buf [k++ - pos]);
4312 if (count > 1)
4313 - __put_user('\n', &buf [k++ - filp->f_pos]);
4314 + __put_user('\n', &buf [k++ - pos]);
4315
4316 } else if (op->flag & OPP_STRINGLIST) {
4317 char *tmp;
4318 @@ -273,47 +275,48 @@
4319
4320 if ((k < i - 1) && (k & 1)) {
4321 sprintf (buffer, "%02x", *(op->value + (k >> 1)));
4322 - __put_user(buffer[1], &buf[k++ - filp->f_pos]);
4323 + __put_user(buffer[1], &buf[k++ - pos]);
4324 count--;
4325 }
4326
4327 for (; (count > 1) && (k < i - 1); k += 2) {
4328 sprintf (buffer, "%02x", *(op->value + (k >> 1)));
4329 - copy_to_user (buf + k - filp->f_pos, buffer, 2);
4330 + copy_to_user (buf + k - pos, buffer, 2);
4331 count -= 2;
4332 }
4333
4334 if (count && (k < i - 1)) {
4335 sprintf (buffer, "%02x", *(op->value + (k >> 1)));
4336 - __put_user(buffer[0], &buf[k++ - filp->f_pos]);
4337 + __put_user(buffer[0], &buf[k++ - pos]);
4338 count--;
4339 }
4340
4341 if (count)
4342 - __put_user('\n', &buf [k++ - filp->f_pos]);
4343 + __put_user('\n', &buf [k++ - pos]);
4344 }
4345 - count = k - filp->f_pos;
4346 - filp->f_pos = k;
4347 + count = k - pos;
4348 + *ppos = k;
4349 return count;
4350 }
4351
4352 static ssize_t property_write(struct file *filp, const char *buf,
4353 size_t count, loff_t *ppos)
4354 {
4355 + loff_t pos = *ppos;
4356 int i, j, k;
4357 char *p;
4358 u32 *q;
4359 void *b;
4360 openprom_property *op;
4361
4362 - if (filp->f_pos >= 0xffffff)
4363 + if (pos < 0 || pos >= 0xffffff)
4364 return -EINVAL;
4365 if (!filp->private_data) {
4366 i = property_read (filp, NULL, 0, 0);
4367 if (i)
4368 return i;
4369 }
4370 - k = filp->f_pos;
4371 + k = pos;
4372 op = (openprom_property *)filp->private_data;
4373 if (!(op->flag & OPP_STRING)) {
4374 u32 *first, *last;
4375 @@ -433,7 +436,8 @@
4376 op->len = i;
4377 } else
4378 op->len = i;
4379 - filp->f_pos += count;
4380 + pos += count;
4381 + *ppos = pos;
4382 }
4383 write_try_string:
4384 if (!(op->flag & OPP_BINARY)) {
4385 @@ -450,7 +454,8 @@
4386 op->flag |= OPP_QUOTED;
4387 buf++;
4388 count--;
4389 - filp->f_pos++;
4390 + pos++;
4391 + *ppos = pos;
4392 if (!count) {
4393 op->flag |= OPP_STRING;
4394 return 1;
4395 @@ -459,9 +464,9 @@
4396 op->flag |= OPP_NOTQUOTED;
4397 }
4398 op->flag |= OPP_STRING;
4399 - if (op->alloclen <= count + filp->f_pos) {
4400 + if (op->alloclen <= count + pos) {
4401 b = kmalloc (sizeof (openprom_property)
4402 - + 2 * (count + filp->f_pos), GFP_KERNEL);
4403 + + 2 * (count + pos), GFP_KERNEL);
4404 if (!b)
4405 return -ENOMEM;
4406 memcpy (b, filp->private_data,
4407 @@ -469,14 +474,14 @@
4408 + strlen (op->name) + op->alloclen);
4409 memset (((char *)b) + sizeof (openprom_property)
4410 + strlen (op->name) + op->alloclen,
4411 - 0, 2*(count - filp->f_pos) - op->alloclen);
4412 + 0, 2*(count - pos) - op->alloclen);
4413 op = (openprom_property *)b;
4414 - op->alloclen = 2*(count + filp->f_pos);
4415 + op->alloclen = 2*(count + pos);
4416 b = filp->private_data;
4417 filp->private_data = (void *)op;
4418 kfree (b);
4419 }
4420 - p = op->value + filp->f_pos - ((op->flag & OPP_QUOTED) ? 1 : 0);
4421 + p = op->value + pos - ((op->flag & OPP_QUOTED) ? 1 : 0);
4422 copy_from_user (p, buf, count);
4423 op->flag |= OPP_DIRTY;
4424 for (i = 0; i < count; i++, p++)
4425 @@ -486,17 +491,19 @@
4426 }
4427 if (i < count) {
4428 op->len = p - op->value;
4429 - filp->f_pos += i + 1;
4430 + pos += i + 1;
4431 + *ppos = pos;
4432 if ((p > op->value) && (op->flag & OPP_QUOTED)
4433 && (*(p - 1) == '\''))
4434 op->len--;
4435 } else {
4436 if (p - op->value > op->len)
4437 op->len = p - op->value;
4438 - filp->f_pos += count;
4439 + pos += count;
4440 + *ppos = pos;
4441 }
4442 }
4443 - return filp->f_pos - k;
4444 + return pos - k;
4445 }
4446
4447 int property_release (struct inode *inode, struct file *filp)
4448 diff -Nru a/fs/proc/base.c b/fs/proc/base.c
4449 --- a/fs/proc/base.c 2004-08-11 19:29:57 -07:00
4450 +++ b/fs/proc/base.c 2004-08-11 19:29:57 -07:00
4451 @@ -337,6 +337,7 @@
4452 ssize_t length;
4453 ssize_t end;
4454 struct task_struct *task = inode->u.proc_i.task;
4455 + loff_t pos = *ppos;
4456
4457 if (count > PROC_BLOCK_SIZE)
4458 count = PROC_BLOCK_SIZE;
4459 @@ -350,14 +351,14 @@
4460 return length;
4461 }
4462 /* Static 4kB (or whatever) block capacity */
4463 - if (*ppos >= length) {
4464 + if (pos < 0 || pos >= length) {
4465 free_page(page);
4466 return 0;
4467 }
4468 - if (count + *ppos > length)
4469 - count = length - *ppos;
4470 - end = count + *ppos;
4471 - copy_to_user(buf, (char *) page + *ppos, count);
4472 + if (count > length - pos)
4473 + count = length - pos;
4474 + end = count + pos;
4475 + copy_to_user(buf, (char *) page + pos, count);
4476 *ppos = end;
4477 free_page(page);
4478 return count;
4479 diff -Nru a/fs/proc/generic.c b/fs/proc/generic.c
4480 --- a/fs/proc/generic.c 2004-08-11 19:29:57 -07:00
4481 +++ b/fs/proc/generic.c 2004-08-11 19:29:57 -07:00
4482 @@ -56,6 +56,7 @@
4483 ssize_t n, count;
4484 char *start;
4485 struct proc_dir_entry * dp;
4486 + loff_t pos = *ppos;
4487
4488 dp = (struct proc_dir_entry *) inode->u.generic_ip;
4489 if (!(page = (char*) __get_free_page(GFP_KERNEL)))
4490 @@ -64,6 +65,8 @@
4491 while ((nbytes > 0) && !eof)
4492 {
4493 count = MIN(PROC_BLOCK_SIZE, nbytes);
4494 + if ((unsigned)pos > INT_MAX)
4495 + break;
4496
4497 start = NULL;
4498 if (dp->get_info) {
4499 @@ -71,11 +74,11 @@
4500 * Handle backwards compatibility with the old net
4501 * routines.
4502 */
4503 - n = dp->get_info(page, &start, *ppos, count);
4504 + n = dp->get_info(page, &start, pos, count);
4505 if (n < count)
4506 eof = 1;
4507 } else if (dp->read_proc) {
4508 - n = dp->read_proc(page, &start, *ppos,
4509 + n = dp->read_proc(page, &start, pos,
4510 count, &eof, dp->data);
4511 } else
4512 break;
4513 @@ -84,8 +87,8 @@
4514 /*
4515 * For proc files that are less than 4k
4516 */
4517 - start = page + *ppos;
4518 - n -= *ppos;
4519 + start = page + pos;
4520 + n -= pos;
4521 if (n <= 0)
4522 break;
4523 if (n > count)
4524 @@ -111,12 +114,13 @@
4525 break;
4526 }
4527
4528 - *ppos += start < page ? (long)start : n; /* Move down the file */
4529 + pos += start < page ? (long)start : n; /* Move down the file */
4530 nbytes -= n;
4531 buf += n;
4532 retval += n;
4533 }
4534 free_page((unsigned long) page);
4535 + *ppos = pos;
4536 return retval;
4537 }
4538
4539 diff -Nru a/fs/proc/kcore.c b/fs/proc/kcore.c
4540 --- a/fs/proc/kcore.c 2004-08-11 19:29:57 -07:00
4541 +++ b/fs/proc/kcore.c 2004-08-11 19:29:57 -07:00
4542 @@ -96,8 +96,9 @@
4543 if (copy_to_user(buf, (void *) (PAGE_OFFSET+p-PAGE_SIZE), count))
4544 return -EFAULT;
4545 read += count;
4546 + p += count;
4547 }
4548 - *ppos += read;
4549 + *ppos = p;
4550 return read;
4551 }
4552 #else /* CONFIG_KCORE_AOUT */
4553 diff -Nru a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
4554 --- a/fs/proc/proc_misc.c 2004-08-11 19:29:57 -07:00
4555 +++ b/fs/proc/proc_misc.c 2004-08-11 19:29:57 -07:00
4556 @@ -500,12 +500,13 @@
4557 static ssize_t read_profile(struct file *file, char *buf,
4558 size_t count, loff_t *ppos)
4559 {
4560 - unsigned long p = *ppos;
4561 + loff_t n = *ppos;
4562 + unsigned p = n;
4563 ssize_t read;
4564 char * pnt;
4565 unsigned int sample_step = 1 << prof_shift;
4566
4567 - if (p >= (prof_len+1)*sizeof(unsigned int))
4568 + if (p != n || p >= (prof_len+1)*sizeof(unsigned int))
4569 return 0;
4570 if (count > (prof_len+1)*sizeof(unsigned int) - p)
4571 count = (prof_len+1)*sizeof(unsigned int) - p;
4572 @@ -519,7 +520,7 @@
4573 if (copy_to_user(buf,(void *)pnt,count))
4574 return -EFAULT;
4575 read += count;
4576 - *ppos += read;
4577 + *ppos = n + read;
4578 return read;
4579 }
4580
4581 diff -Nru a/fs/udf/file.c b/fs/udf/file.c
4582 --- a/fs/udf/file.c 2004-08-11 19:29:57 -07:00
4583 +++ b/fs/udf/file.c 2004-08-11 19:29:57 -07:00
4584 @@ -155,7 +155,8 @@
4585 {
4586 ssize_t retval;
4587 struct inode *inode = file->f_dentry->d_inode;
4588 - int err, pos;
4589 + int err;
4590 + loff_t pos;
4591
4592 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB)
4593 {
4594 @@ -164,8 +165,11 @@
4595 else
4596 pos = *ppos;
4597
4598 - if (inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) +
4599 - pos + count))
4600 + if (pos < 0 || pos + count < pos)
4601 + return 0;
4602 +
4603 + if (inode->i_sb->s_blocksize - udf_file_entry_alloc_offset(inode) <
4604 + pos + count)
4605 {
4606 udf_expand_file_adinicb(inode, pos + count, &err);
4607 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB)
4608 diff -Nru a/mm/shmem.c b/mm/shmem.c
4609 --- a/mm/shmem.c 2004-08-11 19:29:57 -07:00
4610 +++ b/mm/shmem.c 2004-08-11 19:29:57 -07:00
4611 @@ -1051,9 +1051,13 @@
4612 struct inode *inode = filp->f_dentry->d_inode;
4613 struct address_space *mapping = inode->i_mapping;
4614 unsigned long index, offset;
4615 + loff_t pos = *ppos;
4616
4617 - index = *ppos >> PAGE_CACHE_SHIFT;
4618 - offset = *ppos & ~PAGE_CACHE_MASK;
4619 + if (unlikely(pos < 0))
4620 + return;
4621 +
4622 + index = pos >> PAGE_CACHE_SHIFT;
4623 + offset = pos & ~PAGE_CACHE_MASK;
4624
4625 for (;;) {
4626 struct page *page = NULL;
4627 diff -Nru a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
4628 --- a/net/8021q/vlanproc.c 2004-08-11 19:29:57 -07:00
4629 +++ b/net/8021q/vlanproc.c 2004-08-11 19:29:57 -07:00
4630 @@ -234,7 +234,9 @@
4631 struct inode *inode = file->f_dentry->d_inode;
4632 struct proc_dir_entry *dent;
4633 char *page;
4634 - int pos, offs, len;
4635 + int pos, len;
4636 + loff_t n = *ppos;
4637 + unsigned offs = n;
4638
4639 if (count <= 0)
4640 return 0;
4641 @@ -251,15 +253,14 @@
4642 return -ENOBUFS;
4643
4644 pos = dent->get_info(page, dent->data, 0, 0);
4645 - offs = file->f_pos;
4646 - if (offs < pos) {
4647 + if (offs == n && offs < pos) {
4648 len = min_t(int, pos - offs, count);
4649 if (copy_to_user(buf, (page + offs), len)) {
4650 kfree(page);
4651 return -EFAULT;
4652 }
4653
4654 - file->f_pos += len;
4655 + *ppos = offs + len;
4656 } else {
4657 len = 0;
4658 }
4659 diff -Nru a/net/atm/br2684.c b/net/atm/br2684.c
4660 --- a/net/atm/br2684.c 2004-08-11 19:29:57 -07:00
4661 +++ b/net/atm/br2684.c 2004-08-11 19:29:57 -07:00
4662 @@ -737,6 +737,8 @@
4663 unsigned long page;
4664 int len = 0, x, left;
4665 + loff_t n = *pos;
4666 +
4667 page = get_free_page(GFP_KERNEL);
4668 if (!page)
4669 return -ENOMEM;
4670 left = PAGE_SIZE - 256;
4671 @@ -744,7 +745,7 @@
4672 left = count;
4673 read_lock(&devs_lock);
4674 for (;;) {
4675 - x = br2684_proc_engine(*pos, &((char *) page)[len]);
4676 + x = br2684_proc_engine(n, &((char *) page)[len]);
4677 if (x == 0)
4678 break;
4679 if (x > left)
4680 @@ -759,11 +760,12 @@
4681 }
4682 len += x;
4683 left -= x;
4684 - (*pos)++;
4685 + n++;
4686 if (left < 256)
4687 break;
4688 }
4689 read_unlock(&devs_lock);
4690 + *pos = n;
4691 if (len > 0 && copy_to_user(buf, (char *) page, len))
4692 len = -EFAULT;
4693 free_page(page);
4694 diff -Nru a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c
4695 --- a/net/atm/mpoa_proc.c 2004-08-11 19:29:57 -07:00
4696 +++ b/net/atm/mpoa_proc.c 2004-08-11 19:29:57 -07:00
4697 @@ -109,6 +109,7 @@
4698 eg_cache_entry *eg_entry;
4699 struct timeval now;
4700 unsigned char ip_string[16];
4701 + loff_t n = *pos;
4702 if(count == 0)
4703 return 0;
4704 page = get_free_page(GFP_KERNEL);
4705 @@ -150,14 +151,14 @@
4706 mpc = mpc->next;
4707 }
4708
4709 - if (*pos >= length) length = 0;
4710 + if (n != (unsigned)n || n >= length) length = 0;
4711 else {
4712 - if ((count + *pos) > length) count = length - *pos;
4713 + if (count > length - n) count = length - n;
4714 if (copy_to_user(buff, (char *)page , count)) {
4715 free_page(page);
4716 return -EFAULT;
4717 }
4718 - *pos += count;
4719 + *pos = n + count;
4720 }
4721
4722 free_page(page);
4723 diff -Nru a/net/wanrouter/wanproc.c b/net/wanrouter/wanproc.c
4724 --- a/net/wanrouter/wanproc.c 2004-08-11 19:29:57 -07:00
4725 +++ b/net/wanrouter/wanproc.c 2004-08-11 19:29:57 -07:00
4726 @@ -243,7 +243,9 @@
4727 struct inode *inode = file->f_dentry->d_inode;
4728 struct proc_dir_entry* dent;
4729 char* page;
4730 - int pos, offs, len;
4731 + int pos, len;
4732 + loff_t n = *ppos;
4733 + unsigned offs = n;
4734
4735 if (count <= 0)
4736 return 0;
4737 @@ -257,14 +259,13 @@
4738 return -ENOBUFS;
4739
4740 pos = dent->get_info(page, dent->data, 0, 0);
4741 - offs = file->f_pos;
4742 - if (offs < pos) {
4743 + if (offs == n && offs < pos) {
4744 len = min_t(unsigned int, pos - offs, count);
4745 if (copy_to_user(buf, (page + offs), len)) {
4746 kfree(page);
4747 return -EFAULT;
4748 }
4749 - file->f_pos += len;
4750 + *ppos = offs + len;
4751 }
4752 else
4753 len = 0;
4754 #ChangeSet 1.1469
4755 # This is a BitKeeper generated diff -Nru style patch.
4756 #
4757 # ChangeSet
4758 # 2004/08/04 16:16:57-03:00 geert@linux-m68k.org
4759 # [PATCH] Fix net/atm/br2684.c file offset patch
4760 #
4761 # Breaks the build with gcc 2.95. Trivial fix below:
4762 #
4763 # net/atm/br2684.c
4764 # 2004/08/04 12:21:16-03:00 geert@linux-m68k.org +2 -1
4765 # Fix net/atm/br2684.c file offset patch
4766 # *** Incorporated into patch for ChangeSet 1.1465 above - Horms 2004/08/12 ***
4767 #
4768
4769 #ChangeSet1.1458.1.11
4770 # This is a BitKeeper generated diff -Nru style patch.
4771 #
4772 # ChangeSet
4773 # 2004/08/04 16:16:57-03:00 geert@linux-m68k.org
4774 # [PATCH] Fix net/atm/br2684.c file offset patch
4775 #
4776 # Breaks the build with gcc 2.95. Trivial fix below:
4777 #
4778 # net/atm/br2684.c
4779 # 2004/08/04 12:21:16-03:00 geert@linux-m68k.org +2 -1
4780 # Fix net/atm/br2684.c file offset patch
4781 # *** Incorporated into patch for ChangeSet 1.1465 above - Horms 2004/08/14 ***
4782 #
4783
4784 # Reverse bogus patch
4785 # Horms 2004/08/12
4786
4787 --- a/drivers/acpi/asus_acpi.c 2004-08-12 17:35:40.000000000 +0900
4788 +++ b/drivers/acpi/asus_acpi.c 2004-08-12 17:36:24.000000000 +0900
4789 @@ -403,8 +403,7 @@
4790 if (copy_from_user(s, buf, count))
4791 return -EFAULT;
4792 s[count] = 0;
4793 - count = parse_arg(buffer, count, &value);
4794 - if (count > 0)
4795 + if (sscanf(s, "%i", val) != 1)
4796 return -EINVAL;
4797 return count;
4798 }
4799
4800 # Device mapper merged in from devmapper-1.00.19
4801 # Horms 2004/08/12
4802 --- kernel-source-2.4.26-2.4.26/MAINTAINERS 2004-08-12 14:04:29.000000000 +0900
4803 +++ kernel-source-2.4.26-2.4.26.devmap/MAINTAINERS 2004-08-12 13:57:11.000000000 +0900
4804 @@ -589,9 +589,9 @@
4805
4806 DEVICE MAPPER
4807 P: Joe Thornber
4808 -M: dm@uk.sistina.com
4809 -L: linux-LVM@sistina.com
4810 -W: http://www.sistina.com/lvm
4811 +M: dm-devel@redhat.com
4812 +L: dm-devel@redhat.com
4813 +W: http://sources.redhat.com/dm
4814 S: Maintained
4815
4816 DEVICE NUMBER REGISTRY
4817 --- kernel-source-2.4.26-2.4.26/arch/mips64/kernel/ioctl32.c 2004-08-12 14:04:28.000000000 +0900
4818 +++ kernel-source-2.4.26-2.4.26.devmap/arch/mips64/kernel/ioctl32.c 2004-08-12 14:03:12.000000000 +0900
4819 @@ -49,7 +49,6 @@
4820 #if defined(CONFIG_BLK_DEV_LVM) || defined(CONFIG_BLK_DEV_LVM_MODULE)
4821 #include <linux/lvm.h>
4822 #endif /* LVM */
4823 -#include <linux/dm-ioctl.h>
4824
4825 #include <scsi/scsi.h>
4826 #undef __KERNEL__ /* This file was born to be ugly ... */
4827 @@ -63,6 +62,7 @@
4828
4829 #include <linux/mtd/mtd.h>
4830 #include <linux/serial.h>
4831 +#include <linux/dm-ioctl.h>
4832
4833 #ifdef CONFIG_SIBYTE_TBPROF
4834 #include <asm/sibyte/trace_prof.h>
4835 @@ -2342,6 +2342,7 @@
4836 IOCTL32_DEFAULT(DM_DEV_WAIT),
4837 IOCTL32_DEFAULT(DM_LIST_DEVICES),
4838 IOCTL32_DEFAULT(DM_TABLE_CLEAR),
4839 + IOCTL32_DEFAULT(DM_LIST_VERSIONS),
4840 #endif /* CONFIG_BLK_DEV_DM */
4841
4842 #ifdef CONFIG_SIBYTE_TBPROF
4843 --- kernel-source-2.4.26-2.4.26/arch/parisc/kernel/ioctl32.c 2004-08-12 14:04:28.000000000 +0900
4844 +++ kernel-source-2.4.26-2.4.26.devmap/arch/parisc/kernel/ioctl32.c 2004-08-12 13:41:02.000000000 +0900
4845 @@ -3439,6 +3439,7 @@
4846 COMPATIBLE_IOCTL(DM_DEV_WAIT)
4847 COMPATIBLE_IOCTL(DM_LIST_DEVICES)
4848 COMPATIBLE_IOCTL(DM_TABLE_CLEAR)
4849 +COMPATIBLE_IOCTL(DM_LIST_VERSIONS)
4850 #endif /* CONFIG_BLK_DEV_DM */
4851 #if defined(CONFIG_DRM) || defined(CONFIG_DRM_MODULE)
4852 COMPATIBLE_IOCTL(DRM_IOCTL_GET_MAGIC)
4853 --- kernel-source-2.4.26-2.4.26/arch/ppc64/kernel/ioctl32.c 2004-08-12 14:04:28.000000000 +0900
4854 +++ kernel-source-2.4.26-2.4.26.devmap/arch/ppc64/kernel/ioctl32.c 2004-08-12 13:44:38.000000000 +0900
4855 @@ -4424,6 +4423,7 @@
4856 COMPATIBLE_IOCTL(DM_DEV_WAIT),
4857 COMPATIBLE_IOCTL(DM_LIST_DEVICES),
4858 COMPATIBLE_IOCTL(DM_TABLE_CLEAR),
4859 +COMPATIBLE_IOCTL(DM_LIST_VERSIONS),
4860 #endif /* CONFIG_BLK_DEV_DM */
4861 /* Remove *PRIVATE in 2.5 */
4862 COMPATIBLE_IOCTL(SIOCDEVPRIVATE),
4863 --- kernel-source-2.4.26-2.4.26/arch/s390x/kernel/ioctl32.c 2004-08-12 14:04:28.000000000 +0900
4864 +++ kernel-source-2.4.26-2.4.26.devmap/arch/s390x/kernel/ioctl32.c 2004-08-12 13:41:02.000000000 +0900
4865 @@ -641,6 +641,7 @@
4866 IOCTL32_DEFAULT(DM_DEV_WAIT),
4867 IOCTL32_DEFAULT(DM_LIST_DEVICES),
4868 IOCTL32_DEFAULT(DM_TABLE_CLEAR),
4869 + IOCTL32_DEFAULT(DM_LIST_VERSIONS),
4870
4871 IOCTL32_DEFAULT(LOOP_SET_FD),
4872 IOCTL32_DEFAULT(LOOP_CLR_FD),
4873 --- kernel-source-2.4.26-2.4.26/arch/sparc64/kernel/ioctl32.c 2004-08-12 14:04:28.000000000 +0900
4874 +++ kernel-source-2.4.26-2.4.26.devmap/arch/sparc64/kernel/ioctl32.c 2004-08-12 13:41:02.000000000 +0900
4875 @@ -5141,6 +5141,7 @@
4876 COMPATIBLE_IOCTL(DM_DEV_WAIT)
4877 COMPATIBLE_IOCTL(DM_LIST_DEVICES)
4878 COMPATIBLE_IOCTL(DM_TABLE_CLEAR)
4879 +COMPATIBLE_IOCTL(DM_LIST_VERSIONS)
4880 #endif /* CONFIG_BLK_DEV_DM */
4881 /* Linux-1394 */
4882 #if defined(CONFIG_IEEE1394) || defined(CONFIG_IEEE1394_MODULE)
4883 --- kernel-source-2.4.26-2.4.26/arch/x86_64/ia32/ia32_ioctl.c 2004-08-12 14:04:28.000000000 +0900
4884 +++ kernel-source-2.4.26-2.4.26.devmap/arch/x86_64/ia32/ia32_ioctl.c 2004-08-12 13:41:02.000000000 +0900
4885 @@ -4156,6 +4156,7 @@
4886 COMPATIBLE_IOCTL(DM_DEV_WAIT)
4887 COMPATIBLE_IOCTL(DM_LIST_DEVICES)
4888 COMPATIBLE_IOCTL(DM_TABLE_CLEAR)
4889 +COMPATIBLE_IOCTL(DM_LIST_VERSIONS)
4890 #endif /* CONFIG_BLK_DEV_DM */
4891 #ifdef CONFIG_AUTOFS_FS
4892 COMPATIBLE_IOCTL(AUTOFS_IOC_READY)
4893 --- kernel-source-2.4.26-2.4.26/drivers/md/Config.in 2004-08-12 14:04:28.000000000 +0900
4894 +++ kernel-source-2.4.26-2.4.26.devmap/drivers/md/Config.in 2004-08-12 13:41:02.000000000 +0900
4895 @@ -15,5 +15,6 @@
4896
4897 dep_tristate ' Logical volume manager (LVM) support' CONFIG_BLK_DEV_LVM $CONFIG_MD
4898 dep_tristate ' Device-mapper support' CONFIG_BLK_DEV_DM $CONFIG_MD
4899 +dep_tristate ' Mirror (RAID-1) support' CONFIG_BLK_DEV_DM_MIRROR $CONFIG_BLK_DEV_DM
4900
4901 endmenu
4902 --- kernel-source-2.4.26-2.4.26/drivers/md/Makefile 2004-08-12 14:04:28.000000000 +0900
4903 +++ kernel-source-2.4.26-2.4.26.devmap/drivers/md/Makefile 2004-08-12 13:41:02.000000000 +0900
4904 @@ -4,13 +4,16 @@
4905
4906 O_TARGET := mddev.o
4907
4908 -export-objs := md.o xor.o dm-table.o dm-target.o \
4909 - dm.o
4910 +export-objs := md.o xor.o dm-table.o dm-target.o kcopyd.o dm-daemon.o \
4911 + dm-log.o dm-io.o dm.o
4912
4913 -list-multi := lvm-mod.o dm-mod.o
4914 +list-multi := lvm-mod.o dm-mod.o dm-mirror-mod.o
4915 lvm-mod-objs := lvm.o lvm-snap.o lvm-fs.o
4916 dm-mod-objs := dm.o dm-table.o dm-target.o dm-ioctl.o \
4917 - dm-linear.o dm-stripe.o
4918 + dm-linear.o dm-stripe.o dm-snapshot.o dm-exception-store.o \
4919 + kcopyd.o dm-daemon.o dm-io.o
4920 +dm-mirror-mod-objs := dm-raid1.o dm-log.o
4921 +
4922
4923 # Note: link order is important. All raid personalities
4924 # and xor.o must come before md.o, as they each initialise
4925 @@ -27,6 +30,7 @@
4926 obj-$(CONFIG_BLK_DEV_LVM) += lvm-mod.o
4927
4928 obj-$(CONFIG_BLK_DEV_DM) += dm-mod.o
4929 +obj-$(CONFIG_BLK_DEV_DM_MIRROR) += dm-mirror.o
4930
4931 include $(TOPDIR)/Rules.make
4932
4933 @@ -36,3 +40,7 @@
4934 dm-mod.o: $(dm-mod-objs)
4935 $(LD) -r -o $@ $(dm-mod-objs)
4936
4937 +dm-mirror.o: $(dm-mirror-mod-objs)
4938 + $(LD) -r -o $@ $(dm-mirror-mod-objs)
4939 +
4940 +
4941 --- kernel-source-2.4.26-2.4.26/drivers/md/dm-ioctl.c 2004-08-12 14:04:28.000000000 +0900
4942 +++ kernel-source-2.4.26-2.4.26.devmap/drivers/md/dm-ioctl.c 2004-08-12 13:41:02.000000000 +0900
4943 @@ -17,7 +17,7 @@
4944
4945 #include <asm/uaccess.h>
4946
4947 -#define DM_DRIVER_EMAIL "dm@uk.sistina.com"
4948 +#define DM_DRIVER_EMAIL "dm-devel@redhat.com"
4949
4950 /*-----------------------------------------------------------------
4951 * The ioctl interface needs to be able to look up devices by
4952 @@ -36,6 +36,13 @@
4953 devfs_handle_t devfs_entry;
4954 };
4955
4956 +struct vers_iter {
4957 + size_t param_size;
4958 + struct dm_target_versions *vers, *old_vers;
4959 + char *end;
4960 + uint32_t flags;
4961 +};
4962 +
4963 #define NUM_BUCKETS 64
4964 #define MASK_BUCKETS (NUM_BUCKETS - 1)
4965 static struct list_head _name_buckets[NUM_BUCKETS];
4966 @@ -420,6 +427,78 @@
4967 return 0;
4968 }
4969
4970 +static void list_version_get_needed(struct target_type *tt, void *param)
4971 +{
4972 + int *needed = param;
4973 +
4974 + *needed += strlen(tt->name);
4975 + *needed += sizeof(tt->version);
4976 + *needed += ALIGN_MASK;
4977 +}
4978 +
4979 +static void list_version_get_info(struct target_type *tt, void *param)
4980 +{
4981 + struct vers_iter *info = param;
4982 +
4983 + /* Check space - it might have changed since the first iteration */
4984 + if ((char *)info->vers + sizeof(tt->version) + strlen(tt->name) + 1 >
4985 + info->end) {
4986 + info->flags = DM_BUFFER_FULL_FLAG;
4987 + return;
4988 + }
4989 +
4990 + if (info->old_vers)
4991 + info->old_vers->next = (uint32_t) ((void *)info->vers -
4992 + (void *)info->old_vers);
4993 +
4994 + info->vers->version[0] = tt->version[0];
4995 + info->vers->version[1] = tt->version[1];
4996 + info->vers->version[2] = tt->version[2];
4997 + info->vers->next = 0;
4998 + strcpy(info->vers->name, tt->name);
4999 +
5000 + info->old_vers = info->vers;
5001 + info->vers = align_ptr(((void *) ++info->vers) + strlen(tt->name) + 1);
5002 +}
5003 +
5004 +static int list_versions(struct dm_ioctl *param, size_t param_size)
5005 +{
5006 + size_t len, needed = 0;
5007 + struct dm_target_versions *vers;
5008 + struct vers_iter iter_info;
5009 +
5010 + /*
5011 + * Loop through all the devices working out how much
5012 + * space we need.
5013 + */
5014 + dm_target_iterate(list_version_get_needed, &needed);
5015 +
5016 + /*
5017 + * Grab our output buffer.
5018 + */
5019 + vers = get_result_buffer(param, param_size, &len);
5020 + if (len < needed) {
5021 + param->flags |= DM_BUFFER_FULL_FLAG;
5022 + goto out;
5023 + }
5024 + param->data_size = param->data_start + needed;
5025 +
5026 + iter_info.param_size = param_size;
5027 + iter_info.old_vers = NULL;
5028 + iter_info.vers = vers;
5029 + iter_info.flags = 0;
5030 + iter_info.end = (char *)vers+len;
5031 +
5032 + /*
5033 + * Now loop through filling out the names & versions.
5034 + */
5035 + dm_target_iterate(list_version_get_info, &iter_info);
5036 + param->flags |= iter_info.flags;
5037 +
5038 + out:
5039 + return 0;
5040 +}
5041 +
5042 static int check_name(const char *name)
5043 {
5044 if (strchr(name, '/')) {
5045 @@ -723,7 +802,7 @@
5046 struct dm_target *ti = dm_table_get_target(table, i);
5047
5048 remaining = len - (outptr - outbuf);
5049 - if (remaining < sizeof(struct dm_target_spec)) {
5050 + if (remaining <= sizeof(struct dm_target_spec)) {
5051 param->flags |= DM_BUFFER_FULL_FLAG;
5052 break;
5053 }
5054 @@ -1044,7 +1123,9 @@
5055 {DM_TABLE_LOAD_CMD, table_load},
5056 {DM_TABLE_CLEAR_CMD, table_clear},
5057 {DM_TABLE_DEPS_CMD, table_deps},
5058 - {DM_TABLE_STATUS_CMD, table_status}
5059 + {DM_TABLE_STATUS_CMD, table_status},
5060 +
5061 + {DM_LIST_VERSIONS_CMD, list_versions}
5062 };
5063
5064 return (cmd >= ARRAY_SIZE(_ioctls)) ? NULL : _ioctls[cmd].fn;
5065 @@ -1118,7 +1199,8 @@
5066 param->flags &= ~DM_BUFFER_FULL_FLAG;
5067
5068 /* Ignores parameters */
5069 - if (cmd == DM_REMOVE_ALL_CMD || cmd == DM_LIST_DEVICES_CMD)
5070 + if (cmd == DM_REMOVE_ALL_CMD || cmd == DM_LIST_DEVICES_CMD ||
5071 + cmd == DM_LIST_VERSIONS_CMD)
5072 return 0;
5073
5074 /* Unless creating, either name or uuid but not both */
5075 --- kernel-source-2.4.26-2.4.26/drivers/md/dm-linear.c 2004-08-12 14:04:28.000000000 +0900
5076 +++ kernel-source-2.4.26-2.4.26.devmap/drivers/md/dm-linear.c 2004-08-12 13:41:02.000000000 +0900
5077 @@ -1,5 +1,5 @@
5078 /*
5079 - * Copyright (C) 2001 Sistina Software (UK) Limited.
5080 + * Copyright (C) 2001-2003 Sistina Software (UK) Limited.
5081 *
5082 * This file is released under the GPL.
5083 */
5084 @@ -97,6 +97,7 @@
5085
5086 static struct target_type linear_target = {
5087 .name = "linear",
5088 + .version= {1, 0, 1},
5089 .module = THIS_MODULE,
5090 .ctr = linear_ctr,
5091 .dtr = linear_dtr,
5092 --- kernel-source-2.4.26-2.4.26/drivers/md/dm-stripe.c 2004-08-12 14:04:28.000000000 +0900
5093 +++ kernel-source-2.4.26-2.4.26.devmap/drivers/md/dm-stripe.c 2004-08-12 13:41:02.000000000 +0900
5094 @@ -1,5 +1,5 @@
5095 /*
5096 - * Copyright (C) 2001 Sistina Software (UK) Limited.
5097 + * Copyright (C) 2001-2003 Sistina Software (UK) Limited.
5098 *
5099 * This file is released under the GPL.
5100 */
5101 @@ -231,6 +231,7 @@
5102
5103 static struct target_type stripe_target = {
5104 .name = "striped",
5105 + .version= {1, 0, 1},
5106 .module = THIS_MODULE,
5107 .ctr = stripe_ctr,
5108 .dtr = stripe_dtr,
5109 --- kernel-source-2.4.26-2.4.26/drivers/md/dm-target.c 2004-08-12 14:04:28.000000000 +0900
5110 +++ kernel-source-2.4.26-2.4.26.devmap/drivers/md/dm-target.c 2004-08-12 13:41:02.000000000 +0900
5111 @@ -105,6 +105,20 @@
5112 return ti;
5113 }
5114
5115 +
5116 +int dm_target_iterate(void (*iter_func)(struct target_type *tt,
5117 + void *param), void *param)
5118 +{
5119 + struct tt_internal *ti;
5120 +
5121 + down_read(&_lock);
5122 + list_for_each_entry (ti, &_targets, list)
5123 + iter_func(&ti->tt, param);
5124 + up_read(&_lock);
5125 +
5126 + return 0;
5127 +}
5128 +
5129 int dm_register_target(struct target_type *t)
5130 {
5131 int rv = 0;
5132 @@ -168,6 +182,7 @@
5133
5134 static struct target_type error_target = {
5135 .name = "error",
5136 + .version = {1, 0, 1},
5137 .ctr = io_err_ctr,
5138 .dtr = io_err_dtr,
5139 .map = io_err_map,
5140 --- kernel-source-2.4.26-2.4.26/drivers/md/dm.c 2004-08-12 14:04:28.000000000 +0900
5141 +++ kernel-source-2.4.26-2.4.26.devmap/drivers/md/dm.c 2004-08-12 13:41:02.000000000 +0900
5142 @@ -5,6 +5,7 @@
5143 */
5144
5145 #include "dm.h"
5146 +#include "kcopyd.h"
5147
5148 #include <linux/init.h>
5149 #include <linux/module.h>
5150 @@ -363,9 +364,11 @@
5151 } _inits[] = {
5152 #define xx(n) {n ## _init, n ## _exit},
5153 xx(local)
5154 + xx(kcopyd)
5155 xx(dm_target)
5156 xx(dm_linear)
5157 xx(dm_stripe)
5158 + xx(dm_snapshot)
5159 xx(dm_interface)
5160 #undef xx
5161 };
5162 --- kernel-source-2.4.26-2.4.26/drivers/md/dm.h 2004-08-12 14:04:28.000000000 +0900
5163 +++ kernel-source-2.4.26-2.4.26.devmap/drivers/md/dm.h 2004-08-12 13:41:02.000000000 +0900
5164 @@ -123,6 +123,8 @@
5165 void dm_target_exit(void);
5166 struct target_type *dm_get_target_type(const char *name);
5167 void dm_put_target_type(struct target_type *t);
5168 +int dm_target_iterate(void (*iter_func)(struct target_type *tt,
5169 + void *param), void *param);
5170
5171
5172 /*-----------------------------------------------------------------
5173 @@ -169,4 +171,7 @@
5174 int dm_stripe_init(void);
5175 void dm_stripe_exit(void);
5176
5177 +int dm_snapshot_init(void);
5178 +void dm_snapshot_exit(void);
5179 +
5180 #endif
5181 --- kernel-source-2.4.26-2.4.26/drivers/md/lvm.c 2004-02-18 22:36:31.000000000 +0900
5182 +++ kernel-source-2.4.26-2.4.26.devmap/drivers/md/lvm.c 2004-08-12 13:41:02.000000000 +0900
5183 @@ -236,9 +236,6 @@
5184 #define DEVICE_OFF(device)
5185 #define LOCAL_END_REQUEST
5186
5187 -/* lvm_do_lv_create calls fsync_dev_lockfs()/unlockfs() */
5188 -/* #define LVM_VFS_ENHANCEMENT */
5189 -
5190 #include <linux/config.h>
5191 #include <linux/module.h>
5192 #include <linux/kernel.h>
5193 @@ -2250,12 +2247,8 @@
5194 if (lv_ptr->lv_access & LV_SNAPSHOT) {
5195 lv_t *org = lv_ptr->lv_snapshot_org, *last;
5196
5197 - /* sync the original logical volume */
5198 - fsync_dev(org->lv_dev);
5199 -#ifdef LVM_VFS_ENHANCEMENT
5200 /* VFS function call to sync and lock the filesystem */
5201 fsync_dev_lockfs(org->lv_dev);
5202 -#endif
5203
5204 down_write(&org->lv_lock);
5205 org->lv_access |= LV_SNAPSHOT_ORG;
5206 @@ -2281,11 +2274,9 @@
5207 else
5208 set_device_ro(lv_ptr->lv_dev, 1);
5209
5210 -#ifdef LVM_VFS_ENHANCEMENT
5211 /* VFS function call to unlock the filesystem */
5212 if (lv_ptr->lv_access & LV_SNAPSHOT)
5213 unlockfs(lv_ptr->lv_snapshot_org->lv_dev);
5214 -#endif
5215
5216 lvm_gendisk.part[MINOR(lv_ptr->lv_dev)].de =
5217 lvm_fs_create_lv(vg_ptr, lv_ptr);
5218 --- kernel-source-2.4.26-2.4.26/fs/buffer.c 2004-08-12 14:04:28.000000000 +0900
5219 +++ kernel-source-2.4.26-2.4.26.devmap/fs/buffer.c 2004-08-12 13:41:02.000000000 +0900
5220 @@ -419,6 +419,34 @@
5221 fsync_dev(dev);
5222 }
5223
5224 +int fsync_dev_lockfs(kdev_t dev)
5225 +{
5226 + /* you are not allowed to try locking all the filesystems
5227 + ** on the system, your chances of getting through without
5228 + ** total deadlock are slim to none.
5229 + */
5230 + if (!dev)
5231 + return fsync_dev(dev) ;
5232 +
5233 + sync_buffers(dev, 0);
5234 +
5235 + lock_kernel();
5236 + /* note, the FS might need to start transactions to
5237 + ** sync the inodes, or the quota, no locking until
5238 + ** after these are done
5239 + */
5240 + sync_inodes(dev);
5241 + DQUOT_SYNC_DEV(dev);
5242 + /* if inodes or quotas could be dirtied during the
5243 + ** sync_supers_lockfs call, the FS is responsible for getting
5244 + ** them on disk, without deadlocking against the lock
5245 + */
5246 + sync_supers_lockfs(dev) ;
5247 + unlock_kernel();
5248 +
5249 + return sync_buffers(dev, 1) ;
5250 +}
5251 +
5252 asmlinkage long sys_sync(void)
5253 {
5254 fsync_dev(0);
5255 --- kernel-source-2.4.26-2.4.26/fs/reiserfs/super.c 2003-08-25 20:44:43.000000000 +0900
5256 +++ kernel-source-2.4.26-2.4.26.devmap/fs/reiserfs/super.c 2004-08-12 13:41:02.000000000 +0900
5257 @@ -73,7 +73,7 @@
5258 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
5259 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s));
5260 reiserfs_block_writes(&th) ;
5261 - journal_end(&th, s, 1) ;
5262 + journal_end_sync(&th, s, 1) ;
5263 }
5264 s->s_dirt = dirty;
5265 unlock_kernel() ;
5266 --- kernel-source-2.4.26-2.4.26/fs/super.c 2003-08-25 20:44:43.000000000 +0900
5267 +++ kernel-source-2.4.26-2.4.26.devmap/fs/super.c 2004-08-12 13:41:02.000000000 +0900
5268 @@ -39,6 +39,12 @@
5269 spinlock_t sb_lock = SPIN_LOCK_UNLOCKED;
5270
5271 /*
5272 + * stub of a filesystem used to make sure an FS isn't mounted
5273 + * in the middle of a lockfs call
5274 + */
5275 +static DECLARE_FSTYPE_DEV(lockfs_fs_type, "lockfs", NULL);
5276 +
5277 +/*
5278 * Handling of filesystem drivers list.
5279 * Rules:
5280 * Inclusion to/removals from/scanning of list are protected by spinlock.
5281 @@ -436,6 +442,25 @@
5282 put_super(sb);
5283 }
5284
5285 +static void write_super_lockfs(struct super_block *sb)
5286 +{
5287 + lock_super(sb);
5288 + if (sb->s_root && sb->s_op) {
5289 + if (sb->s_dirt && sb->s_op->write_super)
5290 + sb->s_op->write_super(sb);
5291 + if (sb->s_op->write_super_lockfs)
5292 + sb->s_op->write_super_lockfs(sb);
5293 + }
5294 + unlock_super(sb);
5295 +
5296 + /*
5297 + * if no lockfs call is provided, use the sync_fs call instead.
5298 + * this must be done without the super lock held
5299 + */
5300 + if (!sb->s_op->write_super_lockfs && sb->s_op->sync_fs)
5301 + sb->s_op->sync_fs(sb);
5302 +}
5303 +
5304 static inline void write_super(struct super_block *sb)
5305 {
5306 lock_super(sb);
5307 @@ -483,6 +508,119 @@
5308 spin_unlock(&sb_lock);
5309 }
5310
5311 +static struct super_block *find_super_for_lockfs(kdev_t dev)
5312 +{
5313 + struct super_block *lockfs_sb = alloc_super();
5314 + struct super_block * s;
5315 +
5316 + if (!dev)
5317 + return NULL;
5318 +restart:
5319 + spin_lock(&sb_lock);
5320 + s = find_super(dev);
5321 + if (s) {
5322 + spin_unlock(&sb_lock);
5323 + down_read(&s->s_umount);
5324 + if (s->s_root) {
5325 + destroy_super(lockfs_sb);
5326 + return s;
5327 + }
5328 + drop_super(s);
5329 + goto restart;
5330 + }
5331 + /* if (s) we either return or goto, so we know s == NULL here.
5332 + * At this point, there are no mounted filesystems on this device,
5333 + * so we pretend to mount one.
5334 + */
5335 + if (!lockfs_sb) {
5336 + spin_unlock(&sb_lock);
5337 + return NULL;
5338 + }
5339 + s = lockfs_sb;
5340 + s->s_dev = dev;
5341 + if (lockfs_fs_type.fs_supers.prev == NULL)
5342 + INIT_LIST_HEAD(&lockfs_fs_type.fs_supers);
5343 + insert_super(s, &lockfs_fs_type);
5344 + s->s_root = (struct dentry *)1;
5345 + /* alloc_super gives us a write lock on s_umount, this
5346 + * way we know there are no concurrent lockfs holders for this dev.
5347 + * It allows us to remove the temp super from the list of supers
5348 + * immediately when unlockfs is called
5349 + */
5350 + return s;
5351 +}
5352 +/*
5353 + * Note: don't check the dirty flag before waiting, we want the lock
5354 + * to happen every time this is called. dev must be non-zero
5355 + */
5356 +void sync_supers_lockfs(kdev_t dev)
5357 +{
5358 + struct super_block *sb;
5359 + sb = find_super_for_lockfs(dev);
5360 + if (sb) {
5361 + write_super_lockfs(sb);
5362 + /* the drop_super is done by unlockfs */
5363 + }
5364 +}
5365 +
5366 +static void drop_super_lockfs(struct super_block *s)
5367 +{
5368 + if (s->s_type == &lockfs_fs_type) {
5369 + struct file_system_type *fs = s->s_type;
5370 +
5371 + /*
5372 + * nobody else is allowed to grab_super() on our temp
5373 + */
5374 + if (!deactivate_super(s))
5375 + BUG();
5376 +
5377 + spin_lock(&sb_lock);
5378 + s->s_root = NULL;
5379 + list_del(&s->s_list);
5380 + list_del(&s->s_instances);
5381 + spin_unlock(&sb_lock);
5382 +
5383 + up_write(&s->s_umount);
5384 + put_super(s);
5385 + put_filesystem(fs);
5386 + } else
5387 + drop_super(s);
5388 +}
5389 +
5390 +void unlockfs(kdev_t dev)
5391 +{
5392 + struct super_block *s;
5393 + if (!dev)
5394 + return;
5395 +
5396 + spin_lock(&sb_lock);
5397 + s = find_super(dev);
5398 + if (s) {
5399 + /*
5400 + * find_super and the original lockfs call both incremented
5401 + * the reference count. drop one of them
5402 + */
5403 + s->s_count--;
5404 + spin_unlock(&sb_lock);
5405 + if (s->s_root) {
5406 + if (s->s_op->unlockfs)
5407 + s->s_op->unlockfs(s);
5408 + drop_super_lockfs(s);
5409 + goto out;
5410 + } else {
5411 + printk("unlockfs: no s_root, dev %s\n", kdevname(dev));
5412 + BUG();
5413 + }
5414 + } else {
5415 + printk("unlockfs: no super found, dev %s\n", kdevname(dev));
5416 + BUG();
5417 + }
5418 +
5419 + spin_unlock(&sb_lock);
5420 +out:
5421 + return;
5422 +}
5423 +
5424 /**
5425 * get_super - get the superblock of a device
5426 * @dev: device to get the superblock for
5427 --- kernel-source-2.4.26-2.4.26/include/linux/device-mapper.h 2004-08-12 14:04:28.000000000 +0900
5428 +++ kernel-source-2.4.26-2.4.26.devmap/include/linux/device-mapper.h 2004-08-12 13:41:02.000000000 +0900
5429 @@ -74,6 +74,7 @@
5430 struct target_type {
5431 const char *name;
5432 struct module *module;
5433 + unsigned version[3];
5434 dm_ctr_fn ctr;
5435 dm_dtr_fn dtr;
5436 dm_map_fn map;
5437 --- kernel-source-2.4.26-2.4.26/include/linux/dm-ioctl.h 2004-08-12 14:04:28.000000000 +0900
5438 +++ kernel-source-2.4.26-2.4.26.devmap/include/linux/dm-ioctl.h 2004-08-12 13:41:02.000000000 +0900
5439 @@ -163,6 +163,16 @@
5440 };
5441
5442 /*
5443 + * Used to retrieve the target versions
5444 + */
5445 +struct dm_target_versions {
5446 + uint32_t next;
5447 + uint32_t version[3];
5448 +
5449 + char name[0];
5450 +};
5451 +
5452 +/*
5453 * If you change this make sure you make the corresponding change
5454 * to dm-ioctl.c:lookup_ioctl()
5455 */
5456 @@ -185,6 +195,9 @@
5457 DM_TABLE_CLEAR_CMD,
5458 DM_TABLE_DEPS_CMD,
5459 DM_TABLE_STATUS_CMD,
5460 +
5461 + /* Added later */
5462 + DM_LIST_VERSIONS_CMD,
5463 };
5464
5465 #define DM_IOCTL 0xfd
5466 @@ -205,10 +218,12 @@
5467 #define DM_TABLE_DEPS _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, struct dm_ioctl)
5468 #define DM_TABLE_STATUS _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, struct dm_ioctl)
5469
5470 +#define DM_LIST_VERSIONS _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, struct dm_ioctl)
5471 +
5472 #define DM_VERSION_MAJOR 4
5473 -#define DM_VERSION_MINOR 0
5474 -#define DM_VERSION_PATCHLEVEL 5
5475 -#define DM_VERSION_EXTRA "-ioctl (2003-11-18)"
5476 +#define DM_VERSION_MINOR 1
5477 +#define DM_VERSION_PATCHLEVEL 1
5478 +#define DM_VERSION_EXTRA "-ioctl (2004-04-07)"
5479
5480 /* Status bits */
5481 #define DM_READONLY_FLAG (1 << 0) /* In/Out */
5482 --- kernel-source-2.4.26-2.4.26/include/linux/fs.h 2004-08-12 14:04:28.000000000 +0900
5483 +++ kernel-source-2.4.26-2.4.26.devmap/include/linux/fs.h 2004-08-12 13:41:02.000000000 +0900
5484 @@ -1279,6 +1279,7 @@
5485 extern int sync_buffers(kdev_t, int);
5486 extern void sync_dev(kdev_t);
5487 extern int fsync_dev(kdev_t);
5488 +extern int fsync_dev_lockfs(kdev_t);
5489 extern int fsync_super(struct super_block *);
5490 extern int fsync_no_super(kdev_t);
5491 extern void sync_inodes_sb(struct super_block *);
5492 @@ -1297,6 +1298,8 @@
5493 extern int filemap_fdatasync(struct address_space *);
5494 extern int filemap_fdatawait(struct address_space *);
5495 extern void sync_supers(kdev_t dev, int wait);
5496 +extern void sync_supers_lockfs(kdev_t);
5497 +extern void unlockfs(kdev_t);
5498 extern int bmap(struct inode *, int);
5499 extern int notify_change(struct dentry *, struct iattr *);
5500 extern int permission(struct inode *, int);
5501 --- kernel-source-2.4.26-2.4.26/kernel/ksyms.c 2004-08-12 14:04:28.000000000 +0900
5502 +++ kernel-source-2.4.26-2.4.26.devmap/kernel/ksyms.c 2004-08-12 13:41:02.000000000 +0900
5503 @@ -207,6 +207,8 @@
5504 EXPORT_SYMBOL(invalidate_inode_pages);
5505 EXPORT_SYMBOL(truncate_inode_pages);
5506 EXPORT_SYMBOL(fsync_dev);
5507 +EXPORT_SYMBOL(fsync_dev_lockfs);
5508 +EXPORT_SYMBOL(unlockfs);
5509 EXPORT_SYMBOL(fsync_no_super);
5510 EXPORT_SYMBOL(permission);
5511 EXPORT_SYMBOL(vfs_permission);
5512 --- kernel-source-2.4.26-2.4.26/mm/filemap.c 2004-04-14 22:05:41.000000000 +0900
5513 +++ kernel-source-2.4.26-2.4.26.devmap/mm/filemap.c 2004-08-12 13:41:02.000000000 +0900
5514 @@ -1809,7 +1809,8 @@
5515 retval = do_generic_direct_read(filp, buf, count, ppos);
5516 up(&inode->i_sem);
5517 up_read(&inode->i_alloc_sem);
5518 - UPDATE_ATIME(filp->f_dentry->d_inode);
5519 + if (!S_ISBLK(inode->i_mode))
5520 + UPDATE_ATIME(filp->f_dentry->d_inode);
5521 goto out;
5522 }
5523 }
5524 @@ -3187,8 +3188,12 @@
5525 goto out;
5526
5527 remove_suid(inode);
5528 - inode->i_ctime = inode->i_mtime = CURRENT_TIME;
5529 - mark_inode_dirty_sync(inode);
5530 +
5531 + /* Don't update times for block devices using O_DIRECT */
5532 + if (!(file->f_flags & O_DIRECT) || !S_ISBLK(inode->i_mode)) {
5533 + inode->i_ctime = inode->i_mtime = CURRENT_TIME;
5534 + mark_inode_dirty_sync(inode);
5535 + }
5536
5537 do {
5538 unsigned long index, offset;
5539 #ChangeSet1.1722.10.22
5540 # This is a BitKeeper generated diff -Nru style patch.
5541 #
5542 # ChangeSet
5543 # 2004/05/22 13:35:20-07:00 herbet@gondor.apana.org.au
5544 # [IPSEC]: Lock policy in policy timer.
5545 #
5546 # net/xfrm/xfrm_policy.c
5547 # 2004/05/22 13:35:06-07:00 herbet@gondor.apana.org.au +3 -0
5548 # [IPSEC]: Lock policy in policy timer.
5549 #
5550 diff -Nru a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
5551 --- a/net/xfrm/xfrm_policy.c 2004-07-28 22:26:39 -07:00
5552 +++ b/net/xfrm/xfrm_policy.c 2004-07-28 22:26:39 -07:00
5553 @@ -148,6 +148,8 @@
5554 int warn = 0;
5555 int dir;
5556
5557 + read_lock(&xp->lock);
5558 +
5559 if (xp->dead)
5560 goto out;
5561
5562 @@ -197,6 +199,7 @@
5563 xfrm_pol_hold(xp);
5564
5565 out:
5566 + read_unlock(&xp->lock);
5567 xfrm_pol_put(xp);
5568 return;
5569
5570 #ChangeSet1.1722.15.5
5571 # This is a BitKeeper generated diff -Nru style patch.
5572 #
5573 # ChangeSet
5574 # 2004/05/25 11:01:22-07:00 herbert@gondor.apana.org.au
5575 # [IPSEC]: Do not leak entries in xfrm_state_find.
5576 #
5577 # In xfrm_state_find, the larval state never actually matures with
5578 # Openswan so it only ever gets deleted by the timer which means
5579 # that the time crash can't happen :) It becomes a (possible) memory
5580 # leak instead.
5581 #
5582 # net/xfrm/xfrm_state.c
5583 # 2004/05/25 11:01:09-07:00 herbert@gondor.apana.org.au +6 -10
5584 # [IPSEC]: Do not leak entries in xfrm_state_find.
5585 #
5586 # In xfrm_state_find, the larval state never actually matures with
5587 # Openswan so it only ever gets deleted by the timer which means
5588 # that the time crash can't happen :) It becomes a (possible) memory
5589 # leak instead.
5590 #
5591 diff -Nru a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
5592 --- a/net/xfrm/xfrm_state.c 2004-07-28 21:51:45 -07:00
5593 +++ b/net/xfrm/xfrm_state.c 2004-07-28 21:51:45 -07:00
5594 @@ -331,14 +331,8 @@
5595 }
5596 }
5597
5598 - if (best) {
5599 - xfrm_state_hold(best);
5600 - spin_unlock_bh(&xfrm_state_lock);
5601 - return best;
5602 - }
5603 -
5604 - x = NULL;
5605 - if (!error && !acquire_in_progress &&
5606 + x = best;
5607 + if (!x && !error && !acquire_in_progress &&
5608 ((x = xfrm_state_alloc()) != NULL)) {
5609 /* Initialize temporary selector matching only
5610 * to current session. */
5611 @@ -363,10 +357,12 @@
5612 error = 1;
5613 }
5614 }
5615 - spin_unlock_bh(&xfrm_state_lock);
5616 - if (!x)
5617 + if (x)
5618 + xfrm_state_hold(x);
5619 + else
5620 *err = acquire_in_progress ? -EAGAIN :
5621 (error ? -ESRCH : -ENOMEM);
5622 + spin_unlock_bh(&xfrm_state_lock);
5623 return x;
5624 }
5625
5626 #ChangeSet1.1722.15.6
5627 # This is a BitKeeper generated diff -Nru style patch.
5628 #
5629 # ChangeSet
5630 # 2004/05/25 11:02:07-07:00 herbert@gondor.apana.org.au
5631 # [IPSEC]: Fix outdated comment in __xfrm_state_delete.
5632 #
5633 # net/xfrm/xfrm_state.c
5634 # 2004/05/25 11:01:54-07:00 herbert@gondor.apana.org.au +3 -7
5635 # [IPSEC]: Fix outdated comment in __xfrm_state_delete.
5636 #
5637 diff -Nru a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
5638 --- a/net/xfrm/xfrm_state.c 2004-07-28 21:50:36 -07:00
5639 +++ b/net/xfrm/xfrm_state.c 2004-07-28 21:50:36 -07:00
5640 @@ -221,13 +221,9 @@
5641 if (atomic_read(&x->refcnt) > 2)
5642 xfrm_flush_bundles();
5643
5644 - /* All xfrm_state objects are created by one of two possible
5645 - * paths:
5646 - *
5647 - * 2) xfrm_state_lookup --> xfrm_state_insert
5648 - *
5649 - * The xfrm_state_lookup or xfrm_state_alloc call gives a
5650 - * reference, and that is what we are dropping here.
5651 + /* All xfrm_state objects are created by xfrm_state_alloc.
5652 + * The xfrm_state_alloc call gives a reference, and that
5653 + * is what we are dropping here.
5654 */
5655 atomic_dec(&x->refcnt);
5656 }
5657 #ChangeSet1.1722.15.7
5658 # This is a BitKeeper generated diff -Nru style patch.
5659 #
5660 # ChangeSet
5661 # 2004/05/25 11:02:48-07:00 herbert@gondor.apana.org.au
5662 # [IPSEC]: Use add_timer() in xfrm_state_find.
5663 #
5664 # net/xfrm/xfrm_state.c
5665 # 2004/05/25 11:02:35-07:00 herbert@gondor.apana.org.au +2 -1
5666 # [IPSEC]: Use add_timer() in xfrm_state_find.
5667 #
5668 diff -Nru a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
5669 --- a/net/xfrm/xfrm_state.c 2004-07-28 21:45:32 -07:00
5670 +++ b/net/xfrm/xfrm_state.c 2004-07-28 21:45:32 -07:00
5671 @@ -345,7 +345,8 @@
5672 }
5673 x->lft.hard_add_expires_seconds = XFRM_ACQ_EXPIRES;
5674 xfrm_state_hold(x);
5675 - mod_timer(&x->timer, XFRM_ACQ_EXPIRES*HZ);
5676 + x->timer.expires = jiffies + XFRM_ACQ_EXPIRES*HZ;
5677 + add_timer(&x->timer);
5678 } else {
5679 x->km.state = XFRM_STATE_DEAD;
5680 xfrm_state_put(x);
5681 #ChangeSet1.1722.172.4
5682 # This is a BitKeeper generated diff -Nru style patch.
5683 #
5684 # ChangeSet
5685 # 2004/06/18 15:21:08+09:00 yoshfuji@linux-ipv6.org
5686 # [XFRM] fix dependency issues for CONFIG_IPV6=m.
5687 #
5688 # include/net/xfrm.h
5689 # 2004/06/18 15:20:58+09:00 yoshfuji@linux-ipv6.org +1 -1
5690 # [XFRM] split up xfrm_check_output() into two functions to solve dependency issues.
5691 #
5692 # net/xfrm/Makefile
5693 # 2004/06/18 15:20:58+09:00 yoshfuji@linux-ipv6.org +1 -1
5694 # [XFRM] split up xfrm_check_output() into two functions to solve dependency issues.
5695 #
5696 # net/xfrm/xfrm_export.c
5697 # 2004/06/18 15:20:58+09:00 yoshfuji@linux-ipv6.org +1 -1
5698 # [XFRM] split up xfrm_check_output() into two functions to solve dependency issues.
5699 #
5700 # net/xfrm/xfrm_state.c
5701 # 2004/06/18 15:20:58+09:00 yoshfuji@linux-ipv6.org +10 -0
5702 # [XFRM] split up xfrm_check_output() into two functions to solve dependency issues.
5703 #
5704 diff -Nru a/include/net/xfrm.h b/include/net/xfrm.h
5705 --- a/include/net/xfrm.h 2004-07-28 21:35:50 -07:00
5706 +++ b/include/net/xfrm.h 2004-07-28 21:35:50 -07:00
5707 @@ -816,7 +816,7 @@
5708 extern int xfrm_replay_check(struct xfrm_state *x, u32 seq);
5709 extern void xfrm_replay_advance(struct xfrm_state *x, u32 seq);
5710 extern int xfrm_check_selectors(struct xfrm_state **x, int n, struct flowi *fl);
5711 -extern int xfrm_check_output(struct xfrm_state *x, struct sk_buff *skb, unsigned short family);
5712 +extern int xfrm_state_check(struct xfrm_state *x, struct sk_buff *skb);
5713 extern int xfrm4_rcv(struct sk_buff *skb);
5714 extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler);
5715 extern int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler);
5716 diff -Nru a/net/xfrm/Makefile b/net/xfrm/Makefile
5717 --- a/net/xfrm/Makefile 2004-07-28 21:35:50 -07:00
5718 +++ b/net/xfrm/Makefile 2004-07-28 21:35:50 -07:00
5719 @@ -2,7 +2,7 @@
5720 # Makefile for the XFRM subsystem.
5721 #
5722
5723 -obj-$(CONFIG_XFRM) := xfrm_policy.o xfrm_state.o xfrm_input.o xfrm_algo.o xfrm_output.o \
5724 +obj-$(CONFIG_XFRM) := xfrm_policy.o xfrm_state.o xfrm_input.o xfrm_algo.o \
5725 xfrm_export.o
5726 obj-$(CONFIG_XFRM_USER) += xfrm_user.o
5727
5728 diff -Nru a/net/xfrm/xfrm_export.c b/net/xfrm/xfrm_export.c
5729 --- a/net/xfrm/xfrm_export.c 2004-07-28 21:35:50 -07:00
5730 +++ b/net/xfrm/xfrm_export.c 2004-07-28 21:35:50 -07:00
5731 @@ -18,6 +18,7 @@
5732 EXPORT_SYMBOL(xfrm_state_update);
5733 EXPORT_SYMBOL(xfrm_state_check_expire);
5734 EXPORT_SYMBOL(xfrm_state_check_space);
5735 +EXPORT_SYMBOL(xfrm_state_check);
5736 EXPORT_SYMBOL(xfrm_state_lookup);
5737 EXPORT_SYMBOL(xfrm_state_register_afinfo);
5738 EXPORT_SYMBOL(xfrm_state_unregister_afinfo);
5739 @@ -27,7 +28,6 @@
5740 EXPORT_SYMBOL(xfrm_replay_check);
5741 EXPORT_SYMBOL(xfrm_replay_advance);
5742 EXPORT_SYMBOL(xfrm_check_selectors);
5743 -EXPORT_SYMBOL(xfrm_check_output);
5744 EXPORT_SYMBOL(__secpath_destroy);
5745 EXPORT_SYMBOL(secpath_dup);
5746 EXPORT_SYMBOL(xfrm_get_acqseq);
5747 diff -Nru a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
5748 --- a/net/xfrm/xfrm_output.c 2004-07-28 21:35:50 -07:00
5749 --- b/net/xfrm/xfrm_output.c 2004-07-28 21:35:50 -07:00
5750 @@ -1,46 +1 @@
5751 -/*
5752 - * generic xfrm output routines
5753 - *
5754 - * Copyright (c) 2003 James Morris <jmorris@intercode.com.au>
5755 - *
5756 - * This program is free software; you can redistribute it and/or modify it
5757 - * under the terms of the GNU General Public License as published by the Free
5758 - * Software Foundation; either version 2 of the License, or (at your option)
5759 - * any later version.
5760 - */
5761 -#include <linux/config.h>
5762 -#include <linux/kernel.h>
5763 -#include <linux/skbuff.h>
5764 -#include <net/xfrm.h>
5765 -
5766 -int xfrm_check_output(struct xfrm_state *x,
5767 - struct sk_buff *skb, unsigned short family)
5768 -{
5769 - int err;
5770 -
5771 - err = xfrm_state_check_expire(x);
5772 - if (err)
5773 - goto out;
5774 -
5775 - if (x->props.mode) {
5776 - switch (family) {
5777 - case AF_INET:
5778 - err = xfrm4_tunnel_check_size(skb);
5779 - break;
5780 -
5781 - case AF_INET6:
5782 - err = xfrm6_tunnel_check_size(skb);
5783 - break;
5784 -
5785 - default:
5786 - err = -EINVAL;
5787 - }
5788 -
5789 - if (err)
5790 - goto out;
5791 - }
5792 -
5793 - err = xfrm_state_check_space(x, skb);
5794 -out:
5795 - return err;
5796 -}
5797 +/* Dummy File as dpkg-source does not handle file deletion */
5798 diff -Nru a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
5799 --- a/net/xfrm/xfrm_state.c 2004-07-28 21:35:50 -07:00
5800 +++ b/net/xfrm/xfrm_state.c 2004-07-28 21:35:50 -07:00
5801 @@ -531,6 +531,16 @@
5802 return 0;
5803 }
5804
5805 +int xfrm_state_check(struct xfrm_state *x, struct sk_buff *skb)
5806 +{
5807 + int err = xfrm_state_check_expire(x);
5808 + if (err < 0)
5809 + goto err;
5810 + err = xfrm_state_check_space(x, skb);
5811 +err:
5812 + return err;
5813 +}
5814 +
5815 struct xfrm_state *
5816 xfrm_state_lookup(xfrm_address_t *daddr, u32 spi, u8 proto,
5817 unsigned short family)
5818 diff -u a/net/ipv6/ah6.c b/net/ipv6/ah6.c
5819 --- a/net/ipv6/ah6.c.orig 2004-08-12 16:54:08.000000000 +0900
5820 +++ b/net/ipv6/ah6.c 2004-08-15 11:56:43.000000000 +0900
5821 @@ -174,11 +174,15 @@
5822 }
5823
5824 spin_lock_bh(&x->lock);
5825 - err = xfrm_check_output(x, skb, AF_INET);
5826 + err = xfrm_state_check(x, skb);
5827 if (err)
5828 goto error;
5829
5830 if (x->props.mode) {
5831 + err = xfrm6_tunnel_check_size(skb);
5832 + if (err)
5833 + goto error;
5834 +
5835 iph = skb->nh.ipv6h;
5836 skb->nh.ipv6h = (struct ipv6hdr*)skb_push(skb, x->props.header_len);
5837 skb->nh.ipv6h->version = 6;
5838 diff -u a/net/ipv6/esp6.c b/net/ipv6/esp6.c
5839 --- a/net/ipv6/esp6.c.orig 2004-08-12 16:54:08.000000000 +0900
5840 +++ b/net/ipv6/esp6.c 2004-08-15 11:57:00.000000000 +0900
5841 @@ -76,14 +76,16 @@
5842 }
5843
5844 spin_lock_bh(&x->lock);
5845 - err = xfrm_check_output(x, skb, AF_INET6);
5846 + err = xfrm_state_check(x, skb);
5847 if (err)
5848 goto error;
5849 - err = -ENOMEM;
5850 -
5851 - /* Strip IP header in transport mode. Save it. */
5852
5853 - if (!x->props.mode) {
5854 + if (x->props.mode) {
5855 + err = xfrm6_tunnel_check_size(skb);
5856 + if (err)
5857 + goto error;
5858 + } else {
5859 + /* Strip IP header in transport mode. Save it. */
5860 hdr_len = ip6_find_1stfragopt(skb, &prevhdr);
5861 nexthdr = *prevhdr;
5862 *prevhdr = IPPROTO_ESP;
5863 @@ -97,6 +99,7 @@
5864 }
5865
5866 /* Now skb is pure payload to encrypt */
5867 + err = -ENOMEM;
5868
5869 /* Round to block size */
5870 clen = skb->len;
5871 diff -u a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
5872 --- a/net/ipv6/ipcomp6.c.orig 2004-08-12 16:54:08.000000000 +0900
5873 +++ b/net/ipv6/ipcomp6.c 2004-08-15 11:42:38.000000000 +0900
5874 @@ -150,11 +150,15 @@
5875
5876 spin_lock_bh(&x->lock);
5877
5878 - err = xfrm_check_output(x, skb, AF_INET6);
5879 + err = xfrm_state_check(x, skb);
5880 if (err)
5881 goto error;
5882
5883 if (x->props.mode) {
5884 + err = xfrm6_tunnel_check_size(skb);
5885 + if (err)
5886 + goto error;
5887 +
5888 hdr_len = sizeof(struct ipv6hdr);
5889 nexthdr = IPPROTO_IPV6;
5890 iph = skb->nh.ipv6h;
5891 diff -u a/net/ipv4/ah4.c b/net/ipv4/ah4.c
5892 --- a/net/ipv4/ah4.c.orig 2004-08-12 16:54:08.000000000 +0900
5893 +++ b/net/ipv4/ah4.c 2004-08-15 11:46:18.000000000 +0900
5894 @@ -73,12 +73,15 @@
5895 }
5896
5897 spin_lock_bh(&x->lock);
5898 - err = xfrm_check_output(x, skb, AF_INET);
5899 + err = xfrm_state_check(x, skb);
5900 if (err)
5901 goto error;
5902
5903 iph = skb->nh.iph;
5904 if (x->props.mode) {
5905 + err = xfrm4_tunnel_check_size(skb);
5906 + if (err)
5907 + goto error;
5908 top_iph = (struct iphdr*)skb_push(skb, x->props.header_len);
5909 top_iph->ihl = 5;
5910 top_iph->version = 4;
5911 diff -u a/net/ipv4/esp4.c b/net/ipv4/esp4.c
5912 --- a/net/ipv4/esp4.c.orig 2004-08-12 16:54:08.000000000 +0900
5913 +++ b/net/ipv4/esp4.c 2004-08-15 11:48:12.000000000 +0900
5914 @@ -48,13 +48,16 @@
5915 }
5916
5917 spin_lock_bh(&x->lock);
5918 - err = xfrm_check_output(x, skb, AF_INET);
5919 + err = xfrm_state_check(x, skb);
5920 if (err)
5921 goto error;
5922 - err = -ENOMEM;
5923
5924 - /* Strip IP header in transport mode. Save it. */
5925 - if (!x->props.mode) {
5926 + if (x->props.mode) {
5927 + err = xfrm4_tunnel_check_size(skb);
5928 + if (err)
5929 + goto error;
5930 + } else {
5931 + /* Strip IP header in transport mode. Save it. */
5932 iph = skb->nh.iph;
5933 memcpy(&tmp_iph, iph, iph->ihl*4);
5934 __skb_pull(skb, iph->ihl*4);
5935 diff -u a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
5936 --- a/net/ipv4/ipcomp.c.orig 2004-08-15 11:25:51.000000000 +0900
5937 +++ b/net/ipv4/ipcomp.c 2004-08-15 11:50:12.000000000 +0900
5938 @@ -168,12 +168,16 @@
5939 }
5940
5941 spin_lock_bh(&x->lock);
5942 - err = xfrm_check_output(x, skb, AF_INET);
5943 + err = xfrm_state_check(x, skb);
5944 if (err)
5945 goto error;
5946
5947 - /* Don't bother compressing */
5948 - if (!x->props.mode) {
5949 + if (x->props.mode) {
5950 + err = xfrm4_tunnel_check_size(skb);
5951 + if (err)
5952 + goto error;
5953 + } else {
5954 + /* Don't bother compressing */
5955 iph = skb->nh.iph;
5956 hdr_len = iph->ihl * 4;
5957 }
5958 #ChangeSet1.1722.2.41
5959 # This is a BitKeeper generated diff -Nru style patch.
5960 #
5961 # ChangeSet
5962 # 2004/05/29 12:46:04-07:00 herbert@gondor.apana.org.au
5963 # [IPSEC]: Fix ref counting in __xfrmN_bundle_create().
5964 #
5965 # net/ipv4/xfrm4_policy.c
5966 # 2004/05/29 12:45:43-07:00 herbert@gondor.apana.org.au +2 -1
5967 # [IPSEC]: Fix ref counting in __xfrmN_bundle_create().
5968 #
5969 # net/ipv6/xfrm6_policy.c
5970 # 2004/05/29 12:45:43-07:00 herbert@gondor.apana.org.au +2 -1
5971 # [IPSEC]: Fix ref counting in __xfrmN_bundle_create().
5972 #
5973 # net/xfrm/xfrm_policy.c
5974 # 2004/05/29 12:45:43-07:00 herbert@gondor.apana.org.au +2 -0
5975 # [IPSEC]: Fix ref counting in __xfrmN_bundle_create().
5976 #
5977 diff -Nru a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
5978 --- a/net/ipv4/xfrm4_policy.c 2004-07-28 23:04:01 -07:00
5979 +++ b/net/ipv4/xfrm4_policy.c 2004-07-28 23:04:01 -07:00
5980 @@ -90,7 +90,6 @@
5981 goto error;
5982 }
5983
5984 - dst1->xfrm = xfrm[i];
5985 if (!dst)
5986 dst = dst1;
5987 else {
5988 @@ -120,10 +119,12 @@
5989 dst_hold(&rt->u.dst);
5990 }
5991 dst_prev->child = &rt->u.dst;
5992 + i = 0;
5993 for (dst_prev = dst; dst_prev != &rt->u.dst; dst_prev = dst_prev->child) {
5994 struct xfrm_dst *x = (struct xfrm_dst*)dst_prev;
5995 x->u.rt.fl = *fl;
5996
5997 + dst_prev->xfrm = xfrm[i++];
5998 dst_prev->dev = rt->u.dst.dev;
5999 if (rt->u.dst.dev)
6000 dev_hold(rt->u.dst.dev);
6001 diff -Nru a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
6002 --- a/net/ipv6/xfrm6_policy.c 2004-07-28 23:04:01 -07:00
6003 +++ b/net/ipv6/xfrm6_policy.c 2004-07-28 23:04:01 -07:00
6004 @@ -107,7 +107,6 @@
6005 goto error;
6006 }
6007
6008 - dst1->xfrm = xfrm[i];
6009 if (!dst)
6010 dst = dst1;
6011 else {
6012 @@ -139,9 +138,11 @@
6013 dst_hold(&rt->u.dst);
6014 }
6015 dst_prev->child = &rt->u.dst;
6016 + i = 0;
6017 for (dst_prev = dst; dst_prev != &rt->u.dst; dst_prev = dst_prev->child) {
6018 struct xfrm_dst *x = (struct xfrm_dst*)dst_prev;
6019
6020 + dst_prev->xfrm = xfrm[i++];
6021 dst_prev->dev = rt->u.dst.dev;
6022 if (rt->u.dst.dev)
6023 dev_hold(rt->u.dst.dev);
6024 diff -Nru a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
6025 --- a/net/xfrm/xfrm_policy.c 2004-07-28 23:04:01 -07:00
6026 +++ b/net/xfrm/xfrm_policy.c 2004-07-28 23:04:01 -07:00
6027 @@ -1017,6 +1017,8 @@
6028
6029 static void xfrm_dst_destroy(struct dst_entry *dst)
6030 {
6031 + if (!dst->xfrm)
6032 + return;
6033 xfrm_state_put(dst->xfrm);
6034 dst->xfrm = NULL;
6035 }
6036 #ChangeSet1.1722.6.4
6037 # This is a BitKeeper generated diff -Nru style patch.
6038 #
6039 # ChangeSet
6040 # 2004/05/21 14:43:13-07:00 herbert@gondor.apana.org.au
6041 # [IPSEC]: Fix state modifications in xfrm_state_update().
6042 #
6043 # doing a mod_timer on a live state without holding a lock or for that
6044 # matter not even checking whether the state is dead is definitely a bad
6045 # idea
6046 #
6047 # net/xfrm/xfrm_state.c
6048 # 2004/05/21 14:42:59-07:00 herbert@gondor.apana.org.au +6 -5
6049 # [IPSEC]: Fix state modifications in xfrm_state_update().
6050 #
6051 # doing a mod_timer on a live state without holding a lock or for that
6052 # matter not even checking whether the state is dead is definitely a bad
6053 # idea
6054 #
6055 diff -Nru a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
6056 --- a/net/xfrm/xfrm_state.c 2004-07-28 21:52:49 -07:00
6057 +++ b/net/xfrm/xfrm_state.c 2004-07-28 21:52:49 -07:00
6058 @@ -489,14 +489,15 @@
6059 memcpy(x1->encap, x->encap, sizeof(*x1->encap));
6060 memcpy(&x1->lft, &x->lft, sizeof(x1->lft));
6061 x1->km.dying = 0;
6062 +
6063 + if (!mod_timer(&x1->timer, jiffies + HZ))
6064 + xfrm_state_hold(x1);
6065 + if (x1->curlft.use_time)
6066 + xfrm_state_check_expire(x1);
6067 +
6068 err = 0;
6069 }
6070 spin_unlock_bh(&x1->lock);
6071 -
6072 - if (!mod_timer(&x1->timer, jiffies + HZ))
6073 - xfrm_state_hold(x1);
6074 - if (x1->curlft.use_time)
6075 - xfrm_state_check_expire(x1);
6076
6077 xfrm_state_put(x1);
6078
6079 #ChangeSet1.1722.74.3
6080 # This is a BitKeeper generated diff -Nru style patch.
6081 #
6082 # ChangeSet
6083 # 2004/06/01 12:35:39-07:00 herbert@gondor.apana.org.au
6084 # [IPSEC]: Fix xfrm_tunnel leak.
6085 #
6086 # Turns out that the IPIP tunnel used by IPCOMP states are only freed
6087 # if the IPCOMP state is deleted by xfrm_state_delete.
6088 #
6089 # This is not the case for all states. For example, an immature IPCOMP
6090 # state that dies in add_sa will not go through xfrm_state_delete.
6091 #
6092 # The following patch moves the delete_tunnel call into IPCOMP's
6093 # destructor. I think it makes more sense there as IPCOMP is the
6094 # only user of the tunnel anyway.
6095 #
6096 # net/ipv4/ipcomp.c
6097 # 2004/06/01 12:35:15-07:00 herbert@gondor.apana.org.au +1 -0
6098 # [IPSEC]: Fix xfrm_tunnel leak.
6099 #
6100 # Turns out that the IPIP tunnel used by IPCOMP states are only freed
6101 # if the IPCOMP state is deleted by xfrm_state_delete.
6102 #
6103 # This is not the case for all states. For example, an immature IPCOMP
6104 # state that dies in add_sa will not go through xfrm_state_delete.
6105 #
6106 # The following patch moves the delete_tunnel call into IPCOMP's
6107 # destructor. I think it makes more sense there as IPCOMP is the
6108 # only user of the tunnel anyway.
6109 #
6110 # net/xfrm/xfrm_state.c
6111 # 2004/06/01 12:35:15-07:00 herbert@gondor.apana.org.au +0 -1
6112 # [IPSEC]: Fix xfrm_tunnel leak.
6113 #
6114 # Turns out that the IPIP tunnel used by IPCOMP states are only freed
6115 # if the IPCOMP state is deleted by xfrm_state_delete.
6116 #
6117 # This is not the case for all states. For example, an immature IPCOMP
6118 # state that dies in add_sa will not go through xfrm_state_delete.
6119 #
6120 # The following patch moves the delete_tunnel call into IPCOMP's
6121 # destructor. I think it makes more sense there as IPCOMP is the
6122 # only user of the tunnel anyway.
6123 #
6124 diff -Nru a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
6125 --- a/net/ipv4/ipcomp.c 2004-07-28 21:37:23 -07:00
6126 +++ b/net/ipv4/ipcomp.c 2004-07-28 21:37:23 -07:00
6127 @@ -339,6 +339,7 @@
6128 struct ipcomp_data *ipcd = x->data;
6129 if (!ipcd)
6130 return;
6131 + xfrm_state_delete_tunnel(x);
6132 ipcomp_free_data(ipcd);
6133 kfree(ipcd);
6134 }
6135 diff -Nru a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
6136 --- a/net/xfrm/xfrm_state.c 2004-07-28 21:37:23 -07:00
6137 +++ b/net/xfrm/xfrm_state.c 2004-07-28 21:37:23 -07:00
6138 @@ -231,7 +231,6 @@
6139
6140 void xfrm_state_delete(struct xfrm_state *x)
6141 {
6142 - xfrm_state_delete_tunnel(x);
6143 spin_lock_bh(&x->lock);
6144 __xfrm_state_delete(x);
6145 spin_unlock_bh(&x->lock);
6146 #ChangeSet1.1784.11.13
6147 # This is a BitKeeper generated diff -Nru style patch.
6148 #
6149 # ChangeSet
6150 # 2004/07/09 16:51:35-07:00 herbert@gondor.apana.org.au
6151 # [XFRM]: Add FLUSHSA and FLUSHPOLICY.
6152 #
6153 # This patch adds FLUSHSA and FLUSHPOLICY to xfrm_user which are
6154 # analagous to SADB_FLUSH and SADB_X_SPDFLUSH in af_key.
6155 #
6156 # This is useful in KMs on startup/shutdown so that the system is
6157 # reset to a known state.
6158 #
6159 # Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
6160 # Signed-off-by: David S. Miller <davem@redhat.com>
6161 #
6162 # include/linux/xfrm.h
6163 # 2004/07/09 16:51:20-07:00 herbert@gondor.apana.org.au +9 -0
6164 # [XFRM]: Add FLUSHSA and FLUSHPOLICY.
6165 #
6166 # This patch adds FLUSHSA and FLUSHPOLICY to xfrm_user which are
6167 # analagous to SADB_FLUSH and SADB_X_SPDFLUSH in af_key.
6168 #
6169 # This is useful in KMs on startup/shutdown so that the system is
6170 # reset to a known state.
6171 #
6172 # Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
6173 # Signed-off-by: David S. Miller <davem@redhat.com>
6174 #
6175 # net/xfrm/xfrm_user.c
6176 # 2004/07/09 16:51:20-07:00 herbert@gondor.apana.org.au +20 -0
6177 # [XFRM]: Add FLUSHSA and FLUSHPOLICY.
6178 #
6179 # This patch adds FLUSHSA and FLUSHPOLICY to xfrm_user which are
6180 # analagous to SADB_FLUSH and SADB_X_SPDFLUSH in af_key.
6181 #
6182 # This is useful in KMs on startup/shutdown so that the system is
6183 # reset to a known state.
6184 #
6185 # Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
6186 # Signed-off-by: David S. Miller <davem@redhat.com>
6187 #
6188 # *** xfrm.h patch updated for 2.4 backport ***
6189 # *** Joshua Kwan & Horms 2004/08/12 ***
6190 --- a/include/linux/xfrm.h 2004-08-12 16:32:18.000000000 +0900
6191 +++ b/include/linux/xfrm.h 2004-08-12 16:37:17.000000000 +0900
6192 @@ -122,7 +122,10 @@
6193
6194 #define XFRM_MSG_POLEXPIRE (XFRM_MSG_BASE + 11)
6195
6196 -#define XFRM_MSG_MAX (XFRM_MSG_POLEXPIRE+1)
6197 +#define XFRM_MSG_FLUSHSA (XFRM_MSG_BASE + 12)
6198 +#define XFRM_MSG_FLUSHPOLICY (XFRM_MSG_BASE + 13)
6199 +
6200 +#define XFRM_MSG_MAX (XFRM_MSG_FLUSHPOLICY+1)
6201
6202 struct xfrm_user_tmpl {
6203 struct xfrm_id id;
6204 @@ -227,6 +230,10 @@
6205 __u8 hard;
6206 };
6207
6208 +struct xfrm_usersa_flush {
6209 + __u8 proto;
6210 +};
6211 +
6212 #define XFRMGRP_ACQUIRE 1
6213 #define XFRMGRP_EXPIRE 2
6214
6215 diff -Nru a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
6216 --- a/net/xfrm/xfrm_user.c 2004-07-28 22:44:21 -07:00
6217 +++ b/net/xfrm/xfrm_user.c 2004-07-28 22:44:21 -07:00
6218 @@ -814,6 +814,20 @@
6219 return err;
6220 }
6221
6222 +static int xfrm_flush_sa(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma)
6223 +{
6224 + struct xfrm_usersa_flush *p = NLMSG_DATA(nlh);
6225 +
6226 + xfrm_state_flush(p->proto);
6227 + return 0;
6228 +}
6229 +
6230 +static int xfrm_flush_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma)
6231 +{
6232 + xfrm_policy_flush();
6233 + return 0;
6234 +}
6235 +
6236 static const int xfrm_msg_min[(XFRM_MSG_MAX + 1 - XFRM_MSG_BASE)] = {
6237 NLMSG_LENGTH(sizeof(struct xfrm_usersa_info)), /* NEW SA */
6238 NLMSG_LENGTH(sizeof(struct xfrm_usersa_id)), /* DEL SA */
6239 @@ -826,6 +840,9 @@
6240 NLMSG_LENGTH(sizeof(struct xfrm_user_expire)), /* EXPIRE */
6241 NLMSG_LENGTH(sizeof(struct xfrm_userpolicy_info)),/* UPD POLICY */
6242 NLMSG_LENGTH(sizeof(struct xfrm_usersa_info)), /* UPD SA */
6243 + NLMSG_LENGTH(sizeof(struct xfrm_user_polexpire)), /* POLEXPIRE */
6244 + NLMSG_LENGTH(sizeof(struct xfrm_usersa_flush)), /* FLUSH SA */
6245 + NLMSG_LENGTH(0), /* FLUSH POLICY */
6246 };
6247
6248 static struct xfrm_link {
6249 @@ -849,6 +866,9 @@
6250 {},
6251 { .doit = xfrm_add_policy },
6252 { .doit = xfrm_add_sa, },
6253 + {},
6254 + { .doit = xfrm_flush_sa },
6255 + { .doit = xfrm_flush_policy },
6256 };
6257
6258 static int xfrm_done(struct netlink_callback *cb)
6259 #ChangeSet1.1807.13.20
6260 # This is a BitKeeper generated diff -Nru style patch.
6261 #
6262 # ChangeSet
6263 # 2004/07/25 16:54:54-07:00 kaber@trash.net
6264 # [XFRM]: Wake up km_waitq once per gc-run instead of once per state.
6265 #
6266 # Signed-off-by: Patrick McHardy <kaber@trash.net>
6267 # Signed-off-by: David S. Miller <davem@redhat.com>
6268 #
6269 # net/xfrm/xfrm_state.c
6270 # 2004/07/25 16:54:39-07:00 kaber@trash.net +1 -1
6271 # [XFRM]: Wake up km_waitq once per gc-run instead of once per state.
6272 #
6273 # Signed-off-by: Patrick McHardy <kaber@trash.net>
6274 # Signed-off-by: David S. Miller <davem@redhat.com>
6275 #
6276 diff -Nru a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
6277 --- a/net/xfrm/xfrm_state.c 2004-08-11 23:21:30 -07:00
6278 +++ b/net/xfrm/xfrm_state.c 2004-08-11 23:21:30 -07:00
6279 @@ -65,7 +65,6 @@
6280 xfrm_put_type(x->type);
6281 }
6282 kfree(x);
6283 - wake_up(&km_waitq);
6284 }
6285
6286 static void xfrm_state_gc_task(void *data)
6287 @@ -82,6 +81,7 @@
6288 x = list_entry(entry, struct xfrm_state, bydst);
6289 xfrm_state_gc_destroy(x);
6290 }
6291 + wake_up(&km_waitq);
6292 }
6293
6294 static inline unsigned long make_jiffies(long secs)
6295 #ChangeSet1.1807.13.3
6296 # This is a BitKeeper generated diff -Nru style patch.
6297 #
6298 # ChangeSet
6299 # 2004/07/23 13:23:48-07:00 herbert@gondor.apana.org.au
6300 # [IPSEC]: Missing unlock in policy timer.
6301 #
6302 # Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
6303 # Signed-off-by: David S. Miller <davem@redhat.com>
6304 #
6305 # net/xfrm/xfrm_policy.c
6306 # 2004/07/23 13:23:33-07:00 herbert@gondor.apana.org.au +1 -0
6307 # [IPSEC]: Missing unlock in policy timer.
6308 #
6309 # Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
6310 # Signed-off-by: David S. Miller <davem@redhat.com>
6311 #
6312 diff -Nru a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
6313 --- a/net/xfrm/xfrm_policy.c 2004-08-11 23:25:52 -07:00
6314 +++ b/net/xfrm/xfrm_policy.c 2004-08-11 23:25:52 -07:00
6315 @@ -204,6 +204,7 @@
6316 return;
6317
6318 expired:
6319 + read_unlock(&xp->lock);
6320 km_policy_expired(xp, dir, 1);
6321 xfrm_policy_delete(xp, dir);
6322 xfrm_pol_put(xp);
6323 #ChangeSet1.1807.19.12
6324 # This is a BitKeeper generated diff -Nru style patch.
6325 #
6326 # ChangeSet
6327 # 2004/07/28 18:56:51-07:00 nakam@linux-ipv6.org
6328 # [IPSEC]: xfrm_user code forgets to call xfrm_probe_algs()
6329 #
6330 # Signed-off-by: Masahide Nakmura <nakam@linux-ipv6.org>
6331 # Signed-off-by: David S. Miller <davem@redhat.com>
6332 #
6333 # net/xfrm/xfrm_user.c
6334 # 2004/07/28 18:56:37-07:00 nakam@linux-ipv6.org +2 -0
6335 # [IPSEC]: xfrm_user code forgets to call xfrm_probe_algs()
6336 #
6337 # Signed-off-by: Masahide Nakmura <nakam@linux-ipv6.org>
6338 # Signed-off-by: David S. Miller <davem@redhat.com>
6339 #
6340 diff -Nru a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
6341 --- a/net/xfrm/xfrm_user.c 2004-08-11 23:01:30 -07:00
6342 +++ b/net/xfrm/xfrm_user.c 2004-08-11 23:01:30 -07:00
6343 @@ -267,6 +267,8 @@
6344 if (err)
6345 return err;
6346
6347 + xfrm_probe_algs();
6348 +
6349 x = xfrm_state_construct(p, (struct rtattr **) xfrma, &err);
6350 if (!x)
6351 return err;
6352 #ChangeSet1.1836
6353 # This is a BitKeeper generated diff -Nru style patch.
6354 #
6355 # ChangeSet
6356 # 2004/07/31 23:30:00-07:00 herbert@gondor.apana.org.au
6357 # [IPSEC]: Remove redundant check in xfrm_state_add()
6358 #
6359 # This is the patch referred to in the netlink_get_spi thread.
6360 #
6361 # I was actually wrong about the reason for this patch though. Firstly
6362 # it's the SPI check that is redundant and not the find_acq() call.
6363 # And it's redundant because of the find_acq() patch, not because
6364 # of the fact that this is in xfrm_state_add().
6365 #
6366 # Now that find_acq() only returns SAs with SPIs, we don't need to
6367 # check this in xfrm_state_add() anymore.
6368 #
6369 # We do still need the call though to clean up leftover larval states.
6370 #
6371 # Another side-effect of the change is that we can move the existence
6372 # check above find_acq() since find_acq() will never return any SAs
6373 # matching the SPI we're trying to add (It doesn't need to because if
6374 # an SA with a matching SPI existed, it would've been returned by
6375 # state_lookup() already).
6376 #
6377 # Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
6378 # Signed-off-by: David S. Miller <davem@redhat.com>
6379 #
6380 # net/xfrm/xfrm_state.c
6381 # 2004/07/31 23:29:46-07:00 herbert@gondor.apana.org.au +5 -11
6382 # [IPSEC]: Remove redundant check in xfrm_state_add()
6383 #
6384 # This is the patch referred to in the netlink_get_spi thread.
6385 #
6386 # I was actually wrong about the reason for this patch though. Firstly
6387 # it's the SPI check that is redundant and not the find_acq() call.
6388 # And it's redundant because of the find_acq() patch, not because
6389 # of the fact that this is in xfrm_state_add().
6390 #
6391 # Now that find_acq() only returns SAs with SPIs, we don't need to
6392 # check this in xfrm_state_add() anymore.
6393 #
6394 # We do still need the call though to clean up leftover larval states.
6395 #
6396 # Another side-effect of the change is that we can move the existence
6397 # check above find_acq() since find_acq() will never return any SAs
6398 # matching the SPI we're trying to add (It doesn't need to because if
6399 # an SA with a matching SPI existed, it would've been returned by
6400 # state_lookup() already).
6401 #
6402 # Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
6403 # Signed-off-by: David S. Miller <davem@redhat.com>
6404 #
6405 diff -Nru a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
6406 --- a/net/xfrm/xfrm_state.c 2004-08-11 23:14:58 -07:00
6407 +++ b/net/xfrm/xfrm_state.c 2004-08-11 23:14:58 -07:00
6408 @@ -400,22 +400,16 @@
6409 spin_lock_bh(&xfrm_state_lock);
6410
6411 x1 = afinfo->state_lookup(&x->id.daddr, x->id.spi, x->id.proto);
6412 - if (!x1) {
6413 - x1 = afinfo->find_acq(
6414 - x->props.mode, x->props.reqid, x->id.proto,
6415 - &x->id.daddr, &x->props.saddr, 0);
6416 - if (x1 && x1->id.spi != x->id.spi && x1->id.spi) {
6417 - xfrm_state_put(x1);
6418 - x1 = NULL;
6419 - }
6420 - }
6421 -
6422 - if (x1 && x1->id.spi) {
6423 + if (x1) {
6424 xfrm_state_put(x1);
6425 x1 = NULL;
6426 err = -EEXIST;
6427 goto out;
6428 }
6429 +
6430 + x1 = afinfo->find_acq(
6431 + x->props.mode, x->props.reqid, x->id.proto,
6432 + &x->id.daddr, &x->props.saddr, 0);
6433
6434 __xfrm_state_insert(x);
6435 err = 0;
6436 #ChangeSet1.1837
6437 # This is a BitKeeper generated diff -Nru style patch.
6438 #
6439 # ChangeSet
6440 # 2004/07/31 23:33:16-07:00 herbert@gondor.apana.org.au
6441 # [IPSEC]: xfrm_alloc_spi always succeeds on non-trivial range
6442 #
6443 # xfrm_alloc_spi will always succeed if minspi < maxspi, even if
6444 # minspi + 1 == maxspi. If the range is already occupied this
6445 # will obviously lead to breakage.
6446 #
6447 # Of course this is very unlikely to occur in reality due to the
6448 # size of the range. Although with IPCOMP it might actually happen
6449 # on a very large server.
6450 #
6451 # The fix is obivous.
6452 #
6453 # Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
6454 # Signed-off-by: David S. Miller <davem@redhat.com>
6455 #
6456 # net/xfrm/xfrm_state.c
6457 # 2004/07/31 23:33:00-07:00 herbert@gondor.apana.org.au +3 -2
6458 # [IPSEC]: xfrm_alloc_spi always succeeds on non-trivial range
6459 #
6460 # xfrm_alloc_spi will always succeed if minspi < maxspi, even if
6461 # minspi + 1 == maxspi. If the range is already occupied this
6462 # will obviously lead to breakage.
6463 #
6464 # Of course this is very unlikely to occur in reality due to the
6465 # size of the range. Although with IPCOMP it might actually happen
6466 # on a very large server.
6467 #
6468 # The fix is obivous.
6469 #
6470 # Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
6471 # Signed-off-by: David S. Miller <davem@redhat.com>
6472 #
6473 diff -Nru a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
6474 --- a/net/xfrm/xfrm_state.c 2004-08-11 23:21:50 -07:00
6475 +++ b/net/xfrm/xfrm_state.c 2004-08-11 23:21:50 -07:00
6476 @@ -624,11 +624,12 @@
6477 for (h=0; h<maxspi-minspi+1; h++) {
6478 spi = minspi + net_random()%(maxspi-minspi+1);
6479 x0 = xfrm_state_lookup(&x->id.daddr, htonl(spi), x->id.proto, x->props.family);
6480 - if (x0 == NULL)
6481 + if (x0 == NULL) {
6482 + x->id.spi = htonl(spi);
6483 break;
6484 + }
6485 xfrm_state_put(x0);
6486 }
6487 - x->id.spi = htonl(spi);
6488 }
6489 if (x->id.spi) {
6490 spin_lock_bh(&xfrm_state_lock);
6491 # *** The folling section updates SATA for 2.4.26 ***
6492 # *** from bitkeeper. The patches from the individual ***
6493 # *** changesets have been combined in order to allow ***
6494 # *** patch -R to work with a single patch, which is ***
6495 # *** required for the kernel-source-2.4.26 apply and ***
6496 # *** unpatch scripts. ***
6497 # *** ***
6498 # *** The comments for the individual changesets are below, ***
6499 # *** followed by the combined patch. ***
6500 # *** ***
6501 # *** No other changes were made ***
6502 # *** ***
6503 # *** Horms 2004/08/13 ***
6504
6505 #ChangeSet1.1359.15.1
6506 # This is a BitKeeper generated diff -Nru style patch.
6507 #
6508 # ChangeSet
6509 # 2004/04/22 00:48:40-04:00 jgarzik@redhat.com
6510 # [libata sata_sis] add new PCI id
6511 #
6512 # Also remove constant from linux/pci_ids.h.
6513 #
6514 # drivers/scsi/sata_sis.c
6515 # 2004/04/22 00:47:55-04:00 jgarzik@redhat.com +2 -1
6516 # [libata sata_sis] add new PCI id
6517 #
6518 # Also remove constant from linux/pci_ids.h.
6519 #
6520 # include/linux/pci_ids.h
6521 # 2004/04/22 00:47:55-04:00 jgarzik@redhat.com +0 -1
6522 # [libata sata_sis] add new PCI id
6523 #
6524 # Also remove constant from linux/pci_ids.h.
6525 #
6526 #ChangeSet1.1359.11.4
6527 # This is a BitKeeper generated diff -Nru style patch.
6528 #
6529 # ChangeSet
6530 # 2004/04/22 15:57:43-04:00 jgarzik@redhat.com
6531 # [libata] Promise driver split part 1: clone to sx4
6532 #
6533 # Clone sata_promise to sata_sx4.
6534 #
6535 # drivers/scsi/Config.in
6536 # 2004/04/22 15:57:42-04:00 jgarzik@redhat.com +2 -1
6537 # [libata] Promise driver split part 1: clone to sx4
6538 #
6539 # Clone sata_promise to sata_sx4.
6540 #
6541 # drivers/scsi/Makefile
6542 # 2004/04/22 15:57:42-04:00 jgarzik@redhat.com +1 -0
6543 # [libata] Promise driver split part 1: clone to sx4
6544 #
6545 # Clone sata_promise to sata_sx4.
6546 #
6547 # drivers/scsi/sata_sx4.c
6548 # 2004/04/14 20:56:04-03:00 jgarzik@pobox.com +0 -0
6549 # BitKeeper file /home/marcelo/bk/linux-2.4/drivers/scsi/sata_promise.c
6550 #
6551 # drivers/scsi/sata_sx4.c
6552 # 2004/04/14 20:56:04-03:00 jgarzik@pobox.com +1879 -0
6553 # Add SATA support
6554 #
6555 # drivers/scsi/sata_sx4.c
6556 # 2004/04/22 15:54:46-04:00 jgarzik@redhat.com +0 -0
6557 # bk cp drivers/scsi/sata_promise.c drivers/scsi/sata_sx4.c
6558 #
6559 #ChangeSet1.1359.11.5
6560 # This is a BitKeeper generated diff -Nru style patch.
6561 #
6562 # ChangeSet
6563 # 2004/04/22 15:58:27-04:00 jgarzik@redhat.com
6564 # [libata] Promise driver split part 2: remove SX4 code from sata_promise
6565 #
6566 # drivers/scsi/sata_promise.c
6567 # 2004/04/22 15:58:26-04:00 jgarzik@redhat.com +7 -1106
6568 # [libata] Promise driver split part 2: remove SX4 code from sata_promise
6569 #
6570 #ChangeSet1.1359.11.6
6571 # This is a BitKeeper generated diff -Nru style patch.
6572 #
6573 # ChangeSet
6574 # 2004/04/22 15:59:11-04:00 jgarzik@redhat.com
6575 # [libata] Promise driver split part 3: remove TX2/4 code from sata_sx4
6576 #
6577 # drivers/scsi/sata_sx4.c
6578 # 2004/04/22 15:59:10-04:00 jgarzik@redhat.com +26 -333
6579 # [libata] Promise driver split part 3: remove TX2/4 code from sata_sx4
6580 #
6581 #ChangeSet1.1359.11.7
6582 # This is a BitKeeper generated diff -Nru style patch.
6583 #
6584 # ChangeSet
6585 # 2004/04/22 15:59:34-04:00 jgarzik@redhat.com
6586 # [libata] Promise driver split part 4: common header
6587 #
6588 # drivers/scsi/sata_promise.c
6589 # 2004/04/22 11:59:31-04:00 jgarzik@redhat.com +2 -125
6590 # [libata] Promise driver split part 4: common header
6591 #
6592 # drivers/scsi/sata_promise.h
6593 # 2004/04/22 11:59:31-04:00 jgarzik@redhat.com +0 -0
6594 # BitKeeper file /spare/repo/libata-upstream-2.4/drivers/scsi/sata_promise.h
6595 #
6596 # drivers/scsi/sata_promise.h
6597 # 2004/04/22 11:59:31-04:00 jgarzik@redhat.com +154 -0
6598 # [libata] Promise driver split part 4: common header
6599 #
6600 # drivers/scsi/sata_sx4.c
6601 # 2004/04/22 11:59:31-04:00 jgarzik@redhat.com +1 -124
6602 # [libata] Promise driver split part 4: common header
6603 #
6604 #ChangeSet1.1359.11.8
6605 # This is a BitKeeper generated diff -Nru style patch.
6606 #
6607 # ChangeSet
6608 # 2004/04/24