while ((ch = getopt(argc, argv, "f:t:")) != -1) {
while ((ch = getopt(argc, argv, "f:")) != -1) {
main(int argc, char *argv[]){	struct commands *comp;	struct mtget mt_status;	struct mtop mt_com;	int ch, len, mtfd, flags;	char *p, *tape, *realtape;	if ((progname = strrchr(argv[0], '/')))		progname++;	else		progname = argv[0];	if (strcmp(progname, "eject") == 0) {		eject = 1;		tape = NULL;	} else {		if ((tape = getenv("TAPE")) == NULL)			tape = _PATH_DEFTAPE;	}	while ((ch = getopt(argc, argv, "f:t:")) != -1) {		switch (ch) {		case 'f':		case 't':			tape = optarg;			break;		default:			usage();		}	}	argc -= optind;	argv += optind;	if (eject) {		if (argc == 1) {			tape = *argv++;			argc--;		}		if (argc != 0)			usage();	} else if (argc < 1 || argc > 2)		usage();	if (tape == NULL)		usage();	if (strchr(tape, ':')) {		host = tape;		tape = strchr(host, ':');		*tape++ = '\0';		if (rmthost(host) == 0)			exit(X_ABORT);	}	if (eject)		comp = &com[COM_EJECT];	else {		len = strlen(p = *argv++);		for (comp = com;; comp++) {			if (comp->c_name == NULL)				errx(1, "%s: unknown command", p);			if (strncmp(p, comp->c_name, len) == 0)				break;		}	}	flags = comp->c_ronly ? O_RDONLY : O_WRONLY | O_CREAT;	if ((mtfd = host ? rmtopen(tape, flags) : opendev(tape, flags,	    OPENDEV_PART | OPENDEV_DRCT, &realtape)) < 0) {		if (errno != 0)			warn("%s", host ? tape : realtape);		exit(2);	}	if (comp->c_code != MTNOP) {		mt_com.mt_op = comp->c_code;		if (*argv) {			mt_com.mt_count = strtol(*argv, &p, 10);			if (mt_com.mt_count < comp->c_mincount || *p)				errx(2, "%s: illegal count", *argv);		}		else			mt_com.mt_count = 1;		if ((host ? rmtioctl(mt_com.mt_op, mt_com.mt_count) :		    ioctl(mtfd, MTIOCTOP, &mt_com)) < 0)			err(2, "%s: %s", tape, comp->c_name);	} else {		if (host)			status(rmtstatus());		else {			if (ioctl(mtfd, MTIOCGET, &mt_status) < 0)				err(2, "ioctl MTIOCGET");			status(&mt_status);		}	}	if (host)		rmtclose();	exit(X_FINOK);	/* NOTREACHED */}