[BACK]Return to xfs_dev-bsd.c CVS log [TXT][DIR] Up to [local] / sys / xfs

Annotation of sys/xfs/xfs_dev-bsd.c, Revision 1.1.1.1

1.1       nbrk        1: /* $OpenBSD: xfs_dev-bsd.c,v 1.10 2004/01/18 21:46:54 beck Exp $
                      2:
                      3:  * Copyright (c) 2004 Bob Beck
                      4:  * Copyright (c) 1995 - 2003 Kungliga Tekniska Högskolan
                      5:  * (Royal Institute of Technology, Stockholm, Sweden).
                      6:  * All rights reserved.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  *
                     12:  * 1. Redistributions of source code must retain the above copyright
                     13:  *    notice, this list of conditions and the following disclaimer.
                     14:  *
                     15:  * 2. Redistributions in binary form must reproduce the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer in the
                     17:  *    documentation and/or other materials provided with the distribution.
                     18:  *
                     19:  * 3. Neither the name of the Institute nor the names of its contributors
                     20:  *    may be used to endorse or promote products derived from this software
                     21:  *    without specific prior written permission.
                     22:  *
                     23:  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
                     24:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     25:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     26:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
                     27:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     28:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     29:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     30:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     31:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     32:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     33:  * SUCH DAMAGE.
                     34:  */
                     35:
                     36: #include <xfs/xfs_locl.h>
                     37: #include <xfs/xfs_message.h>
                     38: #include <xfs/xfs_msg_locl.h>
                     39: #include <xfs/xfs_fs.h>
                     40: #include <xfs/xfs_dev.h>
                     41: #include <xfs/xfs_deb.h>
                     42:
                     43: int
                     44: xfs_devopen(dev_t dev, int flag, int devtype, d_thread_t *proc)
                     45: {
                     46:        NNPFSDEB(XDEBDEV, ("xfsopen dev = %d.%d, flag = %d, devtype = %d\n",
                     47:            major(dev), minor(dev), flag, devtype));
                     48:        return xfs_devopen_common(dev);
                     49: }
                     50:
                     51: int
                     52: xfs_devclose(dev_t dev, int flag, int devtype, d_thread_t *p)
                     53: {
                     54:        NNPFSDEB(XDEBDEV, ("xfs_devclose dev = %d(%d), flag = 0x%x\n",
                     55:           major(dev), minor(dev), flag));
                     56:
                     57:        return xfs_devclose_common(dev, p);
                     58: }
                     59:
                     60: int
                     61: xfs_devioctl(dev_t dev,  u_long cmd,  caddr_t data, int flags,  d_thread_t *p)
                     62: {
                     63:        NNPFSDEB(XDEBDEV, ("xfs_devioctl dev = %d.%d, cmd = %lu, "
                     64:            "data = %lx, flags = %x\n", major(dev), minor(dev),
                     65:            (unsigned long)cmd, (unsigned long)data, flags));
                     66:        return ENOTTY;
                     67: }
                     68:
                     69: int
                     70: xfs_devpoll(dev_t dev, int events, d_thread_t * p)
                     71: {
                     72:        struct xfs_channel *chan = &xfs_channel[minor(dev)];
                     73:
                     74:        NNPFSDEB(XDEBDEV, ("xfs_devpoll dev = %d(%d), events = 0x%x\n",
                     75:            major(dev), minor(dev), events));
                     76:
                     77:        if ((events & (POLLIN | POLLRDNORM)) == 0)
                     78:                return 0;                       /* only supports read */
                     79:
                     80:        if (!xfs_emptyq(&chan->messageq))
                     81:                return (events & (POLLIN | POLLRDNORM));
                     82:
                     83:        selrecord (p, &chan->selinfo);
                     84:
                     85:        return 0;
                     86: }
                     87:
                     88: void
                     89: xfs_select_wakeup(struct xfs_channel *chan)
                     90: {
                     91:        selwakeup (&chan->selinfo);
                     92: }
                     93:
                     94: /*
                     95:  * Install and uninstall device.
                     96:  */
                     97:
                     98: struct cdevsw xfs_dev = {
                     99:        xfs_devopen,
                    100:        xfs_devclose,
                    101:        xfs_devread,
                    102:        xfs_devwrite,
                    103:        xfs_devioctl,
                    104:        (dev_type_stop((*))) enodev,
                    105:        0,
                    106:        xfs_devpoll,
                    107:        (dev_type_mmap((*))) enodev,
                    108:        0
                    109: };
                    110:
                    111: int
                    112: xfs_install_device(void)
                    113: {
                    114:        int i;
                    115:
                    116:        for (i = 0; i < NNNPFS; i++) {
                    117:                NNPFSDEB(XDEBDEV, ("before initq(messageq and sleepq)\n"));
                    118:                xfs_initq(&xfs_channel[i].messageq);
                    119:                xfs_initq(&xfs_channel[i].sleepq);
                    120:                xfs_channel[i].status = 0;
                    121:        }
                    122:        return 0;
                    123: }
                    124:
                    125: int
                    126: xfs_uninstall_device(void)
                    127: {
                    128:        int i;
                    129:        struct xfs_channel *chan;
                    130:        int ret = 0;
                    131:
                    132:        for (i = 0; i < NNNPFS; i++) {
                    133:                chan = &xfs_channel[i];
                    134:                if (chan->status & CHANNEL_OPENED)
                    135:                        xfs_devclose(makedev(0, i), 0, 0, NULL);
                    136:        }
                    137:
                    138:        NNPFSDEB(XDEBLKM, ("xfs_uninstall_device error %d\n", ret));
                    139:        return ret;
                    140: }
                    141:
                    142: int
                    143: xfs_stat_device(void)
                    144: {
                    145:        return xfs_uprintf_device();
                    146: }
                    147:
                    148: int
                    149: xfs_is_xfs_dev(dev_t dev)
                    150: {
                    151:     return major(dev) <= nchrdev &&
                    152:        cdevsw[major(dev)].d_open == xfs_devopen &&
                    153:        minor(dev) >= 0 && minor(dev) < NNNPFS;
                    154: }

CVSweb