aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/compat_ioctl.c336
-rw-r--r--fs/compat_ioctl.c337
2 files changed, 336 insertions, 337 deletions
diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
index 92b3e8d07ca6..f84093b97f70 100644
--- a/block/compat_ioctl.c
+++ b/block/compat_ioctl.c
@@ -203,6 +203,332 @@ static int compat_blkpg_ioctl(struct inode *inode, struct file *file,
203#define BLKBSZSET_32 _IOW(0x12, 113, int) 203#define BLKBSZSET_32 _IOW(0x12, 113, int)
204#define BLKGETSIZE64_32 _IOR(0x12, 114, int) 204#define BLKGETSIZE64_32 _IOR(0x12, 114, int)
205 205
206struct compat_floppy_struct {
207 compat_uint_t size;
208 compat_uint_t sect;
209 compat_uint_t head;
210 compat_uint_t track;
211 compat_uint_t stretch;
212 unsigned char gap;
213 unsigned char rate;
214 unsigned char spec1;
215 unsigned char fmt_gap;
216 const compat_caddr_t name;
217};
218
219struct compat_floppy_drive_params {
220 char cmos;
221 compat_ulong_t max_dtr;
222 compat_ulong_t hlt;
223 compat_ulong_t hut;
224 compat_ulong_t srt;
225 compat_ulong_t spinup;
226 compat_ulong_t spindown;
227 unsigned char spindown_offset;
228 unsigned char select_delay;
229 unsigned char rps;
230 unsigned char tracks;
231 compat_ulong_t timeout;
232 unsigned char interleave_sect;
233 struct floppy_max_errors max_errors;
234 char flags;
235 char read_track;
236 short autodetect[8];
237 compat_int_t checkfreq;
238 compat_int_t native_format;
239};
240
241struct compat_floppy_drive_struct {
242 signed char flags;
243 compat_ulong_t spinup_date;
244 compat_ulong_t select_date;
245 compat_ulong_t first_read_date;
246 short probed_format;
247 short track;
248 short maxblock;
249 short maxtrack;
250 compat_int_t generation;
251 compat_int_t keep_data;
252 compat_int_t fd_ref;
253 compat_int_t fd_device;
254 compat_int_t last_checked;
255 compat_caddr_t dmabuf;
256 compat_int_t bufblocks;
257};
258
259struct compat_floppy_fdc_state {
260 compat_int_t spec1;
261 compat_int_t spec2;
262 compat_int_t dtr;
263 unsigned char version;
264 unsigned char dor;
265 compat_ulong_t address;
266 unsigned int rawcmd:2;
267 unsigned int reset:1;
268 unsigned int need_configure:1;
269 unsigned int perp_mode:2;
270 unsigned int has_fifo:1;
271 unsigned int driver_version;
272 unsigned char track[4];
273};
274
275struct compat_floppy_write_errors {
276 unsigned int write_errors;
277 compat_ulong_t first_error_sector;
278 compat_int_t first_error_generation;
279 compat_ulong_t last_error_sector;
280 compat_int_t last_error_generation;
281 compat_uint_t badness;
282};
283
284#define FDSETPRM32 _IOW(2, 0x42, struct compat_floppy_struct)
285#define FDDEFPRM32 _IOW(2, 0x43, struct compat_floppy_struct)
286#define FDGETPRM32 _IOR(2, 0x04, struct compat_floppy_struct)
287#define FDSETDRVPRM32 _IOW(2, 0x90, struct compat_floppy_drive_params)
288#define FDGETDRVPRM32 _IOR(2, 0x11, struct compat_floppy_drive_params)
289#define FDGETDRVSTAT32 _IOR(2, 0x12, struct compat_floppy_drive_struct)
290#define FDPOLLDRVSTAT32 _IOR(2, 0x13, struct compat_floppy_drive_struct)
291#define FDGETFDCSTAT32 _IOR(2, 0x15, struct compat_floppy_fdc_state)
292#define FDWERRORGET32 _IOR(2, 0x17, struct compat_floppy_write_errors)
293
294static struct {
295 unsigned int cmd32;
296 unsigned int cmd;
297} fd_ioctl_trans_table[] = {
298 { FDSETPRM32, FDSETPRM },
299 { FDDEFPRM32, FDDEFPRM },
300 { FDGETPRM32, FDGETPRM },
301 { FDSETDRVPRM32, FDSETDRVPRM },
302 { FDGETDRVPRM32, FDGETDRVPRM },
303 { FDGETDRVSTAT32, FDGETDRVSTAT },
304 { FDPOLLDRVSTAT32, FDPOLLDRVSTAT },
305 { FDGETFDCSTAT32, FDGETFDCSTAT },
306 { FDWERRORGET32, FDWERRORGET }
307};
308
309#define NR_FD_IOCTL_TRANS ARRAY_SIZE(fd_ioctl_trans_table)
310
311static int compat_fd_ioctl(struct inode *inode, struct file *file,
312 struct gendisk *disk, unsigned int cmd, unsigned long arg)
313{
314 mm_segment_t old_fs = get_fs();
315 void *karg = NULL;
316 unsigned int kcmd = 0;
317 int i, err;
318
319 for (i = 0; i < NR_FD_IOCTL_TRANS; i++)
320 if (cmd == fd_ioctl_trans_table[i].cmd32) {
321 kcmd = fd_ioctl_trans_table[i].cmd;
322 break;
323 }
324 if (!kcmd)
325 return -EINVAL;
326
327 switch (cmd) {
328 case FDSETPRM32:
329 case FDDEFPRM32:
330 case FDGETPRM32:
331 {
332 compat_uptr_t name;
333 struct compat_floppy_struct __user *uf;
334 struct floppy_struct *f;
335
336 uf = compat_ptr(arg);
337 f = karg = kmalloc(sizeof(struct floppy_struct), GFP_KERNEL);
338 if (!karg)
339 return -ENOMEM;
340 if (cmd == FDGETPRM32)
341 break;
342 err = __get_user(f->size, &uf->size);
343 err |= __get_user(f->sect, &uf->sect);
344 err |= __get_user(f->head, &uf->head);
345 err |= __get_user(f->track, &uf->track);
346 err |= __get_user(f->stretch, &uf->stretch);
347 err |= __get_user(f->gap, &uf->gap);
348 err |= __get_user(f->rate, &uf->rate);
349 err |= __get_user(f->spec1, &uf->spec1);
350 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
351 err |= __get_user(name, &uf->name);
352 f->name = compat_ptr(name);
353 if (err) {
354 err = -EFAULT;
355 goto out;
356 }
357 break;
358 }
359 case FDSETDRVPRM32:
360 case FDGETDRVPRM32:
361 {
362 struct compat_floppy_drive_params __user *uf;
363 struct floppy_drive_params *f;
364
365 uf = compat_ptr(arg);
366 f = karg = kmalloc(sizeof(struct floppy_drive_params), GFP_KERNEL);
367 if (!karg)
368 return -ENOMEM;
369 if (cmd == FDGETDRVPRM32)
370 break;
371 err = __get_user(f->cmos, &uf->cmos);
372 err |= __get_user(f->max_dtr, &uf->max_dtr);
373 err |= __get_user(f->hlt, &uf->hlt);
374 err |= __get_user(f->hut, &uf->hut);
375 err |= __get_user(f->srt, &uf->srt);
376 err |= __get_user(f->spinup, &uf->spinup);
377 err |= __get_user(f->spindown, &uf->spindown);
378 err |= __get_user(f->spindown_offset, &uf->spindown_offset);
379 err |= __get_user(f->select_delay, &uf->select_delay);
380 err |= __get_user(f->rps, &uf->rps);
381 err |= __get_user(f->tracks, &uf->tracks);
382 err |= __get_user(f->timeout, &uf->timeout);
383 err |= __get_user(f->interleave_sect, &uf->interleave_sect);
384 err |= __copy_from_user(&f->max_errors, &uf->max_errors, sizeof(f->max_errors));
385 err |= __get_user(f->flags, &uf->flags);
386 err |= __get_user(f->read_track, &uf->read_track);
387 err |= __copy_from_user(f->autodetect, uf->autodetect, sizeof(f->autodetect));
388 err |= __get_user(f->checkfreq, &uf->checkfreq);
389 err |= __get_user(f->native_format, &uf->native_format);
390 if (err) {
391 err = -EFAULT;
392 goto out;
393 }
394 break;
395 }
396 case FDGETDRVSTAT32:
397 case FDPOLLDRVSTAT32:
398 karg = kmalloc(sizeof(struct floppy_drive_struct), GFP_KERNEL);
399 if (!karg)
400 return -ENOMEM;
401 break;
402 case FDGETFDCSTAT32:
403 karg = kmalloc(sizeof(struct floppy_fdc_state), GFP_KERNEL);
404 if (!karg)
405 return -ENOMEM;
406 break;
407 case FDWERRORGET32:
408 karg = kmalloc(sizeof(struct floppy_write_errors), GFP_KERNEL);
409 if (!karg)
410 return -ENOMEM;
411 break;
412 default:
413 return -EINVAL;
414 }
415 set_fs(KERNEL_DS);
416 err = blkdev_driver_ioctl(inode, file, disk, kcmd, (unsigned long)karg);
417 set_fs(old_fs);
418 if (err)
419 goto out;
420 switch (cmd) {
421 case FDGETPRM32:
422 {
423 struct floppy_struct *f = karg;
424 struct compat_floppy_struct __user *uf = compat_ptr(arg);
425
426 err = __put_user(f->size, &uf->size);
427 err |= __put_user(f->sect, &uf->sect);
428 err |= __put_user(f->head, &uf->head);
429 err |= __put_user(f->track, &uf->track);
430 err |= __put_user(f->stretch, &uf->stretch);
431 err |= __put_user(f->gap, &uf->gap);
432 err |= __put_user(f->rate, &uf->rate);
433 err |= __put_user(f->spec1, &uf->spec1);
434 err |= __put_user(f->fmt_gap, &uf->fmt_gap);
435 err |= __put_user((u64)f->name, (compat_caddr_t __user *)&uf->name);
436 break;
437 }
438 case FDGETDRVPRM32:
439 {
440 struct compat_floppy_drive_params __user *uf;
441 struct floppy_drive_params *f = karg;
442
443 uf = compat_ptr(arg);
444 err = __put_user(f->cmos, &uf->cmos);
445 err |= __put_user(f->max_dtr, &uf->max_dtr);
446 err |= __put_user(f->hlt, &uf->hlt);
447 err |= __put_user(f->hut, &uf->hut);
448 err |= __put_user(f->srt, &uf->srt);
449 err |= __put_user(f->spinup, &uf->spinup);
450 err |= __put_user(f->spindown, &uf->spindown);
451 err |= __put_user(f->spindown_offset, &uf->spindown_offset);
452 err |= __put_user(f->select_delay, &uf->select_delay);
453 err |= __put_user(f->rps, &uf->rps);
454 err |= __put_user(f->tracks, &uf->tracks);
455 err |= __put_user(f->timeout, &uf->timeout);
456 err |= __put_user(f->interleave_sect, &uf->interleave_sect);
457 err |= __copy_to_user(&uf->max_errors, &f->max_errors, sizeof(f->max_errors));
458 err |= __put_user(f->flags, &uf->flags);
459 err |= __put_user(f->read_track, &uf->read_track);
460 err |= __copy_to_user(uf->autodetect, f->autodetect, sizeof(f->autodetect));
461 err |= __put_user(f->checkfreq, &uf->checkfreq);
462 err |= __put_user(f->native_format, &uf->native_format);
463 break;
464 }
465 case FDGETDRVSTAT32:
466 case FDPOLLDRVSTAT32:
467 {
468 struct compat_floppy_drive_struct __user *uf;
469 struct floppy_drive_struct *f = karg;
470
471 uf = compat_ptr(arg);
472 err = __put_user(f->flags, &uf->flags);
473 err |= __put_user(f->spinup_date, &uf->spinup_date);
474 err |= __put_user(f->select_date, &uf->select_date);
475 err |= __put_user(f->first_read_date, &uf->first_read_date);
476 err |= __put_user(f->probed_format, &uf->probed_format);
477 err |= __put_user(f->track, &uf->track);
478 err |= __put_user(f->maxblock, &uf->maxblock);
479 err |= __put_user(f->maxtrack, &uf->maxtrack);
480 err |= __put_user(f->generation, &uf->generation);
481 err |= __put_user(f->keep_data, &uf->keep_data);
482 err |= __put_user(f->fd_ref, &uf->fd_ref);
483 err |= __put_user(f->fd_device, &uf->fd_device);
484 err |= __put_user(f->last_checked, &uf->last_checked);
485 err |= __put_user((u64)f->dmabuf, &uf->dmabuf);
486 err |= __put_user((u64)f->bufblocks, &uf->bufblocks);
487 break;
488 }
489 case FDGETFDCSTAT32:
490 {
491 struct compat_floppy_fdc_state __user *uf;
492 struct floppy_fdc_state *f = karg;
493
494 uf = compat_ptr(arg);
495 err = __put_user(f->spec1, &uf->spec1);
496 err |= __put_user(f->spec2, &uf->spec2);
497 err |= __put_user(f->dtr, &uf->dtr);
498 err |= __put_user(f->version, &uf->version);
499 err |= __put_user(f->dor, &uf->dor);
500 err |= __put_user(f->address, &uf->address);
501 err |= __copy_to_user((char __user *)&uf->address + sizeof(uf->address),
502 (char *)&f->address + sizeof(f->address), sizeof(int));
503 err |= __put_user(f->driver_version, &uf->driver_version);
504 err |= __copy_to_user(uf->track, f->track, sizeof(f->track));
505 break;
506 }
507 case FDWERRORGET32:
508 {
509 struct compat_floppy_write_errors __user *uf;
510 struct floppy_write_errors *f = karg;
511
512 uf = compat_ptr(arg);
513 err = __put_user(f->write_errors, &uf->write_errors);
514 err |= __put_user(f->first_error_sector, &uf->first_error_sector);
515 err |= __put_user(f->first_error_generation, &uf->first_error_generation);
516 err |= __put_user(f->last_error_sector, &uf->last_error_sector);
517 err |= __put_user(f->last_error_generation, &uf->last_error_generation);
518 err |= __put_user(f->badness, &uf->badness);
519 break;
520 }
521 default:
522 break;
523 }
524 if (err)
525 err = -EFAULT;
526
527out:
528 kfree(karg);
529 return err;
530}
531
206struct compat_blk_user_trace_setup { 532struct compat_blk_user_trace_setup {
207 char name[32]; 533 char name[32];
208 u16 act_mask; 534 u16 act_mask;
@@ -268,6 +594,16 @@ static int compat_blkdev_driver_ioctl(struct inode *inode, struct file *file,
268 case HDIO_GET_ADDRESS: 594 case HDIO_GET_ADDRESS:
269 case HDIO_GET_BUSSTATE: 595 case HDIO_GET_BUSSTATE:
270 return compat_hdio_ioctl(inode, file, disk, cmd, arg); 596 return compat_hdio_ioctl(inode, file, disk, cmd, arg);
597 case FDSETPRM32:
598 case FDDEFPRM32:
599 case FDGETPRM32:
600 case FDSETDRVPRM32:
601 case FDGETDRVPRM32:
602 case FDGETDRVSTAT32:
603 case FDPOLLDRVSTAT32:
604 case FDGETFDCSTAT32:
605 case FDWERRORGET32:
606 return compat_fd_ioctl(inode, file, disk, cmd, arg);
271 case CDROMREADAUDIO: 607 case CDROMREADAUDIO:
272 return compat_cdrom_read_audio(inode, file, disk, cmd, arg); 608 return compat_cdrom_read_audio(inode, file, disk, cmd, arg);
273 case CDROM_SEND_PACKET: 609 case CDROM_SEND_PACKET:
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 24c743571127..b9e3357bcc2e 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -32,7 +32,6 @@
32#include <linux/vt.h> 32#include <linux/vt.h>
33#include <linux/fs.h> 33#include <linux/fs.h>
34#include <linux/file.h> 34#include <linux/file.h>
35#include <linux/fd.h>
36#include <linux/ppp_defs.h> 35#include <linux/ppp_defs.h>
37#include <linux/if_ppp.h> 36#include <linux/if_ppp.h>
38#include <linux/if_pppox.h> 37#include <linux/if_pppox.h>
@@ -1407,333 +1406,6 @@ static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg)
1407#define HIDPGETCONNLIST _IOR('H', 210, int) 1406#define HIDPGETCONNLIST _IOR('H', 210, int)
1408#define HIDPGETCONNINFO _IOR('H', 211, int) 1407#define HIDPGETCONNINFO _IOR('H', 211, int)
1409 1408
1410#ifdef CONFIG_BLOCK
1411struct floppy_struct32 {
1412 compat_uint_t size;
1413 compat_uint_t sect;
1414 compat_uint_t head;
1415 compat_uint_t track;
1416 compat_uint_t stretch;
1417 unsigned char gap;
1418 unsigned char rate;
1419 unsigned char spec1;
1420 unsigned char fmt_gap;
1421 const compat_caddr_t name;
1422};
1423
1424struct floppy_drive_params32 {
1425 char cmos;
1426 compat_ulong_t max_dtr;
1427 compat_ulong_t hlt;
1428 compat_ulong_t hut;
1429 compat_ulong_t srt;
1430 compat_ulong_t spinup;
1431 compat_ulong_t spindown;
1432 unsigned char spindown_offset;
1433 unsigned char select_delay;
1434 unsigned char rps;
1435 unsigned char tracks;
1436 compat_ulong_t timeout;
1437 unsigned char interleave_sect;
1438 struct floppy_max_errors max_errors;
1439 char flags;
1440 char read_track;
1441 short autodetect[8];
1442 compat_int_t checkfreq;
1443 compat_int_t native_format;
1444};
1445
1446struct floppy_drive_struct32 {
1447 signed char flags;
1448 compat_ulong_t spinup_date;
1449 compat_ulong_t select_date;
1450 compat_ulong_t first_read_date;
1451 short probed_format;
1452 short track;
1453 short maxblock;
1454 short maxtrack;
1455 compat_int_t generation;
1456 compat_int_t keep_data;
1457 compat_int_t fd_ref;
1458 compat_int_t fd_device;
1459 compat_int_t last_checked;
1460 compat_caddr_t dmabuf;
1461 compat_int_t bufblocks;
1462};
1463
1464struct floppy_fdc_state32 {
1465 compat_int_t spec1;
1466 compat_int_t spec2;
1467 compat_int_t dtr;
1468 unsigned char version;
1469 unsigned char dor;
1470 compat_ulong_t address;
1471 unsigned int rawcmd:2;
1472 unsigned int reset:1;
1473 unsigned int need_configure:1;
1474 unsigned int perp_mode:2;
1475 unsigned int has_fifo:1;
1476 unsigned int driver_version;
1477 unsigned char track[4];
1478};
1479
1480struct floppy_write_errors32 {
1481 unsigned int write_errors;
1482 compat_ulong_t first_error_sector;
1483 compat_int_t first_error_generation;
1484 compat_ulong_t last_error_sector;
1485 compat_int_t last_error_generation;
1486 compat_uint_t badness;
1487};
1488
1489#define FDSETPRM32 _IOW(2, 0x42, struct floppy_struct32)
1490#define FDDEFPRM32 _IOW(2, 0x43, struct floppy_struct32)
1491#define FDGETPRM32 _IOR(2, 0x04, struct floppy_struct32)
1492#define FDSETDRVPRM32 _IOW(2, 0x90, struct floppy_drive_params32)
1493#define FDGETDRVPRM32 _IOR(2, 0x11, struct floppy_drive_params32)
1494#define FDGETDRVSTAT32 _IOR(2, 0x12, struct floppy_drive_struct32)
1495#define FDPOLLDRVSTAT32 _IOR(2, 0x13, struct floppy_drive_struct32)
1496#define FDGETFDCSTAT32 _IOR(2, 0x15, struct floppy_fdc_state32)
1497#define FDWERRORGET32 _IOR(2, 0x17, struct floppy_write_errors32)
1498
1499static struct {
1500 unsigned int cmd32;
1501 unsigned int cmd;
1502} fd_ioctl_trans_table[] = {
1503 { FDSETPRM32, FDSETPRM },
1504 { FDDEFPRM32, FDDEFPRM },
1505 { FDGETPRM32, FDGETPRM },
1506 { FDSETDRVPRM32, FDSETDRVPRM },
1507 { FDGETDRVPRM32, FDGETDRVPRM },
1508 { FDGETDRVSTAT32, FDGETDRVSTAT },
1509 { FDPOLLDRVSTAT32, FDPOLLDRVSTAT },
1510 { FDGETFDCSTAT32, FDGETFDCSTAT },
1511 { FDWERRORGET32, FDWERRORGET }
1512};
1513
1514#define NR_FD_IOCTL_TRANS ARRAY_SIZE(fd_ioctl_trans_table)
1515
1516static int fd_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
1517{
1518 mm_segment_t old_fs = get_fs();
1519 void *karg = NULL;
1520 unsigned int kcmd = 0;
1521 int i, err;
1522
1523 for (i = 0; i < NR_FD_IOCTL_TRANS; i++)
1524 if (cmd == fd_ioctl_trans_table[i].cmd32) {
1525 kcmd = fd_ioctl_trans_table[i].cmd;
1526 break;
1527 }
1528 if (!kcmd)
1529 return -EINVAL;
1530
1531 switch (cmd) {
1532 case FDSETPRM32:
1533 case FDDEFPRM32:
1534 case FDGETPRM32:
1535 {
1536 compat_uptr_t name;
1537 struct floppy_struct32 __user *uf;
1538 struct floppy_struct *f;
1539
1540 uf = compat_ptr(arg);
1541 f = karg = kmalloc(sizeof(struct floppy_struct), GFP_KERNEL);
1542 if (!karg)
1543 return -ENOMEM;
1544 if (cmd == FDGETPRM32)
1545 break;
1546 err = __get_user(f->size, &uf->size);
1547 err |= __get_user(f->sect, &uf->sect);
1548 err |= __get_user(f->head, &uf->head);
1549 err |= __get_user(f->track, &uf->track);
1550 err |= __get_user(f->stretch, &uf->stretch);
1551 err |= __get_user(f->gap, &uf->gap);
1552 err |= __get_user(f->rate, &uf->rate);
1553 err |= __get_user(f->spec1, &uf->spec1);
1554 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
1555 err |= __get_user(name, &uf->name);
1556 f->name = compat_ptr(name);
1557 if (err) {
1558 err = -EFAULT;
1559 goto out;
1560 }
1561 break;
1562 }
1563 case FDSETDRVPRM32:
1564 case FDGETDRVPRM32:
1565 {
1566 struct floppy_drive_params32 __user *uf;
1567 struct floppy_drive_params *f;
1568
1569 uf = compat_ptr(arg);
1570 f = karg = kmalloc(sizeof(struct floppy_drive_params), GFP_KERNEL);
1571 if (!karg)
1572 return -ENOMEM;
1573 if (cmd == FDGETDRVPRM32)
1574 break;
1575 err = __get_user(f->cmos, &uf->cmos);
1576 err |= __get_user(f->max_dtr, &uf->max_dtr);
1577 err |= __get_user(f->hlt, &uf->hlt);
1578 err |= __get_user(f->hut, &uf->hut);
1579 err |= __get_user(f->srt, &uf->srt);
1580 err |= __get_user(f->spinup, &uf->spinup);
1581 err |= __get_user(f->spindown, &uf->spindown);
1582 err |= __get_user(f->spindown_offset, &uf->spindown_offset);
1583 err |= __get_user(f->select_delay, &uf->select_delay);
1584 err |= __get_user(f->rps, &uf->rps);
1585 err |= __get_user(f->tracks, &uf->tracks);
1586 err |= __get_user(f->timeout, &uf->timeout);
1587 err |= __get_user(f->interleave_sect, &uf->interleave_sect);
1588 err |= __copy_from_user(&f->max_errors, &uf->max_errors, sizeof(f->max_errors));
1589 err |= __get_user(f->flags, &uf->flags);
1590 err |= __get_user(f->read_track, &uf->read_track);
1591 err |= __copy_from_user(f->autodetect, uf->autodetect, sizeof(f->autodetect));
1592 err |= __get_user(f->checkfreq, &uf->checkfreq);
1593 err |= __get_user(f->native_format, &uf->native_format);
1594 if (err) {
1595 err = -EFAULT;
1596 goto out;
1597 }
1598 break;
1599 }
1600 case FDGETDRVSTAT32:
1601 case FDPOLLDRVSTAT32:
1602 karg = kmalloc(sizeof(struct floppy_drive_struct), GFP_KERNEL);
1603 if (!karg)
1604 return -ENOMEM;
1605 break;
1606 case FDGETFDCSTAT32:
1607 karg = kmalloc(sizeof(struct floppy_fdc_state), GFP_KERNEL);
1608 if (!karg)
1609 return -ENOMEM;
1610 break;
1611 case FDWERRORGET32:
1612 karg = kmalloc(sizeof(struct floppy_write_errors), GFP_KERNEL);
1613 if (!karg)
1614 return -ENOMEM;
1615 break;
1616 default:
1617 return -EINVAL;
1618 }
1619 set_fs (KERNEL_DS);
1620 err = sys_ioctl (fd, kcmd, (unsigned long)karg);
1621 set_fs (old_fs);
1622 if (err)
1623 goto out;
1624 switch (cmd) {
1625 case FDGETPRM32:
1626 {
1627 struct floppy_struct *f = karg;
1628 struct floppy_struct32 __user *uf = compat_ptr(arg);
1629
1630 err = __put_user(f->size, &uf->size);
1631 err |= __put_user(f->sect, &uf->sect);
1632 err |= __put_user(f->head, &uf->head);
1633 err |= __put_user(f->track, &uf->track);
1634 err |= __put_user(f->stretch, &uf->stretch);
1635 err |= __put_user(f->gap, &uf->gap);
1636 err |= __put_user(f->rate, &uf->rate);
1637 err |= __put_user(f->spec1, &uf->spec1);
1638 err |= __put_user(f->fmt_gap, &uf->fmt_gap);
1639 err |= __put_user((u64)f->name, (compat_caddr_t __user *)&uf->name);
1640 break;
1641 }
1642 case FDGETDRVPRM32:
1643 {
1644 struct floppy_drive_params32 __user *uf;
1645 struct floppy_drive_params *f = karg;
1646
1647 uf = compat_ptr(arg);
1648 err = __put_user(f->cmos, &uf->cmos);
1649 err |= __put_user(f->max_dtr, &uf->max_dtr);
1650 err |= __put_user(f->hlt, &uf->hlt);
1651 err |= __put_user(f->hut, &uf->hut);
1652 err |= __put_user(f->srt, &uf->srt);
1653 err |= __put_user(f->spinup, &uf->spinup);
1654 err |= __put_user(f->spindown, &uf->spindown);
1655 err |= __put_user(f->spindown_offset, &uf->spindown_offset);
1656 err |= __put_user(f->select_delay, &uf->select_delay);
1657 err |= __put_user(f->rps, &uf->rps);
1658 err |= __put_user(f->tracks, &uf->tracks);
1659 err |= __put_user(f->timeout, &uf->timeout);
1660 err |= __put_user(f->interleave_sect, &uf->interleave_sect);
1661 err |= __copy_to_user(&uf->max_errors, &f->max_errors, sizeof(f->max_errors));
1662 err |= __put_user(f->flags, &uf->flags);
1663 err |= __put_user(f->read_track, &uf->read_track);
1664 err |= __copy_to_user(uf->autodetect, f->autodetect, sizeof(f->autodetect));
1665 err |= __put_user(f->checkfreq, &uf->checkfreq);
1666 err |= __put_user(f->native_format, &uf->native_format);
1667 break;
1668 }
1669 case FDGETDRVSTAT32:
1670 case FDPOLLDRVSTAT32:
1671 {
1672 struct floppy_drive_struct32 __user *uf;
1673 struct floppy_drive_struct *f = karg;
1674
1675 uf = compat_ptr(arg);
1676 err = __put_user(f->flags, &uf->flags);
1677 err |= __put_user(f->spinup_date, &uf->spinup_date);
1678 err |= __put_user(f->select_date, &uf->select_date);
1679 err |= __put_user(f->first_read_date, &uf->first_read_date);
1680 err |= __put_user(f->probed_format, &uf->probed_format);
1681 err |= __put_user(f->track, &uf->track);
1682 err |= __put_user(f->maxblock, &uf->maxblock);
1683 err |= __put_user(f->maxtrack, &uf->maxtrack);
1684 err |= __put_user(f->generation, &uf->generation);
1685 err |= __put_user(f->keep_data, &uf->keep_data);
1686 err |= __put_user(f->fd_ref, &uf->fd_ref);
1687 err |= __put_user(f->fd_device, &uf->fd_device);
1688 err |= __put_user(f->last_checked, &uf->last_checked);
1689 err |= __put_user((u64)f->dmabuf, &uf->dmabuf);
1690 err |= __put_user((u64)f->bufblocks, &uf->bufblocks);
1691 break;
1692 }
1693 case FDGETFDCSTAT32:
1694 {
1695 struct floppy_fdc_state32 __user *uf;
1696 struct floppy_fdc_state *f = karg;
1697
1698 uf = compat_ptr(arg);
1699 err = __put_user(f->spec1, &uf->spec1);
1700 err |= __put_user(f->spec2, &uf->spec2);
1701 err |= __put_user(f->dtr, &uf->dtr);
1702 err |= __put_user(f->version, &uf->version);
1703 err |= __put_user(f->dor, &uf->dor);
1704 err |= __put_user(f->address, &uf->address);
1705 err |= __copy_to_user((char __user *)&uf->address + sizeof(uf->address),
1706 (char *)&f->address + sizeof(f->address), sizeof(int));
1707 err |= __put_user(f->driver_version, &uf->driver_version);
1708 err |= __copy_to_user(uf->track, f->track, sizeof(f->track));
1709 break;
1710 }
1711 case FDWERRORGET32:
1712 {
1713 struct floppy_write_errors32 __user *uf;
1714 struct floppy_write_errors *f = karg;
1715
1716 uf = compat_ptr(arg);
1717 err = __put_user(f->write_errors, &uf->write_errors);
1718 err |= __put_user(f->first_error_sector, &uf->first_error_sector);
1719 err |= __put_user(f->first_error_generation, &uf->first_error_generation);
1720 err |= __put_user(f->last_error_sector, &uf->last_error_sector);
1721 err |= __put_user(f->last_error_generation, &uf->last_error_generation);
1722 err |= __put_user(f->badness, &uf->badness);
1723 break;
1724 }
1725 default:
1726 break;
1727 }
1728 if (err)
1729 err = -EFAULT;
1730
1731out:
1732 kfree(karg);
1733 return err;
1734}
1735#endif
1736
1737struct mtd_oob_buf32 { 1409struct mtd_oob_buf32 {
1738 u_int32_t start; 1410 u_int32_t start;
1739 u_int32_t length; 1411 u_int32_t length;
@@ -3025,15 +2697,6 @@ HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp)
3025HANDLE_IOCTL(SIOCGSTAMPNS, do_siocgstampns) 2697HANDLE_IOCTL(SIOCGSTAMPNS, do_siocgstampns)
3026#endif 2698#endif
3027#ifdef CONFIG_BLOCK 2699#ifdef CONFIG_BLOCK
3028HANDLE_IOCTL(FDSETPRM32, fd_ioctl_trans)
3029HANDLE_IOCTL(FDDEFPRM32, fd_ioctl_trans)
3030HANDLE_IOCTL(FDGETPRM32, fd_ioctl_trans)
3031HANDLE_IOCTL(FDSETDRVPRM32, fd_ioctl_trans)
3032HANDLE_IOCTL(FDGETDRVPRM32, fd_ioctl_trans)
3033HANDLE_IOCTL(FDGETDRVSTAT32, fd_ioctl_trans)
3034HANDLE_IOCTL(FDPOLLDRVSTAT32, fd_ioctl_trans)
3035HANDLE_IOCTL(FDGETFDCSTAT32, fd_ioctl_trans)
3036HANDLE_IOCTL(FDWERRORGET32, fd_ioctl_trans)
3037HANDLE_IOCTL(SG_IO,sg_ioctl_trans) 2700HANDLE_IOCTL(SG_IO,sg_ioctl_trans)
3038HANDLE_IOCTL(SG_GET_REQUEST_TABLE, sg_grt_trans) 2701HANDLE_IOCTL(SG_GET_REQUEST_TABLE, sg_grt_trans)
3039#endif 2702#endif