~wgrant/ubuntu/quantal/lxc/bug-1050351

« back to all changes in this revision

Viewing changes to src/lxc/conf.c

  • Committer: Serge Hallyn
  • Date: 2012-09-13 03:44:17 UTC
  • Revision ID: serge.hallyn@ubuntu.com-20120913034417-6e0r9x73ry1ion1y
0216-hook-kmsg-to-console: link /dev/kmsg to /dev/console so init log
messages can be seen.  (LP: #1049926)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1054
1054
        return setup_ttydir_console(rootfs, console, ttydir);
1055
1055
}
1056
1056
 
 
1057
static int setup_kmsg(const struct lxc_rootfs *rootfs,
 
1058
                       const struct lxc_console *console)
 
1059
{
 
1060
        char cpath[MAXPATHLEN], kpath[MAXPATHLEN];
 
1061
 
 
1062
        ret = snprintf(cpath, sizeof(kpath), "%s/dev/console", rootfs->mount);
 
1063
        if (ret < 0 || ret >= sizeof(kpath))
 
1064
                return -1;
 
1065
        ret = snprintf(kpath, sizeof(kpath), "%s/dev/kmsg", rootfs->mount);
 
1066
        if (ret < 0 || ret >= sizeof(kpath))
 
1067
                return -1;
 
1068
 
 
1069
        ret = unlink(kpath);
 
1070
        if (ret && errno != ENOENT) {
 
1071
                SYSERROR("error unlinking %s\n", kpath);
 
1072
                return -1;
 
1073
        }
 
1074
 
 
1075
        ret = symlink(cpath, kpath);
 
1076
        if (ret) {
 
1077
                SYSERROR("failed to create symlink for kmsg");
 
1078
                return -1;
 
1079
        }
 
1080
 
 
1081
        return 0;
 
1082
}
 
1083
 
1057
1084
static int setup_cgroup(const char *name, struct lxc_list *cgroups)
1058
1085
{
1059
1086
        struct lxc_list *iterator;
2207
2234
                return -1;
2208
2235
        }
2209
2236
 
 
2237
        if (setup_kmsg(&lxc_conf->rootfs, &lxc_conf->console)) {
 
2238
                ERROR("failed to setup kmsg for '%s'", name);
 
2239
                return -1;
 
2240
        }
 
2241
 
2210
2242
        if (setup_tty(&lxc_conf->rootfs, &lxc_conf->tty_info, lxc_conf->ttydir)) {
2211
2243
                ERROR("failed to setup the ttys for '%s'", name);
2212
2244
                return -1;