summaryrefslogtreecommitdiff
path: root/e2fsprogs/e2fs_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'e2fsprogs/e2fs_lib.c')
-rw-r--r--e2fsprogs/e2fs_lib.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/e2fsprogs/e2fs_lib.c b/e2fsprogs/e2fs_lib.c
index 3e8d956..70ae1f4 100644
--- a/e2fsprogs/e2fs_lib.c
+++ b/e2fsprogs/e2fs_lib.c
@@ -28,33 +28,20 @@ static void close_silently(int fd)
/* Iterate a function on each entry of a directory */
int iterate_on_dir(const char *dir_name,
- int (*func)(const char *, struct dirent *, void *),
- void * private)
+ int FAST_FUNC (*func)(const char *, struct dirent *, void *),
+ void *private)
{
DIR *dir;
- struct dirent *de, *dep;
- int max_len, len;
-
- max_len = PATH_MAX + sizeof(struct dirent);
- de = xmalloc(max_len+1);
- memset(de, 0, max_len+1);
+ struct dirent *de;
dir = opendir(dir_name);
if (dir == NULL) {
- free(de);
return -1;
}
- while ((dep = readdir(dir))) {
- len = sizeof(struct dirent);
- if (len < dep->d_reclen)
- len = dep->d_reclen;
- if (len > max_len)
- len = max_len;
- memcpy(de, dep, len);
+ while ((de = readdir(dir)) != NULL) {
func(dir_name, de, private);
}
closedir(dir);
- free(de);
return 0;
}