[libvirt] [PATCH 1/9] Add helpers for resolving path to resources in build tree
Eric Blake
eblake at redhat.com
Thu Apr 24 20:42:21 UTC 2014
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 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140424/56ed287c/attachment-0001.sig>
More information about the libvir-list
mailing list