Remove autotools products
[zfs.git] / lib / libzfs / libzfs_import.c
index ee00648..d12dc86 100644 (file)
@@ -20,6 +20,8 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2011 by Delphix. All rights reserved.
  */
 
 /*
@@ -441,7 +443,7 @@ get_configs(libzfs_handle_t *hdl, pool_list_t *pl, boolean_t active_ok)
        uint_t i, nspares, nl2cache;
        boolean_t config_seen;
        uint64_t best_txg;
-       char *name, *hostname;
+       char *name, *hostname, *comment;
        uint64_t version, guid;
        uint_t children = 0;
        nvlist_t **child = NULL;
@@ -530,6 +532,7 @@ get_configs(libzfs_handle_t *hdl, pool_list_t *pl, boolean_t active_ok)
                                 *      version
                                 *      pool guid
                                 *      name
+                                *      comment (if available)
                                 *      pool state
                                 *      hostid (if available)
                                 *      hostname (if available)
@@ -551,11 +554,24 @@ get_configs(libzfs_handle_t *hdl, pool_list_t *pl, boolean_t active_ok)
                                if (nvlist_add_string(config,
                                    ZPOOL_CONFIG_POOL_NAME, name) != 0)
                                        goto nomem;
+
+                               /*
+                                * COMMENT is optional, don't bail if it's not
+                                * there, instead, set it to NULL.
+                                */
+                               if (nvlist_lookup_string(tmp,
+                                   ZPOOL_CONFIG_COMMENT, &comment) != 0)
+                                       comment = NULL;
+                               else if (nvlist_add_string(config,
+                                   ZPOOL_CONFIG_COMMENT, comment) != 0)
+                                       goto nomem;
+
                                verify(nvlist_lookup_uint64(tmp,
                                    ZPOOL_CONFIG_POOL_STATE, &state) == 0);
                                if (nvlist_add_uint64(config,
                                    ZPOOL_CONFIG_POOL_STATE, state) != 0)
                                        goto nomem;
+
                                hostid = 0;
                                if (nvlist_lookup_uint64(tmp,
                                    ZPOOL_CONFIG_HOSTID, &hostid) == 0) {
@@ -1078,6 +1094,10 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg)
                         * parport* - Parallel port interface.
                         * lp*      - Printer interface.
                         * fd*      - Floppy interface.
+                        * hpet     - High Precision Event Timer, crashes qemu
+                        *            when accessed from a virtual machine.
+                        * core     - Symlink to /proc/kcore, causes a crash
+                        *            when access from Xen dom0.
                         */
                        if ((strncmp(name, "watchdog", 8) == 0) ||
                            (strncmp(name, "fuse", 4) == 0)     ||
@@ -1086,22 +1106,22 @@ zpool_find_import_impl(libzfs_handle_t *hdl, importargs_t *iarg)
                            (strncmp(name, "vcs", 3) == 0)      ||
                            (strncmp(name, "parport", 7) == 0)  ||
                            (strncmp(name, "lp", 2) == 0)       ||
-                           (strncmp(name, "fd", 2) == 0))
-                               continue;
-
-                       if ((fd = openat64(dfd, name, O_RDONLY)) < 0)
+                           (strncmp(name, "fd", 2) == 0)       ||
+                           (strncmp(name, "hpet", 4) == 0)     ||
+                           (strncmp(name, "core", 4) == 0))
                                continue;
 
                        /*
                         * Ignore failed stats.  We only want regular
-                        * files and block devs.
+                        * files and block devices.
                         */
-                       if (fstat64(fd, &statbuf) != 0 ||
+                       if ((fstatat64(dfd, name, &statbuf, 0) != 0) ||
                            (!S_ISREG(statbuf.st_mode) &&
-                           !S_ISBLK(statbuf.st_mode))) {
-                               (void) close(fd);
+                           !S_ISBLK(statbuf.st_mode)))
+                               continue;
+
+                       if ((fd = openat64(dfd, name, O_RDONLY)) < 0)
                                continue;
-                       }
 
                        if ((zpool_read_label(fd, &config)) != 0) {
                                (void) close(fd);