X-Git-Url: http://git.archive.openwrt.org/?p=project%2Ffstools.git;a=blobdiff_plain;f=libfstools%2Foverlay.c;h=db80798a53620896c46bb4cb40004be43a3c6622;hp=d6c311bd2b41fc5cb8429aae680de858e9a04470;hb=532a5568104449777d24c4f83f24b9c9581d54ab;hpb=eee7814420990b0a733fbc68defa56d4d0c388a7 diff --git a/libfstools/overlay.c b/libfstools/overlay.c index d6c311b..db80798 100644 --- a/libfstools/overlay.c +++ b/libfstools/overlay.c @@ -78,10 +78,16 @@ foreachdir(const char *dir, int (*cb)(const char*)) snprintf(globdir, 256, "%s/*", dir); /**/ if (!glob(globdir, GLOB_NOESCAPE | GLOB_MARK | GLOB_ONLYDIR, NULL, &gl)) - for (j = 0; j < gl.gl_pathc; j++) - if (!stat(gl.gl_pathv[j], &s) && !S_ISLNK(s.st_mode)) - foreachdir(gl.gl_pathv[j], cb); + for (j = 0; j < gl.gl_pathc; j++) { + char *dir = gl.gl_pathv[j]; + int len = strlen(gl.gl_pathv[j]); + + if (len > 1 && dir[len - 1] == '/') + dir[len - 1] = '\0'; + if (!lstat(gl.gl_pathv[j], &s) && !S_ISLNK(s.st_mode)) + foreachdir(gl.gl_pathv[j], cb); + } cb(dir); } @@ -274,7 +280,7 @@ static int overlay_mount_fs(struct volume *v) return -1; } - return -1; + return 0; } enum fs_state fs_state_get(const char *dir) @@ -305,6 +311,9 @@ int fs_state_set(const char *dir, enum fs_state state) char valstr[16]; char *path; + if (fs_state_get(dir) == state) + return 0; + path = alloca(strlen(dir) + 1 + sizeof("/.fs_state")); sprintf(path, "%s/.fs_state", dir); unlink(path);