X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvattribute.c;h=86e90bab612f7ea50f6bff412ca6446545ab4e06;hb=88847d302dd8df68f18a2f02a13ca579a83fb26f;hp=b3fd69d9a64c6407e6d217aa95299bf006ad53e0;hpb=92cc2793f07b1925c27da50f3dd58520b62e49d5;p=util-vserver.git diff --git a/src/vattribute.c b/src/vattribute.c index b3fd69d..86e90ba 100644 --- a/src/vattribute.c +++ b/src/vattribute.c @@ -21,6 +21,7 @@ #endif #include "util.h" +#include "attribute-util.h" #include #include @@ -156,60 +157,18 @@ parseSecure(struct vc_ctx_flags UNUSED * flags, flags->mask = VC_VXF_HIDE_NETIF; } -static inline int -ffsull(unsigned long long word) -{ - int bit; - for (bit = 0; bit < 64; bit++) { - if (word & (1ULL << bit)) - break; - } - if (bit == 64) - bit = 0; - return bit; -} - static int printAttrs(struct Arguments *args) { struct vc_ctx_flags flags; struct vc_ctx_caps caps; - int first; Evc_get_cflags(args->xid, &flags); Evc_get_ccaps(args->xid, &caps); -#define PRINT_VALUES(type, name, var) \ - WRITE_MSG(1, name ":\n"); \ - first = 1; \ - while (1) { \ - char const *i; \ - i = vc_lo ## type ## 2text(var); \ - if (!i) \ - break; \ - if (!first) \ - WRITE_MSG(1, ","); \ - else \ - first = 0; \ - WRITE_STR(1, i); \ - } \ - while (*(var)) { \ - int bit = ffsull(*(var)); \ - if (!bit) \ - break; \ - if (!first) \ - WRITE_MSG(1, ","); \ - else \ - first = 0; \ - WRITE_MSG(1, "^"); \ - WRITE_INT(1, bit); \ - *(var) &= ~(1ULL << bit); \ - } \ - WRITE_MSG(1, "\n"); - - PRINT_VALUES(bcap, "bcapabilities", &caps.bcaps); - PRINT_VALUES(ccap, "ccapabilities", &caps.ccaps); - PRINT_VALUES(cflag, "flags", &flags.flagword); + print_bitfield(1, bcap, "bcapabilities", &caps.bcaps); + print_bitfield(1, ccap, "ccapabilities", &caps.ccaps); + print_bitfield(1, cflag, "flags", &flags.flagword); return 0; }