libc: FTS support for dynamic inode numbering

Edited by Lionel Sambuc and David van Moolenbroek.

Change-Id: I29d6383499d8c0524f86f9dcec701aff35ce8a43
This commit is contained in:
Ben Gras 2015-04-02 13:04:27 +02:00 committed by David van Moolenbroek
parent f837aff6e8
commit b329f2c73b

View file

@ -1197,6 +1197,10 @@ fts_maxarglen(char * const *argv)
return (max + 1);
}
#ifdef __minix
#include <minix/dmap.h>
#endif
/*
* Change to dir specified by fd or p->fts_accpath without getting
* tricked by someone changing the world out from underneath us.
@ -1217,7 +1221,22 @@ fts_safe_changedir(const FTS *sp, const FTSENT *p, int fd, const char *path)
if (fstat(fd, &sb) == -1)
goto bail;
#ifdef __minix
/*
* Skip the safety check on file systems where inodes are not static.
* On such file systems, a file may legitimately be assigned a new
* inode number due to being deleted and regenerated while we are
* running. This behavior is not POSIX compliant, but necessary for
* certain types of file systems. Currently, we assume that this
* applies to all (and only) file systems that are not device backed.
* In the future, we may have to obtain an appropriate flag through
* statvfs(3) instead.
*/
if ((sb.st_ino != p->fts_ino || sb.st_dev != p->fts_dev)
&& major(sb.st_dev) != NONE_MAJOR) {
#else
if (sb.st_ino != p->fts_ino || sb.st_dev != p->fts_dev) {
#endif
errno = ENOENT;
goto bail;
}