On Fri, Jan 10, 2014 at 05:36:39PM +0100, Pino Toscano wrote:
[..]
This still isn't quite what I meant. My meaning was that mode
would be disabled by default (unless all:true).
How about:
int copy_mode, copy_xattributes, copy_ownership;
/* Set defaults. */
if (all)
copy_mode = copy_xattributes = copy_ownership = 1;
else
copy_mode = copy_xattributes = copy_ownership = 0;
/* If set in the original struct, copy those settings overriding
* the defaults.
*/
if ((optargs_bitmask & GUESTFS_COPY_ATTRIBUTES_MODE_BITMASK))
copy_mode = mode;
if ((optargs_bitmask & GUESTFS_COPY_ATTRIBUTES_XATTRIBUTES_BITMASK))
copy_xattributes = xattributes;
if ((optargs_bitmask & GUESTFS_COPY_ATTRIBUTES_OWNERSHIP_BITMASK))
copy_ownership = ownership;
if (!copy_mode && !copy_xattributes && !copy_ownership) {
/* Short-circuit the code, but this *isn't* an error. */
return 0;
}
[...]
if (copy_mode)
// chmod
etc.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages.
http://libguestfs.org