133510Sbostic /* 233510Sbostic * Copyright (c) 1982, 1986, 1988 Regents of the University of California. 333510Sbostic * All rights reserved. 433510Sbostic * 533510Sbostic * Redistribution and use in source and binary forms are permitted 633510Sbostic * provided that this notice is preserved and that due credit is given 733510Sbostic * to the University of California at Berkeley. The name of the University 833510Sbostic * may not be used to endorse or promote products derived from this 933510Sbostic * software without specific prior written permission. This software 1033510Sbostic * is provided ``as is'' without express or implied warranty. 1133510Sbostic * 12*34517Skarels * @(#)dev.c 7.3 (Berkeley) 05/27/88 1333510Sbostic */ 1433510Sbostic 1533510Sbostic #include "param.h" 1633510Sbostic #include "inode.h" 1733510Sbostic #include "fs.h" 1833510Sbostic #include "saio.h" 1933510Sbostic 2033670Sbostic /* 2133670Sbostic * NB: the value "io->i_ino.i_dev", used to offset the devsw[] array 2233670Sbostic * in the routines below, is munged by the vaxstand Makefile to work 2333670Sbostic * for certain boots. 2433670Sbostic */ 2533670Sbostic 2633510Sbostic devread(io) 2733510Sbostic register struct iob *io; 2833510Sbostic { 2933510Sbostic int cc; 3033510Sbostic 3133510Sbostic io->i_flgs |= F_RDDATA; 3233510Sbostic io->i_error = 0; 3333510Sbostic cc = (*devsw[io->i_ino.i_dev].dv_strategy)(io, READ); 3433510Sbostic io->i_flgs &= ~F_TYPEMASK; 3533510Sbostic return (cc); 3633510Sbostic } 3733510Sbostic 3833510Sbostic devwrite(io) 3933510Sbostic register struct iob *io; 4033510Sbostic { 4133510Sbostic int cc; 4233510Sbostic 4333510Sbostic io->i_flgs |= F_WRDATA; 4433510Sbostic io->i_error = 0; 4533510Sbostic cc = (*devsw[io->i_ino.i_dev].dv_strategy)(io, WRITE); 4633510Sbostic io->i_flgs &= ~F_TYPEMASK; 4733510Sbostic return (cc); 4833510Sbostic } 4933510Sbostic 5033510Sbostic devopen(io) 5133510Sbostic register struct iob *io; 5233510Sbostic { 5333670Sbostic int ret; 5433670Sbostic 5533670Sbostic if (!(ret = (*devsw[io->i_ino.i_dev].dv_open)(io))) 5633670Sbostic return (0); 5733670Sbostic printf("%s(%d,%d,%d,%d): ", devsw[io->i_ino.i_dev].dv_name, 5833670Sbostic io->i_adapt, io->i_ctlr, io->i_unit, io->i_part); 5933670Sbostic switch(ret) { 60*34517Skarels case EIO: 61*34517Skarels break; /* already reported */ 6233670Sbostic case EADAPT: 63*34517Skarels printf("bad adaptor number\n"); 6433670Sbostic break; 6533670Sbostic case ECTLR: 66*34517Skarels printf("bad controller number\n"); 6733670Sbostic break; 6833670Sbostic case EUNIT: 69*34517Skarels printf("bad drive number\n"); 7033670Sbostic break; 7133670Sbostic case EPART: 7233670Sbostic printf("bad partition\n"); 7333670Sbostic break; 7433670Sbostic case ERDLAB: 7533670Sbostic printf("can't read disk label\n"); 7633670Sbostic break; 7733670Sbostic case EUNLAB: 7833670Sbostic printf("unlabeled\n"); 7933670Sbostic break; 8033670Sbostic case ENXIO: 81*34517Skarels printf("bad device specification\n"); 82*34517Skarels break; 8333670Sbostic default: 84*34517Skarels printf("unknown open error\n"); 85*34517Skarels break; 8633670Sbostic } 8733670Sbostic return (ret); 8833510Sbostic } 8933510Sbostic 9033510Sbostic devclose(io) 9133510Sbostic register struct iob *io; 9233510Sbostic { 9333510Sbostic (*devsw[io->i_ino.i_dev].dv_close)(io); 9433510Sbostic } 9533510Sbostic 9633510Sbostic devioctl(io, cmd, arg) 9733510Sbostic register struct iob *io; 9833510Sbostic int cmd; 9933510Sbostic caddr_t arg; 10033510Sbostic { 10133510Sbostic return ((*devsw[io->i_ino.i_dev].dv_ioctl)(io, cmd, arg)); 10233510Sbostic } 10333510Sbostic 10433510Sbostic /*ARGSUSED*/ 10533510Sbostic nullsys(io) 10633510Sbostic struct iob *io; 10733510Sbostic {} 10833510Sbostic 10933510Sbostic /*ARGSUSED*/ 11033510Sbostic nodev(io) 11133510Sbostic struct iob *io; 11233510Sbostic { 11333510Sbostic errno = EBADF; 11433510Sbostic } 11533510Sbostic 11633510Sbostic /*ARGSUSED*/ 11733510Sbostic noioctl(io, cmd, arg) 11833510Sbostic struct iob *io; 11933510Sbostic int cmd; 12033510Sbostic caddr_t arg; 12133510Sbostic { 12233510Sbostic return (ECMD); 12333510Sbostic } 124