Print this page
5526 One more gcc warning for cmd/power


   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 #include "pmconfig.h"
  27 #include <sys/mkdev.h>
  28 #include <sys/syslog.h>
  29 #include <sys/openpromio.h>
  30 #include <sys/mnttab.h>
  31 #include <sys/vtoc.h>
  32 #include <sys/efi_partition.h>
  33 #include <syslog.h>
  34 #include <stdlib.h>
  35 #include <sys/pm.h>
  36 #include <kstat.h>
  37 #include <sys/smbios.h>
  38 #include <libzfs.h>
  39 
  40 
  41 #define STRCPYLIM(dst, src, str) strcpy_limit(dst, src, sizeof (dst), str)


 998  * given the path to a zvol, return the cXtYdZ name
 999  * returns < 0 on error, 0 if it isn't a zvol, > 1 on success
1000  */
1001 static int
1002 ztop(char *arg, char *diskname)
1003 {
1004         zpool_handle_t *zpool_handle;
1005         nvlist_t *config, *nvroot;
1006         nvlist_t **child;
1007         uint_t children;
1008         libzfs_handle_t *lzfs;
1009         char *vname;
1010         char *p;
1011         char pool_name[MAXPATHLEN];
1012 
1013         if (strncmp(arg, "/dev/zvol/dsk/", 14)) {
1014                 return (0);
1015         }
1016         arg += 14;
1017         (void) strncpy(pool_name, arg, MAXPATHLEN);
1018         if (p = strchr(pool_name, '/'))
1019                 *p = '\0';
1020         STRCPYLIM(new_cc.cf_fs, p + 1, "statefile path");
1021 
1022         if ((lzfs = libzfs_init()) == NULL) {
1023                 mesg(MERR, "failed to initialize ZFS library\n");
1024                 return (-1);
1025         }
1026         if ((zpool_handle = zpool_open(lzfs, pool_name)) == NULL) {
1027                 mesg(MERR, "couldn't open pool '%s'\n", pool_name);
1028                 libzfs_fini(lzfs);
1029                 return (-1);
1030         }
1031         config = zpool_get_config(zpool_handle, NULL);
1032         if (nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
1033             &nvroot) != 0) {
1034                 zpool_close(zpool_handle);
1035                 libzfs_fini(lzfs);
1036                 return (-1);
1037         }
1038         verify(nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN,




   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 2015 Gary Mills
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #include "pmconfig.h"
  28 #include <sys/mkdev.h>
  29 #include <sys/syslog.h>
  30 #include <sys/openpromio.h>
  31 #include <sys/mnttab.h>
  32 #include <sys/vtoc.h>
  33 #include <sys/efi_partition.h>
  34 #include <syslog.h>
  35 #include <stdlib.h>
  36 #include <sys/pm.h>
  37 #include <kstat.h>
  38 #include <sys/smbios.h>
  39 #include <libzfs.h>
  40 
  41 
  42 #define STRCPYLIM(dst, src, str) strcpy_limit(dst, src, sizeof (dst), str)


 999  * given the path to a zvol, return the cXtYdZ name
1000  * returns < 0 on error, 0 if it isn't a zvol, > 1 on success
1001  */
1002 static int
1003 ztop(char *arg, char *diskname)
1004 {
1005         zpool_handle_t *zpool_handle;
1006         nvlist_t *config, *nvroot;
1007         nvlist_t **child;
1008         uint_t children;
1009         libzfs_handle_t *lzfs;
1010         char *vname;
1011         char *p;
1012         char pool_name[MAXPATHLEN];
1013 
1014         if (strncmp(arg, "/dev/zvol/dsk/", 14)) {
1015                 return (0);
1016         }
1017         arg += 14;
1018         (void) strncpy(pool_name, arg, MAXPATHLEN);
1019         if ((p = strchr(pool_name, '/')) != NULL)
1020                 *p = '\0';
1021         STRCPYLIM(new_cc.cf_fs, p + 1, "statefile path");
1022 
1023         if ((lzfs = libzfs_init()) == NULL) {
1024                 mesg(MERR, "failed to initialize ZFS library\n");
1025                 return (-1);
1026         }
1027         if ((zpool_handle = zpool_open(lzfs, pool_name)) == NULL) {
1028                 mesg(MERR, "couldn't open pool '%s'\n", pool_name);
1029                 libzfs_fini(lzfs);
1030                 return (-1);
1031         }
1032         config = zpool_get_config(zpool_handle, NULL);
1033         if (nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
1034             &nvroot) != 0) {
1035                 zpool_close(zpool_handle);
1036                 libzfs_fini(lzfs);
1037                 return (-1);
1038         }
1039         verify(nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN,