]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libe2p: Change iterate_on_dir so that it counts non-zero returns
authorTheodore Ts'o <tytso@mit.edu>
Mon, 22 Oct 2007 12:25:13 +0000 (08:25 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 22 Oct 2007 12:25:13 +0000 (08:25 -0400)
To allow error messages to be reflected up, if the callback function
returns a non-zero value, bump a counter and return the number of
times the callback function signals an error by returning a non-zero
status code.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/e2p/iod.c

index 808d3a39d097ceffd6ad035ae0f3f7174fc3966f..84c97094c0ed0268cd95d555b542857c2d626246 100644 (file)
@@ -27,7 +27,7 @@ int iterate_on_dir (const char * dir_name,
 {
        DIR * dir;
        struct dirent *de, *dep;
-       int     max_len = -1, len;
+       int     max_len = -1, len, ret = 0;
 
 #if HAVE_PATHCONF && defined(_PC_NAME_MAX) 
        max_len = pathconf(dir_name, _PC_NAME_MAX);
@@ -64,9 +64,10 @@ int iterate_on_dir (const char * dir_name,
                        len = max_len;
 #endif
                memcpy(de, dep, len);
-               (*func) (dir_name, de, private);
+               if ((*func)(dir_name, de, private))
+                       ret++;
        }
        free(de);
        closedir(dir);
-       return 0;
+       return ret;
 }