~serge-hallyn/ubuntu/natty/lxc/lxc-fix-3bugs

« back to all changes in this revision

Viewing changes to src/lxc/lxc_init.c

  • Committer: Bazaar Package Importer
  • Author(s): Guido Trotter, Stéphane Graber, Guido Trotter
  • Date: 2010-01-10 10:40:21 UTC
  • mfrom: (1.1.2 upstream) (3.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100110104021-z8rj5zw5mlvra08l
Tags: 0.6.4-1
[ Stéphane Graber ]
* Upgrade standards-version to 3.8.3
* Drop the copy of etc/* from rules as "etc" is no longer in the tarball

[ Guido Trotter ]
* New Upstream Version
* Update libcap2-dev dependency to libcap-dev
* Install upstream-built man pages via debian/lxc.manpages
* Drop unneeded docbook-utils build dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <errno.h>
28
28
#include <signal.h>
29
29
#include <libgen.h>
 
30
#include <sys/stat.h>
30
31
#include <sys/types.h>
31
32
#include <sys/wait.h>
32
 
#include <sys/mount.h>
33
33
#define _GNU_SOURCE
34
34
#include <getopt.h>
35
 
#include "lxc.h"
 
35
 
 
36
#include <lxc/lxc.h>
 
37
#include <lxc/log.h>
 
38
#include <lxc/utils.h>
 
39
#include <lxc/error.h>
36
40
 
37
41
lxc_log_define(lxc_init, lxc);
38
42
 
47
51
        { 0, 0, 0, 0 },
48
52
};
49
53
 
50
 
static int mount_fs(const char *source, const char *target, const char *type)
51
 
{
52
 
        /* sometimes the umount fails */
53
 
        if (umount(target))
54
 
                WARN("failed to unmount %s : %s", target, strerror(errno));
55
 
 
56
 
        if (mount(source, target, type, 0, NULL)) {
57
 
                ERROR("failed to mount %s : %s", target, strerror(errno));
58
 
                return -1;
59
 
        }
60
 
 
61
 
        DEBUG("'%s' mounted on '%s'", source, target);
62
 
 
63
 
        return 0;
64
 
}
65
 
 
66
 
static inline int setup_fs(void)
67
 
{
68
 
        if (mount_fs("proc", "/proc", "proc"))
69
 
                return -1;
70
 
 
71
 
        if (mount_fs("shmfs", "/dev/shm", "tmpfs"))
72
 
                return -1;
73
 
 
74
 
        return 0;
75
 
}
76
 
 
77
54
int main(int argc, char *argv[])
78
55
{
79
56
        pid_t pid;
113
90
 
114
91
        if (!pid) {
115
92
                
116
 
                if (setup_fs())
 
93
                if (lxc_setup_fs())
117
94
                        exit(err);
118
95
 
119
96
                NOTICE("about to exec '%s'", aargv[0]);
157
134
out:
158
135
        return err;
159
136
}
 
137