mirror of https://github.com/vitalif/e2fsprogs
libe2p: Change iterate_on_dir so that it counts non-zero returns
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>bitmap-optimize
parent
1a4ce9df58
commit
14bd240b46
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue