Re: [PATCH] add ftok() and getenv() functions to the synthetic target

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] add ftok() and getenv() functions to the synthetic target

Alexander Neundorf
On Thursday 27 October 2005 20:53, you wrote:

> On Thu, Oct 27, 2005 at 07:18:24PM +0200, Alexander Neundorf wrote:
> > On Thursday 27 October 2005 11:55, Andrew Lunn wrote:
> >
> > ...
> >
> > > So i see no reason why you should not include the packages you need
> > > for synth into the build for your target application as well. It will
> > > not affect the size of your target application.
> >
> > Yes, but there will be other headers available under the synthetic
> > target than under the real target, so I'll have a different
> > environment and won't be able to check whether my software will work
> > without CYGPKG_LIBC_STDLIB (which my application might not need). I
> > think the functions for accessing resources from the host under the
> > synthetic target should be independent from the actual configuration
> > for the target.
>
> You are missing the point. It does not matter if your application
> needs CYGPKG_LIBC_STDLIB or not. Having the package makes no
> difference to the size of the target image.  So you might as well have
> it in the target build so that the target and the synth system are the
> same.

Ok.
So how about cyg_hal_sys_ftok() ?
I can't create a "reengineered" version of the patch anymore.

Bye
Alex
--
Work: [hidden email] - http://www.jenoptik-los.de
Home: [hidden email]                - http://www.kde.org
      [hidden email]               - http://www.neundorf.net
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] add ftok() and getenv() functions to the synthetic target

Andrew Lunn-2
> So how about cyg_hal_sys_ftok() ?

Im working on it, but it crashes horribly, becasue it corrupts the
stack.

It looks like your implementations of cyg_hal_sys_?stat() are passing
the wrong structure to the kernel. So i first need to fix this before
i can test your ftok() implementation.

        Andrew
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] add ftok() and getenv() functions to the synthetic target

Andrew Lunn-2
On Sat, Nov 05, 2005 at 06:46:52PM +0100, Andrew Lunn wrote:
> > So how about cyg_hal_sys_ftok() ?
>
> Im working on it, but it crashes horribly, becasue it corrupts the
> stack.
>
> It looks like your implementations of cyg_hal_sys_?stat() are passing
> the wrong structure to the kernel. So i first need to fix this before
> i can test your ftok() implementation.

Turns out to be more interesting than i expected.

First off i cleaned up the cyg_hal_sys_*stat functions. There was
various breaking of naming conventions going on to start with. There
are now two sets of functions: cyg_hal_sys_{old|new}*stat, which
correspond to the two sets of kernel system calls. Similarly there are
now struct cyg_hal_sys_{old|new}_stat structures. I've synchronised
these structures with the linux 2.6.14 kernel. Looking at
http://lxr.linux.no they might will also work OK with older kernels,
back to 2.0.40, but since i only have 2.6.14, thats all i've
tested. So please report any breakages to me...

Once stat worked i then went back to your ftok() implementation and
tested it. In the patch you can find my test program. On native linux
is produces:

ftok("/etc/passwd",0x12)) = 0x12052e51
ftok("/etc/passwd",0x72)) = 0x72052e51
ftok("/boot/vmlinuz",0x72)) = 0x7201001a
ftok("/boot/vmlinuz",0x12)) = 0x1201001a

Your implementation in eCos produced:

ftok("/etc/passwd",0x12)) = 0x12052e51
ftok("/etc/passwd",0x72)) = 0x72052e51
ftok("/boot/vmlinuz",0x72)) = 0x7201000d
ftok("/boot/vmlinuz",0x12)) = 0x1201000d

So the FreeBSD version is not compatible with the glibc version. I can
imagine people wanting a native Linux application to talk to an eCos
synthetic system using shared memory, semaphores, or message
queues. So the keys have to be compatible.

Playing around i bit more i fixed it. Doing various ls -i is became
obvious that linux uses the inode of what a symbolic link points to,
not the inode of the symbolic link. So changing *_lstat to *_stat and
it produced compatible values.

Attached is the overall patch.

        Andrew

ftok.diff (10K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] add ftok() and getenv() functions to the synthetic target

Andrew Lunn-2
> Attached is the overall patch.

Upps. Forgot the -N

        Andrew

ftok.c (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] add ftok() and getenv() functions to the synthetic target

Alexander Neundorf
In reply to this post by Andrew Lunn-2
On Saturday 05 November 2005 20:42, Andrew Lunn wrote:
...
> First off i cleaned up the cyg_hal_sys_*stat functions. There was
> various breaking of naming conventions going on to start with. There
> are now two sets of functions: cyg_hal_sys_{old|new}*stat, which
> correspond to the two sets of kernel system calls. Similarly there are
> now struct cyg_hal_sys_{old|new}_stat structures. I've synchronised
> these structures with the linux 2.6.14 kernel. Looking at
> http://lxr.linux.no they might will also work OK with older kernels,
> back to 2.0.40, but since i only have 2.6.14, thats all i've
> tested. So please report any breakages to me...

Yes, works also here on kernel 2.4.22.

Thanks
Alex
--
Work: [hidden email] - http://www.jenoptik-los.de
Home: [hidden email]                - http://www.kde.org
      [hidden email]               - http://www.neundorf.net