linux_misc.c (91d5354a2ce810d848eca6ecf9da1027aeb2be6d) | linux_misc.c (b7e23e826c650173f9175c42f1b03cd80fdb0a93) |
---|---|
1/*- 2 * Copyright (c) 1994-1995 S�ren Schmidt 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 --- 781 unchanged lines hidden (view full) --- 790#endif /* __i386__ */ 791 792#define __WCLONE 0x80000000 793 794#ifndef __alpha__ 795int 796linux_waitpid(struct thread *td, struct linux_waitpid_args *args) 797{ | 1/*- 2 * Copyright (c) 1994-1995 S�ren Schmidt 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 --- 781 unchanged lines hidden (view full) --- 790#endif /* __i386__ */ 791 792#define __WCLONE 0x80000000 793 794#ifndef __alpha__ 795int 796linux_waitpid(struct thread *td, struct linux_waitpid_args *args) 797{ |
798 struct wait_args /* { 799 int pid; 800 int *status; 801 int options; 802 struct rusage *rusage; 803 } */ tmp; 804 int error, tmpstat; | 798 int error, options, tmpstat; |
805 806#ifdef DEBUG 807 if (ldebug(waitpid)) 808 printf(ARGS(waitpid, "%d, %p, %d"), 809 args->pid, (void *)args->status, args->options); 810#endif 811 | 799 800#ifdef DEBUG 801 if (ldebug(waitpid)) 802 printf(ARGS(waitpid, "%d, %p, %d"), 803 args->pid, (void *)args->status, args->options); 804#endif 805 |
812 tmp.pid = args->pid; 813 tmp.status = args->status; 814 tmp.options = (args->options & (WNOHANG | WUNTRACED)); | 806 options = (args->options & (WNOHANG | WUNTRACED)); |
815 /* WLINUXCLONE should be equal to __WCLONE, but we make sure */ 816 if (args->options & __WCLONE) | 807 /* WLINUXCLONE should be equal to __WCLONE, but we make sure */ 808 if (args->options & __WCLONE) |
817 tmp.options |= WLINUXCLONE; 818 tmp.rusage = NULL; | 809 options |= WLINUXCLONE; |
819 | 810 |
820 if ((error = wait4(td, &tmp)) != 0) | 811 error = kern_wait(td, args->pid, &tmpstat, options, NULL); 812 if (error) |
821 return error; 822 823 if (args->status) { | 813 return error; 814 815 if (args->status) { |
824 if ((error = copyin(args->status, &tmpstat, sizeof(int))) != 0) 825 return error; | |
826 tmpstat &= 0xffff; 827 if (WIFSIGNALED(tmpstat)) 828 tmpstat = (tmpstat & 0xffffff80) | 829 BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat)); 830 else if (WIFSTOPPED(tmpstat)) 831 tmpstat = (tmpstat & 0xffff00ff) | 832 (BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8); 833 return copyout(&tmpstat, args->status, sizeof(int)); 834 } 835 836 return 0; 837} 838#endif /*!__alpha__*/ 839 840int 841linux_wait4(struct thread *td, struct linux_wait4_args *args) 842{ | 816 tmpstat &= 0xffff; 817 if (WIFSIGNALED(tmpstat)) 818 tmpstat = (tmpstat & 0xffffff80) | 819 BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat)); 820 else if (WIFSTOPPED(tmpstat)) 821 tmpstat = (tmpstat & 0xffff00ff) | 822 (BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8); 823 return copyout(&tmpstat, args->status, sizeof(int)); 824 } 825 826 return 0; 827} 828#endif /*!__alpha__*/ 829 830int 831linux_wait4(struct thread *td, struct linux_wait4_args *args) 832{ |
843 struct wait_args /* { 844 int pid; 845 int *status; 846 int options; 847 struct rusage *rusage; 848 } */ tmp; 849 int error, tmpstat; | 833 int error, options, tmpstat; 834 struct rusage ru; |
850 struct proc *p; 851 852#ifdef DEBUG 853 if (ldebug(wait4)) 854 printf(ARGS(wait4, "%d, %p, %d, %p"), 855 args->pid, (void *)args->status, args->options, 856 (void *)args->rusage); 857#endif 858 | 835 struct proc *p; 836 837#ifdef DEBUG 838 if (ldebug(wait4)) 839 printf(ARGS(wait4, "%d, %p, %d, %p"), 840 args->pid, (void *)args->status, args->options, 841 (void *)args->rusage); 842#endif 843 |
859 tmp.pid = args->pid; 860 tmp.status = args->status; 861 tmp.options = (args->options & (WNOHANG | WUNTRACED)); | 844 options = (args->options & (WNOHANG | WUNTRACED)); |
862 /* WLINUXCLONE should be equal to __WCLONE, but we make sure */ 863 if (args->options & __WCLONE) | 845 /* WLINUXCLONE should be equal to __WCLONE, but we make sure */ 846 if (args->options & __WCLONE) |
864 tmp.options |= WLINUXCLONE; 865 tmp.rusage = (struct rusage *)args->rusage; | 847 options |= WLINUXCLONE; |
866 | 848 |
867 if ((error = wait4(td, &tmp)) != 0) | 849 error = kern_wait(td, args->pid, &tmpstat, options, &ru); 850 if (error) |
868 return error; 869 870 p = td->td_proc; 871 PROC_LOCK(p); 872 SIGDELSET(p->p_siglist, SIGCHLD); 873 PROC_UNLOCK(p); 874 875 if (args->status) { | 851 return error; 852 853 p = td->td_proc; 854 PROC_LOCK(p); 855 SIGDELSET(p->p_siglist, SIGCHLD); 856 PROC_UNLOCK(p); 857 858 if (args->status) { |
876 if ((error = copyin(args->status, &tmpstat, sizeof(int))) != 0) 877 return error; | |
878 tmpstat &= 0xffff; 879 if (WIFSIGNALED(tmpstat)) 880 tmpstat = (tmpstat & 0xffffff80) | 881 BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat)); 882 else if (WIFSTOPPED(tmpstat)) 883 tmpstat = (tmpstat & 0xffff00ff) | 884 (BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8); | 859 tmpstat &= 0xffff; 860 if (WIFSIGNALED(tmpstat)) 861 tmpstat = (tmpstat & 0xffffff80) | 862 BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat)); 863 else if (WIFSTOPPED(tmpstat)) 864 tmpstat = (tmpstat & 0xffff00ff) | 865 (BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8); |
885 return copyout(&tmpstat, args->status, sizeof(int)); | 866 error = copyout(&tmpstat, args->status, sizeof(int)); |
886 } | 867 } |
868 if (args->rusage != NULL && error == 0) 869 error = copyout(&ru, args->rusage, sizeof(ru)); |
|
887 | 870 |
888 return 0; | 871 return (error); |
889} 890 891int 892linux_mknod(struct thread *td, struct linux_mknod_args *args) 893{ 894 char *path; 895 int error; 896 --- 465 unchanged lines hidden --- | 872} 873 874int 875linux_mknod(struct thread *td, struct linux_mknod_args *args) 876{ 877 char *path; 878 int error; 879 --- 465 unchanged lines hidden --- |