Add the freebsd32 compatibility shims for the *at() syscalls.

Reviewed by:	rwatson, rdivacky
Tested by:	pho
This commit is contained in:
Konstantin Belousov 2008-03-31 12:08:30 +00:00
parent 7104518b07
commit 4f1e7213d4
2 changed files with 90 additions and 7 deletions

View File

@ -260,16 +260,18 @@ freebsd32_exec_copyin_args(struct image_args *args, char *fname,
args->endp = args->begin_argv;
args->stringspace = ARG_MAX;
args->fname = args->buf + ARG_MAX;
/*
* Copy the file name.
*/
error = (segflg == UIO_SYSSPACE) ?
copystr(fname, args->fname, PATH_MAX, &length) :
copyinstr(fname, args->fname, PATH_MAX, &length);
if (error != 0)
goto err_exit;
if (fname != NULL) {
args->fname = args->buf + ARG_MAX;
error = (segflg == UIO_SYSSPACE) ?
copystr(fname, args->fname, PATH_MAX, &length) :
copyinstr(fname, args->fname, PATH_MAX, &length);
if (error != 0)
goto err_exit;
} else
args->fname = NULL;
/*
* extract arguments first
@ -342,6 +344,21 @@ freebsd32_execve(struct thread *td, struct freebsd32_execve_args *uap)
return (error);
}
int
freebsd32_fexecve(struct thread *td, struct freebsd32_fexecve_args *uap)
{
struct image_args eargs;
int error;
error = freebsd32_exec_copyin_args(&eargs, NULL, UIO_SYSSPACE,
uap->argv, uap->envv);
if (error == 0) {
eargs.fd = uap->fd;
error = kern_execve(td, &eargs, NULL);
}
return (error);
}
#ifdef __ia64__
static int
freebsd32_mmap_partial(struct thread *td, vm_offset_t start, vm_offset_t end,
@ -1229,6 +1246,27 @@ freebsd32_futimes(struct thread *td, struct freebsd32_futimes_args *uap)
return (kern_futimes(td, uap->fd, sp, UIO_SYSSPACE));
}
int
freebsd32_futimesat(struct thread *td, struct freebsd32_futimesat_args *uap)
{
struct timeval32 s32[2];
struct timeval s[2], *sp;
int error;
if (uap->times != NULL) {
error = copyin(uap->times, s32, sizeof(s32));
if (error)
return (error);
CP(s32[0], s[0], tv_sec);
CP(s32[0], s[0], tv_usec);
CP(s32[1], s[1], tv_sec);
CP(s32[1], s[1], tv_usec);
sp = s;
} else
sp = NULL;
return (kern_utimesat(td, uap->fd, uap->path, UIO_USERSPACE,
sp, UIO_SYSSPACE));
}
int
freebsd32_adjtime(struct thread *td, struct freebsd32_adjtime_args *uap)
@ -1916,6 +1954,21 @@ freebsd32_fstat(struct thread *td, struct freebsd32_fstat_args *uap)
return (error);
}
int
freebsd32_fstatat(struct thread *td, struct freebsd32_fstatat_args *uap)
{
struct stat ub;
struct stat32 ub32;
int error;
error = kern_statat(td, uap->flag, uap->fd, uap->path, UIO_USERSPACE, &ub);
if (error)
return (error);
copy_stat(&ub, &ub32);
error = copyout(&ub32, uap->buf, sizeof(ub32));
return (error);
}
int
freebsd32_lstat(struct thread *td, struct freebsd32_lstat_args *uap)
{

View File

@ -810,3 +810,33 @@
488 AUE_NULL NOPROTO { int cpuset_setaffinity(cpulevel_t level, \
cpuwhich_t which, id_t id, size_t cpusetsize, \
const cpuset_t *mask); }
489 AUE_FACCESSAT NOPROTO { int faccessat(int fd, char *path, int mode, \
int flag); }
490 AUE_FCHMODAT NOPROTO { int fchmodat(int fd, const char *path, \
mode_t mode, int flag); }
491 AUE_FCHOWNAT NOPROTO { int fchownat(int fd, char *path, uid_t uid, \
gid_t gid, int flag); }
492 AUE_FEXECVE STD { int freebsd32_fexecve(int fd, \
u_int32_t *argv, u_int32_t *envv); }
493 AUE_FSTATAT STD { int freebsd32_fstatat(int fd, char *path, \
struct stat *buf, int flag); }
494 AUE_FUTIMESAT STD { int freebsd32_futimesat(int fd, char *path, \
struct timeval *times); }
495 AUE_LINKAT NOPROTO { int linkat(int fd1, char *path1, int fd2, \
char *path2, int flag); }
496 AUE_MKDIRAT NOPROTO { int mkdirat(int fd, char *path, \
mode_t mode); }
497 AUE_MKFIFOAT NOPROTO { int mkfifoat(int fd, char *path, \
mode_t mode); }
498 AUE_MKNODAT NOPROTO { int mknodat(int fd, char *path, \
mode_t mode, dev_t dev); }
499 AUE_OPENAT_RWTC NOPROTO { int openat(int fd, char *path, int flag, \
mode_t mode); }
500 AUE_READLINKAT NOPROTO { int readlinkat(int fd, char *path, char *buf, \
size_t bufsize); }
501 AUE_RENAMEAT NOPROTO { int renameat(int oldfd, char *old, int newfd, \
const char *new); }
502 AUE_SYMLINKAT NOPROTO { int symlinkat(char *path1, int fd, \
char *path2); }
503 AUE_UNLINKAT NOPROTO { int unlinkat(int fd, char *path, \
int flag); }