make jffs2reset not iterate over symlinked folders
authorJohn Crispin <blogic@openwrt.org>
Tue, 25 Aug 2015 20:43:18 +0000 (22:43 +0200)
committerJohn Crispin <blogic@openwrt.org>
Tue, 25 Aug 2015 23:28:44 +0000 (01:28 +0200)
Signed-off-by: John Crispin <blogic@openwrt.org>
libfstools/overlay.c

index 62a99f8f354f7f37d8c3ad7bc949f4a6c5adfaee..d6c311bd2b41fc5cb8429aae680de858e9a04470 100644 (file)
@@ -67,6 +67,7 @@ handle_rmdir(const char *dir)
 void
 foreachdir(const char *dir, int (*cb)(const char*))
 {
+       struct stat s = { 0 };
        char globdir[256];
        glob_t gl;
        int j;
@@ -78,7 +79,8 @@ foreachdir(const char *dir, int (*cb)(const char*))
 
        if (!glob(globdir, GLOB_NOESCAPE | GLOB_MARK | GLOB_ONLYDIR, NULL, &gl))
                for (j = 0; j < gl.gl_pathc; j++)
-                       foreachdir(gl.gl_pathv[j], cb);
+                       if (!stat(gl.gl_pathv[j], &s) && !S_ISLNK(s.st_mode))
+                               foreachdir(gl.gl_pathv[j], cb);
 
        cb(dir);
 }