]> git.proxmox.com Git - mirror_zfs.git/commit
Make `zpool import -d|-c` behave consistently
authorBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 30 Oct 2014 20:17:33 +0000 (13:17 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 28 Jan 2015 19:12:31 +0000 (11:12 -0800)
commit6466b61db6b4def6b077882ebbd4c3e83e917613
treea245c9cd08db4c8fb33fae93580f684e7a650954
parenta485efc4cd7589ec7993aee4b0746a05f42409d5
Make `zpool import -d|-c` behave consistently

When importing pools with zpool import -aN there is inconsistent
behavior between '-d /dev/disk/by-id' (or another path) and
'-c /etc/zfs/zpool.cache'.

The difference in behavior is caused by zpool_find_import_cached()
returning an empty nvlist_t when there are no pools to import but
zpool_find_import_impl() returns NULL for the same situation. The
behavior of zpool_find_import_cached() is arguably more correct
because it allows returning NULL to be used for an error case and
not an empty set.

This change resolves the issue by updating get_configs() such that
it returns an empty set instead of NULL when no config is found.
The updated behavior will now always return 0 for this case.

$ zpool import -aN; echo $?
no pools available to import
0

$ zpool import -aN -d /var/tmp/; echo $?
no pools available to import
0

$ zpool import -aN -c /etc/zfs/zpool.cache; echo $?
no pools available to import
0

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2080
lib/libzfs/libzfs_import.c