ash: Tab completion doesn't work for broken symlinks

Alexander Griesser alexander.griesser at lkh-vil.or.at
Wed Mar 29 00:45:55 PST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!

Today I found out, that tab completion in cmdedit.c doesn't work
for broken symbolic links.

Symptoms:
- ---------
[lxtc3861 - ~ #] ls -l | grep -- "->"
lrwxrwxrwx [...] Mar 23 11:16 root -> /
lrwxrwxrwx [...] Mar 29 09:57 symlink -> i_do_not_exist
lrwxrwxrwx [...] Mar 29 10:01 symlink_working -> linuxrc
lrwxrwxrwx [...] Mar 23 11:16 tmp -> var/tmp
[lxtc3861 - ~ #] ls sy
symlink_working   sys/              system/
[lxtc3861 - ~ #] ls sy

Explanation:
- ------------
The symbolic link "symlink" points to "i_do_not_exist" and this file
does (surprise, surprise) not exist. Although the symlink is there and
occupies an inode and is a "real" file, it doesn't get listed as part
of the possible matches.

Resolution:
- -----------
Took me some time to find out why, but in fact, it was quite harmless.
I think, this patch shouldn't do anything bad, if I understood the
manpages correctly.

- --- cmdedit.c   2006-03-29 10:39:41.616114697 +0200
+++ cmdedit.c.new       2006-03-29 10:38:45.716506398 +0200
@@ -776,7 +776,7 @@
                        }
                        found = concat_path_file(paths[i], str_found);
                        /* hmm, remover in progress? */
- -                       if (stat(found, &st) < 0)
+                       if (lstat(found, &st) < 0)
                                goto cont;
                        /* find with dirs ? */
                        if (paths[i] != dirbuf)


ciao,
- --
Alexander Griesser (Netzwerkadministration)
E-Mail: alexander.griesser at lkh-vil.or.at | Web: http://www.lkh-vil.or.at
KABEG LKH Villach | Nikolaigasse 43 | 9500 Villach
Tel.:   +43 4242 208 3061 | Fax.:   +43 4242 971 3061
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEKklC66HVD6KUm1oRAqXBAJ4i22U4quMXV43JtwR6/agztMkWdACglCZq
DCQR3uApSaTYdE5Lagl21W0=
=4PZt
-----END PGP SIGNATURE-----


More information about the busybox mailing list