freebsd32_misc.c (1ce4b357402c3cd0cba264a15c06b6fd00591088) | freebsd32_misc.c (e015b1ab0a428e65297e44471d257d7eb589b383) |
---|---|
1/*- 2 * Copyright (c) 2002 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 2614 unchanged lines hidden (view full) --- 2623 error = copyout(&s32, p32, sizeof(s32)); 2624 } 2625 return (error); 2626} 2627#endif 2628 2629int 2630syscall32_register(int *offset, struct sysent *new_sysent, | 1/*- 2 * Copyright (c) 2002 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 2614 unchanged lines hidden (view full) --- 2623 error = copyout(&s32, p32, sizeof(s32)); 2624 } 2625 return (error); 2626} 2627#endif 2628 2629int 2630syscall32_register(int *offset, struct sysent *new_sysent, |
2631 struct sysent *old_sysent) | 2631 struct sysent *old_sysent, int flags) |
2632{ | 2632{ |
2633 2634 if ((flags & ~SY_THR_STATIC) != 0) 2635 return (EINVAL); 2636 |
|
2633 if (*offset == NO_SYSCALL) { 2634 int i; 2635 2636 for (i = 1; i < SYS_MAXSYSCALL; ++i) 2637 if (freebsd32_sysent[i].sy_call == 2638 (sy_call_t *)lkmnosys) 2639 break; 2640 if (i == SYS_MAXSYSCALL) 2641 return (ENFILE); 2642 *offset = i; 2643 } else if (*offset < 0 || *offset >= SYS_MAXSYSCALL) 2644 return (EINVAL); 2645 else if (freebsd32_sysent[*offset].sy_call != (sy_call_t *)lkmnosys && 2646 freebsd32_sysent[*offset].sy_call != (sy_call_t *)lkmressys) 2647 return (EEXIST); 2648 2649 *old_sysent = freebsd32_sysent[*offset]; 2650 freebsd32_sysent[*offset] = *new_sysent; | 2637 if (*offset == NO_SYSCALL) { 2638 int i; 2639 2640 for (i = 1; i < SYS_MAXSYSCALL; ++i) 2641 if (freebsd32_sysent[i].sy_call == 2642 (sy_call_t *)lkmnosys) 2643 break; 2644 if (i == SYS_MAXSYSCALL) 2645 return (ENFILE); 2646 *offset = i; 2647 } else if (*offset < 0 || *offset >= SYS_MAXSYSCALL) 2648 return (EINVAL); 2649 else if (freebsd32_sysent[*offset].sy_call != (sy_call_t *)lkmnosys && 2650 freebsd32_sysent[*offset].sy_call != (sy_call_t *)lkmressys) 2651 return (EEXIST); 2652 2653 *old_sysent = freebsd32_sysent[*offset]; 2654 freebsd32_sysent[*offset] = *new_sysent; |
2651 return 0; | 2655 atomic_store_rel_32(&freebsd32_sysent[*offset].sy_thrcnt, flags); 2656 return (0); |
2652} 2653 2654int 2655syscall32_deregister(int *offset, struct sysent *old_sysent) 2656{ 2657 | 2657} 2658 2659int 2660syscall32_deregister(int *offset, struct sysent *old_sysent) 2661{ 2662 |
2658 if (*offset) 2659 freebsd32_sysent[*offset] = *old_sysent; 2660 return 0; | 2663 if (*offset == 0) 2664 return (0); 2665 2666 freebsd32_sysent[*offset] = *old_sysent; 2667 return (0); |
2661} 2662 2663int 2664syscall32_module_handler(struct module *mod, int what, void *arg) 2665{ 2666 struct syscall_module_data *data = (struct syscall_module_data*)arg; 2667 modspecific_t ms; 2668 int error; 2669 2670 switch (what) { 2671 case MOD_LOAD: 2672 error = syscall32_register(data->offset, data->new_sysent, | 2668} 2669 2670int 2671syscall32_module_handler(struct module *mod, int what, void *arg) 2672{ 2673 struct syscall_module_data *data = (struct syscall_module_data*)arg; 2674 modspecific_t ms; 2675 int error; 2676 2677 switch (what) { 2678 case MOD_LOAD: 2679 error = syscall32_register(data->offset, data->new_sysent, |
2673 &data->old_sysent); | 2680 &data->old_sysent, SY_THR_STATIC_KLD); |
2674 if (error) { 2675 /* Leave a mark so we know to safely unload below. */ 2676 data->offset = NULL; 2677 return error; 2678 } 2679 ms.intval = *data->offset; 2680 MOD_XLOCK; 2681 module_setspecific(mod, &ms); --- 20 unchanged lines hidden (view full) --- 2702 error = EOPNOTSUPP; 2703 if (data->chainevh) 2704 error = data->chainevh(mod, what, data->chainarg); 2705 return (error); 2706 } 2707} 2708 2709int | 2681 if (error) { 2682 /* Leave a mark so we know to safely unload below. */ 2683 data->offset = NULL; 2684 return error; 2685 } 2686 ms.intval = *data->offset; 2687 MOD_XLOCK; 2688 module_setspecific(mod, &ms); --- 20 unchanged lines hidden (view full) --- 2709 error = EOPNOTSUPP; 2710 if (data->chainevh) 2711 error = data->chainevh(mod, what, data->chainarg); 2712 return (error); 2713 } 2714} 2715 2716int |
2710syscall32_helper_register(struct syscall_helper_data *sd) | 2717syscall32_helper_register(struct syscall_helper_data *sd, int flags) |
2711{ 2712 struct syscall_helper_data *sd1; 2713 int error; 2714 2715 for (sd1 = sd; sd1->syscall_no != NO_SYSCALL; sd1++) { 2716 error = syscall32_register(&sd1->syscall_no, &sd1->new_sysent, | 2718{ 2719 struct syscall_helper_data *sd1; 2720 int error; 2721 2722 for (sd1 = sd; sd1->syscall_no != NO_SYSCALL; sd1++) { 2723 error = syscall32_register(&sd1->syscall_no, &sd1->new_sysent, |
2717 &sd1->old_sysent); | 2724 &sd1->old_sysent, flags); |
2718 if (error != 0) { 2719 syscall32_helper_unregister(sd); 2720 return (error); 2721 } 2722 sd1->registered = 1; 2723 } 2724 return (0); 2725} --- 282 unchanged lines hidden --- | 2725 if (error != 0) { 2726 syscall32_helper_unregister(sd); 2727 return (error); 2728 } 2729 sd1->registered = 1; 2730 } 2731 return (0); 2732} --- 282 unchanged lines hidden --- |