Пример #1
0
static int
rmtreply(char *cmd)
{
	char code[30], emsg[BUFSIZ];

	rmtgets(code, sizeof (code));
	if (*code == 'E' || *code == 'F') {
		rmtgets(emsg, sizeof (emsg));
		/*
		 * don't print error message for ioctl or status;
		 * or if we are opening up a full path (i.e. device)
		 * and the tape is not loaded (EIO error)
		 */
		if (strcmp(cmd, "ioctl") != 0 &&
		    strcmp(cmd, "status") != 0 &&
		    !(cmd[0] == '/' && atoi(code + 1) == EIO))
			print("%s: %s\n", cmd, emsg);
		errno = atoi(code + 1);
		if (*code == 'F') {
			rmtstate = TS_CLOSED;
			return (-1);
		}
		return (-1);
	}
	if (*code != 'A') {
		print(dgettext(domainname,
			"Protocol to remote tape server botched (code %s?).\n"),
			code);
		rmtconnaborted(0);
	}
	return (atoi(code + 1));
}
Пример #2
0
static int
rmtreply(const char *cmd)
{
	char *cp;
	char code[30], emsg[BUFSIZ];

	rmtgets(code, sizeof (code));
	if (*code == 'E' || *code == 'F') {
		rmtgets(emsg, sizeof (emsg));
		msg("%s: %s", cmd, emsg);
		errno = atoi(code + 1);
		if (*code == 'F')
			rmtstate = TS_CLOSED;
		return (-1);
	}
	if (*code != 'A') {
		/* Kill trailing newline */
		cp = code + strlen(code);
		if (cp > code && *--cp == '\n')
			*cp = '\0';

		msg("Protocol to remote tape server botched (code \"%s\").\n",
		    code);
		rmtconnaborted(0);
	}
	return (atoi(code + 1));
}