exec-remount remounts proc and sys, to get the right namespaces associated with them.
[util-vserver.git] / src / exec-remount.c
1 // $Id$    --*- c -*--
2
3 // Copyright (C) 2008 Daniel Hokka Zakrisson
4 //  
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; version 2 of the License.
8 //  
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 // GNU General Public License for more details.
13 //  
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18
19 #ifdef HAVE_CONFIG_H
20 #  include <config.h>
21 #endif
22
23 #include "util.h"
24
25 #include <vserver.h>
26
27 #include <getopt.h>
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <unistd.h>
31 #include <sys/mount.h>
32 #include <errno.h>
33
34 #define ENSC_WRAPPERS_PREFIX    "exec-remount: "
35 #define ENSC_WRAPPERS_MOUNT     1
36 #define ENSC_WRAPPERS_UNISTD    1
37 #include <wrappers.h>
38
39 #define CMD_HELP                0x1000
40 #define CMD_VERSION             0x1001
41
42 int             wrapper_exit_code  =  255;
43
44 int main(int argc, char *argv[])
45 {
46         int i = 1;
47         if (vc_isSupported(vcFEATURE_PIDSPACE)) {
48                 /* FIXME: Get options from etc/mtab
49                  *        Get list of filesystems from argv
50                  */
51                 if (umount("proc") == 0)
52                         Emount("proc", "proc", "proc", 0, NULL);
53                 if (umount("sys") == 0)
54                         Emount("sysfs", "sys", "sysfs", 0, NULL);
55         }
56         if (strcmp(argv[i], "--") == 0)
57                 i++;
58         EexecvpD(argv[i], argv+i);
59         /* NOTREACHED */
60         return 1;
61 }