
On 04/24/2014 10:05 AM, Daniel P. Berrange wrote:
Add virFileFindResource which will try to locate files in the local build tree if the calling binary (eg libvirtd or test suite) is being run from the build tree. The corresponding virFileActivateDirOverride should be called at startup passing in argv[0]. This will be examined for evidence of libtool magic binary prefix / sub-directory in order to activate the override.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/Makefile.am | 2 ++ src/libvirt_private.syms | 3 ++ src/util/virfile.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++ src/util/virfile.h | 11 +++++++ 4 files changed, 99 insertions(+)
+ +static bool useDirOverride = false;
C99 guarantees that static variables will initialize false, without an explicit initializer.
+char *virFileFindResourceFull(const char *filename,
+char * +virFileFindResource(const char *filename,
+void virFileActivateDirOverride(const char *argv0)
Not very consistent on whether to have a line break between return type and function name.
+{ + char *file = strrchr(argv0, '/'); + if (!file || file[1] == '\0') + return;
If file[1] == '\0', someone is playing nasty games with their exec() call, because you can't exec a directory :) At least your code is defensive against it. In addition to the 's/none/non/' pointed out in the other thread, ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org