|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1982, 1986, 1988 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution and use in source and binary forms are permitted ! 6: * provided that the above copyright notice and this paragraph are ! 7: * duplicated in all such forms and that any documentation, ! 8: * advertising materials, and other materials related to such ! 9: * distribution and use acknowledge that the software was developed ! 10: * by the University of California, Berkeley. The name of the ! 11: * University may not be used to endorse or promote products derived ! 12: * from this software without specific prior written permission. ! 13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 16: * ! 17: * @(#)dev.c 7.4 (Berkeley) 6/29/88 ! 18: */ ! 19: ! 20: #include "param.h" ! 21: #include "inode.h" ! 22: #include "fs.h" ! 23: #include "saio.h" ! 24: ! 25: /* ! 26: * NB: the value "io->i_ino.i_dev", used to offset the devsw[] array ! 27: * in the routines below, is munged by the vaxstand Makefile to work ! 28: * for certain boots. ! 29: */ ! 30: ! 31: devread(io) ! 32: register struct iob *io; ! 33: { ! 34: int cc; ! 35: ! 36: io->i_flgs |= F_RDDATA; ! 37: io->i_error = 0; ! 38: cc = (*devsw[io->i_ino.i_dev].dv_strategy)(io, READ); ! 39: io->i_flgs &= ~F_TYPEMASK; ! 40: return (cc); ! 41: } ! 42: ! 43: devwrite(io) ! 44: register struct iob *io; ! 45: { ! 46: int cc; ! 47: ! 48: io->i_flgs |= F_WRDATA; ! 49: io->i_error = 0; ! 50: cc = (*devsw[io->i_ino.i_dev].dv_strategy)(io, WRITE); ! 51: io->i_flgs &= ~F_TYPEMASK; ! 52: return (cc); ! 53: } ! 54: ! 55: devopen(io) ! 56: register struct iob *io; ! 57: { ! 58: int ret; ! 59: ! 60: if (!(ret = (*devsw[io->i_ino.i_dev].dv_open)(io))) ! 61: return (0); ! 62: printf("%s(%d,%d,%d,%d): ", devsw[io->i_ino.i_dev].dv_name, ! 63: io->i_adapt, io->i_ctlr, io->i_unit, io->i_part); ! 64: switch(ret) { ! 65: case EIO: ! 66: break; /* already reported */ ! 67: case EADAPT: ! 68: printf("bad adaptor number\n"); ! 69: break; ! 70: case ECTLR: ! 71: printf("bad controller number\n"); ! 72: break; ! 73: case EUNIT: ! 74: printf("bad drive number\n"); ! 75: break; ! 76: case EPART: ! 77: printf("bad partition\n"); ! 78: break; ! 79: case ERDLAB: ! 80: printf("can't read disk label\n"); ! 81: break; ! 82: case EUNLAB: ! 83: printf("unlabeled\n"); ! 84: break; ! 85: case ENXIO: ! 86: printf("bad device specification\n"); ! 87: break; ! 88: default: ! 89: printf("unknown open error\n"); ! 90: break; ! 91: } ! 92: return (ret); ! 93: } ! 94: ! 95: devclose(io) ! 96: register struct iob *io; ! 97: { ! 98: (*devsw[io->i_ino.i_dev].dv_close)(io); ! 99: } ! 100: ! 101: devioctl(io, cmd, arg) ! 102: register struct iob *io; ! 103: int cmd; ! 104: caddr_t arg; ! 105: { ! 106: return ((*devsw[io->i_ino.i_dev].dv_ioctl)(io, cmd, arg)); ! 107: } ! 108: ! 109: /*ARGSUSED*/ ! 110: nullsys(io) ! 111: struct iob *io; ! 112: {} ! 113: ! 114: /*ARGSUSED*/ ! 115: nodev(io) ! 116: struct iob *io; ! 117: { ! 118: errno = EBADF; ! 119: } ! 120: ! 121: /*ARGSUSED*/ ! 122: noioctl(io, cmd, arg) ! 123: struct iob *io; ! 124: int cmd; ! 125: caddr_t arg; ! 126: { ! 127: return (ECMD); ! 128: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.