From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: Re: replace dev.d/ with a rule based program execution
Date: Thu, 24 Feb 2005 21:52:36 +0000 [thread overview]
Message-ID: <1109281956.7242.30.camel@localhost.localdomain> (raw)
In-Reply-To: <20050221181242.GA22891@vrfy.org>
[-- Attachment #1: Type: text/plain, Size: 692 bytes --]
On Thu, 2005-02-24 at 22:04 +0100, Kay Sievers wrote:
>On Thu, 2005-02-24 at 15:45 -0500, David Zeuthen wrote:
>>On Thu, 2005-02-24 at 21:34 +0100, Kay Sievers wrote:
>>>HAL needs this only in the coldplug case, so what about letting udevinfo
>>>dumping a list of _all_ devpath -> node matches with a single call and
>>>HAL can merge all the names in one go into the device objects?
>>
>>That would work, yeah.
>
>So we should go for it? What format? Any options needed?
>
> $ udevinfo -d
> /block/fd0:/dev/fd0
> /block/hda:/dev/hda
> /class/input/mice:/dev/input/mice
> /class/mem/null:/dev/null
> ...
Something stupid like this? It dumps all my ~700 devices in 0.02
seconds. :)
Kay
[-- Attachment #2: udev-dump-db-01.patch --]
[-- Type: text/x-patch, Size: 2919 bytes --]
===== udev_db.c 1.45 vs edited =====
--- 1.45/udev_db.c 2005-02-24 12:13:24 +01:00
+++ edited/udev_db.c 2005-02-24 22:26:41 +01:00
@@ -239,3 +239,38 @@
return 0;
}
+
+int udev_db_call_foreach(int (*handler_function)(struct udevice *udev))
+{
+ struct dirent *ent;
+ DIR *dir;
+ char filename[NAME_SIZE];
+ struct udevice db_udev;
+
+ dir = opendir(udev_db_path);
+ if (dir == NULL) {
+ dbg("unable to udev db '%s'", udev_db_path);
+ return -1;
+ }
+
+ while (1) {
+ ent = readdir(dir);
+ if (ent == NULL || ent->d_name[0] == '\0')
+ break;
+
+ if (ent->d_name[0] == '.')
+ continue;
+
+ snprintf(filename, NAME_SIZE, "%s/%s", udev_db_path, ent->d_name);
+ filename[NAME_SIZE-1] = '\0';
+
+ memset(&db_udev, 0x00, sizeof(struct udevice));
+ if (parse_db_file(&db_udev, filename) == 0) {
+ if (handler_function(&db_udev) != 0)
+ break;
+ }
+ }
+
+ closedir(dir);
+ return 0;
+}
===== udev_db.h 1.20 vs edited =====
--- 1.20/udev_db.h 2005-02-24 12:13:24 +01:00
+++ edited/udev_db.h 2005-02-24 22:26:10 +01:00
@@ -30,5 +30,6 @@
extern int udev_db_get_device_by_devpath(struct udevice *dev, const char *devpath);
extern int udev_db_get_device_by_name(struct udevice *udev, const char *name);
+extern int udev_db_call_foreach(int (*handler_function)(struct udevice *udev));
#endif /* _UDEV_DB_H_ */
===== udevinfo.8 1.16 vs edited =====
--- 1.16/udevinfo.8 2005-02-23 04:21:38 +01:00
+++ edited/udevinfo.8 2005-02-24 22:44:05 +01:00
@@ -47,6 +47,10 @@
unique attributes to compose a rule.
.RB Needs " \-p " specified.
.TP
+.B \-d
+Print the relationship between the devpath and the node name for all devices
+currently available in the database.
+.TP
.B \-h
Print help text.
.SH "FILES"
===== udevinfo.c 1.44 vs edited =====
--- 1.44/udevinfo.c 2005-02-24 12:13:24 +01:00
+++ edited/udevinfo.c 2005-02-24 22:43:27 +01:00
@@ -178,9 +178,14 @@
return retval;
}
+static int print_dump(struct udevice *udev) {
+ printf("%s:%s/%s\n", udev->devpath, udev_root, udev->name);
+ return 0;
+}
+
static int process_options(int argc, char *argv[])
{
- static const char short_options[] = "an:p:q:rVh";
+ static const char short_options[] = "adn:p:q:rVh";
int option;
int retval = 1;
struct udevice udev;
@@ -245,6 +250,10 @@
attributes = 1;
break;
+ case 'd':
+ udev_db_call_foreach(print_dump);
+ exit(0);
+
case 'V':
printf("udevinfo, version %s\n", UDEV_VERSION);
exit(0);
@@ -384,7 +393,8 @@
"\n"
" -r print udev root\n"
" -a print all SYSFS_attributes along the device chain\n"
- " -s print all sysfs devices with major/minor, physical device and bus\n"
+ " -d print the relationship of devpath and the node name for all\n"
+ " devices available in the database\n"
" -V print udev version\n"
" -h print this help text\n"
"\n");
next prev parent reply other threads:[~2005-02-24 21:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-21 18:12 replace dev.d/ with a rule based program execution Kay Sievers
2005-02-22 8:08 ` Hannes Reinecke
2005-02-22 17:53 ` Harald Hoyer
2005-02-23 1:08 ` Marco d'Itri
2005-02-24 20:15 ` David Zeuthen
2005-02-24 20:34 ` Kay Sievers
2005-02-24 20:45 ` David Zeuthen
2005-02-24 21:04 ` Kay Sievers
2005-02-24 21:52 ` Kay Sievers [this message]
2005-02-24 22:03 ` David Zeuthen
2005-02-25 23:26 ` Greg KH
2005-02-26 0:28 ` Kay Sievers
2005-02-26 0:57 ` Marco d'Itri
2005-02-26 1:04 ` Kay Sievers
2005-02-26 1:06 ` Marco d'Itri
2005-02-26 2:22 ` Kay Sievers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1109281956.7242.30.camel@localhost.localdomain \
--to=kay.sievers@vrfy.org \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).