Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/client/client/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,13 @@ extern int dlopen_filter(const char *name);
static char patch[4096];
static char *last_patch_location = NULL;
static int last_patch_len;
static int last_hwcaps_offset;
static const char *stat_not_found_prefix = NOT_FOUND_PREFIX "/";

static void pathpatch_old_name(char *filename)
{
int len;
const char * hwcaps;
if (have_stat_patches)
return;

Expand All @@ -419,8 +421,13 @@ static void pathpatch_old_name(char *filename)
return;
}

hwcaps = strstr(filename, HWCAPS_DIRNAME);
last_hwcaps_offset = (hwcaps != NULL) ? hwcaps - filename : 0;

memcpy(patch, filename, len);
debug_printf2("Patching nonexistent directory name %s\n", filename);
memcpy(filename, stat_not_found_prefix, len);
debug_printf2("Patched directory name to %s\n", filename);
last_patch_location = filename;
last_patch_len = len;
}
Expand All @@ -431,12 +438,16 @@ void restore_pathpatch()
return;
if (!last_patch_location || !last_patch_len)
return;
if (last_hwcaps_offset > 0 && last_hwcaps_offset < last_patch_len)
last_patch_len = last_hwcaps_offset;
if (strncmp(last_patch_location, stat_not_found_prefix, last_patch_len) != 0) {
last_patch_location = NULL;
last_patch_len = 0;
return;
}
debug_printf2("Restoring patched directory name %s\n", last_patch_location);
memcpy(last_patch_location, patch, last_patch_len);
debug_printf2("Restored patched directory name to %s\n", last_patch_location);
last_patch_location = NULL;
last_patch_len = 0;
}
Expand Down
1 change: 1 addition & 0 deletions src/client/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include "spindle_regex.h"

#define NOT_FOUND_PREFIX "/__not_exists"
#define HWCAPS_DIRNAME "glibc-hwcaps"

extern int use_ldcs;
extern int ldcsid;
Expand Down