+ struct stat_list_t stself;
+ int fd = dirfd (handle);
+
+ if ((fd == -1) || fstat (fd, &stself.st))
+ {
+ msg_Err (p_playlist, "cannot stat `%s': %s", psz_name,
+ strerror (errno));
+ return VLC_EGENERIC;
+ }
+
+ for (stat_list_t *stats = stparent; stats != NULL; stats = stats->parent)
+ {
+#ifndef WIN32
+ if ((stself.st.st_ino == stats->st.st_ino)
+ && (stself.st.st_dev == stats->st.st_dev))
+ {
+ msg_Warn (p_playlist,
+ "ignoring infinitely recursive directory `%s'",
+ psz_name);
+ return VLC_SUCCESS;
+ }
+#else
+ /* Windows has st_dev (driver letter - 'A'), but it zeroes st_ino,
+ * so that the test above will always incorrectly succeed. */
+#endif
+ }
+
+ stself.parent = stparent;
+