| 1950 | } |
| 1951 | |
| 1952 | int |
| 1953 | kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old, |
| 1954 | size_t *oldlenp, void *new, size_t newlen, size_t *retval, int flags) |
| 1955 | { |
| 1956 | int error = 0; |
| 1957 | struct sysctl_req req; |
| 1958 | |
| 1959 | bzero(&req, sizeof req); |
| 1960 | |
| 1961 | req.td = td; |
| 1962 | req.flags = flags; |
| 1963 | |
| 1964 | if (oldlenp) { |
| 1965 | req.oldlen = *oldlenp; |
| 1966 | } |
| 1967 | req.validlen = req.oldlen; |
| 1968 | |
| 1969 | if (old) { |
| 1970 | req.oldptr= old; |
| 1971 | } |
| 1972 | |
| 1973 | if (new != NULL) { |
| 1974 | req.newlen = newlen; |
| 1975 | req.newptr = new; |
| 1976 | } |
| 1977 | |
| 1978 | req.oldfunc = sysctl_old_kernel; |
| 1979 | req.newfunc = sysctl_new_kernel; |
| 1980 | req.lock = REQ_UNWIRED; |
| 1981 | |
| 1982 | error = sysctl_root(0, name, namelen, &req); |
| 1983 | |
| 1984 | if (req.lock == REQ_WIRED && req.validlen > 0) |
| 1985 | vsunlock(req.oldptr, req.validlen); |
| 1986 | |
| 1987 | if (error && error != ENOMEM) |
| 1988 | return (error); |
| 1989 | |
| 1990 | if (retval) { |
| 1991 | if (req.oldptr && req.oldidx > req.validlen) |
| 1992 | *retval = req.validlen; |
| 1993 | else |
| 1994 | *retval = req.oldidx; |
| 1995 | } |
| 1996 | return (error); |
| 1997 | } |
| 1998 | |
| 1999 | int |
| 2000 | kernel_sysctlbyname(struct thread *td, char *name, void *old, size_t *oldlenp, |
no test coverage detected