Improve systemd script to not leave stale sharetab

The systemd script zfs-share.service does 'zfs share -a' to share
any required datasets.  Unfortunately, /etc/dfs/sharetab is stale
from the previous boot.  Delete it before we share.

Signed-off-by: Dan Swartzendruber <dswartz@druber.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2883
zpool upgrade return errors to stderr instead of stdout

Signed-off-by: Jacek Feflinski <feflik@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2955
Fix typo in %post scriptlet lines

Missing space made the %post directive be part of the package
%description and not have a %post scriptlet defined.

Signed-off-by: Andy Bakun <github@thwartedefforts.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2961
Correct error returns to unify cross-pool operation error handling

Signed-off-by: Boris Protopopov <boris.protopopov@actifio.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2911
Fix cstyle issue from c66989b

Commit c66989b accidentally introduced a cstyle issue which went
unnoticed.  This tiny patch corrects that oversight.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
vdev_id: use mawk-compatible regular expression

Slot mapping in vdev_id doesn't work on systems using mawk as the 'awk'
alternative. A regular expression in map_slot() contains an unquoted
empty string following the alternation (|) operator, which results in an
"missing operand" error with mawk. The solution is to rearrange the
expression so the alternation has two operands.

Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes zfsonlinux/pkg-zfs#136
Closes zfsonlinux/zfs#2965
Initramfs scripts for ZoL.

These are taken from the Debian GNU/Linux packages distributed by ZoL, but have been
merged with the dracut scripts - one code base for basically the same thing.

* Supports booting of a ZFS snapshot.
  Do this by cloning the snapshot into a dataset. If this, the resulting
  dataset, already exists, destroy it. Then set mountpoint=/ on that
  dataset and mount it on root.
  + If snapshot does not exist, use base dataset (the part before '@')
    as boot filesystem instead.
* Support all currently used kernel command line arguments
  All the different distributions have their own standard on what to specify
  on the kernel command line to boot of a ZFS filesystem.
* Allows mounting a rootfs with mountpoint=legacy set
* Don't auto import pools when loading module - keep better control of the imports.
* Only try to import pool if it haven't already been imported
  + This will negate the need to force import a pool that have not been exported cleanly.
  + Support exclusion of pools to import by setting ZFS_POOL_EXCEPTIONS in /etc/default/zfs.
* Support mounting additional filesystems (such as /var and /usr etc) by
  the space separated setting ZFS_INITRD_ADDITIONAL_DATASETS in /etc/default/zfs.
* Include /etc/modprobe.d/{zfs,spl}.conf in the initrd if they exist.
* Include the udev rule to use by-vdev for pool imports.
* Only try /dev/disk/by-* in the initrd if USE_DISK_BY_ID is set.
  + Use /dev/disk/by-vdev before anything.
  + Add /dev as a last ditch attempt.
  + Fallback to using the cache file if that exist if nothing else worked.
* Use /sbin/modprobe instead of built-in (BusyBox) modprobe.
  This gets rid of the message "modprobe: can't load module zcommon".
  Thanx to pcoultha for finding this.