Print this page
10133 smatch fixes for usr/src/cmd/fs.d


   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 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*




  27  * smbfs umount
  28  */
  29 
  30 #include <stdio.h>
  31 #include <stdlib.h>
  32 #include <string.h>
  33 #include <stdarg.h>
  34 #include <signal.h>
  35 #include <unistd.h>
  36 #include <kstat.h>
  37 #include <rpc/rpc.h>
  38 #include <sys/mnttab.h>
  39 #include <sys/mount.h>
  40 #include <sys/mntent.h>
  41 #include <errno.h>
  42 #include <locale.h>
  43 #include <fslib.h>
  44 #include <priv_utils.h>
  45 
  46 #define RET_OK  0


 162         char *dirname;
 163 {
 164         FILE *fp;
 165         struct extmnttab mnt;
 166         struct extmnttab *res = NULL;
 167 
 168         fp = fopen(MNTTAB, "r");
 169         if (fp == NULL) {
 170                 pr_err("%s: %s\n", MNTTAB, strerror(errno));
 171                 return (NULL);
 172         }
 173         while (getextmntent(fp, &mnt, sizeof (struct extmnttab)) == 0) {
 174                 if (strcmp(mnt.mnt_mountp, dirname) == 0 ||
 175                     strcmp(mnt.mnt_special, dirname) == 0) {
 176                         if (res)
 177                                 fsfreemnttab(res);
 178                         res = fsdupmnttab(&mnt);
 179                 }
 180         }
 181 
 182         fclose(fp);
 183         return (res);
 184 }


   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 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  * Copyright (c) 2018, Joyent, Inc.
  28  */
  29 
  30 /*
  31  * smbfs umount
  32  */
  33 
  34 #include <stdio.h>
  35 #include <stdlib.h>
  36 #include <string.h>
  37 #include <stdarg.h>
  38 #include <signal.h>
  39 #include <unistd.h>
  40 #include <kstat.h>
  41 #include <rpc/rpc.h>
  42 #include <sys/mnttab.h>
  43 #include <sys/mount.h>
  44 #include <sys/mntent.h>
  45 #include <errno.h>
  46 #include <locale.h>
  47 #include <fslib.h>
  48 #include <priv_utils.h>
  49 
  50 #define RET_OK  0


 166         char *dirname;
 167 {
 168         FILE *fp;
 169         struct extmnttab mnt;
 170         struct extmnttab *res = NULL;
 171 
 172         fp = fopen(MNTTAB, "r");
 173         if (fp == NULL) {
 174                 pr_err("%s: %s\n", MNTTAB, strerror(errno));
 175                 return (NULL);
 176         }
 177         while (getextmntent(fp, &mnt, sizeof (struct extmnttab)) == 0) {
 178                 if (strcmp(mnt.mnt_mountp, dirname) == 0 ||
 179                     strcmp(mnt.mnt_special, dirname) == 0) {
 180                         if (res)
 181                                 fsfreemnttab(res);
 182                         res = fsdupmnttab(&mnt);
 183                 }
 184         }
 185 
 186         (void) fclose(fp);
 187         return (res);
 188 }