コード例 #1
0
ファイル: rmtlib.c プロジェクト: andreiw/polaris
int
rmtopen(char *tape, int mode)
{
	struct mtget mt;
	char buf[256];
	int fd;

	(void) snprintf(buf, sizeof (buf), "O%s\n%d\n", tape, mode);
	rmtstate = TS_OPEN;
	fd = rmtcall(tape, buf);
	if (fd != -1) {
		/* see if the rmt server supports the extended protocol */
		rmtversion = rmtioctl(-1, 0);

		/*
		 * Some rmt daemons apparently close the connection
		 * when they get a bogus ioctl.  See 1210852 (ignore
		 * the evaluation).  Make sure we can still talk to
		 * the device, re-opening it if necessary.
		 */
		if (rmtversion < 1) {
			if (rmtstatus(&mt) < 0) {
				rmtclose();
				rmtgetconn();
				rmtversion = 0;
			}
		}
	}
	return (fd);
}
コード例 #2
0
ファイル: mt.c プロジェクト: Bluerise/bitrig
struct mtget *
_rmtstatus(int fd)
{
	static struct mtget mt_status;

#ifdef RMT
	if (host)
		return rmtstatus();
#endif
	if (ioctl(fd, MTIOCGET, &mt_status) < 0)
		err(2, "ioctl MTIOCGET");
	return &mt_status;
}