This patch makes COMPAT_LINUX independant of COMPAT_43. How to apply: cd /usr/src/sys/emulation/linux patch < /path/to/patch Index: Makefile =================================================================== RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/Makefile,v retrieving revision 1.3 diff -u -r1.3 Makefile --- Makefile 15 Aug 2003 06:32:51 -0000 1.3 +++ Makefile 20 Aug 2003 01:00:01 -0000 @@ -10,7 +10,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_linux.h opt_vmpage.h vnode_if.h + linux_util.c opt_linux.h opt_vmpage.h vnode_if.h OBJS= linux_locore.o MAN= linux.8 @@ -33,9 +33,6 @@ linux_genassym.o: linux_genassym.c linux.h @ machine ${CC} -c ${CFLAGS} ${.IMPSRC} - -opt_compat.h: - echo "#define COMPAT_43 1" > opt_compat.h afterinstall: ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ Index: linux_file.c =================================================================== RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/linux_file.c,v retrieving revision 1.9 diff -u -r1.9 linux_file.c --- linux_file.c 15 Aug 2003 06:32:51 -0000 1.9 +++ linux_file.c 18 Aug 2003 23:52:18 -0000 @@ -29,8 +29,6 @@ * $DragonFly: src/sys/emulation/linux/linux_file.c,v 1.9 2003/08/15 06:32:51 dillon Exp $ */ -#include "opt_compat.h" - #include #include #include @@ -696,6 +694,21 @@ error = truncate(&bsd); args->sysmsg_result = bsd.sysmsg_result; return(error); +} + +int +linux_ftruncate(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(&nuap)); } int Index: linux_getcwd.c =================================================================== RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/linux_getcwd.c,v retrieving revision 1.10 diff -u -r1.10 linux_getcwd.c --- linux_getcwd.c 15 Aug 2003 06:32:51 -0000 1.10 +++ linux_getcwd.c 18 Aug 2003 23:52:18 -0000 @@ -38,7 +38,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include "opt_compat.h" #include #include Index: linux_ioctl.c =================================================================== RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/linux_ioctl.c,v retrieving revision 1.9 diff -u -r1.9 linux_ioctl.c --- linux_ioctl.c 15 Aug 2003 06:32:51 -0000 1.9 +++ linux_ioctl.c 21 Aug 2003 22:17:13 -0000 @@ -1567,6 +1567,29 @@ } /* + * 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 */ @@ -1703,8 +1726,9 @@ break; case LINUX_SIOCGIFADDR: - args->cmd = OSIOCGIFADDR; + args->cmd = SIOCGIFADDR; error = ioctl((struct ioctl_args *)args); + bsd_to_linux_ifreq((struct ifreq *)args->arg); break; case LINUX_SIOCSIFADDR: @@ -1714,18 +1738,21 @@ break; case LINUX_SIOCGIFDSTADDR: - args->cmd = OSIOCGIFDSTADDR; + args->cmd = SIOCGIFDSTADDR; error = ioctl((struct ioctl_args *)args); + bsd_to_linux_ifreq((struct ifreq *)args->arg); break; case LINUX_SIOCGIFBRDADDR: - args->cmd = OSIOCGIFBRDADDR; + args->cmd = SIOCGIFBRDADDR; error = ioctl((struct ioctl_args *)args); + bsd_to_linux_ifreq((struct ifreq *)args->arg); break; case LINUX_SIOCGIFNETMASK: - args->cmd = OSIOCGIFNETMASK; + args->cmd = SIOCGIFNETMASK; error = ioctl((struct ioctl_args *)args); + bsd_to_linux_ifreq((struct ifreq *)args->arg); break; case LINUX_SIOCSIFNETMASK: Index: linux_misc.c =================================================================== RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/linux_misc.c,v retrieving revision 1.13 diff -u -r1.13 linux_misc.c --- linux_misc.c 15 Aug 2003 06:32:51 -0000 1.13 +++ linux_misc.c 18 Aug 2003 23:52:19 -0000 @@ -29,8 +29,6 @@ * $DragonFly: src/sys/emulation/linux/linux_misc.c,v 1.13 2003/08/15 06:32:51 dillon Exp $ */ -#include "opt_compat.h" - #include #include #include @@ -1416,3 +1414,19 @@ return(error); } +int +linux_sethostname(struct linux_sethostname_args *args) +{ + struct thread *td = curthread; + struct proc *p = td->td_proc; + int name[2]; + int error; + + KKASSERT(p); + name[0] = CTL_KERN; + name[1] = KERN_HOSTNAME; + if ((error = suser_cred(p->p_ucred, PRISON_ROOT))) + return (error); + return (userland_sysctl(name, 2, 0, 0, 0, args->hostname, + args->len, 0)); +} Index: linux_socket.c =================================================================== RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/linux_socket.c,v retrieving revision 1.8 diff -u -r1.8 linux_socket.c --- linux_socket.c 15 Aug 2003 06:32:51 -0000 1.8 +++ linux_socket.c 22 Aug 2003 01:47:09 -0000 @@ -29,13 +29,6 @@ * $DragonFly: src/sys/emulation/linux/linux_socket.c,v 1.8 2003/08/15 06:32:51 dillon Exp $ */ -/* XXX we use functions that might not exist. */ -#include "opt_compat.h" - -#ifndef COMPAT_43 -#error "Unable to compile Linux-emulator due to missing COMPAT_43 option!" -#endif - #include #include #include @@ -207,6 +200,47 @@ return ret_flags; } +/* + * If bsd_to_linux_sockaddr() or linux_to_bsd_sockaddr() faults, then the + * native syscall will fault. Thus, we don't really need to check the + * return values for these functions. + */ + +static int +bsd_to_linux_sockaddr(struct sockaddr *arg) +{ + struct sockaddr sa; + size_t sa_len = sizeof(struct sockaddr); + int error; + + if ((error = copyin(arg, &sa, sa_len))) + return (error); + + *(u_short *)&sa = sa.sa_family; + + error = copyout(&sa, arg, sa_len); + + return (error); +} + +static int +linux_to_bsd_sockaddr(struct sockaddr *arg, int len) +{ + struct sockaddr sa; + size_t sa_len = sizeof(struct sockaddr); + int error; + + if ((error = copyin(arg, &sa, sa_len))) + return (error); + + sa.sa_family = *(sa_family_t *)&sa; + sa.sa_len = len; + + error = copyout(&sa, arg, sa_len); + + return (error); +} + /* Return 0 if IP_HDRINCL is set for the given socket. */ static int linux_check_hdrincl(int s) @@ -399,7 +433,12 @@ bsd_args.name = (caddr_t)linux_args.name; bsd_args.namelen = linux_to_bsd_namelen(bsd_args.name, linux_args.namelen); + + linux_to_bsd_sockaddr((struct sockaddr *)bsd_args.name, + bsd_args.namelen); error = bind(&bsd_args); + bsd_to_linux_sockaddr((struct sockaddr *)bsd_args.name); + *res = bsd_args.sysmsg_result; return(error); } @@ -441,7 +480,12 @@ bsd_args.name = (caddr_t)linux_args.name; bsd_args.namelen = linux_to_bsd_namelen(bsd_args.name, linux_args.namelen); + + linux_to_bsd_sockaddr((struct sockaddr *)bsd_args.name, + bsd_args.namelen); error = connect(&bsd_args); + bsd_to_linux_sockaddr((struct sockaddr *)bsd_args.name); + *res = bsd_args.sysmsg_result; if (error != EISCONN) return (error); @@ -488,7 +532,9 @@ bsd_args.sysmsg_result = 0; bsd_args.s = linux_args.s; bsd_args.backlog = linux_args.backlog; + error = listen(&bsd_args); + *res = bsd_args.sysmsg_result; return(error); } @@ -522,7 +568,10 @@ bsd_args.s = linux_args.s; bsd_args.name = (caddr_t)linux_args.addr; bsd_args.anamelen = linux_args.namelen; - error = oaccept(&bsd_args); + + error = accept(&bsd_args); + bsd_to_linux_sockaddr((struct sockaddr *)bsd_args.name); + if (error) return (error); @@ -562,7 +611,10 @@ bsd_args.fdes = linux_args.s; bsd_args.asa = (caddr_t) linux_args.addr; bsd_args.alen = linux_args.namelen; - error = ogetsockname(&bsd_args); + + error = getsockname(&bsd_args); + bsd_to_linux_sockaddr((struct sockaddr *)bsd_args.asa); + *res = bsd_args.sysmsg_result; return(error); } @@ -577,7 +629,7 @@ linux_getpeername(struct linux_getpeername_args *args, int *res) { struct linux_getpeername_args linux_args; - struct ogetpeername_args /* { + struct getpeername_args /* { int fdes; caddr_t asa; int *alen; @@ -591,7 +643,10 @@ bsd_args.fdes = linux_args.s; bsd_args.asa = (caddr_t) linux_args.addr; bsd_args.alen = linux_args.namelen; - error = ogetpeername(&bsd_args); + + error = getpeername(&bsd_args); + bsd_to_linux_sockaddr((struct sockaddr *)bsd_args.asa); + *res = bsd_args.sysmsg_result; return(error); } @@ -626,7 +681,9 @@ bsd_args.type = linux_args.type; bsd_args.protocol = linux_args.protocol; bsd_args.rsv = linux_args.rsv; + error = socketpair(&bsd_args); + *res = bsd_args.sysmsg_result; return(error); } @@ -642,11 +699,13 @@ linux_send(struct linux_send_args *args, int *res) { struct linux_send_args linux_args; - struct osend_args /* { + struct sendto_args /* { int s; caddr_t buf; int len; int flags; + caddr_t to; + int tolen; } */ bsd_args; int error; @@ -658,7 +717,11 @@ bsd_args.buf = linux_args.msg; bsd_args.len = linux_args.len; bsd_args.flags = linux_args.flags; - error = osend(&bsd_args); + bsd_args.to = NULL; + bsd_args.tolen = 0; + + error = sendto(&bsd_args); + *res = bsd_args.sysmsg_result; return(error); } @@ -674,11 +737,13 @@ linux_recv(struct linux_recv_args *args, int *res) { struct linux_recv_args linux_args; - struct orecv_args /* { + struct recvfrom_args /* { int s; caddr_t buf; - int len; + size_t len; int flags; + caddr_t from; + int * fromlenaddr; } */ bsd_args; int error; @@ -690,7 +755,11 @@ bsd_args.buf = linux_args.msg; bsd_args.len = linux_args.len; bsd_args.flags = linux_args.flags; - error = orecv(&bsd_args); + bsd_args.from = NULL; + bsd_args.fromlenaddr = 0; + + error = recvfrom(&bsd_args); + *res = bsd_args.sysmsg_result; return(error); } @@ -733,7 +802,11 @@ /* IP_HDRINCL set, tweak the packet before sending */ return (linux_sendto_hdrincl(&bsd_args)); + linux_to_bsd_sockaddr((struct sockaddr *)bsd_args.to, + bsd_args.tolen); error = sendto(&bsd_args); + bsd_to_linux_sockaddr((struct sockaddr *)bsd_args.to); + *res = bsd_args.sysmsg_result; return(error); } @@ -759,11 +832,15 @@ caddr_t from; int *fromlenaddr; } */ bsd_args; + size_t len; int error; if ((error = copyin(args, &linux_args, sizeof(linux_args)))) return (error); + if ((error = copyin(linux_args.fromlen, &len, sizeof(size_t)))) + return (error); + bsd_args.sysmsg_result = 0; bsd_args.s = linux_args.s; bsd_args.buf = linux_args.buf; @@ -771,7 +848,66 @@ bsd_args.flags = linux_to_bsd_msg_flags(linux_args.flags); bsd_args.from = linux_args.from; bsd_args.fromlenaddr = linux_args.fromlen; - error = orecvfrom(&bsd_args); + + linux_to_bsd_sockaddr((struct sockaddr *)bsd_args.from, len); + error = recvfrom(&bsd_args); + bsd_to_linux_sockaddr((struct sockaddr *)bsd_args.from); + + *res = bsd_args.sysmsg_result; + return(error); +} + +struct linux_sendmsg_args { + int s; + caddr_t msg; + int flags; +}; + +static int +linux_sendmsg(struct linux_sendmsg_args *args, int *res) +{ + struct msghdr msg; + struct cmsghdr control; + struct linux_sendmsg_args linux_args; + struct sendmsg_args /* { + int s; + caddr_t msg; + int flags; + } */ bsd_args; + int error; + + if ((error = copyin(args, &linux_args, sizeof(linux_args)))) + return (error); + + if ((error = copyin(linux_args.msg, &msg, sizeof(msg)))) + return (error); + + if (msg.msg_control) { + if ((error = copyin(msg.msg_control, &control, + sizeof(control)))); + return (error); + + control.cmsg_level + = linux_to_bsd_sockopt_level(control.cmsg_level); + + if ((error = copyout(&control, msg.msg_control, + sizeof(control)))) + return (error); + } + + bsd_args.sysmsg_result = 0; + bsd_args.s = linux_args.s; + bsd_args.msg = linux_args.msg; + bsd_args.flags = linux_to_bsd_msg_flags(linux_args.flags); + + if (msg.msg_name) { + linux_to_bsd_sockaddr((struct sockaddr *)msg.msg_name, + msg.msg_namelen); + error = sendmsg(&bsd_args); + bsd_to_linux_sockaddr((struct sockaddr *)msg.msg_name); + } else + error = sendmsg(&bsd_args); + *res = bsd_args.sysmsg_result; return(error); } @@ -785,6 +921,7 @@ static int linux_recvmsg(struct linux_recvmsg_args *args, int *res) { + struct msghdr msg; struct linux_recvmsg_args linux_args; struct recvmsg_args /* { int s; @@ -796,11 +933,22 @@ if ((error = copyin(args, &linux_args, sizeof(linux_args)))) return (error); + if ((error = copyin(linux_args.msg, &msg, sizeof(msg)))) + return error; + bsd_args.sysmsg_result = 0; bsd_args.s = linux_args.s; bsd_args.msg = linux_args.msg; bsd_args.flags = linux_to_bsd_msg_flags(linux_args.flags); - error = recvmsg(&bsd_args); + + if (msg.msg_name) { + linux_to_bsd_sockaddr((struct sockaddr *)msg.msg_name, + msg.msg_namelen); + error = recvmsg(&bsd_args); + bsd_to_linux_sockaddr((struct sockaddr *)msg.msg_name); + } else + error = recvmsg(&bsd_args); + *res = bsd_args.sysmsg_result; return(error); } @@ -826,7 +974,9 @@ bsd_args.sysmsg_result = 0; bsd_args.s = linux_args.s; bsd_args.how = linux_args.how; + error = shutdown(&bsd_args); + *res = bsd_args.sysmsg_result; return(error); } @@ -879,7 +1029,15 @@ bsd_args.name = name; bsd_args.val = linux_args.optval; bsd_args.valsize = linux_args.optlen; - error = setsockopt(&bsd_args); + + if (name == IPV6_NEXTHOP) { + linux_to_bsd_sockaddr((struct sockaddr *)bsd_args.val, + bsd_args.valsize); + error = setsockopt(&bsd_args); + bsd_to_linux_sockaddr((struct sockaddr *)bsd_args.val); + } else + error = setsockopt(&bsd_args); + *res = bsd_args.sysmsg_result; return(error); } @@ -932,7 +1090,13 @@ bsd_args.name = name; bsd_args.val = linux_args.optval; bsd_args.avalsize = linux_args.optlen; - error = getsockopt(&bsd_args); + + if (name == IPV6_NEXTHOP) { + error = getsockopt(&bsd_args); + bsd_to_linux_sockaddr((struct sockaddr *)bsd_args.val); + } else + error = getsockopt(&bsd_args); + *res = bsd_args.sysmsg_result; return(error); } @@ -974,46 +1138,7 @@ case LINUX_GETSOCKOPT: return (linux_getsockopt(arg, &args->sysmsg_result)); case LINUX_SENDMSG: - do { - int error; - int level; - caddr_t control; - struct sendmsg_args bsd_args; - - error = copyin(arg, &bsd_args.s, sizeof(bsd_args) - offsetof(struct sendmsg_args, s)); - if (error) - return (error); - error = copyin(&((struct msghdr *)bsd_args.msg)->msg_control, &control, - sizeof(caddr_t)); - if (error) - return (error); - - if (control == NULL) - goto done; - - error = copyin(&((struct cmsghdr*)control)->cmsg_level, - &level, sizeof(int)); - if (error) - return (error); - - if (level == 1) { - /* - * Linux thinks that SOL_SOCKET is 1; we know - * that it's really 0xffff, of course. - */ - level = SOL_SOCKET; - error = copyout(&level, - &((struct cmsghdr *)control)->cmsg_level, - sizeof(int)); - if (error) - return (error); - } - done: - bsd_args.sysmsg_result = 0; - error = sendmsg(&bsd_args); - args->sysmsg_result = bsd_args.sysmsg_result; - return(error); - } while (0); + return (linux_sendmsg(arg, &args->sysmsg_result)); case LINUX_RECVMSG: return (linux_recvmsg(arg, &args->sysmsg_result)); } Index: linux_stats.c =================================================================== RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/linux_stats.c,v retrieving revision 1.7 diff -u -r1.7 linux_stats.c --- linux_stats.c 15 Aug 2003 06:32:51 -0000 1.7 +++ linux_stats.c 22 Aug 2003 02:01:57 -0000 @@ -50,6 +50,30 @@ #include "linux_util.h" static int +getstat(struct stat *buf, char *path, u_long follow) +{ + struct thread *td = curthread; + struct nameidata nd; + int error; + caddr_t sg; + + sg = stackgap_init(); + CHECKALTEXIST(&sg, path); + + NDINIT(&nd, LOOKUP, follow | LOCKLEAF | NOOBJ, UIO_USERSPACE, + path, td); + error = namei(&nd); + if (error) + return (error); + NDFREE(&nd, NDF_ONLY_PNBUF); + + error = vn_stat(nd.ni_vp, buf, td); + vput(nd.ni_vp); + + return (error); +} + +static int newstat_copyout(struct stat *buf, void *ubuf) { struct l_newstat tbuf; @@ -91,65 +115,35 @@ int linux_newstat(struct linux_newstat_args *args) { - struct thread *td = curthread; struct stat buf; - struct nameidata nd; int error; - caddr_t sg; - - sg = stackgap_init(); - CHECKALTEXIST(&sg, args->path); #ifdef DEBUG if (ldebug(newstat)) printf(ARGS(newstat, "%s, *"), args->path); #endif - NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - args->path, td); - error = namei(&nd); + error = getstat(&buf, args->path, FOLLOW); if (error) return (error); - NDFREE(&nd, NDF_ONLY_PNBUF); - - error = vn_stat(nd.ni_vp, &buf, td); - vput(nd.ni_vp); - if (error) - return (error); - return (newstat_copyout(&buf, args->buf)); } int linux_newlstat(struct linux_newlstat_args *args) { - struct thread *td = curthread; + struct stat buf; int error; - struct stat sb; - struct nameidata nd; - caddr_t sg; - - sg = stackgap_init(); - CHECKALTEXIST(&sg, args->path); #ifdef DEBUG if (ldebug(newlstat)) printf(ARGS(newlstat, "%s, *"), args->path); #endif - NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - args->path, td); - error = namei(&nd); - if (error) - return (error); - NDFREE(&nd, NDF_ONLY_PNBUF); - - error = vn_stat(nd.ni_vp, &sb, td); - vput(nd.ni_vp); + error = getstat(&buf, args->path, NOFOLLOW); if (error) return (error); - - return (newstat_copyout(&sb, args->buf)); + return (newstat_copyout(&buf, args->buf)); } int @@ -368,6 +362,67 @@ return (copyout(&lu, args->ubuf, sizeof(lu))); } +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 linux_stat_args *args) +{ + struct stat buf; + int error; + +#ifdef DEBUG + if (ldebug(stat)) + printf(ARGS(stat, "%s, *"), args->path); +#endif + + error = getstat(&buf, args->path, FOLLOW); + if (error) + return (error); + return(stat_copyout(&buf, args->up)); +} + +int +linux_lstat(struct linux_lstat_args *args) +{ + struct stat buf; + int error; + +#ifdef DEBUG + if (ldebug(lstat)) + printf(ARGS(lstat, "%s, *"), args->path); +#endif + + error = getstat(&buf, args->path, NOFOLLOW); + if (error) + return (error); + return(stat_copyout(&buf, args->up)); +} + #if defined(__i386__) static int @@ -404,65 +459,35 @@ int linux_stat64(struct linux_stat64_args *args) { - struct thread *td = curthread; struct stat buf; - struct nameidata nd; int error; - caddr_t sg; - - sg = stackgap_init(); - CHECKALTEXIST(&sg, args->filename); #ifdef DEBUG if (ldebug(stat64)) printf(ARGS(stat64, "%s, *"), args->filename); #endif - NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - args->filename, td); - error = namei(&nd); - if (error) - return (error); - NDFREE(&nd, NDF_ONLY_PNBUF); - - error = vn_stat(nd.ni_vp, &buf, td); - vput(nd.ni_vp); + error = getstat(&buf, args->filename, FOLLOW); if (error) return (error); - return (stat64_copyout(&buf, args->statbuf)); } int linux_lstat64(struct linux_lstat64_args *args) { - struct thread *td = curthread; + struct stat buf; int error; - struct stat sb; - struct nameidata nd; - caddr_t sg; - - sg = stackgap_init(); - CHECKALTEXIST(&sg, args->filename); #ifdef DEBUG if (ldebug(lstat64)) printf(ARGS(lstat64, "%s, *"), args->filename); #endif - NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, - args->filename, td); - error = namei(&nd); + error = getstat(&buf, args->filename, NOFOLLOW); if (error) return (error); - NDFREE(&nd, NDF_ONLY_PNBUF); - - error = vn_stat(nd.ni_vp, &sb, td); - vput(nd.ni_vp); - if (error) - return (error); - - return (stat64_copyout(&sb, args->statbuf)); + return (stat64_copyout(&buf, args->statbuf)); } int Index: linux_sysctl.c =================================================================== RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/linux_sysctl.c,v retrieving revision 1.5 diff -u -r1.5 linux_sysctl.c --- linux_sysctl.c 15 Aug 2003 06:32:51 -0000 1.5 +++ linux_sysctl.c 18 Aug 2003 23:52:19 -0000 @@ -29,8 +29,6 @@ * $DragonFly: src/sys/emulation/linux/linux_sysctl.c,v 1.5 2003/08/15 06:32:51 dillon Exp $ */ -#include "opt_compat.h" - #include #include #include Index: linux_uid16.c =================================================================== RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/linux_uid16.c,v retrieving revision 1.8 diff -u -r1.8 linux_uid16.c --- linux_uid16.c 15 Aug 2003 06:32:51 -0000 1.8 +++ linux_uid16.c 18 Aug 2003 23:52:19 -0000 @@ -27,8 +27,6 @@ * $DragonFly: src/sys/emulation/linux/linux_uid16.c,v 1.8 2003/08/15 06:32:51 dillon Exp $ */ -#include "opt_compat.h" - #include #include #include Index: i386/linux.h =================================================================== RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/i386/linux.h,v retrieving revision 1.5 diff -u -r1.5 linux.h --- i386/linux.h 7 Aug 2003 21:17:18 -0000 1.5 +++ i386/linux.h 18 Aug 2003 08:51:59 -0000 @@ -167,6 +167,24 @@ l_ulong __unused5; }; +struct l_stat { + l_ushort st_dev; + l_ulong st_ino; + l_ushort st_mode; + l_ushort st_nlink; + l_ushort st_uid; + l_ushort st_gid; + l_ushort st_rdev; + l_long st_size; + struct l_timespec st_atimespec; + struct l_timespec st_mtimespec; + struct l_timespec st_ctimespec; + l_long st_blksize; + l_long st_blocks; + l_ulong st_flags; + l_ulong st_gen; +}; + struct l_stat64 { l_ushort st_dev; u_char __pad0[10]; Index: i386/linux_dummy.c =================================================================== RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/i386/linux_dummy.c,v retrieving revision 1.3 diff -u -r1.3 linux_dummy.c --- i386/linux_dummy.c 7 Aug 2003 21:17:18 -0000 1.3 +++ i386/linux_dummy.c 18 Aug 2003 10:57:15 -0000 @@ -37,7 +37,6 @@ #include "linux_proto.h" #include "../linux_util.h" -DUMMY(stat); DUMMY(mount); DUMMY(stime); DUMMY(fstat); Index: i386/linux_proto.h =================================================================== RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/i386/linux_proto.h,v retrieving revision 1.8 diff -u -r1.8 linux_proto.h --- i386/linux_proto.h 12 Aug 2003 02:36:15 -0000 1.8 +++ i386/linux_proto.h 18 Aug 2003 10:52:48 -0000 @@ -2,7 +2,7 @@ * System call prototypes. * * DO NOT EDIT-- this file is automatically generated. - * $DragonFly: src/sys/emulation/linux/i386/linux_proto.h,v 1.8 2003/08/12 02:36:15 dillon Exp $ + * $DragonFly$ * created from DragonFly: src/sys/emulation/linux/i386/syscalls.master,v 1.3 2003/08/07 21:17:18 dillon Exp */ @@ -123,7 +123,7 @@ #endif union usrmsg usrmsg; char * path; char path_[PAD_(char *)]; - struct ostat * up; char up_[PAD_(struct ostat *)]; + struct l_stat * up; char up_[PAD_(struct l_stat *)]; }; struct linux_lseek_args { #ifdef _KERNEL @@ -419,6 +419,14 @@ union usrmsg usrmsg; l_osigset_t * mask; char mask_[PAD_(l_osigset_t *)]; }; +struct linux_sethostname_args { +#ifdef _KERNEL + union sysmsg sysmsg; +#endif + union usrmsg usrmsg; + char * hostname; char hostname_[PAD_(char *)]; + u_int len; char len_[PAD_(u_int)]; +}; struct linux_setrlimit_args { #ifdef _KERNEL union sysmsg sysmsg; @@ -466,6 +474,14 @@ char * path; char path_[PAD_(char *)]; char * to; char to_[PAD_(char *)]; }; +struct linux_lstat_args { +#ifdef _KERNEL + union sysmsg sysmsg; +#endif + union usrmsg usrmsg; + char * path; char path_[PAD_(char *)]; + struct l_stat * up; char up_[PAD_(struct l_stat *)]; +}; struct linux_readlink_args { #ifdef _KERNEL union sysmsg sysmsg; @@ -516,6 +532,14 @@ char * path; char path_[PAD_(char *)]; l_ulong length; char length_[PAD_(l_ulong)]; }; +struct linux_ftruncate_args { +#ifdef _KERNEL + union sysmsg sysmsg; +#endif + union usrmsg usrmsg; + int fd; char fd_[PAD_(int)]; + long length; char length_[PAD_(long)]; +}; struct linux_statfs_args { #ifdef _KERNEL union sysmsg sysmsg; @@ -1298,18 +1322,21 @@ int linux_setregid16 __P((struct linux_setregid16_args *)); int linux_sigsuspend __P((struct linux_sigsuspend_args *)); int linux_sigpending __P((struct linux_sigpending_args *)); +int linux_sethostname __P((struct linux_sethostname_args *)); int linux_setrlimit __P((struct linux_setrlimit_args *)); int linux_old_getrlimit __P((struct linux_old_getrlimit_args *)); int linux_getgroups16 __P((struct linux_getgroups16_args *)); int linux_setgroups16 __P((struct linux_setgroups16_args *)); int linux_old_select __P((struct linux_old_select_args *)); int linux_symlink __P((struct linux_symlink_args *)); +int linux_lstat __P((struct linux_lstat_args *)); int linux_readlink __P((struct linux_readlink_args *)); int linux_uselib __P((struct linux_uselib_args *)); int linux_reboot __P((struct linux_reboot_args *)); int linux_readdir __P((struct linux_readdir_args *)); int linux_mmap __P((struct linux_mmap_args *)); int linux_truncate __P((struct linux_truncate_args *)); +int linux_ftruncate __P((struct linux_ftruncate_args *)); int linux_statfs __P((struct linux_statfs_args *)); int linux_fstatfs __P((struct linux_fstatfs_args *)); int linux_ioperm __P((struct linux_ioperm_args *)); Index: i386/linux_syscall.h =================================================================== RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/i386/linux_syscall.h,v retrieving revision 1.8 diff -u -r1.8 linux_syscall.h --- i386/linux_syscall.h 12 Aug 2003 02:36:15 -0000 1.8 +++ i386/linux_syscall.h 18 Aug 2003 10:52:48 -0000 @@ -2,7 +2,7 @@ * System call numbers. * * DO NOT EDIT-- this file is automatically generated. - * $DragonFly: src/sys/emulation/linux/i386/linux_syscall.h,v 1.8 2003/08/12 02:36:15 dillon Exp $ + * $DragonFly$ * created from DragonFly: src/sys/emulation/linux/i386/syscalls.master,v 1.3 2003/08/07 21:17:18 dillon Exp */ @@ -71,7 +71,7 @@ #define LINUX_SYS_linux_setregid16 71 #define LINUX_SYS_linux_sigsuspend 72 #define LINUX_SYS_linux_sigpending 73 -#define LINUX_SYS_osethostname 74 +#define LINUX_SYS_linux_sethostname 74 #define LINUX_SYS_linux_setrlimit 75 #define LINUX_SYS_linux_old_getrlimit 76 #define LINUX_SYS_getrusage 77 @@ -81,7 +81,7 @@ #define LINUX_SYS_linux_setgroups16 81 #define LINUX_SYS_linux_old_select 82 #define LINUX_SYS_linux_symlink 83 -#define LINUX_SYS_ostat 84 +#define LINUX_SYS_linux_lstat 84 #define LINUX_SYS_linux_readlink 85 #define LINUX_SYS_linux_uselib 86 #define LINUX_SYS_swapon 87 @@ -90,7 +90,7 @@ #define LINUX_SYS_linux_mmap 90 #define LINUX_SYS_munmap 91 #define LINUX_SYS_linux_truncate 92 -#define LINUX_SYS_oftruncate 93 +#define LINUX_SYS_linux_ftruncate 93 #define LINUX_SYS_fchmod 94 #define LINUX_SYS_fchown 95 #define LINUX_SYS_getpriority 96 Index: i386/linux_sysent.c =================================================================== RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/i386/linux_sysent.c,v retrieving revision 1.8 diff -u -r1.8 linux_sysent.c --- i386/linux_sysent.c 12 Aug 2003 02:36:15 -0000 1.8 +++ i386/linux_sysent.c 18 Aug 2003 10:52:48 -0000 @@ -2,11 +2,10 @@ * System call switch table. * * DO NOT EDIT-- this file is automatically generated. - * $DragonFly: src/sys/emulation/linux/i386/linux_sysent.c,v 1.8 2003/08/12 02:36:15 dillon Exp $ + * $DragonFly$ * created from DragonFly: src/sys/emulation/linux/i386/syscalls.master,v 1.3 2003/08/07 21:17:18 dillon Exp */ -#include "opt_compat.h" #include #include #include @@ -14,6 +13,7 @@ #include "linux_proto.h" #define AS(name) ((sizeof(struct name) - sizeof(union sysmsg) - sizeof(union usrmsg)) / sizeof(register_t)) +#define compat(n, name) 0, (sy_call_t *)nosys /* The casts are bogus but will do for now. */ struct sysent linux_sysent[] = { @@ -91,7 +91,7 @@ { AS(linux_setregid16_args), (sy_call_t *)linux_setregid16 }, /* 71 = linux_setregid16 */ { AS(linux_sigsuspend_args), (sy_call_t *)linux_sigsuspend }, /* 72 = linux_sigsuspend */ { AS(linux_sigpending_args), (sy_call_t *)linux_sigpending }, /* 73 = linux_sigpending */ - { AS(sethostname_args), (sy_call_t *)osethostname }, /* 74 = osethostname */ + { AS(linux_sethostname_args), (sy_call_t *)linux_sethostname }, /* 74 = linux_sethostname */ { AS(linux_setrlimit_args), (sy_call_t *)linux_setrlimit }, /* 75 = linux_setrlimit */ { AS(linux_old_getrlimit_args), (sy_call_t *)linux_old_getrlimit }, /* 76 = linux_old_getrlimit */ { AS(getrusage_args), (sy_call_t *)getrusage }, /* 77 = getrusage */ @@ -101,7 +101,7 @@ { AS(linux_setgroups16_args), (sy_call_t *)linux_setgroups16 }, /* 81 = linux_setgroups16 */ { AS(linux_old_select_args), (sy_call_t *)linux_old_select }, /* 82 = linux_old_select */ { AS(linux_symlink_args), (sy_call_t *)linux_symlink }, /* 83 = linux_symlink */ - { AS(ostat_args), (sy_call_t *)ostat }, /* 84 = ostat */ + { AS(linux_lstat_args), (sy_call_t *)linux_lstat }, /* 84 = linux_lstat */ { AS(linux_readlink_args), (sy_call_t *)linux_readlink }, /* 85 = linux_readlink */ { AS(linux_uselib_args), (sy_call_t *)linux_uselib }, /* 86 = linux_uselib */ { AS(swapon_args), (sy_call_t *)swapon }, /* 87 = swapon */ @@ -110,7 +110,7 @@ { AS(linux_mmap_args), (sy_call_t *)linux_mmap }, /* 90 = linux_mmap */ { AS(munmap_args), (sy_call_t *)munmap }, /* 91 = munmap */ { AS(linux_truncate_args), (sy_call_t *)linux_truncate }, /* 92 = linux_truncate */ - { AS(oftruncate_args), (sy_call_t *)oftruncate }, /* 93 = oftruncate */ + { AS(linux_ftruncate_args), (sy_call_t *)linux_ftruncate }, /* 93 = linux_ftruncate */ { AS(fchmod_args), (sy_call_t *)fchmod }, /* 94 = fchmod */ { AS(fchown_args), (sy_call_t *)fchown }, /* 95 = fchown */ { AS(getpriority_args), (sy_call_t *)getpriority }, /* 96 = getpriority */ Index: i386/linux_sysvec.c =================================================================== RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/i386/linux_sysvec.c,v retrieving revision 1.8 diff -u -r1.8 linux_sysvec.c --- i386/linux_sysvec.c 7 Aug 2003 21:17:18 -0000 1.8 +++ i386/linux_sysvec.c 15 Aug 2003 06:17:59 -0000 @@ -29,13 +29,6 @@ * $DragonFly: src/sys/emulation/linux/i386/linux_sysvec.c,v 1.8 2003/08/07 21:17:18 dillon Exp $ */ -/* XXX we use functions that might not exist. */ -#include "opt_compat.h" - -#ifndef COMPAT_43 -#error "Unable to compile Linux-emulator due to missing COMPAT_43 option!" -#endif - #include #include #include Index: i386/linux_union.h =================================================================== RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/i386/linux_union.h,v retrieving revision 1.4 diff -u -r1.4 linux_union.h --- i386/linux_union.h 12 Aug 2003 02:36:15 -0000 1.4 +++ i386/linux_union.h 18 Aug 2003 10:52:48 -0000 @@ -2,7 +2,7 @@ * Union of syscall args for messaging. * * DO NOT EDIT-- this file is automatically generated. - * $DragonFly: src/sys/emulation/linux/i386/linux_union.h,v 1.4 2003/08/12 02:36:15 dillon Exp $ + * $DragonFly$ * created from DragonFly: src/sys/emulation/linux/i386/syscalls.master,v 1.3 2003/08/07 21:17:18 dillon Exp */ @@ -62,18 +62,21 @@ struct linux_setregid16_args linux_setregid16; struct linux_sigsuspend_args linux_sigsuspend; struct linux_sigpending_args linux_sigpending; + struct linux_sethostname_args linux_sethostname; struct linux_setrlimit_args linux_setrlimit; struct linux_old_getrlimit_args linux_old_getrlimit; struct linux_getgroups16_args linux_getgroups16; struct linux_setgroups16_args linux_setgroups16; struct linux_old_select_args linux_old_select; struct linux_symlink_args linux_symlink; + struct linux_lstat_args linux_lstat; struct linux_readlink_args linux_readlink; struct linux_uselib_args linux_uselib; struct linux_reboot_args linux_reboot; struct linux_readdir_args linux_readdir; struct linux_mmap_args linux_mmap; struct linux_truncate_args linux_truncate; + struct linux_ftruncate_args linux_ftruncate; struct linux_statfs_args linux_statfs; struct linux_fstatfs_args linux_fstatfs; struct linux_ioperm_args linux_ioperm; Index: i386/syscalls.master =================================================================== RCS file: /nfs/daver/cvs-repos/cvs-dragonflybsd/src/sys/emulation/linux/i386/syscalls.master,v retrieving revision 1.3 diff -u -r1.3 syscalls.master --- i386/syscalls.master 7 Aug 2003 21:17:18 -0000 1.3 +++ i386/syscalls.master 21 Aug 2003 23:02:40 -0000 @@ -7,7 +7,7 @@ ; Columns: number type nargs namespc name alt{name,tag,rtyp}/comments ; number system call number, must be in order -; type one of STD, OBSOL, UNIMPL, COMPAT +; type one of STD, OBSOL, UNIMPL ; namespc one of POSIX, BSD, STD, NOHIDE (I dont care :-) -Peter ; name psuedo-prototype of syscall routine ; If one of the following alts is different, then all appear: @@ -18,12 +18,9 @@ ; types: ; STD always included -; COMPAT included on COMPAT #ifdef -; LIBCOMPAT included on COMPAT #ifdef, and placed in syscall.h ; OBSOL obsolete, not included in system, only specifies name ; UNIMPL not implemented, placeholder only -#include "opt_compat.h" #include #include #include @@ -55,7 +52,7 @@ 16 STD LINUX { int linux_lchown16(char *path, l_uid16_t uid, \ l_gid16_t gid); } 17 UNIMPL LINUX break -18 STD LINUX { int linux_stat(char *path, struct ostat *up); } +18 STD LINUX { int linux_stat(char *path, struct l_stat *up); } 19 STD LINUX { int linux_lseek(l_uint fdes, l_off_t off, \ l_int whence); } 20 STD LINUX { int linux_getpid(void); } @@ -122,8 +119,7 @@ 72 STD LINUX { int linux_sigsuspend(l_int hist0, l_int hist1, \ l_osigset_t mask); } 73 STD LINUX { int linux_sigpending(l_osigset_t *mask); } -74 NOPROTO LINUX { int osethostname(char *hostname, u_int len); } \ - osethostname sethostname_args int +74 STD LINUX { int linux_sethostname(char *hostname, u_int len); } 75 STD LINUX { int linux_setrlimit(l_uint resource, \ struct l_rlimit *rlim); } 76 STD LINUX { int linux_old_getrlimit(l_uint resource, \ @@ -140,7 +136,7 @@ 82 STD LINUX { int linux_old_select(struct l_old_select_argv \ *ptr); } 83 STD LINUX { int linux_symlink(char *path, char *to); } -84 NOPROTO LINUX { int ostat(char *path, struct ostat *up); } +84 STD LINUX { int linux_lstat(char *path, struct l_stat *up); } 85 STD LINUX { int linux_readlink(char *name, char *buf, \ l_int count); } 86 STD LINUX { int linux_uselib(char *library); } @@ -152,7 +148,7 @@ 90 STD LINUX { int linux_mmap(struct l_mmap_argv *ptr); } 91 NOPROTO LINUX { int munmap(caddr_t addr, int len); } 92 STD LINUX { int linux_truncate(char *path, l_ulong length); } -93 NOPROTO LINUX { int oftruncate(int fd, long length); } +93 STD LINUX { int linux_ftruncate(int fd, long length); } 94 NOPROTO LINUX { int fchmod(int fd, int mode); } 95 NOPROTO LINUX { int fchown(int fd, int uid, int gid); } 96 NOPROTO LINUX { int getpriority(int which, int who); }