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>
#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
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) {