+/* wait for the "dev" file to show up in the directory in sysfs.
+ * If it doesn't happen in about 10 seconds, give up.
+ */
+#define SECONDS_TO_WAIT_FOR_DEV 10
+static int sleep_for_dev(char *path)
+{
+ char filename[SYSFS_PATH_MAX + 6];
+ struct stat buf;
+ int loop = 0;
+ int retval = -ENODEV;
+
+ strcpy(filename, sysfs_path);
+ strcat(filename, path);
+ strcat(filename, "/dev");
+
+ while (loop < SECONDS_TO_WAIT_FOR_DEV) {
+ dbg("looking for %s", filename);
+ retval = stat(filename, &buf);
+ if (retval == 0) {
+ retval = 0;
+ goto exit;
+ }
+
+ /* sleep for a second or two to give the kernel a chance to
+ * create the dev file */
+ sleep(1);
+ ++loop;
+ }
+ retval = -ENODEV;
+exit:
+ return retval;
+}
+
+int udev_add_device(char *path, char *subsystem)