+ /*
+ * Remove any previously existing symlink from a udev path to
+ * the device before labeling the disk. This makes
+ * zpool_label_disk_wait() truly wait for the new link to show
+ * up instead of returning if it finds an old link still in
+ * place. Otherwise there is a window between when udev
+ * deletes and recreates the link during which access attempts
+ * will fail with ENOENT.
+ */
+ strncpy(udevpath, path, MAXPATHLEN);
+ (void) zfs_append_partition(udevpath, MAXPATHLEN);
+
+ if ((strncmp(udevpath, UDISK_ROOT, strlen(UDISK_ROOT)) == 0) &&
+ (lstat64(udevpath, &statbuf) == 0) &&
+ S_ISLNK(statbuf.st_mode))
+ (void) unlink(udevpath);
+
+ diskname = strrchr(devpath, '/');