#include <libgen.h>
#include <string.h>
#include <stdlib.h>
+#include <limits.h>
int main(int argc, char **argv, char **envp)
/* Now argv[0] is the real qemu binary name */
{
- char *hostbin;
+ int len;
int r;
+ char buf[PATH_MAX];
+ char *hostbin;
+ char *path;
+
+ /* Follow symbolic link if any. */
+ path = realpath(argv[1], buf);
+ if (path == NULL) {
+ /* Error occured, falling back to original argument */
+ path = argv[1];
+ }
- r = asprintf(&hostbin, "/emul/%s", argv[1]);
+ r = asprintf(&hostbin, "/emul/%s", path);
if (!access(hostbin, X_OK) && (r > 0)) {
/*
* We found a host binary replacement for the non-host binary. Let's