From owner-freebsd-emulation Mon Oct 2 15:10:18 2000 Delivered-To: freebsd-emulation@freebsd.org Received: from kithrup.com (kithrup.com [205.179.156.40]) by hub.freebsd.org (Postfix) with ESMTP id EE16437B502 for ; Mon, 2 Oct 2000 15:10:13 -0700 (PDT) Received: (from sef@localhost) by kithrup.com (8.8.8/8.8.8) id PAA11290; Mon, 2 Oct 2000 15:10:13 -0700 (PDT) (envelope-from sef) Date: Mon, 2 Oct 2000 15:10:13 -0700 (PDT) From: Sean Eric Fagan Message-Id: <200010022210.PAA11290@kithrup.com> To: emulation@freebsd.org, ohartman@ipamzlx.physik.uni-mainz.de Subject: Re: Linux compilation errors under FBSD In-Reply-To: Sender: owner-freebsd-emulation@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >My problem is to get the PGI compilers running on FBSD, because >many of our oncoming scientists here bring their stuff based on >PGI's compiler with them. Well, it's a kind of horror ... Okay, first version of fstat64 for linux, in case someone else didn't do it. (I did this on both a 4.0 and 4.1 box, although I haven't tested it beyond compiling. Yes, I know, I'm a complete flake.) --- /sys/i386/linux/linux_dummy.c Wed Jul 19 22:31:56 2000 +++ linux_dummy.c Mon Oct 2 15:07:27 2000 @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/i386/linux/linux_dummy.c,v 1.21.2.3 2000/07/20 05:31:56 marcel Exp $ + * $FreeBSD: src/sys/i386/linux/linux_dummy.c,v 1.21 2000/01/29 12:45:35 peter Exp $ */ #include @@ -98,6 +98,8 @@ DUMMY(rt_sigpending); DUMMY(rt_sigtimedwait); DUMMY(rt_sigqueueinfo); +DUMMY(pread); +DUMMY(pwrite); DUMMY(capget); DUMMY(capset); DUMMY(sendfile); @@ -109,4 +111,3 @@ DUMMY(ftruncate64); DUMMY(stat64); DUMMY(lstat64); -DUMMY(fstat64); --- /sys/i386/linux/syscalls.master Wed Jul 19 14:11:10 2000 +++ syscalls.master Mon Oct 2 15:07:27 2000 @@ -1,4 +1,4 @@ - $FreeBSD: src/sys/i386/linux/syscalls.master,v 1.30.2.2 2000/07/19 21:11:10 marcel Exp $ + $FreeBSD: src/sys/i386/linux/syscalls.master,v 1.30 2000/01/29 12:43:29 peter Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 ; System call name/number master file (or rather, slave, from LINUX). @@ -32,7 +32,7 @@ ; #ifdef's, etc. may be included, and are copied to the output files. 0 STD LINUX { int linux_setup(void); } -1 NOPROTO LINUX { void exit(int rval); } exit rexit_args void +1 NOPROTO LINUX { int exit(int rval); } 2 STD LINUX { int linux_fork(void); } 3 NOPROTO LINUX { int read(int fd, char *buf, u_int nbyte); } 4 NOPROTO LINUX { int write(int fd, char *buf, u_int nbyte); } @@ -113,8 +113,7 @@ linux_osigset_t oldmask, \ linux_osigset_t mask); } 73 STD LINUX { int linux_sigpending(linux_osigset_t *mask); } -74 NOPROTO LINUX { int osethostname(char *hostname, u_int len); } \ - osethostname sethostname_args int +74 NOPROTO LINUX { int osethostname(char *hostname, u_int len); } 75 STD LINUX { int linux_setrlimit(u_int resource, \ struct ogetrlimit *rlim); } 76 STD LINUX { int linux_getrlimit(u_int resource, \ @@ -266,10 +265,8 @@ 178 STD LINUX { int linux_rt_sigqueueinfo(void); } 179 STD LINUX { int linux_rt_sigsuspend(linux_sigset_t *newset, \ size_t sigsetsize); } -180 STD LINUX { int linux_pread(int fd, char *buf, size_t nbyte, \ - off_t offset); } -181 STD LINUX { int linux_pwrite(int fd, const char *buf, \ - size_t nbyte, off_t offset); } +180 STD LINUX { int linux_pread(void); } +181 STD LINUX { int linux_pwrite(void); } 182 STD LINUX { int linux_chown(char *path, int uid, int gid); } 183 STD LINUX { int linux_getcwd(char *buf, unsigned long bufsize); } 184 STD LINUX { int linux_capget(void); } @@ -286,4 +283,4 @@ 194 STD LINUX { int linux_ftruncate64(void); } 195 STD LINUX { int linux_stat64(void); } 196 STD LINUX { int linux_lstat64(void); } -197 STD LINUX { int linux_fstat64(void); } +197 STD LINUX { int linux_fstat64(int fd, struct stat64 *buf); } --- /sys/i386/linux/linux_stats.c Thu Jul 6 18:16:52 2000 +++ linux_stats.c Mon Oct 2 15:07:27 2000 @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/i386/linux/linux_stats.c,v 1.20.2.1 2000/07/07 01:16:52 obrien Exp $ + * $FreeBSD: src/sys/i386/linux/linux_stats.c,v 1.20 2000/01/08 21:09:41 marcel Exp $ */ #include @@ -44,6 +44,8 @@ #include #include +#include + struct linux_newstat { u_short stat_dev; u_short __pad1; @@ -67,6 +69,30 @@ u_long __unused5; }; +struct linux_stat64 { + u_short stat_dev; + u_char __pad0[10]; + u_long stat_ino; + u_int stat_mode; + u_int stat_nlink; + u_long stat_uid; + u_long stat_gid; + u_short stat_rdev; + u_char __pad3[10]; + int64_t stat_size; + u_long stat_blksize; + u_long stat_blocks; + u_long __pad4; + u_long stat_atime; + u_long __pad5; + u_long stat_mtime; + u_long __pad6; + u_long stat_ctime; + u_long __pad7; + u_long __unused1; + u_long __unused2; +}; + struct linux_ustat { int f_tfree; @@ -97,6 +123,29 @@ return (copyout(&tbuf, ubuf, sizeof(tbuf))); } +static int +stat64_copyout(struct stat *buf, void *ubuf) +{ + struct linux_stat64 tbuf; + + bzero(&tbuf, sizeof(tbuf)); + tbuf.stat_dev = uminor(buf->st_dev) | (umajor(buf->st_dev) << 8); + tbuf.stat_ino = buf->st_ino; + tbuf.stat_mode = buf->st_mode; + tbuf.stat_nlink = buf->st_nlink; + tbuf.stat_uid = buf->st_uid; + tbuf.stat_gid = buf->st_gid; + tbuf.stat_rdev = buf->st_rdev; + tbuf.stat_size = buf->st_size; + tbuf.stat_atime = buf->st_atime; + tbuf.stat_mtime = buf->st_mtime; + tbuf.stat_ctime = buf->st_ctime; + tbuf.stat_blksize = buf->st_blksize; + tbuf.stat_blocks = buf->st_blocks; + + return (copyout(&tbuf, ubuf, sizeof(tbuf))); +} + int linux_newstat(struct proc *p, struct linux_newstat_args *args) { @@ -187,6 +236,31 @@ error = fo_stat(fp, &buf, p); if (!error) error = newstat_copyout(&buf, args->buf); + + return (error); +} + +int +linux_fstat64(struct proc *p, struct linux_fstat64_args *args) +{ + struct filedesc *fdp; + struct file *fp; + struct stat buf; + int error; + + fdp = p->p_fd; + +#ifdef DEBUG + printf("Linux-emul(%ld): fstat64(%d, *)\n", (long)p->p_pid, args->fd); +#endif + + if ((unsigned)args->fd >= fdp->fd_nfiles || + (fp = fdp->fd_ofiles[args->fd]) == NULL) + return (EBADF); + + error = fo_stat(fp, &buf, p); + if (!error) + error = stat64_copyout(&buf, args->buf); return (error); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-emulation" in the body of the message