bug#1205: [BusyBox] bug#1205: mount handles links differently in 0.60

Vladimir N. Oleynik dzo at simtreas.ru
Wed Aug 8 02:20:03 UTC 2001


Matt Kraai wrote:
> 
> On Tue, Aug 07, 2001 at 08:03:45PM +0400, Vladimir N. Oleynik wrote:
> > Matt Kraai wrote:
> > >
> > > On Tue, Aug 07, 2001 at 07:06:22PM +0400, Vladimir N. Oleynik wrote:
> > > > > Thanks for the testing.  The problem was a consequence of my last
> > > > > minute attempt to strip trailing /s.  I believe that the following
> > > > > patch doesn't have this problem.
> > > > >
> > > > > As for your patch, it appears to mishandle `foo..'.  Could you
> > > > > submit a fixed version so that we can compare again?
> > > >
> > > > Oops, Source my new version:
> > >
> > > I don't think your code is legal.  According to the strcpy(3)
> > > manpage, the source and destination strings may not overlap.  Your
> > > use of strcpy(3) to cut characters from the string violates this
> > > restriction.
> >
> > No, in this code all is used absolute correctly.
> > overlap: if destination stored in/after source only.
> 
> Is there a specification which says this?  The glibc manual
> prohibits any overlap, and uses the case you mention as an
> example.

You not begin to approve, what realization in the directory generic correctly
functions 
for all architecture, but is not optimum? 
Let's look realization memove() from the catalogue directory glibc. There about
it it is
unambiguously told:  

------ glibc/sysdeps/generic/memmove.c --------

/* Copy memory to memory until the specified number of bytes
   has been copied.  Overlap is handled correctly.
   Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
   Contributed by Torbjorn Granlund (tege at sics.se).
*/

rettype
memmove (a1, a2, len)
     a1const void *a1;
     a2const void *a2;
     size_t len;
{
  unsigned long int dstp = (long int) dest;
  unsigned long int srcp = (long int) src;

  /* This test makes the forward copying code be used whenever possible.
     Reduces the working set.  */
  if (dstp - srcp >= len)       /* *Unsigned* compare!  */
    {
      /* Copy from the beginning to the end.  */

      /* If there not too few bytes to copy, use word copy.  */

     /* Copy whole pages from SRCP to DSTP by virtual address
             manipulation, as much as possible.  */
         
--------- skip -------------------
 else
    {
      /* Copy from the end to the beginning.  */
      srcp += len;
      dstp += len;

      /* If there not too few bytes to copy, use word copy.  */
---------------

Resume: 
begining part - overlap
two part - not overlap.

Result:
strcpy(dst, src) not overlap if src > dst. 


Tomi,

> IMO Matt's argument is correct. W/ strcpy the memory areas may not overlap.
> the strcpy() function may be implemented (in different architectures) the
> way it is most efficient: It may copy from end to beginning on one
> platform, from beginning to end on another -- and perhaps using some
> multiprocessimg/dma -trickery on some ultimate machine.

People have not invented and hardly when will invent architecture which in the
beginning writes and then reads and checks, and how many really it was necessary
to copy. Hence my example will be considered always disputable by way of a
popular belief, 
but examples of use entirely and everywhere. You trust code Miguel de Icaza for
example?


--w
vodz






More information about the busybox mailing list