| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
#ifdef HAVE_CONFIG_H |
|---|
| 20 |
# include <config.h> |
|---|
| 21 |
#endif |
|---|
| 22 |
|
|---|
| 23 |
#include "vserver.h" |
|---|
| 24 |
#include <string.h> |
|---|
| 25 |
#include <assert.h> |
|---|
| 26 |
|
|---|
| 27 |
#define DECL(STR, VAL) { STR, sizeof(STR)-1, VAL } |
|---|
| 28 |
|
|---|
| 29 |
static struct { |
|---|
| 30 |
char const * const id; |
|---|
| 31 |
size_t len; |
|---|
| 32 |
unsigned char val; |
|---|
| 33 |
} const FLAGVALUES[] = { |
|---|
| 34 |
DECL("lock", S_CTX_INFO_LOCK), |
|---|
| 35 |
DECL("sched", S_CTX_INFO_SCHED), |
|---|
| 36 |
DECL("nproc", S_CTX_INFO_NPROC), |
|---|
| 37 |
DECL("private", S_CTX_INFO_PRIVATE), |
|---|
| 38 |
DECL("fakeinit", S_CTX_INFO_INIT), |
|---|
| 39 |
DECL("hideinfo", S_CTX_INFO_HIDEINFO), |
|---|
| 40 |
DECL("ulimit", S_CTX_INFO_ULIMIT), |
|---|
| 41 |
DECL("namespace", S_CTX_INFO_NAMESPACE), |
|---|
| 42 |
}; |
|---|
| 43 |
|
|---|
| 44 |
uint_least32_t |
|---|
| 45 |
vc_text2cflag_compat(char const *str, size_t len) |
|---|
| 46 |
{ |
|---|
| 47 |
size_t i; |
|---|
| 48 |
if (len==0) len=strlen(str); |
|---|
| 49 |
|
|---|
| 50 |
for (i=0; i<sizeof(FLAGVALUES)/sizeof(FLAGVALUES[0]); ++i) |
|---|
| 51 |
if (len==FLAGVALUES[i].len && |
|---|
| 52 |
strncmp(FLAGVALUES[i].id, str, len)==0) |
|---|
| 53 |
return FLAGVALUES[i].val; |
|---|
| 54 |
|
|---|
| 55 |
return 0; |
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
char const * |
|---|
| 59 |
vc_hicflag2text_compat(uint_least32_t val) |
|---|
| 60 |
{ |
|---|
| 61 |
size_t i; |
|---|
| 62 |
size_t idx; |
|---|
| 63 |
|
|---|
| 64 |
assert(S_CTX_INFO_ULIMIT==64); |
|---|
| 65 |
|
|---|
| 66 |
for (i=S_CTX_INFO_ULIMIT, idx=6; i>0; i/=2, --idx) |
|---|
| 67 |
if (val & i) return FLAGVALUES[idx].id; |
|---|
| 68 |
|
|---|
| 69 |
return 0; |
|---|
| 70 |
} |
|---|