libmultipath: Don't chop const strings

multipath was chopping sysfs attr strings in order to make sure that
ending whitespace didn't cause them to overflow their buffer. However
those strings were const strings. This patch makes multipath check how
much of the string length is ending whitespace, so that it can tell if
it will really overflow the buffer without chopping the const string.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
dm-multipath: blacklist NVMe devices

Multipath works at the request level and NVMe bypasses the request layer. So
multipath is not going to be supported for NVMe devices. Add NVMe to default
blacklist.

Signed-off-by: Vaughan Cao <vaughan.cao@oracle.com>
multipathd: not skip paths not belonging to a mpp in check_path

commit bf4c80aee4e977e89d6925df569647acd3d5efef
multipathd: add path when transitioned from 'blocked' state
intends to check paths not belonging to a mpp usually because of
they are in 'blocked' state and we cannot get the path uuid.
So these paths ought not to be skipped at the start of the function.
It could be a fault when merge the original patch -
http://www.redhat.com/archives/dm-devel/2013-December/msg00085.html

Signed-off-by: Vaughan Cao <Vaughan.Cao@oracle.com>
Fix build failure with fomat-security. Specify the format type.

cc -g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat
-Werror=format-security -D_FORTIFY_SOURCE=2 -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -Wunused -Wstrict-prototypes -fPIC
-DLIB_STRING=\"lib\" -I.. -c -o rdac.o rdac.c
rdac.c: In function 'libcheck_check':
rdac.c:311:3: error: format not a string literal and no format arguments
[-Werror=format-security]
   MSG(c, (inqfail) ? MSG_RDAC_DOWN_TYPE("inquiry failed") :
   ^
rdac.c:311:3: error: format not a string literal and no format arguments
[-Werror=format-security]
cc1: some warnings being treated as errors
make[2]: *** [rdac.o] Error 1

Signed-off-by: Ritesh Raj Sarraf <rrs@debian.org>
Minor spelling error fixes

Signed-off-by: Ritesh Raj Sarraf <rrs@debian.org>
New udev rules to deal with stacked devices

This new rules file sets some DM_* udev environment variables to keep
device mapper for doing unnecessary work on multipath device uevents.
Previously, devices with no valid paths were being scanned. Also devices
were being rescanned on uevents caused by paths being added or removed.
These are now avoided.

Signed-off-by: Peter Rajnoha <prajnoha@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Mark reloads with udev flag

In order for the udev rules to be able to distinguish uevents generated by
reloads instead of creates, multipath now tags all the reload resumes with
MPATH_UDEV_RELOAD_FLAG, which is defined as the first multipath
dm subsystem udev flag.  11-dm-mpath.rules watches for multipath events
tag.

Signed-off-by: Peter Rajnoha <prajnoha@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Update FSF address

FSF moved to a different address, and our buildsystem complained.

Signed-off-by: Hannes Reinecke <hare@suse.de>
link against libsystemd, not libsystemd-daemon

With systemd version 210 libsystemd-daemon has been merged
into libsystemd.

Signed-off-by: Hannes Reinecke <hare@suse.de>
mpath_persist: Do not call exit() from a shared library

mpath_persist is a shared library, and shouldn't call exit().
Just return an error code here.

And cleanup formatting while we're at it.

Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath: filter for missing property in get_refwwid()

get_refwwid() needs to filter for missing udev properties,
otherwise it'll accept just about any SCSI device.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Double uevent stacksize yet again

Another report indicates that the uevent stacksize might still be
too small.

Signed-off-by: Hannes Reinecke <hare@suse.de>
discovery: do not fail discovery on individual devices

Any errors returned from individual devices during discovery do
not invalidate the entire discovery. So instead of returning
the pointless accumulated error count we should be returning
the number of devices which were actually discovered.

Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath: Prefer deprecated 'getuid' callout

We need first to check if the deprecated 'getuid' callout
should be used, otherwise it might never be called.

Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath: Skip paths with empty wwid

If the WWID is empty this is pretty much a terminal error, as
we don't have anything to identify the multipath device.
So skip those devices during discovery.

References: bnc#861534

Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath: correctly terminate string in strlcpy()

strlcpy would not add a trailing '\0' if the string buffer
was longer than the string, causing getuid callout to
always fail.

Signed-off-by: Hannes Reinecke <hare@suse.de>
kpartx: Add udev compability rules for SUSE

Older versions of SUSE were using an underscore between the
device-mapper name and the partition string. Newer versions
and upstream would be using a minus here.

This rule adds a compability link with an underscore to
provide compability for older installations.

Signed-off-by: Hannes Reinecke <hare@suse.de>
kpartx: create symlinks for dmraid devices

Signed-off-by: Hannes Reinecke <hare@suse.de>
Make systemd installation path configurable

Older systems might have systemd installed in /lib, so make
the path for systemd and udev configurable.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Add SUSE build scripts

Signed-off-by: Hannes Reinecke <hare@suse.de>