From: Ben Gras Date: Thu, 2 Apr 2015 11:04:27 +0000 (+0200) Subject: libc: FTS support for dynamic inode numbering X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=b329f2c73b7e98fad86b1336475663feba53338d;p=minix.git libc: FTS support for dynamic inode numbering Edited by Lionel Sambuc and David van Moolenbroek. Change-Id: I29d6383499d8c0524f86f9dcec701aff35ce8a43 --- 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; }