summaryrefslogtreecommitdiff
path: root/udevtest.c
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2004-03-22 22:18:34 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:35:10 -0700
commit8a0acf85f25d2fb4659aafbad7db2fe48a58307d (patch)
treebf45b3ff9bac17734dc27ef755c2583a07a65951 /udevtest.c
parentb99c85e440193eb7f7dd84e473cafb16cb75722f (diff)
[PATCH] make udevtest a real program :)
Here are the missing pieces for udevtest. A simple man page is added, the blacklist is removed, cause it can't work without having a subsystem. The Makefile removes all manpages now with a uninstall and installs udevtest in /usr/bin/. Any old version from /sbin/ should be deleted by hand. The only expected argument is the sysfs devpath, here I changed it to be more tolerant to the input. The path may now be specified with or without a leading slash and optionally with the /sys moutpoint prepended. I hope this will end the confusion about the use of this program :)
Diffstat (limited to 'udevtest.c')
-rw-r--r--udevtest.c83
1 files changed, 33 insertions, 50 deletions
diff --git a/udevtest.c b/udevtest.c
index e67d452577..95b85dd8be 100644
--- a/udevtest.c
+++ b/udevtest.c
@@ -37,6 +37,7 @@
char **main_argv;
char **main_envp;
+
#ifdef LOG
unsigned char logname[LOGNAME_SIZE];
void log_message (int level, const char *format, ...)
@@ -51,72 +52,54 @@ void log_message (int level, const char *format, ...)
}
#endif
-static char *subsystem_blacklist[] = {
- "net",
- "scsi_host",
- "scsi_device",
- "usb_host",
- "pci_bus",
- "pcmcia_socket",
- ""
-};
-
-static int udev_hotplug(void)
+int main(int argc, char *argv[], char *envp[])
{
char *devpath;
- char *subsystem;
- int retval = -EINVAL;
- int i;
+ char temp[NAME_SIZE];
+ char subsystem[] = "";
+ const int fake = 1;
+
+ main_argv = argv;
+ main_envp = envp;
+
+ info("version %s", UDEV_VERSION);
- devpath = main_argv[1];
- if (!devpath) {
- dbg("no devpath?");
+ if (argv[1] == NULL) {
+ info("udevinfo expects the DEVPATH of the sysfs device as a argument");
goto exit;
}
- dbg("looking at '%s'", devpath);
+
+ /* initialize our configuration */
+ udev_init_config();
+
+ /* remove sysfs_path if given */
+ if (strncmp(argv[1], sysfs_path, strlen(sysfs_path)) == 0)
+ devpath = argv[1] + strlen(sysfs_path);
+ else
+ if (argv[1][0] != '/') {
+ /* prepend '/' if missing */
+ strfieldcpy(temp, "/");
+ strfieldcat(temp, argv[1]);
+ devpath = temp;
+ } else {
+ devpath = argv[1];
+ }
+
+ info("looking at '%s'", devpath);
/* we only care about class devices and block stuff */
if (!strstr(devpath, "class") &&
!strstr(devpath, "block")) {
- dbg("not a block or class device");
+ info("not a block or class device");
goto exit;
}
- /* skip blacklisted subsystems */
- subsystem = main_argv[1];
- i = 0;
- while (subsystem_blacklist[i][0] != '\0') {
- if (strcmp(subsystem, subsystem_blacklist[i]) == 0) {
- dbg("don't care about '%s' devices", subsystem);
- goto exit;
- }
- i++;
- }
-
- /* initialize our configuration */
- udev_init_config();
-
/* initialize the naming deamon */
namedev_init();
/* simulate node creation with fake flag */
- retval = udev_add_device(devpath, subsystem, 1);
+ udev_add_device(devpath, subsystem, fake);
exit:
- if (retval > 0)
- retval = 0;
-
- return -retval;
-}
-
-int main(int argc, char *argv[], char *envp[])
-{
- main_argv = argv;
- main_envp = envp;
-
- dbg("version %s", UDEV_VERSION);
-
- return udev_hotplug();
+ return 0;
}
-
-