summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWojtek Porczyk2015-12-02 15:08:01 +0000
committerJo-Philipp Wich2015-12-02 16:05:03 +0000
commitbd53eaafbc2a89a57b8adda38f53098a431fa8f4 (patch)
treed4611c1a3fe51cc66777cf2539acefbeda07c1d7
parent98e3d5c1ceddd4a32b92c1cfafe929fe006fb98c (diff)
downloadmake_ext4fs-bd53eaafbc2a89a57b8adda38f53098a431fa8f4.tar.gz
make_ext4fs: explicitly call setlocale() before creating image
The alphasort(3) function, which is used as comparison function for scandir(3) is locale dependent (at least in glibc, in which it defers to strcoll(3)). This patch explicitly calls setlocale(3), setting the locale to "C". Currently, there are no other calls to setlocale(), so this does not change the behaviour. However, we'd like to be sure that in the future no-one will break that. Signed-off-by: Wojtek Porczyk <woju@invisiblethingslab.com>
-rw-r--r--make_ext4fs.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/make_ext4fs.c b/make_ext4fs.c
index cb18161..dd4d0d3 100644
--- a/make_ext4fs.c
+++ b/make_ext4fs.c
@@ -33,6 +33,7 @@
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <locale.h>
/* TODO: Not implemented:
Allocating blocks in the same block group as the file inode
@@ -66,6 +67,9 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
u32 dirs = 0;
bool needs_lost_and_found = false;
+ /* alphasort is locale-dependent; let's fix the locale to some sane value */
+ setlocale(LC_COLLATE, "C");
+
if (full_path) {
entries = scandir(full_path, &namelist, filter_dot, (void*)alphasort);
if (entries < 0) {