util/cutils: Use getexecpath() on OpenBSD for qemu_init_exec_dir()
PATCH 1/1 util/cutils: Use getexecpath() on OpenBSD for qemu_init_exec_dir()
util/cutils: Use getexecpath() on OpenBSD for qemu_init_exec_dir()
OpenBSD has introduced a function getexecpath() to be able to retrieve the executable name and path.
Signed-off-by Brad Smith <[email protected]>
--- meson.build | 8 ++++++++ util/cutils.c | 6 ++++++ 2 files changed, 14 insertions(+)
meson.build +8 -0
@@ -3034,6 +3034,14 @@ config_host_data.set('CONFIG_ELF_AUX_INFO', cc.links(osdep_prefix + ''' return hwcap; }''')) +config_host_data.set('CONFIG_GETEXECPATH', cc.links(osdep_prefix + ''' + #include <limits.h> + #include <unistd.h> + int main(void) { + char buf[PATH_MAX]; + getexecpath(buf, sizeof(buf)); + }''')) + config_host_data.set('CONFIG_USBFS', have_linux_user and cc.compiles(''' #include <linux/usbdevice_fs.h>
util/cutils.c +6 -0
@@ -1091,6 +1091,12 @@ void qemu_init_exec_dir(const char *argv0) p = buf; } } +#elif defined(__OpenBSD__) && defined(CONFIG_GETEXECPATH) + { +if (getexecpath (buf,sizeof (buf)) ==0 ) { + p = buf; + } + }#elif defined(__APPLE__) {char fpath[PATH_MAX ];
Signature · 1 line
2.55.0
ping.
Quoted 47 lines · Brad Smith
util/cutils: Use
getexecpath()on OpenBSD forqemu_init_exec_dir()OpenBSD has introduced a function
getexecpath()to be able to retrieve the executable name and path.Signed-off-by Brad Smith <[email protected]>--- meson.build | 8 ++++++++ util/cutils.c | 6 ++++++ 2 files changed, 14 insertions(+)meson.build +8
-0@@ -3034,6 +3034,14 @@ config_host_data.set('CONFIG_ELF_AUX_INFO', cc.links(osdep_prefix + ''' return hwcap; }''')) +config_host_data.set('CONFIG_GETEXECPATH', cc.links(osdep_prefix + ''' + #include <limits.h> + #include <unistd.h> + int main(void) { + char buf[PATH_MAX]; + getexecpath(buf, sizeof(buf)); + }''')) + config_host_data.set('CONFIG_USBFS', have_linux_user and cc.compiles(''' #include <linux/usbdevice_fs.h>util/cutils.c +6
-0@@ -1091,6 +1091,12 @@ void qemu_init_exec_dir(const char *argv0) p = buf; } } +#elif defined(__OpenBSD__) && defined(CONFIG_GETEXECPATH) + { +if (getexecpath (buf,sizeof (buf)) ==0 ) { + p = buf; + } + }#elif defined(__APPLE__) {char fpath[PATH_MAX ];
Quoted 10 lines · Brad Smith
util/cutils: Use
getexecpath()on OpenBSD forqemu_init_exec_dir()OpenBSD has introduced a function
getexecpath()to be able to retrieve the executable name and path.Signed-off-by Brad Smith <[email protected]>--- meson.build | 8 ++++++++ util/cutils.c | 6 ++++++ 2 files changed, 14 insertions(+)
Reviewed-by Daniel P. Berrangé <[email protected]>
I'll include this if no one else picks it up before my next misc pull request
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|