Deleted Added
full compact
linux32_machdep.c (293493) linux32_machdep.c (293500)
1/*-
2 * Copyright (c) 2004 Tim J. Robbins
3 * Copyright (c) 2002 Doug Rabson
4 * Copyright (c) 2000 Marcel Moolenaar
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 15 unchanged lines hidden (view full) ---

24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2004 Tim J. Robbins
3 * Copyright (c) 2002 Doug Rabson
4 * Copyright (c) 2000 Marcel Moolenaar
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 15 unchanged lines hidden (view full) ---

24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: stable/10/sys/amd64/linux32/linux32_machdep.c 293493 2016-01-09 15:16:13Z dchagin $");
32__FBSDID("$FreeBSD: stable/10/sys/amd64/linux32/linux32_machdep.c 293500 2016-01-09 15:23:54Z dchagin $");
33
34#include <sys/param.h>
35#include <sys/kernel.h>
36#include <sys/systm.h>
37#include <sys/capsicum.h>
38#include <sys/file.h>
39#include <sys/fcntl.h>
40#include <sys/clock.h>

--- 26 unchanged lines hidden (view full) ---

67#include <amd64/linux32/linux.h>
68#include <amd64/linux32/linux32_proto.h>
69#include <compat/linux/linux_ipc.h>
70#include <compat/linux/linux_misc.h>
71#include <compat/linux/linux_signal.h>
72#include <compat/linux/linux_util.h>
73#include <compat/linux/linux_emul.h>
74
33
34#include <sys/param.h>
35#include <sys/kernel.h>
36#include <sys/systm.h>
37#include <sys/capsicum.h>
38#include <sys/file.h>
39#include <sys/fcntl.h>
40#include <sys/clock.h>

--- 26 unchanged lines hidden (view full) ---

67#include <amd64/linux32/linux.h>
68#include <amd64/linux32/linux32_proto.h>
69#include <compat/linux/linux_ipc.h>
70#include <compat/linux/linux_misc.h>
71#include <compat/linux/linux_signal.h>
72#include <compat/linux/linux_util.h>
73#include <compat/linux/linux_emul.h>
74
75static void bsd_to_linux_rusage(struct rusage *ru, struct l_rusage *lru);
76
75struct l_old_select_argv {
76 l_int nfds;
77 l_uintptr_t readfds;
78 l_uintptr_t writefds;
79 l_uintptr_t exceptfds;
80 l_uintptr_t timeout;
81} __packed;
82

--- 45 unchanged lines hidden (view full) ---

128 lru->ru_msgsnd = ru->ru_msgsnd;
129 lru->ru_msgrcv = ru->ru_msgrcv;
130 lru->ru_nsignals = ru->ru_nsignals;
131 lru->ru_nvcsw = ru->ru_nvcsw;
132 lru->ru_nivcsw = ru->ru_nivcsw;
133}
134
135int
77struct l_old_select_argv {
78 l_int nfds;
79 l_uintptr_t readfds;
80 l_uintptr_t writefds;
81 l_uintptr_t exceptfds;
82 l_uintptr_t timeout;
83} __packed;
84

--- 45 unchanged lines hidden (view full) ---

130 lru->ru_msgsnd = ru->ru_msgsnd;
131 lru->ru_msgrcv = ru->ru_msgrcv;
132 lru->ru_nsignals = ru->ru_nsignals;
133 lru->ru_nvcsw = ru->ru_nvcsw;
134 lru->ru_nivcsw = ru->ru_nivcsw;
135}
136
137int
138linux_copyout_rusage(struct rusage *ru, void *uaddr)
139{
140 struct l_rusage lru;
141
142 bsd_to_linux_rusage(ru, &lru);
143
144 return (copyout(&lru, uaddr, sizeof(struct l_rusage)));
145}
146
147int
136linux_execve(struct thread *td, struct linux_execve_args *args)
137{
138 struct image_args eargs;
139 struct vmspace *oldvmspace;
140 char *path;
141 int error;
142
143 LCONVPATHEXIST(td, args->path, &path);

--- 758 unchanged lines hidden (view full) ---

902 } else
903 tzp = NULL;
904 return (kern_settimeofday(td, tvp, tzp));
905}
906
907int
908linux_getrusage(struct thread *td, struct linux_getrusage_args *uap)
909{
148linux_execve(struct thread *td, struct linux_execve_args *args)
149{
150 struct image_args eargs;
151 struct vmspace *oldvmspace;
152 char *path;
153 int error;
154
155 LCONVPATHEXIST(td, args->path, &path);

--- 758 unchanged lines hidden (view full) ---

914 } else
915 tzp = NULL;
916 return (kern_settimeofday(td, tvp, tzp));
917}
918
919int
920linux_getrusage(struct thread *td, struct linux_getrusage_args *uap)
921{
910 struct l_rusage s32;
911 struct rusage s;
912 int error;
913
914 error = kern_getrusage(td, uap->who, &s);
915 if (error != 0)
916 return (error);
922 struct rusage s;
923 int error;
924
925 error = kern_getrusage(td, uap->who, &s);
926 if (error != 0)
927 return (error);
917 if (uap->rusage != NULL) {
918 bsd_to_linux_rusage(&s, &s32);
919 error = copyout(&s32, uap->rusage, sizeof(s32));
920 }
928 if (uap->rusage != NULL)
929 error = linux_copyout_rusage(&s, uap->rusage);
921 return (error);
922}
923
924int
925linux_set_thread_area(struct thread *td,
926 struct linux_set_thread_area_args *args)
927{
928 struct l_user_desc info;

--- 89 unchanged lines hidden (view full) ---

1018
1019 pcb = td->td_pcb;
1020 pcb->pcb_gsbase = (register_t)info.base_addr;
1021 set_pcb_flags(pcb, PCB_32BIT);
1022 update_gdt_gsbase(td, info.base_addr);
1023
1024 return (0);
1025}
930 return (error);
931}
932
933int
934linux_set_thread_area(struct thread *td,
935 struct linux_set_thread_area_args *args)
936{
937 struct l_user_desc info;

--- 89 unchanged lines hidden (view full) ---

1027
1028 pcb = td->td_pcb;
1029 pcb->pcb_gsbase = (register_t)info.base_addr;
1030 set_pcb_flags(pcb, PCB_32BIT);
1031 update_gdt_gsbase(td, info.base_addr);
1032
1033 return (0);
1034}
1026
1027int
1028linux_wait4(struct thread *td, struct linux_wait4_args *args)
1029{
1030 int error, options;
1031 struct rusage ru, *rup;
1032 struct l_rusage lru;
1033
1034#ifdef DEBUG
1035 if (ldebug(wait4))
1036 printf(ARGS(wait4, "%d, %p, %d, %p"),
1037 args->pid, (void *)args->status, args->options,
1038 (void *)args->rusage);
1039#endif
1040
1041 options = (args->options & (WNOHANG | WUNTRACED));
1042 /* WLINUXCLONE should be equal to __WCLONE, but we make sure */
1043 if (args->options & __WCLONE)
1044 options |= WLINUXCLONE;
1045
1046 if (args->rusage != NULL)
1047 rup = &ru;
1048 else
1049 rup = NULL;
1050 error = linux_common_wait(td, args->pid, args->status, options, rup);
1051 if (error)
1052 return (error);
1053 if (args->rusage != NULL) {
1054 bsd_to_linux_rusage(rup, &lru);
1055 error = copyout(&lru, args->rusage, sizeof(lru));
1056 }
1057
1058 return (error);
1059}