Date: Sat, 24 Mar 2001 16:57:18 -0800 From: Sean Chittenden <sean-freebsd-emulation@chittenden.org> To: Kris Kennaway <kris@obsecurity.org> Cc: freebsd-emulation@freebsd.org Subject: Re: linux_fstat64()... Message-ID: <20010324165717.G18546@rand.tgd.net> In-Reply-To: <20010324151152.B41591@xor.obsecurity.org>; from "kris@obsecurity.org" on Sat, Mar 24, 2001 at = 03:11:52PM References: <20010315121531.F54243@rand.tgd.net> <20010324151152.B41591@xor.obsecurity.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--OFj+1YLvsEfSXdCH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I have an old patch that I found on the mailing lists from Sean Eric Fagan <sef@kithrup.com> who created the patch, but hadn't maintained it. I tried applying the patch to the STABLE branch, but didn't have any success. My end solution was to run a 4.0 system (or a 3.4, can't remember). Here's Sean Fagan's patch (found in archives at: http://www.freebsd.org/cgi/getmsg.cgi?fetch=3D20950+27808+/usr/local/www/db= /text/2000/freebsd-emulation/20001008.freebsd-emulation) It doesn't apply 100% cleanly, however, you can do the patch by hand and try and compile. At that point, I run into the following errors: cc -c -O -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmi= ssing-prototypes -Wpointer-arith -Winline -Wcast-qual -fformat-extensions = -ansi -nostdinc -I- -I. -I../.. -I../../../include -D_KERNEL -include opt= _global.h -elf -mpreferred-stack-boundary=3D2 ../../compat/linux/linux_st= ats.c =2E./../compat/linux/linux_stats.c: In function `linux_fstat64': =2E./../compat/linux/linux_stats.c:277: structure has no member named `fd' =2E./../compat/linux/linux_stats.c:278: structure has no member named `fd' =2E./../compat/linux/linux_stats.c:283: structure has no member named `buf' *** Error code 1 Stop in /usr/src/sys/compile/HOST20. Anyway, here's the old patch. I'm about to head out of town for a week, but when I get back hopefully I'll have some time to poke at this, but I'm 100% ignorant of how this works and haven't used C in 4 years, so it's probably in all of our best interests if someone else pokes at this. ;~) -sc --- /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 p= eter Exp $ */ =20 #include <sys/param.h> @@ -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 p= eter Exp $ =20 ; @(#)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. =20 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 m= arcel Exp $ */ =20 #include <sys/param.h> @@ -44,6 +44,8 @@ #include <i386/linux/linux_proto.h> #include <i386/linux/linux_util.h> =20 +#include <vm/vm_zone.h> + struct linux_newstat { u_short stat_dev; u_short __pad1; @@ -67,6 +69,30 @@ u_long __unused5; }; =20 +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=20 { int f_tfree; @@ -97,6 +123,29 @@ return (copyout(&tbuf, ubuf, sizeof(tbuf))); } =20 +static int +stat64_copyout(struct stat *buf, void *ubuf) +{ + struct linux_stat64 tbuf; + + bzero(&tbuf, sizeof(tbuf)); + tbuf.stat_dev =3D uminor(buf->st_dev) | (umajor(buf->st_dev) << 8); + tbuf.stat_ino =3D buf->st_ino; + tbuf.stat_mode =3D buf->st_mode; + tbuf.stat_nlink =3D buf->st_nlink; + tbuf.stat_uid =3D buf->st_uid; + tbuf.stat_gid =3D buf->st_gid; + tbuf.stat_rdev =3D buf->st_rdev; + tbuf.stat_size =3D buf->st_size; + tbuf.stat_atime =3D buf->st_atime; + tbuf.stat_mtime =3D buf->st_mtime; + tbuf.stat_ctime =3D buf->st_ctime; + tbuf.stat_blksize =3D buf->st_blksize; + tbuf.stat_blocks =3D 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 =3D fo_stat(fp, &buf, p); if (!error) error =3D 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 =3D p->p_fd; + +#ifdef DEBUG + printf("Linux-emul(%ld): fstat64(%d, *)\n", (long)p->p_pid, args->fd); +#endif + + if ((unsigned)args->fd >=3D fdp->fd_nfiles || + (fp =3D fdp->fd_ofiles[args->fd]) =3D=3D NULL) + return (EBADF); + + error =3D fo_stat(fp, &buf, p); + if (!error) + error =3D stat64_copyout(&buf, args->buf); =20 return (error); } On Sat, Mar 24, 2001 at 03:11:52PM -0800, Kris Kennaway wrote: > Delivered-To: sean-freebsd-emulation@chittenden.org > Delivered-To: freebsd-emulation@freebsd.org > Date: Sat, 24 Mar 2001 15:11:52 -0800 > From: Kris Kennaway <kris@obsecurity.org> > To: Sean Chittenden <sean-freebsd-emulation@chittenden.org> > Cc: freebsd-emulation@freebsd.org > Subject: Re: linux_fstat64()... > User-Agent: Mutt/1.2.5i > In-Reply-To: <20010315121531.F54243@rand.tgd.net>; from sean-freebsd-emul= ation@chittenden.org on Thu, Mar 15, 2001 at 12:15:32PM -0800 > X-Loop: FreeBSD.org > Precedence: bulk >=20 > On Thu, Mar 15, 2001 at 12:15:32PM -0800, Sean Chittenden wrote: > > Has anyone implimented the linux_fstat64() call? If it hasn't > > and you'd be interested in it, please email me so I can guage the > > level of interest. -sc >=20 > I'm getting warnings from (I think) realplayer about this. Sign me up > as 'interested' if you can submit code to implement it. >=20 > Kris --=20 Sean Chittenden sean@chittenden.org --OFj+1YLvsEfSXdCH Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Comment: For info see http://www.gnupg.org iEYEARECAAYFAjq9Qm0ACgkQn09c7x7d+q1o5wCbBMD7dyz9cjVVhFKCWWtuQOTM mL4AoMTaoIHmHr0WVyxKEapFWo+MGfdp =I1Cg -----END PGP SIGNATURE----- --OFj+1YLvsEfSXdCH-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-emulation" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010324165717.G18546>