+/* 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_FILE 10
+static int sleep_for_file(const char *path, char* file)
+{
+ char filename[SYSFS_PATH_MAX + 6];
+ int loop = SECONDS_TO_WAIT_FOR_FILE;
+ int retval;
+
+ strfieldcpy(filename, sysfs_path);
+ strfieldcat(filename, path);
+ strfieldcat(filename, file);
+
+ while (loop--) {
+ struct stat buf;
+
+ dbg("looking for '%s'", filename);
+ retval = stat(filename, &buf);
+ if (retval == 0)
+ goto exit;
+
+ /* sleep to give the kernel a chance to create the dev file */
+ sleep(1);
+ }
+ retval = -ENODEV;
+exit:
+ return retval;
+}
+
+static int rename_net_if(struct udevice *dev, int fake)
+{
+ int sk;
+ struct ifreq ifr;
+ int retval;
+
+ dbg("changing net interface name from '%s' to '%s'", dev->kernel_name, dev->name);
+ if (fake)
+ return 0;
+
+ sk = socket(PF_INET, SOCK_DGRAM, 0);
+ if (sk < 0) {
+ dbg("error opening socket");
+ return -1;
+ }
+
+ memset(&ifr, 0x00, sizeof(struct ifreq));
+ strfieldcpy(ifr.ifr_name, dev->kernel_name);
+ strfieldcpy(ifr.ifr_newname, dev->name);
+
+ retval = ioctl(sk, SIOCSIFNAME, &ifr);
+ if (retval != 0)
+ dbg("error changing net interface name");
+ close(sk);
+
+ return retval;
+}
+
+int udev_add_device(const char *path, const char *subsystem, int fake)