MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / status_capability

Function status_capability

e2e/support/capbset-probe.c:14–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12#include <sys/prctl.h>
13
14static unsigned long long status_capability(const char *field) {
15 FILE *status = fopen("/proc/self/status", "r");
16 if (status == NULL) {
17 perror("fopen(/proc/self/status)");
18 exit(EXIT_FAILURE);
19 }
20
21 char line[256];
22 unsigned long long value = 0;
23 int found = 0;
24 while (fgets(line, sizeof(line), status) != NULL) {
25 char name[32];
26 unsigned long long candidate;
27 if (sscanf(line, "%31[^:]:%llx", name, &candidate) == 2 &&
28 strcmp(name, field) == 0) {
29 value = candidate;
30 found = 1;
31 break;
32 }
33 }
34 fclose(status);
35
36 if (!found) {
37 fprintf(stderr, "missing %s in /proc/self/status\n", field);
38 exit(EXIT_FAILURE);
39 }
40 return value;
41}
42
43static void print_apparmor_profile(void) {
44 FILE *profile = fopen("/proc/self/attr/current", "r");

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected