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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 #include <sys/atomic.h>
  27 #include <sys/cmn_err.h>
  28 #include <sys/errno.h>
  29 #include <sys/mount.h>
  30 #include <sharefs/sharefs.h>
  31 #include <sys/vfs_opreg.h>
  32 #include <sys/policy.h>
  33 #include <sys/sunddi.h>
  34 #include <sys/sysmacros.h>
  35 #include <sys/systm.h>
  36 
  37 #include <sys/mntent.h>
  38 #include <sys/vfs.h>
  39 
  40 /*
  41  * Kernel sharetab filesystem.
  42  *
  43  * This is a pseudo filesystem which exports information about shares currently
  44  * in kernel memory. The only element of the pseudo filesystem is a file.
  45  *
 
 
 226         /*
 227          * We do not currently support forced unmounts
 228          */
 229         if (flag & MS_FORCE)
 230                 return (ENOTSUP);
 231 
 232         /*
 233          * We should never have a reference count of less than 2: one for the
 234          * caller, one for the root vnode.
 235          */
 236         ASSERT(vfsp->vfs_count >= 2);
 237 
 238         /*
 239          * Any active vnodes will result in a hold on the root vnode
 240          */
 241         data = vfsp->vfs_data;
 242         if (data->sharefs_vfs_root->v_count > 1)
 243                 return (EBUSY);
 244 
 245         /*
 246          * Only allow an unmount iff there are no entries in memory.
 247          */
 248         rw_enter(&sharetab_lock, RW_READER);
 249         if (sharetab_size != 0) {
 250                 rw_exit(&sharetab_lock);
 251                 return (EBUSY);
 252         }
 253         rw_exit(&sharetab_lock);
 254 
 255         /*
 256          * Release the last hold on the root vnode
 257          */
 258         VN_RELE(data->sharefs_vfs_root);
 259 
 260         kmem_free(data, sizeof (sharefs_vfs_t));
 261 
 262         return (0);
 263 }
 264 
 265 static int
 266 sharefs_root(vfs_t *vfsp, vnode_t **vpp)
 267 {
 268         sharefs_vfs_t   *data = vfsp->vfs_data;
 269 
 270         *vpp = data->sharefs_vfs_root;
 271         VN_HOLD(*vpp);
 272 
 273         return (0);
 274 }
 275 
 
 | 
 
 
   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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 /*
  27  * Copyright 2018 Nexenta Systems, Inc.
  28  */
  29 
  30 #include <sys/atomic.h>
  31 #include <sys/cmn_err.h>
  32 #include <sys/errno.h>
  33 #include <sys/mount.h>
  34 #include <sharefs/sharefs.h>
  35 #include <sys/vfs_opreg.h>
  36 #include <sys/policy.h>
  37 #include <sys/sunddi.h>
  38 #include <sys/sysmacros.h>
  39 #include <sys/systm.h>
  40 
  41 #include <sys/mntent.h>
  42 #include <sys/vfs.h>
  43 
  44 /*
  45  * Kernel sharetab filesystem.
  46  *
  47  * This is a pseudo filesystem which exports information about shares currently
  48  * in kernel memory. The only element of the pseudo filesystem is a file.
  49  *
 
 
 230         /*
 231          * We do not currently support forced unmounts
 232          */
 233         if (flag & MS_FORCE)
 234                 return (ENOTSUP);
 235 
 236         /*
 237          * We should never have a reference count of less than 2: one for the
 238          * caller, one for the root vnode.
 239          */
 240         ASSERT(vfsp->vfs_count >= 2);
 241 
 242         /*
 243          * Any active vnodes will result in a hold on the root vnode
 244          */
 245         data = vfsp->vfs_data;
 246         if (data->sharefs_vfs_root->v_count > 1)
 247                 return (EBUSY);
 248 
 249         /*
 250          * Release the last hold on the root vnode
 251          */
 252         VN_RELE(data->sharefs_vfs_root);
 253 
 254         kmem_free(data, sizeof (sharefs_vfs_t));
 255 
 256         return (0);
 257 }
 258 
 259 static int
 260 sharefs_root(vfs_t *vfsp, vnode_t **vpp)
 261 {
 262         sharefs_vfs_t   *data = vfsp->vfs_data;
 263 
 264         *vpp = data->sharefs_vfs_root;
 265         VN_HOLD(*vpp);
 266 
 267         return (0);
 268 }
 269 
 
 |