Mercurial > hg > toybox
annotate toys/unshare.c @ 533:31215cc6c9f2
Consolidate headers.
author | Rob Landley <rob@landley.net> |
---|---|
date | Wed, 07 Mar 2012 19:04:50 -0600 |
parents | 8b0487639db9 |
children | f70187762108 |
rev | line source |
---|---|
398 | 1 /* vi: set sw=4 ts=4: |
2 * | |
3 * unshare.c - run command in new context | |
4 * | |
5 * Copyright 2011 Rob Landley <rob@landley.net> | |
6 * | |
7 * Not in SUSv4. | |
8 | |
9 USE_UNSHARE(NEWTOY(unshare, "<1^nium", TOYFLAG_USR|TOYFLAG_BIN)) | |
10 | |
11 config UNSHARE | |
12 bool "unshare" | |
13 default y | |
426
8b0487639db9
Add autodetect for container support.
Rob Landley <rob@landley.net>
parents:
398
diff
changeset
|
14 depends on TOYBOX_CONTAINER |
398 | 15 help |
16 usage: unshare [-muin] COMMAND... | |
17 | |
18 Create new namespace(s) for this process and its children, so some | |
19 attribute is not shared with the parent process. This is part of | |
20 Linux Containers. Each process can have its own: | |
21 | |
22 -m Mount/unmount tree | |
23 -u Host and domain names | |
24 -i SysV IPC (message queues, semaphores, shared memory) | |
25 -n Network address, sockets, routing, iptables | |
26 */ | |
27 | |
28 #include "toys.h" | |
29 | |
30 void unshare_main(void) | |
31 { | |
32 unsigned flags[]={CLONE_NEWNS, CLONE_NEWUTS, CLONE_NEWIPC, CLONE_NEWNET,0}; | |
33 unsigned f=0; | |
34 int i; | |
35 | |
36 for (i=0; flags[i]; i++) | |
37 if (toys.optflags & (1<<i)) | |
38 f |= flags[i]; | |
39 | |
40 if(unshare(f)) perror_exit("failed"); | |
41 | |
42 xexec(toys.optargs); | |
43 } |