home *** CD-ROM | disk | FTP | other *** search
- wn(7) ioctls
-
-
- EXAMPLE
- main()
- {
- int fd;
- char dummyblock[512], mbb[512];
-
- if ((fd = open("/dev/dsk/0s0", O_RDWR)) == -1) {
- fprintf(stderr, "Can't open drive, errno=%d\n", errno);
- exit(errno);
- }
-
- /*
- ** WHY is this needed???
- */
-
- read(fd,dummyblock,512); /* dummy read to force wnsweep */
-
- read_sector( fd, mbb, 0, 0, 1 ); /* read Master Boot Block */
-
- /* user code to modify it ... */
-
- write_sector( fd, mbb, 0, 0, 1 ); /* and write it back */
-
- close( fd );
- }
-
-
- read_sector(fd, buf, cyl, head, sector)
- dev_t fd;
- byte *buf,head,sector;
- int cyl;
- {
- int i;
- struct i1010iopb *io, iopb;
-
- io = &iopb;
- io->i_addr = (long) buf;
- io->i_actcylinder = cyl;
- io->i_acthead = head;
- io->i_sector = sector;
- io->i_funct = WD_READ_OP;
- i = ioctl(fd,I1010_RAWIO,io);
- if (i)
- fprintf(stderr, "\nread_sector(C=%d, H=%d, S=%d) errno= %d\n",
- cyl, head, sector, i);
- return(i);
- }
-
- write_sector(fd,buf,cyl,head,sector)
- dev_t fd;
- byte *buf,head,sector;
- int cyl;
- {
- int i;
- struct i1010iopb *io, iopb;
-
- io = &iopb;
- io->i_addr = (long) buf;
- io->i_actcylinder = cyl;
- io->i_acthead = head;
- io->i_sector = sector;
- io->i_funct = WD_WRITE_OP;
- i = ioctl(fd, I1010_RAWIO, io);
- if (i)
- fprintf(stderr, "\nwrite_sector(C=%d, H=%d, S=%d) errno= %d\n",
- cyl, head, sector, i);
- return(i);
- }
-
- raw_io(fd,buf,cyl,head,sector,op)
- dev_t fd;
- byte *buf,head,sector;
- int cyl,op;
- {
- int i;
- struct i1010iopb *io, iopb;
-
- io = &iopb;
- io->i_addr = (long) buf;
- io->i_actcylinder = cyl;
- io->i_acthead = head;
- io->i_sector = sector;
- io->i_funct = op;
- i = ioctl(fd, I1010_RAWIO, io);
- if (i) printf("\nRaw I/O(C=%d H=%d S=%d op=%d) errno= %d\n",
- cyl, head, sector, op, i);
- return(i);
- }
-
-