summaryrefslogtreecommitdiff
path: root/ext4_utils
diff options
context:
space:
mode:
Diffstat (limited to 'ext4_utils')
-rw-r--r--ext4_utils/make_ext4fs.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c
index 2f89ae8a..62a3f1ac 100644
--- a/ext4_utils/make_ext4fs.c
+++ b/ext4_utils/make_ext4fs.c
@@ -143,8 +143,18 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
if (full_path) {
entries = scandir(full_path, &namelist, filter_dot, (void*)alphasort);
if (entries < 0) {
- error_errno("scandir");
- return EXT4_ALLOCATE_FAILED;
+#ifdef __GLIBC__
+ /* The scandir function implemented in glibc has a bug that makes it
+ erroneously fail with ENOMEM under certain circumstances.
+ As a workaround we can retry the scandir call with the same arguments.
+ GLIBC BZ: https://sourceware.org/bugzilla/show_bug.cgi?id=17804 */
+ if (errno == ENOMEM)
+ entries = scandir(full_path, &namelist, filter_dot, (void*)alphasort);
+#endif
+ if (entries < 0) {
+ error_errno("scandir");
+ return EXT4_ALLOCATE_FAILED;
+ }
}
}