From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olaf Hering Date: Sun, 29 Feb 2004 19:42:47 +0000 Subject: Re: udevinfo reverse lookup for symlinks Message-Id: <20040229194247.GA1642@suse.de> List-Id: References: <20040209163332.GA2836@suse.de> In-Reply-To: <20040209163332.GA2836@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: linux-hotplug@vger.kernel.org On Mon, Feb 09, Kay Sievers wrote: > On Mon, Feb 09, 2004 at 05:33:32PM +0100, Olaf Hering wrote: > >=20 > > How do I reverse lookup symlinks? > > It seem that is not implemented. > >=20 > > nectarine:~ # udevinfo -n cdrom -q path > > device not found in database >=20 > It's not implemented. I didn't see the need for this, > cause it's easy to follow the link to the real node > and query this instead. But feel free to send a patch :) diff -purN udev-klibc/udevdb.c udev-klibc-debug/udevdb.c --- udev-klibc/udevdb.c 2004-02-28 02:11:47.000000000 +0100 +++ udev-klibc-debug/udevdb.c 2004-02-29 20:38:39.668973696 +0100 @@ -27,6 +27,7 @@ #define _KLIBC_HAS_ARCH_SIG_ATOMIC_T #include #include +#include #include #include #include @@ -178,13 +179,29 @@ static int find_found; =20 static int find_device_by_name(char *path, struct udevice *dev) { + char sp[] =3D " "; + int l, i, j; if (strncmp(dev->name, find_name, sizeof(dev->name)) =3D 0) { memcpy(find_dev, dev, sizeof(*find_dev)); - strfieldcpy(find_path, path); + strncpy(find_path, path, NAME_SIZE); find_found =3D 1; /* stop search */ return 1; } + l =3D strlen(dev->symlink); + if (!l) + return 0; + i =3D j =3D 0; + do { + j =3D strcspn(&dev->symlink[i], sp); + if (j && strncmp(&dev->symlink[i], find_name, j -i) =3D 0) { + memcpy(find_dev, dev, sizeof(*find_dev)); + strncpy(find_path, path, NAME_SIZE); + find_found =3D 1; + return 1; + } + i =3D i + j + 1; + } while (i < l); return 0; } =20 --=20 USB is for mice, FireWire is for men! sUse lINUX ag, n=C3=9CRNBERG ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id438&op=3Dclick _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel