diff options
author | neel <neel@FreeBSD.org> | 2012-10-12 18:14:54 +0000 |
---|---|---|
committer | neel <neel@FreeBSD.org> | 2012-10-12 18:14:54 +0000 |
commit | 4829fce72f3af3b96bc018ac20f556ee33b7f44f (patch) | |
tree | 7cf30aab77e309e47a09d5392208572784beb069 | |
parent | a62f9562ca8f5ed0f5099962cb864c87a2a2865c (diff) | |
download | FreeBSD-src-4829fce72f3af3b96bc018ac20f556ee33b7f44f.zip FreeBSD-src-4829fce72f3af3b96bc018ac20f556ee33b7f44f.tar.gz |
Output the value of all capabilities when the "--getcap" option is used without
a "--capname=<capname>". Do the same for the "--get-all" option.
-rw-r--r-- | usr.sbin/vmmctl/vmmctl.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/usr.sbin/vmmctl/vmmctl.c b/usr.sbin/vmmctl/vmmctl.c index acd7338..331bd728 100644 --- a/usr.sbin/vmmctl/vmmctl.c +++ b/usr.sbin/vmmctl/vmmctl.c @@ -1479,14 +1479,27 @@ main(int argc, char *argv[]) } if (!error && (getcap || get_all)) { - int captype, val; - captype = vm_capability_name2type(capname); - error = vm_get_capability(ctx, vcpu, captype, &val); - if (error == 0) { - printf("Capability \"%s\" is %s on vcpu %d\n", capname, - val ? "set" : "not set", vcpu); - } else if (errno == ENOENT) { - printf("Capability \"%s\" is not available\n", capname); + int captype, val, getcaptype; + + if (getcap && capname) + getcaptype = vm_capability_name2type(capname); + else + getcaptype = -1; + + for (captype = 0; captype < VM_CAP_MAX; captype++) { + if (getcaptype >= 0 && captype != getcaptype) + continue; + error = vm_get_capability(ctx, vcpu, captype, &val); + if (error == 0) { + printf("Capability \"%s\" is %s on vcpu %d\n", + vm_capability_type2name(captype), + val ? "set" : "not set", vcpu); + } else if (errno == ENOENT) { + printf("Capability \"%s\" is not available\n", + vm_capability_type2name(captype)); + } else { + break; + } } } |