Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Decodes a /proc/PID/status capabilities mask.
* Compile just with `gcc -o cap1 cap1.c`
#include <stdio.h>
#include <stdlib.h>
char *get_cap_name(unsigned short cap_index)
static char *dict[] = {
return dict[cap_index];
int main(int argc, char **argv)
if (argc != 2) {
"Syntax: %s hexa-cap-code.\n", argv[0]);
unsigned long long cap, mask;
unsigned short is_enabled, i;
char *cap_status, *cap_name;
cap = strtoull(argv[1], NULL, 16);
printf("capab.: %016llx\n", cap);
for(mask=1, i=0; i<32; i++, mask<<=1) {
//printf("mask: %016llx\n", mask);
is_enabled = (cap & mask) != 0;
cap_status = is_enabled?"enabled":"disabled";
cap_name = get_cap_name(i);
printf("%s(%d) is %s.\n", cap_name, i, cap_status);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment