Re: [PATCH 1/9] Add helpers for resolving path to resources in build tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
>  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

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]