home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.sys.sun.hardware:3455 comp.sys.sun.misc:3264
- Newsgroups: comp.sys.sun.hardware,comp.sys.sun.misc
- Path: sparky!uunet!island!coney!hue
- From: hue@island.COM (Pond Scum)
- Subject: Re: Better format program
- Message-ID: <hue.711742829@coney>
- Sender: usenet@island.COM (The Usenet mail target)
- Organization: Island Graphics Corp.
- References: <1992Jul20.083045.8775@newsroom.bsc.no>
- Date: Tue, 21 Jul 1992 18:20:29 GMT
- Lines: 58
-
- md@bsc.no (Mark Dapoz) writes:
- >Does anyone know if there's available somewhere a format program for SCSI
- >disks which is a little more flexible than the one provided by SunOS? I
- >have a rather peculiar SCSI drive that needs to have some unique pages
- >set up via the Mode Select command before doing the format. The SunOS
-
- There is a company that sells a formatting program, but I don't know if it
- would allow you to do what you need to do. They have ads in the Sun rags.
-
- >for such a program would be appreciated. Alternative if someone could
- >provide enough detail on how to talk directly to the scsi device driver
-
- This code uses an ioctl to read block 0 off of a SCSI disk. You should be
- able to use the same ioctl to do the mode selects (I think). I once read
- that the sd driver supports the uscsi.h ioctls, but I've never tried it so
- I can't say whether or not it works. If it does, it would probably be a
- better way to go. Remember, if you are opening an unlabeled or unformatted
- device, or in the O_NDELAY flag into the open(), otherwise the open will
- fail.
-
- -Jonathan hue@island.COM
-
- ------------------------------------------------------------------------------
-
- #include <fcntl.h>
- #include <sun/dkio.h>
- #include <scsi/generic/commands.h>
- #include <errno.h>
- #include <stdio.h>
-
- char buf[512];
-
- main()
- {
- int fd;
- static struct dk_cmd rcmd =
- {
- SCMD_READ, DK_DIAGNOSE, 0, 0, 0, 0
- };
-
-
- if ((fd = open("/dev/rsd3c", O_NDELAY)) < 0)
- {
- perror("open");
- exit(1);
- }
- rcmd.dkc_blkno = 0;
- rcmd.dkc_secnt = 1;
- rcmd.dkc_bufaddr = buf;
- rcmd.dkc_buflen = sizeof(buf);
- if (ioctl(fd, DKIOCSCMD, &rcmd) < 0)
- {
- perror("ioctl");
- exit(2);
- }
- write(fileno(stdout), buf, sizeof(buf));
- exit(0);
- }
-