[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#230857: Preinst should rename old devpts.sh to mountkernfs



On 2004.03.15 12:22, Thomas Hood wrote:
> On Mon, 2004-03-15 at 01:01, Miquel van Smoorenburg wrote:
> > I'm working on it. To be able to script several parts of this easily,
> > maintaining the /run functionality and also dynamic root dev
> > functionality for lvm and raid in which I have been involved at
> > the kernel level, we need a reliable 'readlink' utility - as Thomas
> > might remember, the behaviour of the current readlink has changed
> > a few times. I have now found that the cause is a questionable
> > implementation of readlink() in glibc, and I'm trying to write
> > a reasonable replacement which isn't quite trivial and is holding
> > things up for now.
> 
> I pursued the readlink() issue with upstream.  Most of the
> discussion is logged in coreutils bug #225836: "readlink: Please
> implement --recursive option".

Nobody noticed, but it's a glibc bug.

According to the glibc docs, realpath() is just a wrapper for
canonicalize_file_name() [in the actual code, it's the other
way around, but oh well]

The canonicalize_file_name() docs say:

   Function: char * canonicalize_file_name (const char *name)
                                                                                
           The canonicalize_file_name function returns the absolute name of
           the file named by name which contains no ., .. components nor any
           repeated path separators (/) or symlinks. The result is passed
           back as the return value of the function in a block of memory
           allocated with malloc. If the result is not used anymore the
           memory should be freed with a call to free.
                                                                                
           In any of the path components except the last one is missing the
                                         ^^^^^^^^^^^^^^^^^^^
           function returns a NULL pointer. This is also what is returned if
           the length of the path reaches or exceeds PATH_MAX characters. In
           any case errno is set accordingly.
                                                                                
Unfortunately, the current glibc implementation doesn't do what the docs say
it should do (the part I underlined with carets).

It's reasonable behaviour for realpath and canonicalize_file_name to
succeed if the entire path exists except the last component. I'd build in
an extra check though - the path leading to the last component must be
a directory.

Mike.



Reply to: