diff options
| author | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2020-08-24 17:06:34 +0000 |
|---|---|---|
| committer | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2020-08-24 17:06:34 +0000 |
| commit | 1400a5d9086e287a91c47aef3f08320562ce3c77 (patch) | |
| tree | 471db615804457427832b8fe00c9b5783430ee6d /sys/compat/linux/linux_misc.c | |
| parent | 93ec9865a5ea249043587ff68863e402838bb43b (diff) | |
Notes
Diffstat (limited to 'sys/compat/linux/linux_misc.c')
| -rw-r--r-- | sys/compat/linux/linux_misc.c | 340 |
1 files changed, 1 insertions, 339 deletions
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 5e24808a8082..af3e774f3505 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -202,10 +202,6 @@ linux_alarm(struct thread *td, struct linux_alarm_args *args) u_int secs; int error; -#ifdef DEBUG - if (ldebug(alarm)) - printf(ARGS(alarm, "%u"), args->secs); -#endif secs = args->secs; /* * Linux alarm() is always successful. Limit secs to INT32_MAX / 2 @@ -237,10 +233,6 @@ linux_brk(struct thread *td, struct linux_brk_args *args) struct vmspace *vm = td->td_proc->p_vmspace; uintptr_t new, old; -#ifdef DEBUG - if (ldebug(brk)) - printf(ARGS(brk, "%p"), (void *)(uintptr_t)args->dsend); -#endif old = (uintptr_t)vm->vm_daddr + ctob(vm->vm_dsize); new = (uintptr_t)args->dsend; if ((caddr_t)new > vm->vm_daddr && !kern_break(td, &new)) @@ -273,11 +265,6 @@ linux_uselib(struct thread *td, struct linux_uselib_args *args) LCONVPATHEXIST(td, args->library, &library); -#ifdef DEBUG - if (ldebug(uselib)) - printf(ARGS(uselib, "%s"), library); -#endif - a_out = NULL; vp = NULL; locked = false; @@ -418,9 +405,6 @@ linux_uselib(struct thread *td, struct linux_uselib_args *args) * (what a waste). */ if (file_offset & PAGE_MASK) { -#ifdef DEBUG - printf("uselib: Non page aligned binary %lu\n", file_offset); -#endif /* Map text+data read/write/execute */ /* a_entry is the load address and is page aligned */ @@ -443,9 +427,6 @@ linux_uselib(struct thread *td, struct linux_uselib_args *args) goto cleanup; } } else { -#ifdef DEBUG - printf("uselib: Page aligned binary %lu\n", file_offset); -#endif /* * for QMAGIC, a_entry is 20 bytes beyond the load address * to skip the executable header @@ -472,10 +453,7 @@ linux_uselib(struct thread *td, struct linux_uselib_args *args) vm_map_unlock(map); textset = false; } -#ifdef DEBUG - printf("mem=%08lx = %08lx %08lx\n", (long)vmaddr, ((long *)vmaddr)[0], - ((long *)vmaddr)[1]); -#endif + if (bss_size != 0) { /* Calculate BSS start address */ vmaddr = trunc_page(a_out->a_entry) + a_out->a_text + @@ -523,13 +501,6 @@ linux_select(struct thread *td, struct linux_select_args *args) struct timeval tv0, tv1, utv, *tvp; int error; -#ifdef DEBUG - if (ldebug(select)) - printf(ARGS(select, "%d, %p, %p, %p, %p"), args->nfds, - (void *)args->readfds, (void *)args->writefds, - (void *)args->exceptfds, (void *)args->timeout); -#endif - /* * Store current time for computation of the amount of * time left. @@ -539,11 +510,6 @@ linux_select(struct thread *td, struct linux_select_args *args) goto select_out; utv.tv_sec = ltv.tv_sec; utv.tv_usec = ltv.tv_usec; -#ifdef DEBUG - if (ldebug(select)) - printf(LMSG("incoming timeout (%jd/%ld)"), - (intmax_t)utv.tv_sec, utv.tv_usec); -#endif if (itimerfix(&utv)) { /* @@ -566,11 +532,6 @@ linux_select(struct thread *td, struct linux_select_args *args) error = kern_select(td, args->nfds, args->readfds, args->writefds, args->exceptfds, tvp, LINUX_NFDBITS); - -#ifdef DEBUG - if (ldebug(select)) - printf(LMSG("real select returns %d"), error); -#endif if (error) goto select_out; @@ -589,11 +550,6 @@ linux_select(struct thread *td, struct linux_select_args *args) timevalclear(&utv); } else timevalclear(&utv); -#ifdef DEBUG - if (ldebug(select)) - printf(LMSG("outgoing timeout (%jd/%ld)"), - (intmax_t)utv.tv_sec, utv.tv_usec); -#endif ltv.tv_sec = utv.tv_sec; ltv.tv_usec = utv.tv_usec; if ((error = copyout(<v, args->timeout, sizeof(ltv)))) @@ -601,10 +557,6 @@ linux_select(struct thread *td, struct linux_select_args *args) } select_out: -#ifdef DEBUG - if (ldebug(select)) - printf(LMSG("select_out -> %d"), error); -#endif return (error); } #endif @@ -616,15 +568,6 @@ linux_mremap(struct thread *td, struct linux_mremap_args *args) size_t len; int error = 0; -#ifdef DEBUG - if (ldebug(mremap)) - printf(ARGS(mremap, "%p, %08lx, %08lx, %08lx"), - (void *)(uintptr_t)args->addr, - (unsigned long)args->old_len, - (unsigned long)args->new_len, - (unsigned long)args->flags); -#endif - if (args->flags & ~(LINUX_MREMAP_FIXED | LINUX_MREMAP_MAYMOVE)) { td->td_retval[0] = 0; return (EINVAL); @@ -677,11 +620,6 @@ linux_time(struct thread *td, struct linux_time_args *args) l_time_t tm; int error; -#ifdef DEBUG - if (ldebug(time)) - printf(ARGS(time, "*")); -#endif - microtime(&tv); tm = tv.tv_sec; if (args->tm && (error = copyout(&tm, args->tm, sizeof(tm)))) @@ -720,11 +658,6 @@ linux_times(struct thread *td, struct linux_times_args *args) struct proc *p; int error; -#ifdef DEBUG - if (ldebug(times)) - printf(ARGS(times, "*")); -#endif - if (args->buf != NULL) { p = td->td_proc; PROC_LOCK(p); @@ -757,11 +690,6 @@ linux_newuname(struct thread *td, struct linux_newuname_args *args) char osrelease[LINUX_MAX_UTSNAME]; char *p; -#ifdef DEBUG - if (ldebug(newuname)) - printf(ARGS(newuname, "*")); -#endif - linux_get_osname(td, osname); linux_get_osrelease(td, osrelease); @@ -807,11 +735,6 @@ linux_utime(struct thread *td, struct linux_utime_args *args) LCONVPATHEXIST(td, args->fname, &fname); -#ifdef DEBUG - if (ldebug(utime)) - printf(ARGS(utime, "%s, *"), fname); -#endif - if (args->times) { if ((error = copyin(args->times, &lut, sizeof lut))) { LFREEPATH(fname); @@ -843,11 +766,6 @@ linux_utimes(struct thread *td, struct linux_utimes_args *args) LCONVPATHEXIST(td, args->fname, &fname); -#ifdef DEBUG - if (ldebug(utimes)) - printf(ARGS(utimes, "%s, *"), fname); -#endif - if (args->tptr != NULL) { if ((error = copyin(args->tptr, ltv, sizeof ltv))) { LFREEPATH(fname); @@ -888,11 +806,6 @@ linux_utimensat(struct thread *td, struct linux_utimensat_args *args) dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; -#ifdef DEBUG - if (ldebug(utimensat)) - printf(ARGS(utimensat, "%d, *"), dfd); -#endif - if (args->flags & ~LINUX_AT_SYMLINK_NOFOLLOW) return (EINVAL); @@ -972,11 +885,6 @@ linux_futimesat(struct thread *td, struct linux_futimesat_args *args) dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; LCONVPATHEXIST_AT(td, args->filename, &fname, dfd); -#ifdef DEBUG - if (ldebug(futimesat)) - printf(ARGS(futimesat, "%s, *"), fname); -#endif - if (args->utimes != NULL) { if ((error = copyin(args->utimes, ltv, sizeof ltv))) { LFREEPATH(fname); @@ -1053,12 +961,6 @@ linux_waitpid(struct thread *td, struct linux_waitpid_args *args) { struct linux_wait4_args wait4_args; -#ifdef DEBUG - if (ldebug(waitpid)) - printf(ARGS(waitpid, "%d, %p, %d"), - args->pid, (void *)args->status, args->options); -#endif - wait4_args.pid = args->pid; wait4_args.status = args->status; wait4_args.options = args->options; @@ -1074,12 +976,6 @@ linux_wait4(struct thread *td, struct linux_wait4_args *args) int error, options; struct __wrusage wru, *wrup; -#ifdef DEBUG - if (ldebug(wait4)) - printf(ARGS(wait4, "%d, %p, %d, %p"), - args->pid, (void *)args->status, args->options, - (void *)args->rusage); -#endif if (args->options & ~(LINUX_WUNTRACED | LINUX_WNOHANG | LINUX_WCONTINUED | __WCLONE | __WNOTHREAD | __WALL)) return (EINVAL); @@ -1169,12 +1065,6 @@ linux_mknod(struct thread *td, struct linux_mknod_args *args) LCONVPATHCREAT(td, args->path, &path); -#ifdef DEBUG - if (ldebug(mknod)) - printf(ARGS(mknod, "%s, %d, %ju"), path, args->mode, - (uintmax_t)args->dev); -#endif - switch (args->mode & S_IFMT) { case S_IFIFO: case S_IFSOCK: @@ -1220,11 +1110,6 @@ linux_mknodat(struct thread *td, struct linux_mknodat_args *args) dfd = (args->dfd == LINUX_AT_FDCWD) ? AT_FDCWD : args->dfd; LCONVPATHCREAT_AT(td, args->filename, &path, dfd); -#ifdef DEBUG - if (ldebug(mknodat)) - printf(ARGS(mknodat, "%s, %d, %d"), path, args->mode, args->dev); -#endif - switch (args->mode & S_IFMT) { case S_IFIFO: case S_IFSOCK: @@ -1269,11 +1154,6 @@ linux_personality(struct thread *td, struct linux_personality_args *args) struct proc *p = td->td_proc; uint32_t old; -#ifdef DEBUG - if (ldebug(personality)) - printf(ARGS(personality, "%u"), args->per); -#endif - PROC_LOCK(p); pem = pem_find(p); old = pem->persona; @@ -1303,12 +1183,6 @@ linux_setitimer(struct thread *td, struct linux_setitimer_args *uap) struct l_itimerval ls; struct itimerval aitv, oitv; -#ifdef DEBUG - if (ldebug(setitimer)) - printf(ARGS(setitimer, "%p, %p"), - (void *)uap->itv, (void *)uap->oitv); -#endif - if (uap->itv == NULL) { uap->itv = uap->oitv; return (linux_getitimer(td, (struct linux_getitimer_args *)uap)); @@ -1318,14 +1192,6 @@ linux_setitimer(struct thread *td, struct linux_setitimer_args *uap) if (error != 0) return (error); B2L_ITIMERVAL(&aitv, &ls); -#ifdef DEBUG - if (ldebug(setitimer)) { - printf("setitimer: value: sec: %jd, usec: %ld\n", - (intmax_t)aitv.it_value.tv_sec, aitv.it_value.tv_usec); - printf("setitimer: interval: sec: %jd, usec: %ld\n", - (intmax_t)aitv.it_interval.tv_sec, aitv.it_interval.tv_usec); - } -#endif error = kern_setitimer(td, uap->which, &aitv, &oitv); if (error != 0 || uap->oitv == NULL) return (error); @@ -1341,10 +1207,6 @@ linux_getitimer(struct thread *td, struct linux_getitimer_args *uap) struct l_itimerval ls; struct itimerval aitv; -#ifdef DEBUG - if (ldebug(getitimer)) - printf(ARGS(getitimer, "%p"), (void *)uap->itv); -#endif error = kern_getitimer(td, uap->which, &aitv); if (error != 0) return (error); @@ -1473,12 +1335,6 @@ linux_setrlimit(struct thread *td, struct linux_setrlimit_args *args) u_int which; int error; -#ifdef DEBUG - if (ldebug(setrlimit)) - printf(ARGS(setrlimit, "%d, %p"), - args->resource, (void *)args->rlim); -#endif - if (args->resource >= LINUX_RLIM_NLIMITS) return (EINVAL); @@ -1503,12 +1359,6 @@ linux_old_getrlimit(struct thread *td, struct linux_old_getrlimit_args *args) struct rlimit bsd_rlim; u_int which; -#ifdef DEBUG - if (ldebug(old_getrlimit)) - printf(ARGS(old_getrlimit, "%d, %p"), - args->resource, (void *)args->rlim); -#endif - if (args->resource >= LINUX_RLIM_NLIMITS) return (EINVAL); @@ -1544,12 +1394,6 @@ linux_getrlimit(struct thread *td, struct linux_getrlimit_args *args) struct rlimit bsd_rlim; u_int which; -#ifdef DEBUG - if (ldebug(getrlimit)) - printf(ARGS(getrlimit, "%d, %p"), - args->resource, (void *)args->rlim); -#endif - if (args->resource >= LINUX_RLIM_NLIMITS) return (EINVAL); @@ -1572,12 +1416,6 @@ linux_sched_setscheduler(struct thread *td, struct thread *tdt; int error, policy; -#ifdef DEBUG - if (ldebug(sched_setscheduler)) - printf(ARGS(sched_setscheduler, "%d, %d, %p"), - args->pid, args->policy, (const void *)args->param); -#endif - switch (args->policy) { case LINUX_SCHED_OTHER: policy = SCHED_OTHER; @@ -1639,11 +1477,6 @@ linux_sched_getscheduler(struct thread *td, struct thread *tdt; int error, policy; -#ifdef DEBUG - if (ldebug(sched_getscheduler)) - printf(ARGS(sched_getscheduler, "%d"), args->pid); -#endif - tdt = linux_tdfind(td, args->pid, -1); if (tdt == NULL) return (ESRCH); @@ -1671,11 +1504,6 @@ linux_sched_get_priority_max(struct thread *td, { struct sched_get_priority_max_args bsd; -#ifdef DEBUG - if (ldebug(sched_get_priority_max)) - printf(ARGS(sched_get_priority_max, "%d"), args->policy); -#endif - if (linux_map_sched_prio) { switch (args->policy) { case LINUX_SCHED_OTHER: @@ -1712,11 +1540,6 @@ linux_sched_get_priority_min(struct thread *td, { struct sched_get_priority_min_args bsd; -#ifdef DEBUG - if (ldebug(sched_get_priority_min)) - printf(ARGS(sched_get_priority_min, "%d"), args->policy); -#endif - if (linux_map_sched_prio) { switch (args->policy) { case LINUX_SCHED_OTHER: @@ -1763,11 +1586,6 @@ linux_reboot(struct thread *td, struct linux_reboot_args *args) { struct reboot_args bsd_args; -#ifdef DEBUG - if (ldebug(reboot)) - printf(ARGS(reboot, "0x%x"), args->cmd); -#endif - if (args->magic1 != REBOOT_MAGIC1) return (EINVAL); @@ -1805,10 +1623,6 @@ int linux_getpid(struct thread *td, struct linux_getpid_args *args) { -#ifdef DEBUG - if (ldebug(getpid)) - printf(ARGS(getpid, "")); -#endif td->td_retval[0] = td->td_proc->p_pid; return (0); @@ -1819,11 +1633,6 @@ linux_gettid(struct thread *td, struct linux_gettid_args *args) { struct linux_emuldata *em; -#ifdef DEBUG - if (ldebug(gettid)) - printf(ARGS(gettid, "")); -#endif - em = em_find(td); KASSERT(em != NULL, ("gettid: emuldata not found.\n")); @@ -1837,11 +1646,6 @@ int linux_getppid(struct thread *td, struct linux_getppid_args *args) { -#ifdef DEBUG - if (ldebug(getppid)) - printf(ARGS(getppid, "")); -#endif - td->td_retval[0] = kern_getppid(td); return (0); } @@ -1850,11 +1654,6 @@ int linux_getgid(struct thread *td, struct linux_getgid_args *args) { -#ifdef DEBUG - if (ldebug(getgid)) - printf(ARGS(getgid, "")); -#endif - td->td_retval[0] = td->td_ucred->cr_rgid; return (0); } @@ -1863,11 +1662,6 @@ int linux_getuid(struct thread *td, struct linux_getuid_args *args) { -#ifdef DEBUG - if (ldebug(getuid)) - printf(ARGS(getuid, "")); -#endif - td->td_retval[0] = td->td_ucred->cr_ruid; return (0); } @@ -1878,11 +1672,6 @@ linux_getsid(struct thread *td, struct linux_getsid_args *args) { struct getsid_args bsd; -#ifdef DEBUG - if (ldebug(getsid)) - printf(ARGS(getsid, "%i"), args->pid); -#endif - bsd.pid = args->pid; return (sys_getsid(td, &bsd)); } @@ -1900,11 +1689,6 @@ linux_getpriority(struct thread *td, struct linux_getpriority_args *args) struct getpriority_args bsd_args; int error; -#ifdef DEBUG - if (ldebug(getpriority)) - printf(ARGS(getpriority, "%i, %i"), args->which, args->who); -#endif - bsd_args.which = args->which; bsd_args.who = args->who; error = sys_getpriority(td, &bsd_args); @@ -1917,11 +1701,6 @@ linux_sethostname(struct thread *td, struct linux_sethostname_args *args) { int name[2]; -#ifdef DEBUG - if (ldebug(sethostname)) - printf(ARGS(sethostname, "*, %i"), args->len); -#endif - name[0] = CTL_KERN; name[1] = KERN_HOSTNAME; return (userland_sysctl(td, name, 2, 0, 0, 0, args->hostname, @@ -1933,11 +1712,6 @@ linux_setdomainname(struct thread *td, struct linux_setdomainname_args *args) { int name[2]; -#ifdef DEBUG - if (ldebug(setdomainname)) - printf(ARGS(setdomainname, "*, %i"), args->len); -#endif - name[0] = CTL_KERN; name[1] = KERN_NISDOMAINNAME; return (userland_sysctl(td, name, 2, 0, 0, 0, args->name, @@ -1948,11 +1722,6 @@ int linux_exit_group(struct thread *td, struct linux_exit_group_args *args) { -#ifdef DEBUG - if (ldebug(exit_group)) - printf(ARGS(exit_group, "%i"), args->error_code); -#endif - LINUX_CTR2(exit_group, "thread(%d) (%d)", td->td_tid, args->error_code); @@ -2003,11 +1772,6 @@ linux_capget(struct thread *td, struct linux_capget_args *uap) u32s = 2; break; default: -#ifdef DEBUG - if (ldebug(capget)) - printf(LMSG("invalid capget capability version 0x%x"), - luch.version); -#endif luch.version = _LINUX_CAPABILITY_VERSION_1; error = copyout(&luch, uap->hdrp, sizeof(luch)); if (error) @@ -2055,11 +1819,6 @@ linux_capset(struct thread *td, struct linux_capset_args *uap) u32s = 2; break; default: -#ifdef DEBUG - if (ldebug(capset)) - printf(LMSG("invalid capset capability version 0x%x"), - luch.version); -#endif luch.version = _LINUX_CAPABILITY_VERSION_1; error = copyout(&luch, uap->hdrp, sizeof(luch)); if (error) @@ -2098,13 +1857,6 @@ linux_prctl(struct thread *td, struct linux_prctl_args *args) char comm[LINUX_MAX_COMM_LEN]; int pdeath_signal; -#ifdef DEBUG - if (ldebug(prctl)) - printf(ARGS(prctl, "%d, %ju, %ju, %ju, %ju"), args->option, - (uintmax_t)args->arg2, (uintmax_t)args->arg3, - (uintmax_t)args->arg4, (uintmax_t)args->arg5); -#endif - switch (args->option) { case LINUX_PR_SET_PDEATHSIG: if (!LINUX_SIG_VALID(args->arg2)) @@ -2190,11 +1942,6 @@ linux_sched_setparam(struct thread *td, struct thread *tdt; int error, policy; -#ifdef DEBUG - if (ldebug(sched_setparam)) - printf(ARGS(sched_setparam, "%d, *"), uap->pid); -#endif - error = copyin(uap->param, &sched_param, sizeof(sched_param)); if (error) return (error); @@ -2249,11 +1996,6 @@ linux_sched_getparam(struct thread *td, struct thread *tdt; int error, policy; -#ifdef DEBUG - if (ldebug(sched_getparam)) - printf(ARGS(sched_getparam, "%d, *"), uap->pid); -#endif - tdt = linux_tdfind(td, uap->pid, -1); if (tdt == NULL) return (ESRCH); @@ -2304,11 +2046,6 @@ linux_sched_getaffinity(struct thread *td, int error; struct thread *tdt; -#ifdef DEBUG - if (ldebug(sched_getaffinity)) - printf(ARGS(sched_getaffinity, "%d, %d, *"), args->pid, - args->len); -#endif if (args->len < sizeof(cpuset_t)) return (EINVAL); @@ -2335,11 +2072,6 @@ linux_sched_setaffinity(struct thread *td, { struct thread *tdt; -#ifdef DEBUG - if (ldebug(sched_setaffinity)) - printf(ARGS(sched_setaffinity, "%d, %d, *"), args->pid, - args->len); -#endif if (args->len < sizeof(cpuset_t)) return (EINVAL); @@ -2368,12 +2100,6 @@ linux_prlimit64(struct thread *td, struct linux_prlimit64_args *args) int flags; int error; -#ifdef DEBUG - if (ldebug(prlimit64)) - printf(ARGS(prlimit64, "%d, %d, %p, %p"), args->pid, - args->resource, (void *)args->new, (void *)args->old); -#endif - if (args->resource >= LINUX_RLIM_NLIMITS) return (EINVAL); @@ -2564,70 +2290,6 @@ linux_ppoll(struct thread *td, struct linux_ppoll_args *args) return (error); } -#if defined(DEBUG) || defined(KTR) -/* XXX: can be removed when every ldebug(...) and KTR stuff are removed. */ - -#ifdef COMPAT_LINUX32 -#define L_MAXSYSCALL LINUX32_SYS_MAXSYSCALL -#else -#define L_MAXSYSCALL LINUX_SYS_MAXSYSCALL -#endif - -u_char linux_debug_map[howmany(L_MAXSYSCALL, sizeof(u_char))]; - -static int -linux_debug(int syscall, int toggle, int global) -{ - - if (global) { - char c = toggle ? 0 : 0xff; - - memset(linux_debug_map, c, sizeof(linux_debug_map)); - return (0); - } - if (syscall < 0 || syscall >= L_MAXSYSCALL) - return (EINVAL); - if (toggle) - clrbit(linux_debug_map, syscall); - else - setbit(linux_debug_map, syscall); - return (0); -} -#undef L_MAXSYSCALL - -/* - * Usage: sysctl linux.debug=<syscall_nr>.<0/1> - * - * E.g.: sysctl linux.debug=21.0 - * - * As a special case, syscall "all" will apply to all syscalls globally. - */ -#define LINUX_MAX_DEBUGSTR 16 -int -linux_sysctl_debug(SYSCTL_HANDLER_ARGS) -{ - char value[LINUX_MAX_DEBUGSTR], *p; - int error, sysc, toggle; - int global = 0; - - value[0] = '\0'; - error = sysctl_handle_string(oidp, value, LINUX_MAX_DEBUGSTR, req); - if (error || req->newptr == NULL) - return (error); - for (p = value; *p != '\0' && *p != '.'; p++); - if (*p == '\0') - return (EINVAL); - *p++ = '\0'; - sysc = strtol(value, NULL, 0); - toggle = strtol(p, NULL, 0); - if (strcmp(value, "all") == 0) - global = 1; - error = linux_debug(sysc, toggle, global); - return (error); -} - -#endif /* DEBUG || KTR */ - int linux_sched_rr_get_interval(struct thread *td, struct linux_sched_rr_get_interval_args *uap) |
