|
Lines 87-97
Link Here
|
| 87 |
goto out_func; |
87 |
goto out_func; |
| 88 |
memset(kbd->fn_handler, 0, sizeof(fn_handler_fn *) * NR_FN_HANDLER); |
88 |
memset(kbd->fn_handler, 0, sizeof(fn_handler_fn *) * NR_FN_HANDLER); |
| 89 |
kbd->accent_table = |
89 |
kbd->accent_table = |
| 90 |
kmalloc(sizeof(struct kbdiacr)*MAX_DIACR, GFP_KERNEL); |
90 |
kmalloc(sizeof(struct kbdiacruc)*MAX_DIACR, GFP_KERNEL); |
| 91 |
if (!kbd->accent_table) |
91 |
if (!kbd->accent_table) |
| 92 |
goto out_fn_handler; |
92 |
goto out_fn_handler; |
| 93 |
memcpy(kbd->accent_table, accent_table, |
93 |
memcpy(kbd->accent_table, accent_table, |
| 94 |
sizeof(struct kbdiacr)*MAX_DIACR); |
94 |
sizeof(struct kbdiacruc)*MAX_DIACR); |
| 95 |
kbd->accent_table_size = accent_table_size; |
95 |
kbd->accent_table_size = accent_table_size; |
| 96 |
return kbd; |
96 |
return kbd; |
| 97 |
|
97 |
|
|
Lines 464-470
Link Here
|
| 464 |
kbd_ioctl(struct kbd_data *kbd, struct file *file, |
464 |
kbd_ioctl(struct kbd_data *kbd, struct file *file, |
| 465 |
unsigned int cmd, unsigned long arg) |
465 |
unsigned int cmd, unsigned long arg) |
| 466 |
{ |
466 |
{ |
| 467 |
struct kbdiacrs *a; |
|
|
| 468 |
int ct, perm; |
467 |
int ct, perm; |
| 469 |
|
468 |
|
| 470 |
/* |
469 |
/* |
|
Lines 482-509
Link Here
|
| 482 |
case KDSKBSENT: |
481 |
case KDSKBSENT: |
| 483 |
return do_kdgkb_ioctl(kbd, (struct kbsentry *)arg, cmd, perm); |
482 |
return do_kdgkb_ioctl(kbd, (struct kbsentry *)arg, cmd, perm); |
| 484 |
case KDGKBDIACR: |
483 |
case KDGKBDIACR: |
| 485 |
a = (struct kbdiacrs *) arg; |
484 |
{ |
|
|
485 |
struct kbdiacrs *a = (struct kbdiacrs *)arg; |
| 486 |
struct kbdiacr diacr; |
| 487 |
int i; |
| 486 |
|
488 |
|
| 487 |
if (put_user(kbd->accent_table_size, &a->kb_cnt)) |
489 |
if (put_user(accent_table_size, &a->kb_cnt)) |
| 488 |
return -EFAULT; |
490 |
return -EFAULT; |
| 489 |
ct = kbd->accent_table_size; |
491 |
for (i = 0; i < accent_table_size; i++) { |
| 490 |
if (copy_to_user(a->kbdiacr, kbd->accent_table, |
492 |
diacr.diacr = accent_table[i].diacr; |
| 491 |
ct * sizeof(struct kbdiacr))) |
493 |
diacr.base = accent_table[i].base; |
|
|
494 |
diacr.result = accent_table[i].base > 0xff ? 0 : accent_table[i].base; |
| 495 |
if (copy_to_user(a->kbdiacr + i, &diacr, sizeof(struct kbdiacr))) |
| 496 |
return -EFAULT; |
| 497 |
} |
| 498 |
return 0; |
| 499 |
} |
| 500 |
case KDGKBDIACRUC: |
| 501 |
{ |
| 502 |
struct kbdiacrsuc *a = (struct kbdiacrsuc *)arg; |
| 503 |
|
| 504 |
if (put_user(accent_table_size, &a->kb_cnt)) |
| 505 |
return -EFAULT; |
| 506 |
if (copy_to_user(a->kbdiacruc, accent_table, accent_table_size*sizeof(struct kbdiacruc))) |
| 492 |
return -EFAULT; |
507 |
return -EFAULT; |
| 493 |
return 0; |
508 |
return 0; |
|
|
509 |
} |
| 494 |
case KDSKBDIACR: |
510 |
case KDSKBDIACR: |
| 495 |
a = (struct kbdiacrs *) arg; |
511 |
{ |
|
|
512 |
struct kbdiacrs *a = (struct kbdiacrs *)arg; |
| 513 |
struct kbdiacr diacr; |
| 514 |
int i; |
| 515 |
|
| 496 |
if (!perm) |
516 |
if (!perm) |
| 497 |
return -EPERM; |
517 |
return -EPERM; |
| 498 |
if (get_user(ct, &a->kb_cnt)) |
518 |
if (get_user(ct,&a->kb_cnt)) |
| 499 |
return -EFAULT; |
519 |
return -EFAULT; |
| 500 |
if (ct >= MAX_DIACR) |
520 |
if (ct >= MAX_DIACR) |
| 501 |
return -EINVAL; |
521 |
return -EINVAL; |
| 502 |
kbd->accent_table_size = ct; |
522 |
accent_table_size = ct; |
| 503 |
if (copy_from_user(kbd->accent_table, a->kbdiacr, |
523 |
for (i = 0; i < ct; i++) { |
| 504 |
ct * sizeof(struct kbdiacr))) |
524 |
if (copy_from_user(&diacr, a->kbdiacr, sizeof(struct kbdiacr))) |
|
|
525 |
return -EFAULT; |
| 526 |
accent_table[i].diacr = diacr.diacr; |
| 527 |
accent_table[i].base = diacr.base; |
| 528 |
accent_table[i].result = diacr.result; |
| 529 |
} |
| 530 |
return 0; |
| 531 |
} |
| 532 |
case KDSKBDIACRUC: |
| 533 |
{ |
| 534 |
struct kbdiacrsuc *a = (struct kbdiacrsuc *)arg; |
| 535 |
unsigned int ct; |
| 536 |
|
| 537 |
if (!perm) |
| 538 |
return -EPERM; |
| 539 |
if (get_user(ct,&a->kb_cnt)) |
| 540 |
return -EFAULT; |
| 541 |
if (ct >= MAX_DIACR) |
| 542 |
return -EINVAL; |
| 543 |
accent_table_size = ct; |
| 544 |
if (copy_from_user(accent_table, a->kbdiacruc, ct*sizeof(struct kbdiacruc))) |
| 505 |
return -EFAULT; |
545 |
return -EFAULT; |
| 506 |
return 0; |
546 |
return 0; |
|
|
547 |
} |
| 507 |
default: |
548 |
default: |
| 508 |
return -ENOIOCTLCMD; |
549 |
return -ENOIOCTLCMD; |
| 509 |
} |
550 |
} |