[libvirt] [PATCH] storage: Set the perms if the pool target already exists for fs pools

Eric Blake eblake at redhat.com
Mon Jun 18 18:02:27 UTC 2012


On 06/18/2012 03:57 AM, Osier Yang wrote:
> The comment says:
> 
> /* Now create the final dir in the path with the uid/gid/mode
>  * requested in the config. If the dir already exists, just set
>  * the perms.
>  */
> 
> However, virDirCreate is only invoked if the target path doesn't
> exist yet (which is opposite with the comment), or the uid from
> the config is not -1 (I don't understand why, think it's just
> another mistake). And the result is the perms of the pool won't
> be changed if one tries to build the pool with different perms
> again.
> 
> Besides these logic error fix, if no uid and gid are specified in
> the config, the practical used uid, gid are reflected.

> -        uid_t uid = (pool->def->target.perms.uid == -1)
> -            ? getuid() : pool->def->target.perms.uid;
> -        gid_t gid = (pool->def->target.perms.gid == -1)
> -            ? getgid() : pool->def->target.perms.gid;
> -

> +    uid = (pool->def->target.perms.uid == -1)

Pre-existing, but comparison of uid_t against -1 is not portable; you
need an explicit cast:

pool->def->target.perms-uid == (uid_t) -1

>  
> +    /* Reflect the actual uid and gid to the config. */
> +    if (pool->def->target.perms.uid == -1)
> +        pool->def->target.perms.uid = uid;
> +    if (pool->def->target.perms.gid == -1)
> +        pool->def->target.perms.gid = gid;

And again.
-- 
Eric Blake   eblake at 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: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120618/885d4b35/attachment-0001.sig>


More information about the libvir-list mailing list