From b329f2c73b7e98fad86b1336475663feba53338d Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Thu, 2 Apr 2015 13:04:27 +0200 Subject: [PATCH] libc: FTS support for dynamic inode numbering Edited by Lionel Sambuc and David van Moolenbroek. Change-Id: I29d6383499d8c0524f86f9dcec701aff35ce8a43 --- lib/libc/gen/fts.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c index d1236fd5f..c5141f1a7 100644 --- a/lib/libc/gen/fts.c +++ b/lib/libc/gen/fts.c @@ -1197,6 +1197,10 @@ fts_maxarglen(char * const *argv) return (max + 1); } +#ifdef __minix +#include +#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; }