Print this page
XXXX don't fail device detach when it's physically removed
   1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */

  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 




  26 #ifndef _SYS_DV_NODE_H
  27 #define _SYS_DV_NODE_H
  28 
  29 /*
  30  * dv_nodes are the file-system specific part of the
  31  * vnodes for the device filesystem.
  32  *
  33  * The device filesystem exports two node types:
  34  *
  35  * VDIR nodes           to represent nexus drivers
  36  * VCHR & VBLK nodes        to represent devices
  37  */
  38 
  39 #include <sys/dirent.h>
  40 #include <sys/sunddi.h>
  41 #include <sys/devops.h>
  42 #include <sys/ddi_impldefs.h>
  43 #include <sys/fs/sdev_impl.h>
  44 #include <sys/devpolicy.h>
  45 #include <sys/avl.h>


  93 #define DV_INTERNAL     0x04            /* internal node */
  94 #define DV_ACL          0x08            /* node has acl */
  95 #define DV_DFLT_MODE    0x010           /* dv_dflt_mode set */
  96 
  97 #define DV_ROOTINO      ((ino_t)2)      /* root inode no. for devfs */
  98 
  99 #define DVTOV(n)        ((struct vnode *)(n)->dv_vnode)
 100 #define VTODV(vp)       ((struct dv_node *)(vp)->v_data)
 101 #define DV_STALE(dv)    (dv->dv_devi == NULL)
 102 
 103 #define DV_UID_DEFAULT  0       /* default uid for devs and dirs */
 104 #define DV_GID_DEFAULT  3       /* default gid for devs and dirs */
 105 #define DV_DIRMODE_DEFAULT      (S_IFDIR | 0755)        /* directories */
 106 #define DV_DEVMODE_DEFAULT      (0600)                  /* special files */
 107 #define DV_DEVMODE_PRIV         (0666)          /* priv based access only */
 108 
 109 /* flags for devfs_clean() */
 110 #define DV_CLEAN_FORCE  0x01    /* force clean of refed directories */
 111 #define DV_RESET_PERM   0x02    /* force resetting of node permission */
 112 #define DV_CLEANDIR_LCK 0x04    /* dv_contents already held */

 113 
 114 struct devfs_data {
 115         struct  dv_node *devfs_root;
 116         struct  vfs     *devfs_vfsp;
 117 };
 118 
 119 #define VFSTODVFS(vfsp) ((struct devfs_data *)((vfsp)->vfs_data))
 120 
 121 /* dv_fid overlays the fid structure (for VFS_VGET) */
 122 struct dv_fid {
 123         uint16_t        dvfid_len;
 124         ino32_t         dvfid_ino;
 125         int32_t         dvfid_gen;
 126 };
 127 
 128 /*
 129  * Compare a vattr's and mperm_t's minor permissions (uid, gid & mode)
 130  */
 131 #define VATTRP_MP_CMP(attrp, mp)                                \
 132         (!((attrp->va_uid == mp.mp_uid) &&                   \


   1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*
  28  * Copyright 2018 Nexenta Systems, Inc.
  29  */
  30 
  31 #ifndef _SYS_DV_NODE_H
  32 #define _SYS_DV_NODE_H
  33 
  34 /*
  35  * dv_nodes are the file-system specific part of the
  36  * vnodes for the device filesystem.
  37  *
  38  * The device filesystem exports two node types:
  39  *
  40  * VDIR nodes           to represent nexus drivers
  41  * VCHR & VBLK nodes        to represent devices
  42  */
  43 
  44 #include <sys/dirent.h>
  45 #include <sys/sunddi.h>
  46 #include <sys/devops.h>
  47 #include <sys/ddi_impldefs.h>
  48 #include <sys/fs/sdev_impl.h>
  49 #include <sys/devpolicy.h>
  50 #include <sys/avl.h>


  98 #define DV_INTERNAL     0x04            /* internal node */
  99 #define DV_ACL          0x08            /* node has acl */
 100 #define DV_DFLT_MODE    0x010           /* dv_dflt_mode set */
 101 
 102 #define DV_ROOTINO      ((ino_t)2)      /* root inode no. for devfs */
 103 
 104 #define DVTOV(n)        ((struct vnode *)(n)->dv_vnode)
 105 #define VTODV(vp)       ((struct dv_node *)(vp)->v_data)
 106 #define DV_STALE(dv)    (dv->dv_devi == NULL)
 107 
 108 #define DV_UID_DEFAULT  0       /* default uid for devs and dirs */
 109 #define DV_GID_DEFAULT  3       /* default gid for devs and dirs */
 110 #define DV_DIRMODE_DEFAULT      (S_IFDIR | 0755)        /* directories */
 111 #define DV_DEVMODE_DEFAULT      (0600)                  /* special files */
 112 #define DV_DEVMODE_PRIV         (0666)          /* priv based access only */
 113 
 114 /* flags for devfs_clean() */
 115 #define DV_CLEAN_FORCE  0x01    /* force clean of refed directories */
 116 #define DV_RESET_PERM   0x02    /* force resetting of node permission */
 117 #define DV_CLEANDIR_LCK 0x04    /* dv_contents already held */
 118 #define DV_DEVI_GONE    0x08    /* force clean of refed files */
 119 
 120 struct devfs_data {
 121         struct  dv_node *devfs_root;
 122         struct  vfs     *devfs_vfsp;
 123 };
 124 
 125 #define VFSTODVFS(vfsp) ((struct devfs_data *)((vfsp)->vfs_data))
 126 
 127 /* dv_fid overlays the fid structure (for VFS_VGET) */
 128 struct dv_fid {
 129         uint16_t        dvfid_len;
 130         ino32_t         dvfid_ino;
 131         int32_t         dvfid_gen;
 132 };
 133 
 134 /*
 135  * Compare a vattr's and mperm_t's minor permissions (uid, gid & mode)
 136  */
 137 #define VATTRP_MP_CMP(attrp, mp)                                \
 138         (!((attrp->va_uid == mp.mp_uid) &&                   \