Print this page
10083 smatch fixes for common/fs/vfs.c


   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 (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2016 Joyent, Inc.
  25  * Copyright 2016 Toomas Soome <tsoome@me.com>
  26  * Copyright (c) 2016, 2017 by Delphix. All rights reserved.
  27  * Copyright 2016 Nexenta Systems, Inc.
  28  * Copyright 2017 RackTop Systems.
  29  */
  30 
  31 /*      Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
  32 /*        All Rights Reserved   */
  33 
  34 /*
  35  * University Copyright- Copyright (c) 1982, 1986, 1988
  36  * The Regents of the University of California
  37  * All Rights Reserved
  38  *
  39  * University Acknowledgment- Portions of this document are derived from
  40  * software developed by the University of California, Berkeley, and its
  41  * contributors.
  42  */
  43 
  44 #include <sys/types.h>


1044         li = kmem_zalloc(sizeof (*li), KM_SLEEP);
1045         li->li_id = vfsp->vfs_lofi_id;
1046         li->li_cleanup = B_TRUE;
1047 
1048         err = ldi_open_by_name("/dev/lofictl", FREAD | FWRITE, kcred,
1049             &ldi_hdl, ldi_id);
1050 
1051         if (err)
1052                 goto out;
1053 
1054         err = ldi_ioctl(ldi_hdl, LOFI_UNMAP_FILE_MINOR, (intptr_t)li,
1055             FREAD | FWRITE | FKIOCTL, kcred, NULL);
1056 
1057         (void) ldi_close(ldi_hdl, FREAD | FWRITE, kcred);
1058 
1059         if (!err)
1060                 vfsp->vfs_lofi_id = 0;
1061 
1062 out:
1063         ldi_ident_release(ldi_id);
1064         if (li != NULL)
1065                 kmem_free(li, sizeof (*li));
1066 }
1067 
1068 /*
1069  * Common mount code.  Called from the system call entry point, from autofs,
1070  * nfsv4 trigger mounts, and from pxfs.
1071  *
1072  * Takes the effective file system type, mount arguments, the mount point
1073  * vnode, flags specifying whether the mount is a remount and whether it
1074  * should be entered into the vfs list, and credentials.  Fills in its vfspp
1075  * parameter with the mounted file system instance's vfs.
1076  *
1077  * Note that the effective file system type is specified as a string.  It may
1078  * be null, in which case it's determined from the mount arguments, and may
1079  * differ from the type specified in the mount arguments; this is a hook to
1080  * allow interposition when instantiating file system instances.
1081  *
1082  * The caller is responsible for releasing its own hold on the mount point
1083  * vp (this routine does its own hold when necessary).
1084  * Also note that for remounts, the mount point vp should be the vnode for


4215                 /* Shouldn't happen, but not bad enough to panic */
4216         }
4217 
4218         VFS_INIT(&EIO_vfs, EIO_vfsops, (caddr_t)NULL);
4219 
4220         /*
4221          * Default EIO_vfs.vfs_flag to VFS_UNMOUNTED so a lookup
4222          * on this vfs can immediately notice it's invalid.
4223          */
4224         EIO_vfs.vfs_flag |= VFS_UNMOUNTED;
4225 
4226         /*
4227          * Call the init routines of non-loadable filesystems only.
4228          * Filesystems which are loaded as separate modules will be
4229          * initialized by the module loading code instead.
4230          */
4231 
4232         for (vswp = &vfssw[1]; vswp < &vfssw[nfstype]; vswp++) {
4233                 RLOCK_VFSSW();
4234                 if (vswp->vsw_init != NULL)
4235                         (*vswp->vsw_init)(vswp - vfssw, vswp->vsw_name);
4236                 RUNLOCK_VFSSW();
4237         }
4238 
4239         vopstats_startup();
4240 
4241         if (vopstats_enabled) {
4242                 /* EIO_vfs can collect stats, but we don't retrieve them */
4243                 initialize_vopstats(&EIO_vfs.vfs_vopstats);
4244                 EIO_vfs.vfs_fstypevsp = NULL;
4245                 EIO_vfs.vfs_vskap = NULL;
4246                 EIO_vfs.vfs_flag |= VFS_STATS;
4247         }
4248 
4249         xattr_init();
4250 
4251         reparse_point_init();
4252 }
4253 
4254 vfs_t *
4255 vfs_alloc(int kmflag)




   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 (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2018, Joyent, Inc.
  25  * Copyright 2016 Toomas Soome <tsoome@me.com>
  26  * Copyright (c) 2016, 2017 by Delphix. All rights reserved.
  27  * Copyright 2016 Nexenta Systems, Inc.
  28  * Copyright 2017 RackTop Systems.
  29  */
  30 
  31 /*      Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
  32 /*        All Rights Reserved   */
  33 
  34 /*
  35  * University Copyright- Copyright (c) 1982, 1986, 1988
  36  * The Regents of the University of California
  37  * All Rights Reserved
  38  *
  39  * University Acknowledgment- Portions of this document are derived from
  40  * software developed by the University of California, Berkeley, and its
  41  * contributors.
  42  */
  43 
  44 #include <sys/types.h>


1044         li = kmem_zalloc(sizeof (*li), KM_SLEEP);
1045         li->li_id = vfsp->vfs_lofi_id;
1046         li->li_cleanup = B_TRUE;
1047 
1048         err = ldi_open_by_name("/dev/lofictl", FREAD | FWRITE, kcred,
1049             &ldi_hdl, ldi_id);
1050 
1051         if (err)
1052                 goto out;
1053 
1054         err = ldi_ioctl(ldi_hdl, LOFI_UNMAP_FILE_MINOR, (intptr_t)li,
1055             FREAD | FWRITE | FKIOCTL, kcred, NULL);
1056 
1057         (void) ldi_close(ldi_hdl, FREAD | FWRITE, kcred);
1058 
1059         if (!err)
1060                 vfsp->vfs_lofi_id = 0;
1061 
1062 out:
1063         ldi_ident_release(ldi_id);

1064         kmem_free(li, sizeof (*li));
1065 }
1066 
1067 /*
1068  * Common mount code.  Called from the system call entry point, from autofs,
1069  * nfsv4 trigger mounts, and from pxfs.
1070  *
1071  * Takes the effective file system type, mount arguments, the mount point
1072  * vnode, flags specifying whether the mount is a remount and whether it
1073  * should be entered into the vfs list, and credentials.  Fills in its vfspp
1074  * parameter with the mounted file system instance's vfs.
1075  *
1076  * Note that the effective file system type is specified as a string.  It may
1077  * be null, in which case it's determined from the mount arguments, and may
1078  * differ from the type specified in the mount arguments; this is a hook to
1079  * allow interposition when instantiating file system instances.
1080  *
1081  * The caller is responsible for releasing its own hold on the mount point
1082  * vp (this routine does its own hold when necessary).
1083  * Also note that for remounts, the mount point vp should be the vnode for


4214                 /* Shouldn't happen, but not bad enough to panic */
4215         }
4216 
4217         VFS_INIT(&EIO_vfs, EIO_vfsops, (caddr_t)NULL);
4218 
4219         /*
4220          * Default EIO_vfs.vfs_flag to VFS_UNMOUNTED so a lookup
4221          * on this vfs can immediately notice it's invalid.
4222          */
4223         EIO_vfs.vfs_flag |= VFS_UNMOUNTED;
4224 
4225         /*
4226          * Call the init routines of non-loadable filesystems only.
4227          * Filesystems which are loaded as separate modules will be
4228          * initialized by the module loading code instead.
4229          */
4230 
4231         for (vswp = &vfssw[1]; vswp < &vfssw[nfstype]; vswp++) {
4232                 RLOCK_VFSSW();
4233                 if (vswp->vsw_init != NULL)
4234                         (void) (*vswp->vsw_init)(vswp - vfssw, vswp->vsw_name);
4235                 RUNLOCK_VFSSW();
4236         }
4237 
4238         vopstats_startup();
4239 
4240         if (vopstats_enabled) {
4241                 /* EIO_vfs can collect stats, but we don't retrieve them */
4242                 initialize_vopstats(&EIO_vfs.vfs_vopstats);
4243                 EIO_vfs.vfs_fstypevsp = NULL;
4244                 EIO_vfs.vfs_vskap = NULL;
4245                 EIO_vfs.vfs_flag |= VFS_STATS;
4246         }
4247 
4248         xattr_init();
4249 
4250         reparse_point_init();
4251 }
4252 
4253 vfs_t *
4254 vfs_alloc(int kmflag)