Changeset View
Changeset View
Standalone View
Standalone View
head/sys/compat/freebsd32/freebsd32_misc.c
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | |||||
CTASSERT(sizeof(struct statfs32) == 256); | CTASSERT(sizeof(struct statfs32) == 256); | ||||
#ifndef __mips__ | #ifndef __mips__ | ||||
CTASSERT(sizeof(struct rusage32) == 72); | CTASSERT(sizeof(struct rusage32) == 72); | ||||
#endif | #endif | ||||
CTASSERT(sizeof(struct sigaltstack32) == 12); | CTASSERT(sizeof(struct sigaltstack32) == 12); | ||||
CTASSERT(sizeof(struct kevent32) == 20); | CTASSERT(sizeof(struct kevent32) == 20); | ||||
CTASSERT(sizeof(struct iovec32) == 8); | CTASSERT(sizeof(struct iovec32) == 8); | ||||
CTASSERT(sizeof(struct msghdr32) == 28); | CTASSERT(sizeof(struct msghdr32) == 28); | ||||
#ifdef __amd64__ | |||||
CTASSERT(sizeof(struct stat32) == 208); | |||||
#endif | |||||
#ifndef __mips__ | #ifndef __mips__ | ||||
CTASSERT(sizeof(struct stat32) == 96); | CTASSERT(sizeof(struct freebsd11_stat32) == 96); | ||||
#endif | #endif | ||||
CTASSERT(sizeof(struct sigaction32) == 24); | CTASSERT(sizeof(struct sigaction32) == 24); | ||||
static int freebsd32_kevent_copyout(void *arg, struct kevent *kevp, int count); | static int freebsd32_kevent_copyout(void *arg, struct kevent *kevp, int count); | ||||
static int freebsd32_kevent_copyin(void *arg, struct kevent *kevp, int count); | static int freebsd32_kevent_copyin(void *arg, struct kevent *kevp, int count); | ||||
static int freebsd32_user_clock_nanosleep(struct thread *td, clockid_t clock_id, | static int freebsd32_user_clock_nanosleep(struct thread *td, clockid_t clock_id, | ||||
int flags, const struct timespec32 *ua_rqtp, struct timespec32 *ua_rmtp); | int flags, const struct timespec32 *ua_rqtp, struct timespec32 *ua_rmtp); | ||||
▲ Show 20 Lines • Show All 308 Lines • ▼ Show 20 Lines | freebsd32_fexecve(struct thread *td, struct freebsd32_fexecve_args *uap) | ||||
if (error == 0) { | if (error == 0) { | ||||
eargs.fd = uap->fd; | eargs.fd = uap->fd; | ||||
error = kern_execve(td, &eargs, NULL); | error = kern_execve(td, &eargs, NULL); | ||||
} | } | ||||
post_execve(td, error, oldvmspace); | post_execve(td, error, oldvmspace); | ||||
return (error); | return (error); | ||||
} | } | ||||
#if defined(COMPAT_FREEBSD11) | |||||
int | int | ||||
freebsd11_freebsd32_mknod(struct thread *td, | |||||
struct freebsd11_freebsd32_mknod_args *uap) | |||||
{ | |||||
return (kern_mknodat(td, AT_FDCWD, uap->path, UIO_USERSPACE, uap->mode, | |||||
uap->dev)); | |||||
} | |||||
int | |||||
freebsd11_freebsd32_mknodat(struct thread *td, | |||||
struct freebsd11_freebsd32_mknodat_args *uap) | |||||
{ | |||||
return (kern_mknodat(td, uap->fd, uap->path, UIO_USERSPACE, uap->mode, | |||||
uap->dev)); | |||||
} | |||||
#endif /* COMPAT_FREEBSD11 */ | |||||
int | |||||
freebsd32_mprotect(struct thread *td, struct freebsd32_mprotect_args *uap) | freebsd32_mprotect(struct thread *td, struct freebsd32_mprotect_args *uap) | ||||
{ | { | ||||
int prot; | int prot; | ||||
prot = uap->prot; | prot = uap->prot; | ||||
#if defined(__amd64__) | #if defined(__amd64__) | ||||
if (i386_read_exec && (prot & PROT_READ) != 0) | if (i386_read_exec && (prot & PROT_READ) != 0) | ||||
prot |= PROT_EXEC; | prot |= PROT_EXEC; | ||||
▲ Show 20 Lines • Show All 1,054 Lines • ▼ Show 20 Lines | ofreebsd32_getdirentries(struct thread *td, | ||||
if (error == 0) { | if (error == 0) { | ||||
loff_cut = loff; | loff_cut = loff; | ||||
error = copyout(&loff_cut, uap->basep, sizeof(int32_t)); | error = copyout(&loff_cut, uap->basep, sizeof(int32_t)); | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
#endif | #endif | ||||
#if defined(COMPAT_FREEBSD11) | |||||
int | int | ||||
freebsd11_freebsd32_getdirentries(struct thread *td, | |||||
struct freebsd11_freebsd32_getdirentries_args *uap) | |||||
{ | |||||
long base; | |||||
int32_t base32; | |||||
int error; | |||||
error = freebsd11_kern_getdirentries(td, uap->fd, uap->buf, uap->count, | |||||
&base, NULL); | |||||
if (error) | |||||
return (error); | |||||
if (uap->basep != NULL) { | |||||
base32 = base; | |||||
error = copyout(&base32, uap->basep, sizeof(int32_t)); | |||||
} | |||||
return (error); | |||||
} | |||||
int | |||||
freebsd11_freebsd32_getdents(struct thread *td, | |||||
struct freebsd11_freebsd32_getdents_args *uap) | |||||
{ | |||||
struct freebsd11_freebsd32_getdirentries_args ap; | |||||
ap.fd = uap->fd; | |||||
ap.buf = uap->buf; | |||||
ap.count = uap->count; | |||||
ap.basep = NULL; | |||||
return (freebsd11_freebsd32_getdirentries(td, &ap)); | |||||
} | |||||
#endif /* COMPAT_FREEBSD11 */ | |||||
int | |||||
freebsd32_getdirentries(struct thread *td, | freebsd32_getdirentries(struct thread *td, | ||||
struct freebsd32_getdirentries_args *uap) | struct freebsd32_getdirentries_args *uap) | ||||
{ | { | ||||
long base; | long base; | ||||
int32_t base32; | int32_t base32; | ||||
int error; | int error; | ||||
error = kern_getdirentries(td, uap->fd, uap->buf, uap->count, &base, | error = kern_getdirentries(td, uap->fd, uap->buf, uap->count, &base, | ||||
▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | copy_stat(struct stat *in, struct stat32 *out) | ||||
TS_CP(*in, *out, st_mtim); | TS_CP(*in, *out, st_mtim); | ||||
TS_CP(*in, *out, st_ctim); | TS_CP(*in, *out, st_ctim); | ||||
CP(*in, *out, st_size); | CP(*in, *out, st_size); | ||||
CP(*in, *out, st_blocks); | CP(*in, *out, st_blocks); | ||||
CP(*in, *out, st_blksize); | CP(*in, *out, st_blksize); | ||||
CP(*in, *out, st_flags); | CP(*in, *out, st_flags); | ||||
CP(*in, *out, st_gen); | CP(*in, *out, st_gen); | ||||
TS_CP(*in, *out, st_birthtim); | TS_CP(*in, *out, st_birthtim); | ||||
out->st_padding0 = 0; | |||||
out->st_padding1 = 0; | |||||
#ifdef __STAT32_TIME_T_EXT | |||||
out->st_atim_ext = 0; | |||||
out->st_mtim_ext = 0; | |||||
out->st_ctim_ext = 0; | |||||
out->st_btim_ext = 0; | |||||
#endif | |||||
bzero(out->st_spare, sizeof(out->st_spare)); | |||||
} | } | ||||
#ifdef COMPAT_43 | #ifdef COMPAT_43 | ||||
static void | static void | ||||
copy_ostat(struct stat *in, struct ostat32 *out) | copy_ostat(struct stat *in, struct ostat32 *out) | ||||
{ | { | ||||
CP(*in, *out, st_dev); | CP(*in, *out, st_dev); | ||||
Show All 9 Lines | copy_ostat(struct stat *in, struct ostat32 *out) | ||||
TS_CP(*in, *out, st_ctim); | TS_CP(*in, *out, st_ctim); | ||||
CP(*in, *out, st_blksize); | CP(*in, *out, st_blksize); | ||||
CP(*in, *out, st_blocks); | CP(*in, *out, st_blocks); | ||||
CP(*in, *out, st_flags); | CP(*in, *out, st_flags); | ||||
CP(*in, *out, st_gen); | CP(*in, *out, st_gen); | ||||
} | } | ||||
#endif | #endif | ||||
int | |||||
freebsd32_stat(struct thread *td, struct freebsd32_stat_args *uap) | |||||
{ | |||||
struct stat sb; | |||||
struct stat32 sb32; | |||||
int error; | |||||
error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE, | |||||
&sb, NULL); | |||||
if (error) | |||||
return (error); | |||||
copy_stat(&sb, &sb32); | |||||
error = copyout(&sb32, uap->ub, sizeof (sb32)); | |||||
return (error); | |||||
} | |||||
#ifdef COMPAT_43 | #ifdef COMPAT_43 | ||||
int | int | ||||
ofreebsd32_stat(struct thread *td, struct ofreebsd32_stat_args *uap) | ofreebsd32_stat(struct thread *td, struct ofreebsd32_stat_args *uap) | ||||
{ | { | ||||
struct stat sb; | struct stat sb; | ||||
struct ostat32 sb32; | struct ostat32 sb32; | ||||
int error; | int error; | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | error = kern_statat(td, uap->flag, uap->fd, uap->path, UIO_USERSPACE, | ||||
&ub, NULL); | &ub, NULL); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
copy_stat(&ub, &ub32); | copy_stat(&ub, &ub32); | ||||
error = copyout(&ub32, uap->buf, sizeof(ub32)); | error = copyout(&ub32, uap->buf, sizeof(ub32)); | ||||
return (error); | return (error); | ||||
} | } | ||||
#ifdef COMPAT_43 | |||||
int | int | ||||
freebsd32_lstat(struct thread *td, struct freebsd32_lstat_args *uap) | ofreebsd32_lstat(struct thread *td, struct ofreebsd32_lstat_args *uap) | ||||
{ | { | ||||
struct stat sb; | struct stat sb; | ||||
struct stat32 sb32; | struct ostat32 sb32; | ||||
int error; | int error; | ||||
error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path, | error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path, | ||||
UIO_USERSPACE, &sb, NULL); | UIO_USERSPACE, &sb, NULL); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
copy_ostat(&sb, &sb32); | |||||
error = copyout(&sb32, uap->ub, sizeof (sb32)); | |||||
return (error); | |||||
} | |||||
#endif | |||||
int | |||||
freebsd32_fhstat(struct thread *td, struct freebsd32_fhstat_args *uap) | |||||
{ | |||||
struct stat sb; | |||||
struct stat32 sb32; | |||||
struct fhandle fh; | |||||
int error; | |||||
error = copyin(uap->u_fhp, &fh, sizeof(fhandle_t)); | |||||
if (error != 0) | |||||
return (error); | |||||
error = kern_fhstat(td, fh, &sb); | |||||
if (error != 0) | |||||
return (error); | |||||
copy_stat(&sb, &sb32); | copy_stat(&sb, &sb32); | ||||
error = copyout(&sb32, uap->sb, sizeof (sb32)); | |||||
return (error); | |||||
} | |||||
#if defined(COMPAT_FREEBSD11) | |||||
static void | |||||
freebsd11_cvtstat32(struct stat *in, struct freebsd11_stat32 *out) | |||||
{ | |||||
CP(*in, *out, st_ino); | |||||
CP(*in, *out, st_nlink); | |||||
CP(*in, *out, st_dev); | |||||
CP(*in, *out, st_mode); | |||||
CP(*in, *out, st_uid); | |||||
CP(*in, *out, st_gid); | |||||
CP(*in, *out, st_rdev); | |||||
TS_CP(*in, *out, st_atim); | |||||
TS_CP(*in, *out, st_mtim); | |||||
TS_CP(*in, *out, st_ctim); | |||||
CP(*in, *out, st_size); | |||||
CP(*in, *out, st_blocks); | |||||
CP(*in, *out, st_blksize); | |||||
CP(*in, *out, st_flags); | |||||
CP(*in, *out, st_gen); | |||||
TS_CP(*in, *out, st_birthtim); | |||||
out->st_lspare = 0; | |||||
bzero((char *)&out->st_birthtim + sizeof(out->st_birthtim), | |||||
sizeof(*out) - offsetof(struct freebsd11_stat32, | |||||
st_birthtim) - sizeof(out->st_birthtim)); | |||||
} | |||||
int | |||||
freebsd11_freebsd32_stat(struct thread *td, | |||||
struct freebsd11_freebsd32_stat_args *uap) | |||||
{ | |||||
struct stat sb; | |||||
struct freebsd11_stat32 sb32; | |||||
int error; | |||||
error = kern_statat(td, 0, AT_FDCWD, uap->path, UIO_USERSPACE, | |||||
&sb, NULL); | |||||
if (error != 0) | |||||
return (error); | |||||
freebsd11_cvtstat32(&sb, &sb32); | |||||
error = copyout(&sb32, uap->ub, sizeof (sb32)); | error = copyout(&sb32, uap->ub, sizeof (sb32)); | ||||
return (error); | return (error); | ||||
} | } | ||||
#ifdef COMPAT_43 | |||||
int | int | ||||
ofreebsd32_lstat(struct thread *td, struct ofreebsd32_lstat_args *uap) | freebsd11_freebsd32_fstat(struct thread *td, | ||||
struct freebsd11_freebsd32_fstat_args *uap) | |||||
{ | { | ||||
struct stat sb; | struct stat sb; | ||||
struct ostat32 sb32; | struct freebsd11_stat32 sb32; | ||||
int error; | int error; | ||||
error = kern_fstat(td, uap->fd, &sb); | |||||
if (error != 0) | |||||
return (error); | |||||
freebsd11_cvtstat32(&sb, &sb32); | |||||
error = copyout(&sb32, uap->ub, sizeof (sb32)); | |||||
return (error); | |||||
} | |||||
int | |||||
freebsd11_freebsd32_fstatat(struct thread *td, | |||||
struct freebsd11_freebsd32_fstatat_args *uap) | |||||
{ | |||||
struct stat sb; | |||||
struct freebsd11_stat32 sb32; | |||||
int error; | |||||
error = kern_statat(td, uap->flag, uap->fd, uap->path, UIO_USERSPACE, | |||||
&sb, NULL); | |||||
if (error != 0) | |||||
return (error); | |||||
freebsd11_cvtstat32(&sb, &sb32); | |||||
error = copyout(&sb32, uap->buf, sizeof (sb32)); | |||||
return (error); | |||||
} | |||||
int | |||||
freebsd11_freebsd32_lstat(struct thread *td, | |||||
struct freebsd11_freebsd32_lstat_args *uap) | |||||
{ | |||||
struct stat sb; | |||||
struct freebsd11_stat32 sb32; | |||||
int error; | |||||
error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path, | error = kern_statat(td, AT_SYMLINK_NOFOLLOW, AT_FDCWD, uap->path, | ||||
UIO_USERSPACE, &sb, NULL); | UIO_USERSPACE, &sb, NULL); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
copy_ostat(&sb, &sb32); | freebsd11_cvtstat32(&sb, &sb32); | ||||
error = copyout(&sb32, uap->ub, sizeof (sb32)); | error = copyout(&sb32, uap->ub, sizeof (sb32)); | ||||
return (error); | |||||
} | |||||
int | |||||
freebsd11_freebsd32_fhstat(struct thread *td, | |||||
struct freebsd11_freebsd32_fhstat_args *uap) | |||||
{ | |||||
struct stat sb; | |||||
struct freebsd11_stat32 sb32; | |||||
struct fhandle fh; | |||||
int error; | |||||
error = copyin(uap->u_fhp, &fh, sizeof(fhandle_t)); | |||||
if (error != 0) | |||||
return (error); | |||||
error = kern_fhstat(td, fh, &sb); | |||||
if (error != 0) | |||||
return (error); | |||||
freebsd11_cvtstat32(&sb, &sb32); | |||||
error = copyout(&sb32, uap->sb, sizeof (sb32)); | |||||
return (error); | return (error); | ||||
} | } | ||||
#endif | #endif | ||||
int | int | ||||
freebsd32_sysctl(struct thread *td, struct freebsd32_sysctl_args *uap) | freebsd32_sysctl(struct thread *td, struct freebsd32_sysctl_args *uap) | ||||
{ | { | ||||
int error, name[CTL_MAXNAME]; | int error, name[CTL_MAXNAME]; | ||||
▲ Show 20 Lines • Show All 1,297 Lines • Show Last 20 Lines |