criu: cleanup load_tty_major_minor()

parent 53c6fcb7
...@@ -79,36 +79,26 @@ struct criu_opts { ...@@ -79,36 +79,26 @@ struct criu_opts {
static int load_tty_major_minor(char *directory, char *output, int len) static int load_tty_major_minor(char *directory, char *output, int len)
{ {
FILE *f;
char path[PATH_MAX]; char path[PATH_MAX];
int ret; ssize_t ret;
ret = snprintf(path, sizeof(path), "%s/tty.info", directory); ret = snprintf(path, sizeof(path), "%s/tty.info", directory);
if (ret < 0 || ret >= sizeof(path)) { if (ret < 0 || (size_t)ret >= sizeof(path))
ERROR("snprintf'd too many characters: %d", ret); return ret_errno(EIO);
return -1;
}
f = fopen(path, "re"); ret = lxc_read_from_file(path, output, len);
if (!f) { if (ret < 0) {
/* This means we're coming from a liblxc which didn't export /*
* This means we're coming from a liblxc which didn't export
* the tty info. In this case they had to have lxc.console.path * the tty info. In this case they had to have lxc.console.path
* = * none, so there's no problem restoring. * = * none, so there's no problem restoring.
*/ */
if (errno == ENOENT) if (errno == ENOENT)
return 0; return 0;
SYSERROR("couldn't open %s", path); return log_error_errno(-errno, errno, "Failed to open \"%s\"", path);
return -1;
} }
if (!fgets(output, len, f)) {
fclose(f);
SYSERROR("couldn't read %s", path);
return -1;
}
fclose(f);
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment