[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3] util/oslib-posix: : qemu_init_exec_dir implementation for
From: |
David CARLIER |
Subject: |
Re: [PATCH v3] util/oslib-posix: : qemu_init_exec_dir implementation for Mac |
Date: |
Mon, 15 Jun 2020 20:14:31 +0100 |
With this basic program
#include <mach-o/dyld.h>
#include <stdio.h>
int main(void)
{
char buf[4096];
uint32_t bufsize = sizeof(buf);
_NSGetExecutablePath(buf, &bufsize);
printf("%s\n", buf);
return 0;
}
I get
Davids-MacBook-Pro-2:Contribs dcarlier$ ./a.out
/Users/dcarlier/Contribs/./a.out
The cast was to avoid possible warning with pedantic compile flags if used.
On Mon, 15 Jun 2020 at 20:05, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Mon, 15 Jun 2020 at 18:06, David CARLIER <devnexen@gmail.com> wrote:
> >
> > From dfa1e900dd950f4d3fca17fbf5d3dfb5725c83fa Mon Sep 17 00:00:00 2001
> > From: David Carlier <devnexen@gmail.com>
> > Date: Tue, 26 May 2020 21:35:27 +0100
> > Subject: [PATCH] util/oslib-posix : qemu_init_exec_dir implementation for
> > Mac
> >
> > Using dyld API to get the full path of the current process.
> >
> > Signed-off-by: David Carlier <devnexen@gmail.com>
>
> > +#elif defined(__APPLE__)
> > + {
> > + uint32_t len = (uint32_t)sizeof(buf);
>
> Why do we need the cast?
>
> > + if (_NSGetExecutablePath(buf, &len) == 0) {
> > + buf[len - 1] = 0;
> > + p = buf;
> > + }
> > + }
>
> What does this return if you start QEMU with a relative
> path (eg "./qemu-system-x86_64") ? The documentation
> suggests that you need to call realpath() to resolve that kind
> of relative path.
>
> Did you try the test I suggested with checking that this
> actually does return something different from argv[0] ?
>
> thanks
> -- PMM