This is mtset.c in view mode; [Download] [Up]
/*
* mtset - set SCSI tape driver characteristics
*
* setmtd - set SCSI tape driver to a fixed block size
* by John L. Chmielewski
* Tue Feb 19, 1991
*
* Modified to take drive name argument and default to non-rewinding mode:
* by David D. Johnson (ddj@gradient.com)
* Sun Feb 24, 1991
*
* Modified to use switches to change tape device name and characteristics:
* mtset [-d name] [-f size] [-i]
* -d tape device name (default /dev/nrst0)
* -f Sets the driver to fixed block mode, uses
* argument of block size in bytes (default 512 bytes),
* Variable block mode is default.
* -i Inhibit illegal length (default is to allow illegal length)
*/
/*
USE AT YOUR OUR RISK.
I NOT NOT BE RESPONSIBLE FOR PROBLEM CAUSED BY THIS PROGRAM.
*/
#include <fcntl.h>
#include <stdio.h>
#include <sys/types.h>
#include <nextdev/scsireg.h>
#define RSTDEVICE "/dev/nrst0"
#define BLOCKSIZE 512
main(int argc, char *argv[])
{
extern int optind;
extern char *optarg;
int fd;
int defsize = BLOCKSIZE;
int size = BLOCKSIZE;
char *deffile = RSTDEVICE;
char *file = RSTDEVICE;
u_int mode = MTIOCVARBLK;
u_int inhibit = MTIOCALILL;
char c;
while ((c = getopt(argc, argv, "d:f:i")) != EOF) {
switch (c) {
case 'd':
file = optarg;
break;
case 'f':
mode = MTIOCFIXBLK;
size = atoi(optarg);
break;
case 'i':
inhibit = MTIOCINILL;
break;
default:
fprintf(stderr,
"usage: %s [-d device] [-f block-size] [-i]\n",
argv[0]);
fprintf(stderr,
" -d tape device name (default %s)\n",
deffile);
fprintf(stderr,
" -f set fix block mode with size (default size %d)\n",
defsize);
fprintf(stderr,
" -i Inhibit illegal length\n");
fprintf(stderr,
" default: variable block mode, allow illegal length\n");
exit(1);
}
}
if ((fd = open(file, O_RDWR)) < 0) {
perror(file);
exit(1);
}
if (ioctl(fd, mode, &size) < 0) {
perror("ioctl");
exit(1);
}
if (ioctl(fd, inhibit) < 0) {
perror("ioctl");
exit(1);
}
(void) close(fd);
return 0;
}These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.