Index: sys/amd64/linux32/linux32_dummy.c =================================================================== RCS file: /import/FreeBSD-CVS/src/sys/amd64/linux32/linux32_dummy.c,v retrieving revision 1.1 diff -u -u -r1.1 linux32_dummy.c --- sys/amd64/linux32/linux32_dummy.c 16 Aug 2004 07:55:06 -0000 1.1 +++ sys/amd64/linux32/linux32_dummy.c 22 Jul 2007 11:12:26 -0000 @@ -67,7 +67,46 @@ DUMMY(mincore); DUMMY(fadvise64); DUMMY(ptrace); -DUMMY(settimeofday); +DUMMY(mq_open); +DUMMY(mq_unlink); +DUMMY(mq_timedsend); +DUMMY(mq_timedreceive); +DUMMY(mq_notify); +DUMMY(mq_getsetattr); +DUMMY(fstatfs64); +DUMMY(tgkill); +DUMMY(fadvise64_64); +DUMMY(mbind); +DUMMY(get_mempolicy); +DUMMY(set_mempolicy); +DUMMY(kexec_load); +DUMMY(waitid); +DUMMY(add_key); +DUMMY(request_key); +DUMMY(keyctl); +DUMMY(ioprio_set); +DUMMY(ioprio_get); +DUMMY(inotify_init); +DUMMY(inotify_add_watch); +DUMMY(inotify_rm_watch); +DUMMY(migrate_pages); +DUMMY(mkdirat); +DUMMY(mknodat); +DUMMY(fchownat); +DUMMY(futimesat); +DUMMY(fstatat64); +DUMMY(unlinkat); +DUMMY(renameat); +DUMMY(linkat); +DUMMY(symlinkat); +DUMMY(readlinkat); +DUMMY(fchmodat); +DUMMY(faccessat); +DUMMY(pselect6); +DUMMY(ppoll); +DUMMY(unshare); +DUMMY(tgkill); +DUMMY(openat); #define DUMMY_XATTR(s) \ int \ Index: sys/amd64/linux32/linux32_machdep.c =================================================================== RCS file: /import/FreeBSD-CVS/src/sys/amd64/linux32/linux32_machdep.c,v retrieving revision 1.10.2.2 diff -u -u -r1.10.2.2 linux32_machdep.c --- sys/amd64/linux32/linux32_machdep.c 8 Jul 2007 12:20:35 -0000 1.10.2.2 +++ sys/amd64/linux32/linux32_machdep.c 22 Jul 2007 11:12:26 -0000 @@ -983,35 +983,41 @@ microtime(&atv); atv32.tv_sec = atv.tv_sec; atv32.tv_usec = atv.tv_usec; - error = copyout(&atv32, uap->tp, sizeof (atv32)); + error = copyout(&atv32, uap->tp, sizeof(atv32)); } if (error == 0 && uap->tzp != NULL) { rtz.tz_minuteswest = tz_minuteswest; rtz.tz_dsttime = tz_dsttime; - error = copyout(&rtz, uap->tzp, sizeof (rtz)); + error = copyout(&rtz, uap->tzp, sizeof(rtz)); } return (error); } int -linux_nanosleep(struct thread *td, struct linux_nanosleep_args *uap) +linux_settimeofday(struct thread *td, struct linux_settimeofday_args *uap) { - struct timespec rqt, rmt; - struct l_timespec ats32; + l_timeval atv32; + struct timeval atv, *tvp; + struct timezone atz, *tzp; int error; - error = copyin(uap->rqtp, &ats32, sizeof(ats32)); - if (error != 0) - return (error); - rqt.tv_sec = ats32.tv_sec; - rqt.tv_nsec = ats32.tv_nsec; - error = kern_nanosleep(td, &rqt, &rmt); - if (uap->rmtp != NULL) { - ats32.tv_sec = rmt.tv_sec; - ats32.tv_nsec = rmt.tv_nsec; - error = copyout(&ats32, uap->rmtp, sizeof(ats32)); - } - return (error); + if (uap->tp) { + error = copyin(uap->tp, &atv32, sizeof(atv32)); + if (error) + return (error); + atv.tv_sec = atv32.tv_sec; + atv.tv_usec = atv32.tv_usec; + tvp = &atv; + } else + tvp = NULL; + if (uap->tzp) { + error = copyin(uap->tzp, &atz, sizeof(atz)); + if (error) + return (error); + tzp = &atz; + } else + tzp = NULL; + return (kern_settimeofday(td, tvp, tzp)); } int Index: sys/amd64/linux32/syscalls.master =================================================================== RCS file: /import/FreeBSD-CVS/src/sys/amd64/linux32/syscalls.master,v retrieving revision 1.4.2.2 diff -u -u -r1.4.2.2 syscalls.master --- sys/amd64/linux32/syscalls.master 8 Jul 2007 12:20:35 -0000 1.4.2.2 +++ sys/amd64/linux32/syscalls.master 22 Jul 2007 11:12:26 -0000 @@ -66,7 +66,8 @@ 16 AUE_NULL MSTD { int linux_lchown16(char *path, \ l_uid16_t uid, l_gid16_t gid); } 17 AUE_NULL UNIMPL break -18 AUE_NULL UNIMPL stat +18 AUE_NULL MSTD { int linux_stat(char *path, \ + struct linux_stat *up); } 19 AUE_NULL MSTD { int linux_lseek(l_uint fdes, l_off_t off, \ l_int whence); } 20 AUE_NULL MSTD { int linux_getpid(void); } @@ -136,9 +137,8 @@ 72 AUE_NULL MSTD { int linux_sigsuspend(l_int hist0, \ l_int hist1, l_osigset_t mask); } 73 AUE_NULL MSTD { int linux_sigpending(l_osigset_t *mask); } -74 AUE_NULL MNOPROTO { int osethostname(char *hostname, \ - u_int len); } osethostname \ - sethostname_args int +74 AUE_NULL MSTD { int linux_sethostname(char *hostname, \ + u_int len); } 75 AUE_NULL MSTD { int linux_setrlimit(l_uint resource, \ struct l_rlimit *rlim); } 76 AUE_NULL MSTD { int linux_old_getrlimit(l_uint resource, \ @@ -159,7 +159,8 @@ struct l_old_select_argv *ptr); } 83 AUE_NULL MSTD { int linux_symlink(char *path, \ char *to); } -84 AUE_NULL UNIMPL ostat +84 AUE_NULL MSTD { int linux_lstat(char *path, \ + struct ostat *up); } 85 AUE_NULL MSTD { int linux_readlink(char *name, \ char *buf, l_int count); } 86 AUE_NULL UNIMPL linux_uselib @@ -173,7 +174,7 @@ 91 AUE_NULL MNOPROTO { int munmap(caddr_t addr, int len); } 92 AUE_NULL MSTD { int linux_truncate(char *path, \ l_ulong length); } -93 AUE_NULL MNOPROTO { int oftruncate(int fd, long length); } +93 AUE_NULL MSTD { int linux_ftruncate(int fd, long length); } 94 AUE_NULL MNOPROTO { int fchmod(int fd, int mode); } 95 AUE_NULL MNOPROTO { int fchown(int fd, int uid, int gid); } 96 AUE_NULL MSTD { int linux_getpriority(int which, int who); } @@ -428,7 +429,58 @@ 261 AUE_NULL UNIMPL linux_timer_gettime 262 AUE_NULL UNIMPL linux_timer_getoverrun 263 AUE_NULL UNIMPL linux_timer_delete -264 AUE_NULL UNIMPL linux_clock_settime -265 AUE_NULL UNIMPL linux_clock_gettime -266 AUE_NULL UNIMPL linux_clock_getres -267 AUE_NULL UNIMPL linux_clock_nanosleep +264 AUE_NULL MSTD { int linux_clock_settime(clockid_t which, \ + struct l_timespec *tp); } +265 AUE_NULL MSTD { int linux_clock_gettime(clockid_t which, \ + struct l_timespec *tp); } +266 AUE_NULL MSTD { int linux_clock_getres(clockid_t which, \ + struct l_timespec *tp); } +267 AUE_NULL MSTD { int linux_clock_nanosleep(clockid_t which, \ + int flags, struct l_timespec *rqtp, \ + struct l_timespec *rmtp); } +268 AUE_NULL MSTD { int linux_statfs64(char *path, \ + struct l_statfs64_buf *buf); } +269 AUE_NULL MSTD { int linux_fstatfs64(void); } +270 AUE_NULL MSTD { int linux_tgkill(int tgid, int pid, int sig); } +271 AUE_NULL MSTD { int linux_utimes(char *fname, \ + struct l_timeval *tptr); } +272 AUE_NULL MSTD { int linux_fadvise64_64(void); } +273 AUE_NULL UNIMPL +274 AUE_NULL MSTD { int linux_mbind(void); } +275 AUE_NULL MSTD { int linux_get_mempolicy(void); } +276 AUE_NULL MSTD { int linux_set_mempolicy(void); } +277 AUE_NULL MSTD { int linux_mq_open(void); } +278 AUE_NULL MSTD { int linux_mq_unlink(void); } +279 AUE_NULL MSTD { int linux_mq_timedsend(void); } +280 AUE_NULL MSTD { int linux_mq_timedreceive(void); } +281 AUE_NULL MSTD { int linux_mq_notify(void); } +282 AUE_NULL MSTD { int linux_mq_getsetattr(void); } +283 AUE_NULL MSTD { int linux_kexec_load(void); } +284 AUE_NULL MSTD { int linux_waitid(void); } +285 AUE_NULL UNIMPL +286 AUE_NULL MSTD { int linux_add_key(void); } +287 AUE_NULL MSTD { int linux_request_key(void); } +288 AUE_NULL MSTD { int linux_keyctl(void); } +289 AUE_NULL MSTD { int linux_ioprio_set(void); } +290 AUE_NULL MSTD { int linux_ioprio_get(void); } +291 AUE_NULL MSTD { int linux_inotify_init(void); } +292 AUE_NULL MSTD { int linux_inotify_add_watch(void); } +293 AUE_NULL MSTD { int linux_inotify_rm_watch(void); } +294 AUE_NULL MSTD { int linux_migrate_pages(void); } +295 AUE_NULL MSTD { int linux_openat(l_int dfd, char *filename, \ + l_int flags, l_int mode); } +296 AUE_NULL MSTD { int linux_mkdirat(void); } +297 AUE_NULL MSTD { int linux_mknodat(void); } +298 AUE_NULL MSTD { int linux_fchownat(void); } +299 AUE_NULL MSTD { int linux_futimesat(void); } +300 AUE_NULL MSTD { int linux_fstatat64(void); } +301 AUE_NULL MSTD { int linux_unlinkat(void); } +302 AUE_NULL MSTD { int linux_renameat(void); } +303 AUE_NULL MSTD { int linux_linkat(void); } +304 AUE_NULL MSTD { int linux_symlinkat(void); } +305 AUE_NULL MSTD { int linux_readlinkat(void); } +306 AUE_NULL MSTD { int linux_fchmodat(void); } +307 AUE_NULL MSTD { int linux_faccessat(void); } +308 AUE_NULL MSTD { int linux_pselect6(void); } +309 AUE_NULL MSTD { int linux_ppoll(void); } +310 AUE_NULL MSTD { int linux_unshare(void); } Index: sys/compat/linux/linux_file.c =================================================================== RCS file: /import/FreeBSD-CVS/src/sys/compat/linux/linux_file.c,v retrieving revision 1.91.2.3 diff -u -u -r1.91.2.3 linux_file.c --- sys/compat/linux/linux_file.c 8 Jul 2007 09:04:43 -0000 1.91.2.3 +++ sys/compat/linux/linux_file.c 22 Jul 2007 11:12:26 -0000 @@ -683,6 +683,21 @@ } int +linux_ftruncate(struct thread *td, struct linux_ftruncate_args *args) +{ + struct ftruncate_args /* { + int fd; + int pad; + off_t length; + } */ nuap; + + nuap.fd = args->fd; + nuap.pad = 0; + nuap.length = args->length; + return (ftruncate(td, &nuap)); +} + +int linux_link(struct thread *td, struct linux_link_args *args) { char *path, *to; Index: sys/compat/linux/linux_ioctl.c =================================================================== RCS file: /import/FreeBSD-CVS/src/sys/compat/linux/linux_ioctl.c,v retrieving revision 1.127.2.4 diff -u -u -r1.127.2.4 linux_ioctl.c --- sys/compat/linux/linux_ioctl.c 10 Apr 2007 21:44:17 -0000 1.127.2.4 +++ sys/compat/linux/linux_ioctl.c 22 Jul 2007 11:12:26 -0000 @@ -2281,6 +2281,29 @@ return (ENOENT); } + + /* +* If we fault in bsd_to_linux_ifreq() then we will fault when we call +* the native ioctl(). Thus, we don't really need to check the return +* value of this function. +*/ +static int +bsd_to_linux_ifreq(struct ifreq *arg) +{ + struct ifreq ifr; + size_t ifr_len = sizeof(struct ifreq); + int error; + + if ((error = copyin(arg, &ifr, ifr_len))) + return (error); + + *(u_short *)&ifr.ifr_addr = ifr.ifr_addr.sa_family; + + error = copyout(&ifr, arg, ifr_len); + + return (error); +} + /* * Socket related ioctls */ @@ -2412,8 +2435,9 @@ break; case LINUX_SIOCGIFADDR: - args->cmd = OSIOCGIFADDR; + args->cmd = SIOCGIFADDR; error = ioctl(td, (struct ioctl_args *)args); + bsd_to_linux_ifreq((struct ifreq *)args->arg); break; case LINUX_SIOCSIFADDR: @@ -2423,18 +2447,21 @@ break; case LINUX_SIOCGIFDSTADDR: - args->cmd = OSIOCGIFDSTADDR; + args->cmd = SIOCGIFDSTADDR; error = ioctl(td, (struct ioctl_args *)args); + bsd_to_linux_ifreq((struct ifreq *)args->arg); break; case LINUX_SIOCGIFBRDADDR: - args->cmd = OSIOCGIFBRDADDR; + args->cmd = SIOCGIFBRDADDR; error = ioctl(td, (struct ioctl_args *)args); + bsd_to_linux_ifreq((struct ifreq *)args->arg); break; case LINUX_SIOCGIFNETMASK: - args->cmd = OSIOCGIFNETMASK; + args->cmd = SIOCGIFNETMASK; error = ioctl(td, (struct ioctl_args *)args); + bsd_to_linux_ifreq((struct ifreq *)args->arg); break; case LINUX_SIOCSIFNETMASK: Index: sys/compat/linux/linux_misc.c =================================================================== RCS file: /import/FreeBSD-CVS/src/sys/compat/linux/linux_misc.c,v retrieving revision 1.170.2.6 diff -u -u -r1.170.2.6 linux_misc.c --- sys/compat/linux/linux_misc.c 8 Jul 2007 12:20:35 -0000 1.170.2.6 +++ sys/compat/linux/linux_misc.c 22 Jul 2007 11:12:26 -0000 @@ -797,6 +797,38 @@ LFREEPATH(fname); return (error); } + +int +linux_utimes(struct thread *td, struct linux_utimes_args *args) +{ + l_timeval ltv[2]; + struct timeval tv[2], *tvp = NULL; + char *fname; + int error; + + 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); + return (error); + } + tv[0].tv_sec = ltv[0].tv_sec; + tv[0].tv_usec = ltv[0].tv_usec; + tv[1].tv_sec = ltv[1].tv_sec; + tv[1].tv_usec = ltv[1].tv_usec; + tvp = tv; + } + + error = kern_utimes(td, fname, UIO_SYSSPACE, tvp, UIO_SYSSPACE); + LFREEPATH(fname); + return (error); +} #endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */ #define __WCLONE 0x80000000 @@ -1468,3 +1500,20 @@ td->td_retval[0] = 20 - td->td_retval[0]; return error; } + +int +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, + args->len, 0, 0)); +} + Index: sys/compat/linux/linux_stats.c =================================================================== RCS file: /import/FreeBSD-CVS/src/sys/compat/linux/linux_stats.c,v retrieving revision 1.72.2.4 diff -u -u -r1.72.2.4 linux_stats.c --- sys/compat/linux/linux_stats.c 8 Jul 2007 09:04:43 -0000 1.72.2.4 +++ sys/compat/linux/linux_stats.c 22 Jul 2007 11:12:26 -0000 @@ -238,6 +238,67 @@ return (error); } +static int +stat_copyout(struct stat *buf, void *ubuf) +{ + struct l_stat lbuf; + + bzero(&lbuf, sizeof(lbuf)); + lbuf.st_dev = buf->st_dev; + lbuf.st_ino = buf->st_ino; + lbuf.st_mode = buf->st_mode; + lbuf.st_nlink = buf->st_nlink; + lbuf.st_uid = buf->st_uid; + lbuf.st_gid = buf->st_gid; + lbuf.st_rdev = buf->st_rdev; + if (buf->st_size < (quad_t)1 << 32) + lbuf.st_size = buf->st_size; + else + lbuf.st_size = -2; + lbuf.st_atime = buf->st_atime; + lbuf.st_mtime = buf->st_mtime; + lbuf.st_ctime = buf->st_ctime; + lbuf.st_blksize = buf->st_blksize; + lbuf.st_blocks = buf->st_blocks; + lbuf.st_flags = buf->st_flags; + lbuf.st_gen = buf->st_gen; + + return (copyout(&lbuf, ubuf, sizeof(lbuf))); +} + +int +linux_stat(struct thread *td, struct linux_stat_args *args) +{ + struct stat buf; + int error; +#ifdef DEBUG + if (ldebug(stat)) + printf(ARGS(stat, "%s, *"), args->path); +#endif + error = kern_stat(td, args->path, UIO_SYSSPACE, &buf); + if (error) + return (error); + translate_path_major_minor(td, args->path, &buf); + return(stat_copyout(&buf, args->up)); +} + +int +linux_lstat(struct thread *td, struct linux_lstat_args *args) +{ + struct stat buf; + int error; + +#ifdef DEBUG + if (ldebug(lstat)) + printf(ARGS(lstat, "%s, *"), args->path); +#endif + error = kern_lstat(td, args->path, UIO_SYSSPACE, &buf); + if (error) + return (error); + translate_path_major_minor(td, args->path, &buf); + return(stat_copyout(&buf, args->up)); +} + /* XXX - All fields of type l_int are defined as l_long on i386 */ struct l_statfs { l_int f_type; @@ -252,6 +313,19 @@ l_int f_spare[6]; }; +struct l_statfs64 { + l_int f_type; + l_int f_bsize; + uint64_t f_blocks; + uint64_t f_bfree; + uint64_t f_bavail; + uint64_t f_files; + uint64_t f_ffree; + l_fsid_t f_fsid; + l_int f_namelen; + l_int f_spare[6]; +}; + #define LINUX_CODA_SUPER_MAGIC 0x73757245L #define LINUX_EXT2_SUPER_MAGIC 0xEF53L #define LINUX_HPFS_SUPER_MAGIC 0xf995e849L @@ -262,7 +336,7 @@ #define LINUX_NTFS_SUPER_MAGIC 0x5346544EL #define LINUX_PROC_SUPER_MAGIC 0x9fa0L #define LINUX_UFS_SUPER_MAGIC 0x00011954L /* XXX - UFS_MAGIC in Linux */ -#define LINUX_DEVFS_SUPER_MAGIC 0x1373L +#define LINUX_DEVFS_SUPER_MAGIC 0x1373L static long bsd_to_linux_ftype(const char *fstypename) @@ -327,6 +401,44 @@ return copyout(&linux_statfs, args->buf, sizeof(linux_statfs)); } +static void +bsd_to_linux_statfs64(struct statfs *bsd_statfs, struct l_statfs64 *linux_statfs) +{ + + linux_statfs->f_type = bsd_to_linux_ftype(bsd_statfs->f_fstypename); + linux_statfs->f_bsize = bsd_statfs->f_bsize; + linux_statfs->f_blocks = bsd_statfs->f_blocks; + linux_statfs->f_bfree = bsd_statfs->f_bfree; + linux_statfs->f_bavail = bsd_statfs->f_bavail; + linux_statfs->f_ffree = bsd_statfs->f_ffree; + linux_statfs->f_files = bsd_statfs->f_files; + linux_statfs->f_fsid.val[0] = bsd_statfs->f_fsid.val[0]; + linux_statfs->f_fsid.val[1] = bsd_statfs->f_fsid.val[1]; + linux_statfs->f_namelen = MAXNAMLEN; +} + +int +linux_statfs64(struct thread *td, struct linux_statfs64_args *args) +{ + struct l_statfs64 linux_statfs; + struct statfs bsd_statfs; + char *path; + int error; + + LCONVPATHEXIST(td, args->path, &path); + +#ifdef DEBUG + if (ldebug(statfs64)) + printf(ARGS(statfs64, "%s, *"), path); +#endif + error = kern_statfs(td, path, UIO_SYSSPACE, &bsd_statfs); + LFREEPATH(path); + if (error) + return (error); + bsd_to_linux_statfs64(&bsd_statfs, &linux_statfs); + return copyout(&linux_statfs, args->buf, sizeof(linux_statfs)); +} + int linux_fstatfs(struct thread *td, struct linux_fstatfs_args *args) { Index: sys/compat/linux/linux_time.c =================================================================== RCS file: sys/compat/linux/linux_time.c diff -N sys/compat/linux/linux_time.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sys/compat/linux/linux_time.c 22 Jul 2007 11:12:26 -0000 @@ -0,0 +1,246 @@ +/* $NetBSD: linux_time.c,v 1.14 2006/05/14 03:40:54 christos Exp $ */ + +/*- + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Emmanuel Dreyfus. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); +#if 0 +__KERNEL_RCSID(0, "$NetBSD: linux_time.c,v 1.14 2006/05/14 03:40:54 christos Exp $"); +#endif + +#include "opt_compat.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef COMPAT_LINUX32 +#include +#include +#else +#include +#include +#endif + +static void native_to_linux_timespec(struct l_timespec *, + struct timespec *); +static int linux_to_native_timespec(struct timespec *, + struct l_timespec *); +static int linux_to_native_clockid(clockid_t *, clockid_t); + +static void +native_to_linux_timespec(struct l_timespec *ltp, struct timespec *ntp) +{ + ltp->tv_sec = ntp->tv_sec; + ltp->tv_nsec = ntp->tv_nsec; +} + +static int +linux_to_native_timespec(struct timespec *ntp, struct l_timespec *ltp) +{ + if (ltp->tv_sec < 0 || ltp->tv_nsec > (l_long)999999999L) + return (EINVAL); + ntp->tv_sec = ltp->tv_sec; + ntp->tv_nsec = ltp->tv_nsec; + + return (0); +} + +static int +linux_to_native_clockid(clockid_t *n, clockid_t l) +{ + switch (l) { + case LINUX_CLOCK_REALTIME: + *n = CLOCK_REALTIME; + break; + case LINUX_CLOCK_MONOTONIC: + *n = CLOCK_MONOTONIC; + break; + case LINUX_CLOCK_PROCESS_CPUTIME_ID: + case LINUX_CLOCK_THREAD_CPUTIME_ID: + case LINUX_CLOCK_REALTIME_HR: + case LINUX_CLOCK_MONOTONIC_HR: + default: + return (EINVAL); + break; + } + + return (0); +} + +int +linux_clock_gettime(struct thread *td, struct linux_clock_gettime_args *args) +{ + struct l_timespec lts; + int error; + clockid_t nwhich = 0; /* XXX: GCC */ + struct timespec tp; + + error = linux_to_native_clockid(&nwhich, args->which); + if (error != 0) + return (error); + error = kern_clock_gettime(td, nwhich, &tp); + if (error != 0) + return (error); + native_to_linux_timespec(<s, &tp); + + return (copyout(<s, args->tp, sizeof lts)); +} + +int +linux_clock_settime(struct thread *td, struct linux_clock_settime_args *args) +{ + struct timespec ts; + struct l_timespec lts; + int error; + clockid_t nwhich = 0; /* XXX: GCC */ + + error = linux_to_native_clockid(&nwhich, args->which); + if (error != 0) + return (error); + error = copyin(args->tp, <s, sizeof lts); + if (error != 0) + return (error); + error = linux_to_native_timespec(&ts, <s); + if (error != 0) + return (error); + + return (kern_clock_settime(td, nwhich, &ts)); +} + +int +linux_clock_getres(struct thread *td, struct linux_clock_getres_args *args) +{ + struct timespec ts; + struct l_timespec lts; + int error; + clockid_t nwhich = 0; /* XXX: GCC */ + + if (args->tp == NULL) + return (0); + + error = linux_to_native_clockid(&nwhich, args->which); + if (error != 0) + return (error); + error = kern_clock_getres(td, nwhich, &ts); + if (error != 0) + return (error); + native_to_linux_timespec(<s, &ts); + + return (copyout(<s, args->tp, sizeof lts)); +} + +int +linux_nanosleep(struct thread *td, struct linux_nanosleep_args *args) +{ + struct timespec *rmtp; + struct l_timespec lrqts, lrmts; + struct timespec rqts, rmts; + int error; + + error = copyin(args->rqtp, &lrqts, sizeof lrqts); + if (error != 0) + return (error); + + if (args->rmtp != NULL) + rmtp = &rmts; + else + rmtp = NULL; + + error = linux_to_native_timespec(&rqts, &lrqts); + if (error != 0) + return (error); + error = kern_nanosleep(td, &rqts, rmtp); + if (error != 0) + return (error); + + if (args->rmtp != NULL) { + native_to_linux_timespec(&lrmts, rmtp); + error = copyout(&lrmts, args->rmtp, sizeof(lrmts)); + if (error != 0) + return (error); + } + + return (0); +} + +int +linux_clock_nanosleep(struct thread *td, struct linux_clock_nanosleep_args *args) +{ + struct timespec *rmtp; + struct l_timespec lrqts, lrmts; + struct timespec rqts, rmts; + int error; + + if (args->flags != 0) + return (EINVAL); /* XXX deal with TIMER_ABSTIME */ + + if (args->which != LINUX_CLOCK_REALTIME) + return (EINVAL); + + error = copyin(args->rqtp, &lrqts, sizeof lrqts); + if (error != 0) + return (error); + + if (args->rmtp != NULL) + rmtp = &rmts; + else + rmtp = NULL; + + error = linux_to_native_timespec(&rqts, &lrqts); + if (error != 0) + return (error); + error = kern_nanosleep(td, &rqts, rmtp); + if (error != 0) + return (error); + + if (args->rmtp != NULL) { + native_to_linux_timespec(&lrmts, rmtp); + error = copyout(&lrmts, args->rmtp, sizeof lrmts ); + if (error != 0) + return (error); + } + + return (0); +} Index: sys/conf/files.amd64 =================================================================== RCS file: /import/FreeBSD-CVS/src/sys/conf/files.amd64,v retrieving revision 1.71.2.13 diff -u -u -r1.71.2.13 files.amd64 --- sys/conf/files.amd64 6 Jun 2007 15:59:29 -0000 1.71.2.13 +++ sys/conf/files.amd64 22 Jul 2007 11:12:26 -0000 @@ -246,6 +246,7 @@ compat/linux/linux_socket.c optional compat_linux32 compat/linux/linux_stats.c optional compat_linux32 compat/linux/linux_sysctl.c optional compat_linux32 +compat/linux/linux_time.c optional compat_linux32 compat/linux/linux_uid16.c optional compat_linux32 compat/linux/linux_util.c optional compat_linux32 # Index: sys/conf/files.i386 =================================================================== RCS file: /import/FreeBSD-CVS/src/sys/conf/files.i386,v retrieving revision 1.538.2.13 diff -u -u -r1.538.2.13 files.i386 --- sys/conf/files.i386 31 Mar 2007 20:21:14 -0000 1.538.2.13 +++ sys/conf/files.i386 22 Jul 2007 11:12:26 -0000 @@ -93,6 +93,7 @@ compat/linux/linux_socket.c optional compat_linux compat/linux/linux_stats.c optional compat_linux compat/linux/linux_sysctl.c optional compat_linux +compat/linux/linux_time.c optional compat_linux compat/linux/linux_uid16.c optional compat_linux compat/linux/linux_util.c optional compat_linux compat/ndis/kern_ndis.c optional ndisapi pci Index: sys/conf/files.pc98 =================================================================== RCS file: /import/FreeBSD-CVS/src/sys/conf/files.pc98,v retrieving revision 1.327.2.7 diff -u -u -r1.327.2.7 files.pc98 --- sys/conf/files.pc98 4 Apr 2007 15:51:09 -0000 1.327.2.7 +++ sys/conf/files.pc98 22 Jul 2007 11:12:26 -0000 @@ -63,6 +63,7 @@ compat/linux/linux_socket.c optional compat_linux compat/linux/linux_stats.c optional compat_linux compat/linux/linux_sysctl.c optional compat_linux +compat/linux/linux_time.c optional compat_linux compat/linux/linux_uid16.c optional compat_linux compat/linux/linux_util.c optional compat_linux compat/pecoff/imgact_pecoff.c optional pecoff_support Index: sys/i386/linux/linux_dummy.c =================================================================== RCS file: /import/FreeBSD-CVS/src/sys/i386/linux/linux_dummy.c,v retrieving revision 1.38 diff -u -u -r1.38 linux_dummy.c --- sys/i386/linux/linux_dummy.c 28 Mar 2004 21:43:27 -0000 1.38 +++ sys/i386/linux/linux_dummy.c 22 Jul 2007 11:12:26 -0000 @@ -37,7 +37,6 @@ #include #include -DUMMY(stat); DUMMY(stime); DUMMY(fstat); DUMMY(olduname); @@ -70,6 +69,56 @@ DUMMY(pivot_root); DUMMY(mincore); DUMMY(fadvise64); +DUMMY(set_tid_address); +DUMMY(lookup_dcookie); +DUMMY(epoll_create); +DUMMY(epoll_ctl); +DUMMY(epoll_wait); +DUMMY(remap_file_pages); +DUMMY(fstatfs64); +DUMMY(tgkill); +DUMMY(fadvise64_64); +DUMMY(mbind); +DUMMY(get_mempolicy); +DUMMY(set_mempolicy); +DUMMY(kexec_load); +DUMMY(waitid); +DUMMY(add_key); +DUMMY(request_key); +DUMMY(keyctl); +DUMMY(ioprio_set); +DUMMY(ioprio_get); +DUMMY(inotify_init); +DUMMY(inotify_add_watch); +DUMMY(inotify_rm_watch); +DUMMY(migrate_pages); +DUMMY(openat); +DUMMY(mkdirat); +DUMMY(mknodat); +DUMMY(fchownat); +DUMMY(futimesat); +DUMMY(fstatat64); +DUMMY(unlinkat); +DUMMY(renameat); +DUMMY(linkat); +DUMMY(symlinkat); +DUMMY(readlinkat); +DUMMY(fchmodat); +DUMMY(faccessat); +DUMMY(pselect6); +DUMMY(ppoll); +DUMMY(unshare); +DUMMY(timer_create); +DUMMY(timer_settime); +DUMMY(timer_gettime); +DUMMY(timer_getoverrun); +DUMMY(timer_delete); +DUMMY(mq_open); +DUMMY(mq_unlink); +DUMMY(mq_timedsend); +DUMMY(mq_timedreceive); +DUMMY(mq_notify); +DUMMY(mq_getsetattr); #define DUMMY_XATTR(s) \ int \ Index: sys/i386/linux/syscalls.master =================================================================== RCS file: /import/FreeBSD-CVS/src/sys/i386/linux/syscalls.master,v retrieving revision 1.61.2.2 diff -u -u -r1.61.2.2 syscalls.master --- sys/i386/linux/syscalls.master 8 Jul 2007 12:22:15 -0000 1.61.2.2 +++ sys/i386/linux/syscalls.master 22 Jul 2007 11:12:26 -0000 @@ -68,7 +68,7 @@ l_uid16_t uid, l_gid16_t gid); } 17 AUE_NULL UNIMPL break 18 AUE_NULL MSTD { int linux_stat(char *path, \ - struct ostat *up); } + struct linux_stat *up); } 19 AUE_NULL MSTD { int linux_lseek(l_uint fdes, l_off_t off, \ l_int whence); } 20 AUE_NULL MSTD { int linux_getpid(void); } @@ -83,7 +83,7 @@ l_long addr, l_long data); } 27 AUE_NULL MSTD { int linux_alarm(l_uint secs); } 28 AUE_NULL MSTD { int linux_fstat(l_uint fd, \ - struct ostat *up); } + struct linux_stat *up); } 29 AUE_NULL MSTD { int linux_pause(void); } 30 AUE_NULL MSTD { int linux_utime(char *fname, \ struct l_utimbuf *times); } @@ -139,9 +139,8 @@ 72 AUE_NULL MSTD { int linux_sigsuspend(l_int hist0, \ l_int hist1, l_osigset_t mask); } 73 AUE_NULL MSTD { int linux_sigpending(l_osigset_t *mask); } -74 AUE_NULL MNOPROTO { int osethostname(char *hostname, \ - u_int len); } osethostname \ - sethostname_args int +74 AUE_NULL MSTD { int linux_sethostname(char *hostname, \ + u_int len); } 75 AUE_NULL MSTD { int linux_setrlimit(l_uint resource, \ struct l_rlimit *rlim); } 76 AUE_NULL MSTD { int linux_old_getrlimit(l_uint resource, \ @@ -159,7 +158,8 @@ 82 AUE_NULL MSTD { int linux_old_select( \ struct l_old_select_argv *ptr); } 83 AUE_NULL MSTD { int linux_symlink(char *path, char *to); } -84 AUE_NULL MNOPROTO { int ostat(char *path, struct ostat *up); } +84 AUE_NULL MSTD { int linux_lstat(char *path, \ + struct ostat *up); } 85 AUE_NULL MSTD { int linux_readlink(char *name, char *buf, \ l_int count); } 86 AUE_NULL STD { int linux_uselib(char *library); } @@ -172,7 +172,7 @@ 91 AUE_NULL MNOPROTO { int munmap(caddr_t addr, int len); } 92 AUE_NULL MSTD { int linux_truncate(char *path, \ l_ulong length); } -93 AUE_NULL MNOPROTO { int oftruncate(int fd, long length); } +93 AUE_NULL MSTD { int linux_ftruncate(int fd, long length); } 94 AUE_NULL MNOPROTO { int fchmod(int fd, int mode); } 95 AUE_NULL MNOPROTO { int fchown(int fd, int uid, int gid); } 96 AUE_NULL MSTD { int linux_getpriority(int which, int who); } @@ -280,9 +280,9 @@ l_int policy); } 161 AUE_NULL MNOPROTO { int sched_rr_get_interval(l_pid_t pid, \ struct l_timespec *interval); } -162 AUE_NULL MNOPROTO { int nanosleep( \ - const struct timespec *rqtp, \ - struct timespec *rmtp); } +162 AUE_NULL MSTD { int linux_nanosleep( \ + const struct l_timespec *rqtp, \ + struct l_timespec *rmtp); } 163 AUE_NULL MSTD { int linux_mremap(l_ulong addr, \ l_ulong old_len, l_ulong new_len, \ l_ulong flags, l_ulong new_addr); } @@ -308,8 +308,12 @@ 175 AUE_NULL MSTD { int linux_rt_sigprocmask(l_int how, \ l_sigset_t *mask, l_sigset_t *omask, \ l_size_t sigsetsize); } -176 AUE_NULL MSTD { int linux_rt_sigpending(void); } -177 AUE_NULL MSTD { int linux_rt_sigtimedwait(void); } +176 AUE_NULL MSTD { int linux_rt_sigpending(l_sigset_t *set, \ + l_size_t sigsetsize); } +177 AUE_NULL MSTD { int linux_rt_sigtimedwait(l_sigset_t *mask, \ + l_siginfo_t *ptr, \ + struct l_timeval *timeout, \ + l_size_t sigsetsize); } 178 AUE_NULL MSTD { int linux_rt_sigqueueinfo(void); } 179 AUE_NULL MSTD { int linux_rt_sigsuspend( \ l_sigset_t *newset, \ @@ -414,18 +418,79 @@ 251 AUE_NULL UNIMPL 252 AUE_NULL MNOPROTO { void sys_exit(int rval); } exit_group \ sys_exit_args void -253 AUE_NULL UNIMPL linux_lookup_dcookie -254 AUE_NULL UNIMPL linux_epoll_create -255 AUE_NULL UNIMPL linux_epoll_ctl -256 AUE_NULL UNIMPL linux_epoll_wait -257 AUE_NULL UNIMPL linux_remap_file_pages -258 AUE_NULL UNIMPL linux_set_tid_address -259 AUE_NULL UNIMPL linux_timer_create -260 AUE_NULL UNIMPL linux_timer_settime -261 AUE_NULL UNIMPL linux_timer_gettime -262 AUE_NULL UNIMPL linux_timer_getoverrun -263 AUE_NULL UNIMPL linux_timer_delete -264 AUE_NULL UNIMPL linux_clock_settime -265 AUE_NULL UNIMPL linux_clock_gettime -266 AUE_NULL UNIMPL linux_clock_getres -267 AUE_NULL UNIMPL linux_clock_nanosleep +253 AUE_NULL MSTD { int linux_lookup_dcookie(void); } +254 AUE_NULL MSTD { int linux_epoll_create(void); } +255 AUE_NULL MSTD { int linux_epoll_ctl(void); } +256 AUE_NULL MSTD { int linux_epoll_wait(void); } +257 AUE_NULL MSTD { int linux_remap_file_pages(void); } +258 AUE_NULL MSTD { int linux_set_tid_address(int *tidptr); } +259 AUE_NULL MSTD { int linux_timer_create(clockid_t clock_id, \ + struct sigevent *evp, l_timer_t *timerid); } +260 AUE_NULL MSTD { int linux_timer_settime(l_timer_t timerid, \ + const struct itimerspec *new, \ + struct itimerspec *old); } +261 AUE_NULL MSTD { int linux_timer_gettime(l_timer_t timerid, \ + struct itimerspec *setting); } +262 AUE_NULL MSTD { int linux_timer_getoverrun(l_timer_t timerid); } +263 AUE_NULL MSTD { int linux_timer_delete(l_timer_t timerid); } +264 AUE_NULL MSTD { int linux_clock_settime(clockid_t which, \ + struct l_timespec *tp); } +265 AUE_NULL MSTD { int linux_clock_gettime(clockid_t which, \ + struct l_timespec *tp); } +266 AUE_NULL MSTD { int linux_clock_getres(clockid_t which, \ + struct l_timespec *tp); } +267 AUE_NULL MSTD { int linux_clock_nanosleep(clockid_t which, \ + int flags, struct l_timespec *rqtp, \ + struct l_timespec *rmtp); } +268 AUE_NULL MSTD { int linux_statfs64(char *path, \ + struct l_statfs64_buf *buf); } +269 AUE_NULL MSTD { int linux_fstatfs64(void); } +270 AUE_NULL MSTD { int linux_tgkill(int tgid, int pid, int sig); } +271 AUE_NULL MSTD { int linux_utimes(char *fname, \ + struct l_timeval *tptr); } +272 AUE_NULL MSTD { int linux_fadvise64_64(void); } +273 AUE_NULL UNIMPL +274 AUE_NULL MSTD { int linux_mbind(void); } +275 AUE_NULL MSTD { int linux_get_mempolicy(void); } +276 AUE_NULL MSTD { int linux_set_mempolicy(void); } +277 AUE_NULL MSTD { int linux_mq_open(const char *name, int oflag, mode_t mode, \ + struct mq_attr *attr); } +278 AUE_NULL MSTD { int linux_mq_unlink(const char *name); } +279 AUE_NULL MSTD { int linux_mq_timedsend(l_mqd_t mqd, const char *msg_ptr, \ + size_t msg_len, unsigned int msg_prio, const struct \ + l_timespec *abs_timeout); } +280 AUE_NULL MSTD { int linux_mq_timedreceive(l_mqd_t mqd, char *msg_ptr, \ + size_t msg_len, unsigned int msg_prio, const struct \ + l_timespec *abs_timeout); } +281 AUE_NULL MSTD { int linux_mq_notify(l_mqd_t mqd, const struct l_timespec *abs_timeout); } +282 AUE_NULL MSTD { int linux_mq_getsetattr(l_mqd_t mqd, const struct mq_attr *attr, \ + struct mq_attr *oattr); } +283 AUE_NULL MSTD { int linux_kexec_load(void); } +284 AUE_NULL MSTD { int linux_waitid(void); } +285 AUE_NULL UNIMPL +286 AUE_NULL MSTD { int linux_add_key(void); } +287 AUE_NULL MSTD { int linux_request_key(void); } +288 AUE_NULL MSTD { int linux_keyctl(void); } +289 AUE_NULL MSTD { int linux_ioprio_set(void); } +290 AUE_NULL MSTD { int linux_ioprio_get(void); } +291 AUE_NULL MSTD { int linux_inotify_init(void); } +292 AUE_NULL MSTD { int linux_inotify_add_watch(void); } +293 AUE_NULL MSTD { int linux_inotify_rm_watch(void); } +294 AUE_NULL MSTD { int linux_migrate_pages(void); } +295 AUE_NULL MSTD { int linux_openat(l_int dfd, char *filename, \ + l_int flags, l_int mode); } +296 AUE_NULL MSTD { int linux_mkdirat(void); } +297 AUE_NULL MSTD { int linux_mknodat(void); } +298 AUE_NULL MSTD { int linux_fchownat(void); } +299 AUE_NULL MSTD { int linux_futimesat(void); } +300 AUE_NULL MSTD { int linux_fstatat64(void); } +301 AUE_NULL MSTD { int linux_unlinkat(void); } +302 AUE_NULL MSTD { int linux_renameat(void); } +303 AUE_NULL MSTD { int linux_linkat(void); } +304 AUE_NULL MSTD { int linux_symlinkat(void); } +305 AUE_NULL MSTD { int linux_readlinkat(void); } +306 AUE_NULL MSTD { int linux_fchmodat(void); } +307 AUE_NULL MSTD { int linux_faccessat(void); } +308 AUE_NULL MSTD { int linux_pselect6(void); } +309 AUE_NULL MSTD { int linux_ppoll(void); } +310 AUE_NULL MSTD { int linux_unshare(void); } Index: sys/modules/linux/Makefile =================================================================== RCS file: /import/FreeBSD-CVS/src/sys/modules/linux/Makefile,v retrieving revision 1.63.2.2 diff -u -u -r1.63.2.2 Makefile --- sys/modules/linux/Makefile 15 Jun 2006 15:52:04 -0000 1.63.2.2 +++ sys/modules/linux/Makefile 22 Jul 2007 11:12:26 -0000 @@ -6,7 +6,7 @@ SRCS= linux_dummy.c linux_file.c linux_getcwd.c linux_ioctl.c linux_ipc.c \ linux_machdep.c linux_mib.c linux_misc.c linux_signal.c linux_socket.c \ linux_stats.c linux_sysctl.c linux_sysent.c linux_sysvec.c \ - linux_util.c opt_compat.h opt_inet6.h opt_mac.h \ + linux_time.c linux_util.c opt_compat.h opt_inet6.h opt_mac.h \ opt_vmpage.h vnode_if.h device_if.h bus_if.h OBJS= linux_locore.o