| 56 | namespace ns { |
| 57 | |
| 58 | Try<int> nstype(const string& ns) |
| 59 | { |
| 60 | const hashmap<string, int> nstypes = { |
| 61 | {"mnt", CLONE_NEWNS}, |
| 62 | {"uts", CLONE_NEWUTS}, |
| 63 | {"ipc", CLONE_NEWIPC}, |
| 64 | {"net", CLONE_NEWNET}, |
| 65 | {"user", CLONE_NEWUSER}, |
| 66 | {"pid", CLONE_NEWPID}, |
| 67 | {"cgroup", CLONE_NEWCGROUP} |
| 68 | }; |
| 69 | |
| 70 | Option<int> nstype = nstypes.get(ns); |
| 71 | |
| 72 | if (nstype.isNone()) { |
| 73 | return Error("Unknown namespace '" + ns + "'"); |
| 74 | } |
| 75 | |
| 76 | return nstype.get(); |
| 77 | } |
| 78 | |
| 79 | |
| 80 | Try<string> nsname(int nsType) |