vconsole-setup.c revision 97c4a07df982ee967705022feaba9be33947abf0
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Kay Sievers
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <ctype.h>
#include <stdbool.h>
#include <stdarg.h>
#include <limits.h>
#include <locale.h>
#include <langinfo.h>
#include "util.h"
#include "log.h"
#include "macro.h"
static bool is_console(int fd) {
unsigned char data[1];
data[0] = TIOCL_GETFGCONSOLE;
}
static bool is_locale_utf8(void) {
const char *set;
return true;
if (!set)
return true;
}
static int disable_utf8(int fd) {
int r = 0, k;
r = -errno;
r = -errno;
r = k;
if (r < 0)
return r;
}
const char *args[7];
int i = 0;
args[i++] = "-q";
args[i++] = "-C";
if (utf8)
args[i++] = "-u";
log_error("Failed to fork: %m");
return -errno;
} else if (pid == 0) {
}
return 0;
}
static int load_font(const char *vc, const char *font, const char *map, const char *unimap, pid_t *_pid) {
const char *args[9];
int i = 0;
args[i++] = "-C";
if (map) {
args[i++] = "-m";
}
if (unimap) {
args[i++] = "-u";
}
log_error("Failed to fork: %m");
return -errno;
} else if (pid == 0) {
}
return 0;
}
const char *vc;
char *vc_font_map = NULL;
char *vc_font_unimap = NULL;
int fd = -1;
bool utf8;
int r = EXIT_FAILURE;
log_open();
if (argv[1])
else
goto finish;
}
if (!is_console(fd)) {
goto finish;
}
if (!(utf8 = is_locale_utf8()))
if ((r = parse_env_file(
"VCONSOLE_KEYMAP", &vc_keymap,
"VCONSOLE_FONT", &vc_font,
"VCONSOLE_FONT_MAP", &vc_font_map,
"VCONSOLE_FONT_UNIMAP", &vc_font_unimap,
NULL)) < 0) {
if (r != -ENOENT)
}
if ((r = parse_env_file(
#ifdef TARGET_FEDORA
"SYSFONT", &vc_font,
"KEYTABLE", &vc_keymap,
#endif
"vconsole.keymap", &vc_keymap,
"vconsole.font", &vc_font,
"vconsole.font.map", &vc_font_map,
"vconsole.font.unimap", &vc_font_unimap,
NULL)) < 0) {
if (r != -ENOENT)
}
if (!vc_keymap)
if (!vc_font)
log_error("Failed to allocate strings.");
goto finish;
}
r = EXIT_SUCCESS;
if (keymap_pid > 0)
if (font_pid > 0)
if (fd >= 0)
return r;
}