Index: configure.ac =================================================================== --- configure.ac (revision 124) +++ configure.ac (working copy) @@ -44,6 +44,16 @@ esac fi +AC_MSG_CHECKING([whether to display hidden files in HostFS]) +AC_ARG_ENABLE(hostfs-hidden-files, + AC_HELP_STRING([--enable-hostfs-hidden-files], + [show hidden files in HostFS]),, + enable_hostfs_hidden_files=no) +AC_MSG_RESULT($enable_hostfs_hidden_files) +if test "$enable_hostfs_hidden_files" = "yes"; then + AC_DEFINE(HOSTFS_SHOW_HIDDEN_FILES, [], [Show hidden files]) +fi + AC_MSG_CHECKING([for Operating System]) case "${host}" in *linux*) Index: hostfs.c =================================================================== --- hostfs.c (revision 124) +++ hostfs.c (working copy) @@ -24,6 +24,7 @@ #include #include #include +#include "config.h" #include "arm.h" #include "mem.h" #include "hostfs.h" @@ -216,21 +217,22 @@ path_construct(const char *old_path, char *new_path, size_t len, ARMword load, ARMword exec) { - char *comma, *new_suffix; + char *new_suffix; /* TODO Ensure buffer safety is observed */ len = len; strcpy(new_path, old_path); - /* Calculate where to place new comma suffix */ - comma = strrchr(new_path, ','); - if (comma) { - /* New suffix overwrites existing comma suffix */ - new_suffix = comma; - } else { - /* New suffix appended onto existing path */ - new_suffix = new_path + strlen(new_path); + /* Default: new suffix appended onto existing path */ + new_suffix = new_path + strlen(new_path); + + /* Check for existing comma suffix (and ensure that subsequent + * characters are valid hex digits) */ + if (new_suffix - new_path > 4 && *(new_suffix - 4) == ',' && + isxdigit(*(new_suffix - 3)) && isxdigit(*(new_suffix - 2)) && + isxdigit(*(new_suffix - 1))) { + new_suffix -= 4; } if ((load & 0xfff00000u) == 0xfff00000u) { @@ -442,8 +444,14 @@ while ((entry = readdir(d)) != NULL) { char entry_path[PATH_MAX]; +#ifndef HOSTFS_SHOW_HIDDEN_FILES /* Hidden files are completely ignored */ if (entry->d_name[0] == '.') { +#else + /* Ignore '.' and '..' */ + if (entry->d_name[0] == '.' && ((_D_EXACT_NAMLEN(entry) == 1) || + (_D_EXACT_NAMLEN(entry) == 2 && entry->d_name[1] == '.'))) { +#endif continue; } @@ -1491,8 +1499,14 @@ while ((count < offset) && ((entry = readdir(d)) != NULL)) { char entry_path[PATH_MAX]; dbug_hostfs("Entry %s\n",entry->d_name); +#ifndef HOSTFS_SHOW_HIDDEN_FILES /* Hidden files are completely ignored */ if (entry->d_name[0] == '.') { +#else + /* Ignore '.' and '..' */ + if (entry->d_name[0] == '.' && ((_D_EXACT_NAMLEN(entry) == 1) || + (_D_EXACT_NAMLEN(entry) == 2 && entry->d_name[1] == '.'))) { +#endif continue; } @@ -1531,8 +1545,14 @@ char entry_path[PATH_MAX]; unsigned string_space, entry_space; +#ifndef HOSTFS_SHOW_HIDDEN_FILES /* Hidden files are completely ignored */ if (entry->d_name[0] == '.') { +#else + /* Ignore '.' and '..' */ + if (entry->d_name[0] == '.' && ((_D_EXACT_NAMLEN(entry) == 1) || + (_D_EXACT_NAMLEN(entry) == 2 && entry->d_name[1] == '.'))) { +#endif continue; }