summaryrefslogtreecommitdiff
path: root/sys-fs/mdadm
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /sys-fs/mdadm
reinit the tree, so we can have metadata
Diffstat (limited to 'sys-fs/mdadm')
-rw-r--r--sys-fs/mdadm/Manifest27
-rw-r--r--sys-fs/mdadm/files/etc-default-mdadm9
-rw-r--r--sys-fs/mdadm/files/mdadm-3.3.1-DDF-validate-metadata_update-size-before-using-it.patch44
-rw-r--r--sys-fs/mdadm/files/mdadm-3.3.1-Grow-Do-not-try-to-restart-if-reshape-is-running.patch45
-rw-r--r--sys-fs/mdadm/files/mdadm-3.3.1-Grow-fix-removal-of-line-in-wrong-case.patch39
-rw-r--r--sys-fs/mdadm/files/mdadm-3.3.1-IMSM-use-strcpy-rather-than-pointless-strncpy.patch32
-rw-r--r--sys-fs/mdadm/files/mdadm-3.3.1-IMSM-validate-metadata_update-size-before-using-it.patch128
-rw-r--r--sys-fs/mdadm/files/mdadm-3.3.1-Makefile-install-mdadm-grow-continue-.service.patch28
-rw-r--r--sys-fs/mdadm/files/mdadm-3.3.1-mdmon-allow-prepare_update-to-report-failure.patch119
-rw-r--r--sys-fs/mdadm/files/mdadm-3.3.1-mdmon-ensure-Unix-domain-socket-is-created-with-safe.patch34
-rw-r--r--sys-fs/mdadm/files/mdadm-3.4-sysmacros.patch31
-rw-r--r--sys-fs/mdadm/files/mdadm.confd7
-rw-r--r--sys-fs/mdadm/files/mdadm.rc25
-rw-r--r--sys-fs/mdadm/files/mdadm.weekly5
-rw-r--r--sys-fs/mdadm/files/mdraid.confd11
-rw-r--r--sys-fs/mdadm/files/mdraid.rc39
-rw-r--r--sys-fs/mdadm/mdadm-3.3.1-r2.ebuild95
-rw-r--r--sys-fs/mdadm/mdadm-3.4.ebuild88
-rw-r--r--sys-fs/mdadm/mdadm-4.0.ebuild88
-rw-r--r--sys-fs/mdadm/metadata.xml8
20 files changed, 902 insertions, 0 deletions
diff --git a/sys-fs/mdadm/Manifest b/sys-fs/mdadm/Manifest
new file mode 100644
index 000000000000..847aea04d4ea
--- /dev/null
+++ b/sys-fs/mdadm/Manifest
@@ -0,0 +1,27 @@
+AUX etc-default-mdadm 320 SHA256 40a18a499909bb790eebcedf6a1da9db83abc20a555c4ac4c258de2f31458acf SHA512 2258f6321e447c05e3da88a41c7a2c4a031973744125d00ee0cdb249170b02ff99b58f3883ef6892c882c313fe929404551234c12917a9d7222e497af1cfa48c WHIRLPOOL 1288254e7dadd76829ff1d06221597742f346776d4c5d2dc5ced4d939e1f8148038a3bea919dcb4bed5df26ed0afd51f44dce56a991b59421762f39e9ba32d01
+AUX mdadm-3.3.1-DDF-validate-metadata_update-size-before-using-it.patch 1409 SHA256 a4168c58f7a75890e74b68ff1634ead1bead5f5ba28e02defb5972e6b62cc080 SHA512 ce8962daeebbdb92a16263d82019ff0ffa2e3127e0477b821ef157e1a71d958434fd2054e776ba0a816f334504a16ad276b655aa5951dd3331868e74db8488c3 WHIRLPOOL 3122994c9f5f31cac0dd4f8e4290148523069cc2f26905cad1fff4afa2408752178c912c52a9528d98eb5f0904e7c92fed1e6c1e60db8e519ff95f7a6c89f97e
+AUX mdadm-3.3.1-Grow-Do-not-try-to-restart-if-reshape-is-running.patch 1656 SHA256 94447d1661040616a32343b6fc122ecde4efd8db88f634dcf7966a2e6a482eed SHA512 ebae416c12d85a381cff25634ee1f574ac1ae376ddf35c1c8ea3abb4f6978b8689a86aebeb7b6ad0496fa683de9882994d78314b49bae707439a5fabccf7fb2a WHIRLPOOL e98d3a171b09ca1584d0d4a119247f2227fcf72d7c32bc7c1522e4212c51356b07b25ebbd7a7429f2b851e30d42806c8957ac9d5e33c6d1a422a7c16b1118160
+AUX mdadm-3.3.1-Grow-fix-removal-of-line-in-wrong-case.patch 1080 SHA256 44ffffc5afaa5e2626cc42a19608b62385207eb10eeccac4632026a23df19958 SHA512 d666877ba2e2d32266beec1d67bff0edb1d3b39cb44e198ef3ff5c4fe1feb348aa1210becd306e3cbda8d46e8360e320080525698504f80a77c02b6781bd5df5 WHIRLPOOL c2145b004fec7007e086e4f41184e16c1b8cba9053a4c8473a599995c716f47c60c2e71e6a7c51c475e9bc848f80ff00109751e5c66e50c23a4d3aa16fd25234
+AUX mdadm-3.3.1-IMSM-use-strcpy-rather-than-pointless-strncpy.patch 1045 SHA256 e8c0e234f0567e8c4438b00b6760c6d5cf03724d642be4f855e77ab7624d0dfc SHA512 c49b50af731c858253d9b570045725748856c8666e071f34a8d72788ec594a4bd4b3a0b528c6a197903b49459b223d8c76bfbf20b8da358e5515c16b8d99b36a WHIRLPOOL 08fe6b31c21f6e5d6be089efc14442fda085b7645b80ba300500ea4e7d37eef3d0db4a267ee114a631942a34368da43feb68ade7b452ab11a23cc4679567d39a
+AUX mdadm-3.3.1-IMSM-validate-metadata_update-size-before-using-it.patch 3882 SHA256 e9ffad102c4ba1d60927b2b9ad88962eb4f306672bf1cd1a2aadab74500ed9f0 SHA512 8ac28b8e6ede9cf51412656b030a84765519243cbd306f33a34920770dafa5b4abcebd5590e2279e524a1a4b1ebbb69a665e1da8939cdaf7051918e10eb0ca2c WHIRLPOOL 7c342506ed5ea6a3b9481b9a62173656c06cf5b6de9812d896911d5ca2a200c87c443cff8c26fb7eb8b0cf1c5a08ab8489ff17e5735172693b9274c7e37a8b37
+AUX mdadm-3.3.1-Makefile-install-mdadm-grow-continue-.service.patch 1001 SHA256 29be282474734ab4210a23bc810d001fb4587c632df2292f9681644a7546661f SHA512 3f2395d00e66d2d45e50cad9de6456bdbe0b1e4ab2ec925e19060b1f6d399f5fada1411539baa5cb9fbcd528d9ec184692a5d78890c3a23ac62de71ed00f5562 WHIRLPOOL b86a38d25e0b35dc34b4ca38580f4fea23f1400452bf96d1d695bec51854a6aba574e66a6b30cb32d6f7e1795855425b7ed3462949f2cbe5587e99cf2c453a00
+AUX mdadm-3.3.1-mdmon-allow-prepare_update-to-report-failure.patch 3654 SHA256 cf75b7def5736ced0e1b80b5a2845a74a1debeb8b116e284576135d9e192eac9 SHA512 05b8f395ba1dbf31998eba0303396dbed92f825d37a99e48ab67dd66b6275d31fced087fcd3d70bb08a5e18a38098efab8a5df855519b457b532bb7f1aeb9f51 WHIRLPOOL 06030ed4374284f82ee30352968c7533a496648c2756468c1c1fda3ad717aebcfa3d1192911709377d16a2fe51c1e3818ce5515d9252eadad8d90f0b3e50a7ee
+AUX mdadm-3.3.1-mdmon-ensure-Unix-domain-socket-is-created-with-safe.patch 1015 SHA256 99b2d3a6cc36102933f393d07c8c45ec1591f001d39b0dc1619022ceb9cddadd SHA512 3f8f8a6cf3f75004916180d67257af504b722cce6fd85a1e0136fd46dc467ea5919e8d65ba7483f3960f0676e1bb0d3cc0b09d24acf235f2045247aa199d377f WHIRLPOOL 40e38f174daae78b45729f464851a39f9d502eccf56ecab5628ce6f87fc2cfa059ef587e8207869751fa8f0417dba9586c70a85c9a20480831d0e0432b43e3aa
+AUX mdadm-3.4-sysmacros.patch 859 SHA256 c604c29c93f77a14c0ce61222af2c4a5b5b438e16f547b995f81564d864c3cc4 SHA512 47564bba9d45dfb39d63df9e6cd96ad03b37b314e794af180911481feb4e038035aa1ea6d3de2061982f46b51d1a205168f98e6f0a092f55f6f8e760dbabdae6 WHIRLPOOL f19255694360acefd19de1f72b1fbdb835fc6c29e8c3699344f86513a0f09bf8bbabbacca64567a29c82f44665ecf166ec33925738bdc547754c8d2785168709
+AUX mdadm.confd 205 SHA256 ec55674955af7a31da51b8b72b599e8519809287dad796a9b16155bcba471b79 SHA512 7bf66898000b3d02bbf0704a8032b0f4fc045380501dc8d2bbbb31d33b122d9c35879b25714663079eeadd207c9da87c9d9af8464e76146bf5b68594e73fd92c WHIRLPOOL b6a86bae6d298bcff17a497739109fa07f2bfb2682454a089dfef7ad51d2d770eec2661a5dd77140fe6ec33e94bc87d2378790eb06d11eace8dbe4ff0b83b677
+AUX mdadm.rc 465 SHA256 5b859ba14b7a4a350c0a8afe6edb352e0db9920bdf1e05315ffbbfb92f201584 SHA512 01fe98e88466afefd84a52cedc5fcbe18eadf8f80fed12b8a2a6a8f5581e7cabe8ce3f2e99cdc3c1bacc626f5eb4f6bffe3cc888153089ee2a461c465ae05570 WHIRLPOOL be038a9ea2ece751b569053136527fdc095c2dce77ff0982c91f69855314199404636ee135f6d1c0c77aa516ecdbac189672fd5fc8967215530d383f7a67b646
+AUX mdadm.weekly 187 SHA256 1234feb39795ebd03c53ca6f2d6496cf69c658890278d803ea40c86b841f898e SHA512 3bc7bf8c9593f06e42ae657e2bce416758090d1f999a447986df17b97e1494b261f02155b83932295f2f3bbab7d8933cf647c834bfb1d7def879cbedfaa6d7c2 WHIRLPOOL ff1b95deee1ee422f05aa438b498708bdb65754cd1158f371d1657f864ea0a52c62e5c93cbb4bfe98cedea23670a3a8b3fa4a04818975d80cf577d12318df7c7
+AUX mdraid.confd 383 SHA256 b489ced10391d4295bb8ca29e128b0d4217c290f1b4e37b05f5a9275048d289d SHA512 37fe70f5df0fb2b68be01ee774e3a943cfb280322f2db0c5d6892e701fb58be26a225b78448814294bf68f154cca697278fcf9572a47b6201920d95ad05189d6 WHIRLPOOL 60de14055064337413b137479ed7f1d45b2293fe8be4ec820dcfc716c8898f9066871a48d094bd4f3e78215e6f6e97a36d4a87f2ea3fd8e048461bfe224848ae
+AUX mdraid.rc 759 SHA256 31e7ba4174f38c05e939aa56fab8a43a3e371ba9e503e029887c99fed7a28331 SHA512 d76190646b393d1480607b0d89d08ce4196738295fbb7790fa1035c53a041b5cb88fe857bb2070920a9c3ae21b9fb8f7838dde240fa0e275e5915add9c113021 WHIRLPOOL 6ee7406ca4b463d1fa4697d1ed0c01873fb33959f1e4da64220468e8338c5de10534287bea2f945fc564ec9e545622962162712d4ba038ab3bc3f0a0b2055c3c
+DIST mdadm-3.3.1.tar.xz 407964 SHA256 d8c74112cfd77bdc1dbc1291fe8d9243c76d91bfa276fcb95f2a75ca7717ab02 SHA512 46fc1889e97d2d14b72ac26ee07eb4301467dc4a0e838ba89920253484fcd443749f3afccb3d792f7e468b20021d50dbc29dda7033d9b5a8fbaee664200f1981 WHIRLPOOL ca690bd35ab8ff475694d8f0420cd762704cc1777116edfdc9394973efa0d6decce1721dc1f7c8c84728d7434073cb6ab5161e5518c46aa8b4a7a5547ebb011d
+DIST mdadm-3.4.tar.xz 422704 SHA256 27d0be4627d38a12ddcd1c1c3721d649d4e89e1093914497e22b57245cda8808 SHA512 5de06f3a2b83333e5346a1e858b15e76f75a13a1d5c5f2032fecc6eb167454b282e12ee111ac2abec778e058ec9554708ac317a476778328546603618e6f70f7 WHIRLPOOL 18a5f2ed027b919e2e365cf9ddc1b616bf1fe315d27196a248ce9600622eb86d5ce825f1b38ecf0a1f5dcf21fa59fd7d88856700aea25a721c8efa37e2b34d39
+DIST mdadm-4.0.tar.xz 430780 SHA256 1d6ae7f24ced3a0fa7b5613b32f4a589bb4881e3946a5a2c3724056254ada3a9 SHA512 12fb26e6b9c1912698defa406e5e47a7ca8d68d4a9aa7acdc9b463ee2d4a37fc6ecef6beb5395ff619018c3f6bdb6d8c573060d027707540f645ad2265170e8b WHIRLPOOL 6587c7817556fbf47f7624a05d000c3a8396c84fbabe43aa574b649a119f987181b909f4347b93b07a45bf4d6519e1c8a39b1c0245538d64fb0eddd27e3e4054
+DIST mdadm_3.3-2.debian.tar.gz 127889 SHA256 c38b155e7395b35380d506458d979b82c5b853de996f21ccab50b1202d726301 SHA512 92e4c403542caba4b9afb870ba803e6bc7ade143b27efdc27e03b3407f322722a635457cce9e8c195a3ecd7cbce66fdebdd6046fc4f36836e56e27d5d838c037 WHIRLPOOL 8f8ef1142a79044093a5f55b181dc35a142b83041a59a9b71945aa6fe84cd089a7e1b183ec6b5db210a0d07e94efad0ab3a0d0341fc6cbbbf4da9d0254b5c737
+DIST mdadm_3.3.4-1.1.debian.tar.xz 86312 SHA256 16dd6b77c14a15afa23e077f0c157c17ef5cc6054b17ccb38cf5af86f7bf55bd SHA512 ea9b34a9952e1ff836cb931c7eef0ae0c44e3f4d46162c7a7eca24936d6f7168e99d67749b3100bc68ebadc8f256e4833d42da48c531cf71e6e8f3100911828f WHIRLPOOL 44df72008fc89f21a461bc45be230383d906fd0c0ea062327a537024ceff245b47ced301d72d5bfe5a0fcde095e99e14cdf30c614550bce023851e7a6ac0c525
+DIST mdadm_3.4-4.debian.tar.xz 81200 SHA256 4b09a90aefc2833040ae570cf4ddc34f98a67525636d3c9f2fabf8c13b51e27e SHA512 86a9edb8f29931fdfa40037d535ca80f0bf59539fe1ef16f2639e666a5ac1bd90ec617ec1635080ae62a02f7986a6e10c97dce5389555ab7d417885f216c0f93 WHIRLPOOL 07ab64531da08999b3d351d3747a870cd996b67cc4e2df2c9f8d974d170bc9537bed4aefcf690a2e0a66715549ff046520bd1c559b11736467b3f881681068ed
+EBUILD mdadm-3.3.1-r2.ebuild 2880 SHA256 0bbfab7da06d63fabec2a76f9023840e429650ebcbbd6993224a44e88dc7bc8e SHA512 3431b69f5a392efc822193101c09f852476b5bb46687601301727cd535d4b3bfa06109d48179536fc51e13b2d92a09d559a4519868df9c551d1a9f6fd9b3baa1 WHIRLPOOL 697b9510c1f13cfd31cd678466c9734a3292df991fba3b243b36f30945d2c6571a866b62bc30bc1fd8d8b25db207b4a7a7dbde4c5b1dc8ad08819d5faa15eeee
+EBUILD mdadm-3.4.ebuild 2324 SHA256 0796656510a3ae1699be505d2fcd61d6f299ea8e30bbb060777fac1a75ead128 SHA512 4aa81c3db6810a1fb0f425c37b33b61a6f4b99f3e11eca3c61e9fe0379bd430f4bd5454005c9e4e4ee15758f21aefe0e091f3b971b1a63b5c7a42ad3c8a0654e WHIRLPOOL e636f58d0a2915ca303daef064dd88b3f37a06ca625682aad62d8ff04c2e291594f31501e0d52c7ac5669b2df8a7d875b6c9ad3dfa0b4eab5ea302d966ccdda6
+EBUILD mdadm-4.0.ebuild 2329 SHA256 4c27e53b7e03e08a69d5b9c8ca0eccb2d158f52fa70afb149d7f23bbbf9e38b9 SHA512 a1bf72afdcd3b9972366f11fb884c77697f15b5cc3b29936cb0e14bfc74e6f628a6267262ca79160048441f63357f40d21d0def05c491390d9d573264bf76983 WHIRLPOOL 9848f6374e5bc6da7ea1178b974f95f52adafb01fa50bb961fc9dc2e1fd49d8214efa938bea56e45147090d613878470462bb4fb5c71a27c0a3e85b695f39e37
+MISC ChangeLog 5097 SHA256 5df3e03b3edde6085d1e5af80910e1df7ac313924e899d1ced1e2264e5d871a5 SHA512 04bb606a2454e6fd34cfad17313fbb36e8da32e51e3ce5cad2276dea5448e726aeeba486a3dcdbc54f3ef4655b820388788b92398e174834d92a0af0796ff26e WHIRLPOOL b3ec8b6b3cf9b416a792b1bd5accc364834610619d06916658fbe68c2134ba1f08d4a40460ece703b2e7a62104b2173d9130a9eb67b85d0e829747ae4e31b20a
+MISC ChangeLog-2015 31212 SHA256 20dc8e59ca2ba5b9d519d495d92bd4925645a3fa8e011956be4b34a7a43b2d15 SHA512 31f7be82e92367c9f613046053fdc4a7cbabf0101567a6adbfa5b151355b0622857df6645fc6a08cc0d9a993308a26a3561d115c5d1a4eb5f25d93990591763a WHIRLPOOL bb81d0547fc8e0dd3c14be8c3ff8605b74e46c893f714638531ce9f8fe36010a7c9245caca18b829532117789e5c21bcf81d1212da03527c1ec7224b110edc24
+MISC metadata.xml 253 SHA256 d82c33ef453113a5c1ebe250dcba373c22934a69b0a86c6ab15a5ca589c25b91 SHA512 54a9069aeb4165d2dff3d473c8001bc51613aac9dff3f7f5e9971a9891a737a31511ffa11cbd523febe581ac1d9de2bdf2f40410f0c4239138f2ccca3ef15555 WHIRLPOOL e5aee23acff864609953a1e4de768f0e4aef704b44c53c021f28573e1ca5c99f1a46d92935ecec2449f7b4419a36d8373127d0ecfa8d7bae72d835e1839eb3f8
diff --git a/sys-fs/mdadm/files/etc-default-mdadm b/sys-fs/mdadm/files/etc-default-mdadm
new file mode 100644
index 000000000000..921c70b19482
--- /dev/null
+++ b/sys-fs/mdadm/files/etc-default-mdadm
@@ -0,0 +1,9 @@
+# Based on Debian /etc/default/mdadm
+
+# Gentoo comment: The cronjob checks for this value to decide to actually
+# validate arrays. If missing, it does NOT actually do anything.
+# AUTOCHECK:
+# should mdadm run periodic redundancy checks over your arrays? See
+# /etc/cron.weekly/mdadm
+
+#AUTOCHECK=true
diff --git a/sys-fs/mdadm/files/mdadm-3.3.1-DDF-validate-metadata_update-size-before-using-it.patch b/sys-fs/mdadm/files/mdadm-3.3.1-DDF-validate-metadata_update-size-before-using-it.patch
new file mode 100644
index 000000000000..befb7da91735
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm-3.3.1-DDF-validate-metadata_update-size-before-using-it.patch
@@ -0,0 +1,44 @@
+From 1f17f96b538793a0e665e471f602c6fa490ec167 Mon Sep 17 00:00:00 2001
+From: NeilBrown <neilb@suse.de>
+Date: Thu, 10 Jul 2014 15:59:06 +1000
+Subject: [PATCH 12/14] DDF: validate metadata_update size before using it.
+
+process_update already checks update->len, for all but
+the 'magic', prepare_update doesn't at all.
+
+So add tests to prepare_update that we don't exceed the buffer.
+This will consequently protect process_update from looking
+for a 'magic' which isn't there.
+
+Reported-by: Vincent Berg <vberg@ioactive.com>
+Signed-off-by: NeilBrown <neilb@suse.de>
+---
+ super-ddf.c | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/super-ddf.c b/super-ddf.c
+index 1e43ca2..8957c2e 100644
+--- a/super-ddf.c
++++ b/super-ddf.c
+@@ -4914,10 +4914,16 @@ static int ddf_prepare_update(struct supertype *st,
+ * If a malloc is needed, do it here.
+ */
+ struct ddf_super *ddf = st->sb;
+- be32 *magic = (be32 *)update->buf;
++ be32 *magic;
++ if (update->len < 4)
++ return 0;
++ magic = (be32 *)update->buf;
+ if (be32_eq(*magic, DDF_VD_CONF_MAGIC)) {
+ struct vcl *vcl;
+- struct vd_config *conf = (struct vd_config *) update->buf;
++ struct vd_config *conf;
++ if (update->len < (int)sizeof(*conf))
++ return 0;
++ conf = (struct vd_config *) update->buf;
+ if (posix_memalign(&update->space, 512,
+ offsetof(struct vcl, conf)
+ + ddf->conf_rec_len * 512) != 0) {
+--
+2.0.0
+
diff --git a/sys-fs/mdadm/files/mdadm-3.3.1-Grow-Do-not-try-to-restart-if-reshape-is-running.patch b/sys-fs/mdadm/files/mdadm-3.3.1-Grow-Do-not-try-to-restart-if-reshape-is-running.patch
new file mode 100644
index 000000000000..717317b8a2d0
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm-3.3.1-Grow-Do-not-try-to-restart-if-reshape-is-running.patch
@@ -0,0 +1,45 @@
+From 13ffbe89b6103c146c08eb1c9a70833306c8322b Mon Sep 17 00:00:00 2001
+From: Pawel Baldysiak <pawel.baldysiak@intel.com>
+Date: Wed, 16 Jul 2014 12:20:34 +0200
+Subject: [PATCH 14/14] Grow: Do not try to restart if reshape is running
+
+Grow process did not check if reshape is already started
+when deciding about restarting.
+Sync_action should be checked in this case, and if
+reshape is running - restart flag should not be set.
+Otherwise, Grow process will fail to write data to
+sysfs, and reshape will not be continued.
+
+Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
+Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
+Signed-off-by: NeilBrown <neilb@suse.de>
+---
+ Grow.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/Grow.c b/Grow.c
+index a2f4f14..ea9cc60 100644
+--- a/Grow.c
++++ b/Grow.c
+@@ -2822,6 +2822,7 @@ static int reshape_array(char *container, int fd, char *devname,
+ unsigned long long array_size;
+ int done;
+ struct mdinfo *sra = NULL;
++ char buf[20];
+
+ /* when reshaping a RAID0, the component_size might be zero.
+ * So try to fix that up.
+@@ -2869,7 +2870,9 @@ static int reshape_array(char *container, int fd, char *devname,
+ goto release;
+ }
+
+- if (st->ss->external && restart && (info->reshape_progress == 0)) {
++ if (st->ss->external && restart && (info->reshape_progress == 0) &&
++ !((sysfs_get_str(info, NULL, "sync_action", buf, sizeof(buf)) > 0) &&
++ (strncmp(buf, "reshape", 7) == 0))) {
+ /* When reshape is restarted from '0', very begin of array
+ * it is possible that for external metadata reshape and array
+ * configuration doesn't happen.
+--
+2.0.0
+
diff --git a/sys-fs/mdadm/files/mdadm-3.3.1-Grow-fix-removal-of-line-in-wrong-case.patch b/sys-fs/mdadm/files/mdadm-3.3.1-Grow-fix-removal-of-line-in-wrong-case.patch
new file mode 100644
index 000000000000..acc38267d160
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm-3.3.1-Grow-fix-removal-of-line-in-wrong-case.patch
@@ -0,0 +1,39 @@
+From e339dba2a1744dc6860a58e286ded39fc993c2db Mon Sep 17 00:00:00 2001
+From: Pawel Baldysiak <pawel.baldysiak@intel.com>
+Date: Wed, 11 Jun 2014 15:18:44 +0000
+Subject: [PATCH 02/14] Grow: fix removal of line in wrong case
+
+Commit 18d9bcfa33939cee345d4d7735bc6081bcc409c8
+removed wrong line (in case RAID0->RAID4).
+This patch corrects this mistake
+(line should be removed in case RAID4->RAID4).
+
+Signed-off-by: Pawel Baldysiak <pawel.baldysiak@intel.com>
+Signed-off-by: NeilBrown <neilb@suse.de>
+---
+ Grow.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Grow.c b/Grow.c
+index 12730e2..a2f4f14 100644
+--- a/Grow.c
++++ b/Grow.c
+@@ -1324,6 +1324,7 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re)
+
+ switch (re->level) {
+ case 4:
++ re->before.layout = 0;
+ re->after.layout = 0;
+ break;
+ case 5:
+@@ -1339,7 +1340,6 @@ char *analyse_change(char *devname, struct mdinfo *info, struct reshape *re)
+
+ switch (re->level) {
+ case 4:
+- re->before.layout = 0;
+ re->after.layout = 0;
+ break;
+ case 5:
+--
+2.0.0
+
diff --git a/sys-fs/mdadm/files/mdadm-3.3.1-IMSM-use-strcpy-rather-than-pointless-strncpy.patch b/sys-fs/mdadm/files/mdadm-3.3.1-IMSM-use-strcpy-rather-than-pointless-strncpy.patch
new file mode 100644
index 000000000000..b63b1e732d36
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm-3.3.1-IMSM-use-strcpy-rather-than-pointless-strncpy.patch
@@ -0,0 +1,32 @@
+From 6d8d290a2f09a3bfd9e44f382ae5daea128772f7 Mon Sep 17 00:00:00 2001
+From: NeilBrown <neilb@suse.de>
+Date: Thu, 3 Jul 2014 15:04:01 +1000
+Subject: [PATCH 03/14] IMSM: use strcpy rather than pointless strncpy.
+
+As strncpy doesn't guarantee to nul-terminate, some static
+analysers get upset that it is followed by a 'strncat'.
+So just use a 'strcpy' - strlen(disk_by_path) is constant
+and definitely less than PATH_MAX.
+
+Link: https://github.com/neilbrown/mdadm/issues/4
+Signed-off-by: NeilBrown <neilb@suse.de>
+---
+ super-intel.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/super-intel.c b/super-intel.c
+index 9dd807a..0106b4f 100644
+--- a/super-intel.c
++++ b/super-intel.c
+@@ -9357,7 +9357,7 @@ static const char *imsm_get_disk_controller_domain(const char *path)
+ char *drv=NULL;
+ struct stat st;
+
+- strncpy(disk_path, disk_by_path, PATH_MAX - 1);
++ strcpy(disk_path, disk_by_path);
+ strncat(disk_path, path, PATH_MAX - strlen(disk_path) - 1);
+ if (stat(disk_path, &st) == 0) {
+ struct sys_dev* hba;
+--
+2.0.0
+
diff --git a/sys-fs/mdadm/files/mdadm-3.3.1-IMSM-validate-metadata_update-size-before-using-it.patch b/sys-fs/mdadm/files/mdadm-3.3.1-IMSM-validate-metadata_update-size-before-using-it.patch
new file mode 100644
index 000000000000..b1610835753a
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm-3.3.1-IMSM-validate-metadata_update-size-before-using-it.patch
@@ -0,0 +1,128 @@
+From 095b8088fa99ad1195d1aba03af2aa561b4a6379 Mon Sep 17 00:00:00 2001
+From: NeilBrown <neilb@suse.de>
+Date: Thu, 10 Jul 2014 16:09:28 +1000
+Subject: [PATCH 13/14] IMSM: validate metadata_update size before using it.
+
+Every case in prepare_update check that the size message
+size is sufficient, so process_update doesn't need to check anything.
+
+Reported-by: Vincent Berg <vberg@ioactive.com>
+Signed-off-by: NeilBrown <neilb@suse.de>
+---
+ super-intel.c | 44 +++++++++++++++++++++++++++++++++++++++++---
+ 1 file changed, 41 insertions(+), 3 deletions(-)
+
+diff --git a/super-intel.c b/super-intel.c
+index 2547b4a..b4efa72 100644
+--- a/super-intel.c
++++ b/super-intel.c
+@@ -8587,7 +8587,7 @@ static void imsm_process_update(struct supertype *st,
+ }
+ case update_add_remove_disk: {
+ /* we may be able to repair some arrays if disks are
+- * being added, check teh status of add_remove_disk
++ * being added, check the status of add_remove_disk
+ * if discs has been added.
+ */
+ if (add_remove_disk_update(super)) {
+@@ -8617,19 +8617,28 @@ static int imsm_prepare_update(struct supertype *st,
+ * integrated by the monitor thread without worrying about live pointers
+ * in the manager thread.
+ */
+- enum imsm_update_type type = *(enum imsm_update_type *) update->buf;
++ enum imsm_update_type type;
+ struct intel_super *super = st->sb;
+ struct imsm_super *mpb = super->anchor;
+ size_t buf_len;
+ size_t len = 0;
+
++ if (update->len < (int)sizeof(type))
++ return 0;
++
++ type = *(enum imsm_update_type *) update->buf;
++
+ switch (type) {
+ case update_general_migration_checkpoint:
++ if (update->len < (int)sizeof(struct imsm_update_general_migration_checkpoint))
++ return 0;
+ dprintf("imsm: prepare_update() "
+ "for update_general_migration_checkpoint called\n");
+ break;
+ case update_takeover: {
+ struct imsm_update_takeover *u = (void *)update->buf;
++ if (update->len < (int)sizeof(*u))
++ return 0;
+ if (u->direction == R0_TO_R10) {
+ void **tail = (void **)&update->space_list;
+ struct imsm_dev *dev = get_imsm_dev(super, u->subarray);
+@@ -8670,6 +8679,9 @@ static int imsm_prepare_update(struct supertype *st,
+ struct intel_dev *dl;
+ void **space_tail = (void**)&update->space_list;
+
++ if (update->len < (int)sizeof(*u))
++ return 0;
++
+ dprintf("imsm: imsm_prepare_update() for update_reshape\n");
+
+ for (dl = super->devlist; dl; dl = dl->next) {
+@@ -8702,6 +8714,9 @@ static int imsm_prepare_update(struct supertype *st,
+ void *s;
+ int current_level = -1;
+
++ if (update->len < (int)sizeof(*u))
++ return 0;
++
+ dprintf("imsm: imsm_prepare_update() for update_reshape\n");
+
+ /* add space for bigger array in update
+@@ -8769,6 +8784,13 @@ static int imsm_prepare_update(struct supertype *st,
+ break;
+ }
+ case update_size_change: {
++ if (update->len < (int)sizeof(struct imsm_update_size_change))
++ return 0;
++ break;
++ }
++ case update_activate_spare: {
++ if (update->len < (int)sizeof(struct imsm_update_activate_spare))
++ return 0;
+ break;
+ }
+ case update_create_array: {
+@@ -8781,6 +8803,9 @@ static int imsm_prepare_update(struct supertype *st,
+ int i;
+ int activate = 0;
+
++ if (update->len < (int)sizeof(*u))
++ return 0;
++
+ inf = get_disk_info(u);
+ len = sizeof_imsm_dev(dev, 1);
+ /* allocate a new super->devlist entry */
+@@ -8802,9 +8827,22 @@ static int imsm_prepare_update(struct supertype *st,
+ }
+ len += activate * sizeof(struct imsm_disk);
+ break;
+- default:
++ }
++ case update_kill_array: {
++ if (update->len < (int)sizeof(struct imsm_update_kill_array))
++ return 0;
+ break;
+ }
++ case update_rename_array: {
++ if (update->len < (int)sizeof(struct imsm_update_rename_array))
++ return 0;
++ break;
++ }
++ case update_add_remove_disk:
++ /* no update->len needed */
++ break;
++ default:
++ return 0;
+ }
+
+ /* check if we need a larger metadata buffer */
+--
+2.0.0
+
diff --git a/sys-fs/mdadm/files/mdadm-3.3.1-Makefile-install-mdadm-grow-continue-.service.patch b/sys-fs/mdadm/files/mdadm-3.3.1-Makefile-install-mdadm-grow-continue-.service.patch
new file mode 100644
index 000000000000..431bfd1abe3b
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm-3.3.1-Makefile-install-mdadm-grow-continue-.service.patch
@@ -0,0 +1,28 @@
+From 616f197f9d6d044afb9e27ddc9cd087d21d610f0 Mon Sep 17 00:00:00 2001
+From: NeilBrown <neilb@suse.de>
+Date: Tue, 10 Jun 2014 20:34:40 +1000
+Subject: [PATCH 01/14] Makefile: install mdadm-grow-continue@.service
+
+Forgot to add this to install-systemd target
+
+Signed-off-by: NeilBrown <neilb@suse.de>
+---
+ Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index c7e7a42..1a4a5dc 100644
+--- a/Makefile
++++ b/Makefile
+@@ -290,7 +290,7 @@ install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules
+
+ install-systemd: systemd/mdmon@.service
+ @for file in mdmon@.service mdmonitor.service mdadm-last-resort@.timer \
+- mdadm-last-resort@.service ; \
++ mdadm-last-resort@.service mdadm-grow-continue@.service; \
+ do sed -e 's,BINDIR,$(BINDIR),g' systemd/$$file > .install.tmp && \
+ echo $(INSTALL) -D -m 644 systemd/$$file $(DESTDIR)$(SYSTEMD_DIR)/$$file ; \
+ $(INSTALL) -D -m 644 .install.tmp $(DESTDIR)$(SYSTEMD_DIR)/$$file ; \
+--
+2.0.0
+
diff --git a/sys-fs/mdadm/files/mdadm-3.3.1-mdmon-allow-prepare_update-to-report-failure.patch b/sys-fs/mdadm/files/mdadm-3.3.1-mdmon-allow-prepare_update-to-report-failure.patch
new file mode 100644
index 000000000000..772248b19c3d
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm-3.3.1-mdmon-allow-prepare_update-to-report-failure.patch
@@ -0,0 +1,119 @@
+From 5fe6f031d9a21a935f0ef1b1fbdb314b53f2199f Mon Sep 17 00:00:00 2001
+From: NeilBrown <neilb@suse.de>
+Date: Thu, 10 Jul 2014 15:54:02 +1000
+Subject: [PATCH 11/14] mdmon: allow prepare_update to report failure.
+
+If 'prepare_update' fails for some reason there is little
+point continuing on to 'process_update'.
+For now only malloc failures are caught, but other failures
+will be considered in future.
+
+Signed-off-by: NeilBrown <neilb@suse.de>
+---
+ managemon.c | 3 ++-
+ mdadm.h | 5 ++++-
+ super-ddf.c | 8 +++++---
+ super-intel.c | 9 +++++----
+ 4 files changed, 16 insertions(+), 9 deletions(-)
+
+diff --git a/managemon.c b/managemon.c
+index 5f7e2ce..1c9eccc 100644
+--- a/managemon.c
++++ b/managemon.c
+@@ -819,7 +819,8 @@ static void handle_message(struct supertype *container, struct metadata_update *
+ mu->space_list = NULL;
+ mu->next = NULL;
+ if (container->ss->prepare_update)
+- container->ss->prepare_update(container, mu);
++ if (!container->ss->prepare_update(container, mu))
++ free_updates(&mu);
+ queue_metadata_update(mu);
+ }
+ }
+diff --git a/mdadm.h b/mdadm.h
+index 914d67c..02a9288 100644
+--- a/mdadm.h
++++ b/mdadm.h
+@@ -929,7 +929,10 @@ extern struct superswitch {
+ void (*sync_metadata)(struct supertype *st);
+ void (*process_update)(struct supertype *st,
+ struct metadata_update *update);
+- void (*prepare_update)(struct supertype *st,
++ /* Prepare updates allocates extra memory that might be
++ * needed. If the update cannot be understood, return 0.
++ */
++ int (*prepare_update)(struct supertype *st,
+ struct metadata_update *update);
+
+ /* activate_spare will check if the array is degraded and, if it
+diff --git a/super-ddf.c b/super-ddf.c
+index ab9fc46..1e43ca2 100644
+--- a/super-ddf.c
++++ b/super-ddf.c
+@@ -4906,8 +4906,8 @@ static void ddf_process_update(struct supertype *st,
+ /* case DDF_SPARE_ASSIGN_MAGIC */
+ }
+
+-static void ddf_prepare_update(struct supertype *st,
+- struct metadata_update *update)
++static int ddf_prepare_update(struct supertype *st,
++ struct metadata_update *update)
+ {
+ /* This update arrived at managemon.
+ * We are about to pass it to monitor.
+@@ -4922,15 +4922,17 @@ static void ddf_prepare_update(struct supertype *st,
+ offsetof(struct vcl, conf)
+ + ddf->conf_rec_len * 512) != 0) {
+ update->space = NULL;
+- return;
++ return 0;
+ }
+ vcl = update->space;
+ vcl->conf.sec_elmnt_count = conf->sec_elmnt_count;
+ if (alloc_other_bvds(ddf, vcl) != 0) {
+ free(update->space);
+ update->space = NULL;
++ return 0;
+ }
+ }
++ return 1;
+ }
+
+ /*
+diff --git a/super-intel.c b/super-intel.c
+index 7734bde..2547b4a 100644
+--- a/super-intel.c
++++ b/super-intel.c
+@@ -8607,8 +8607,8 @@ static void imsm_process_update(struct supertype *st,
+
+ static struct mdinfo *get_spares_for_grow(struct supertype *st);
+
+-static void imsm_prepare_update(struct supertype *st,
+- struct metadata_update *update)
++static int imsm_prepare_update(struct supertype *st,
++ struct metadata_update *update)
+ {
+ /**
+ * Allocate space to hold new disk entries, raid-device entries or a new
+@@ -8828,6 +8828,7 @@ static void imsm_prepare_update(struct supertype *st,
+ else
+ super->next_buf = NULL;
+ }
++ return 1;
+ }
+
+ /* must be called while manager is quiesced */
+@@ -9716,8 +9717,8 @@ static void imsm_update_metadata_locally(struct supertype *st,
+ mu.space = NULL;
+ mu.space_list = NULL;
+ mu.next = NULL;
+- imsm_prepare_update(st, &mu);
+- imsm_process_update(st, &mu);
++ if (imsm_prepare_update(st, &mu))
++ imsm_process_update(st, &mu);
+
+ while (mu.space_list) {
+ void **space = mu.space_list;
+--
+2.0.0
+
diff --git a/sys-fs/mdadm/files/mdadm-3.3.1-mdmon-ensure-Unix-domain-socket-is-created-with-safe.patch b/sys-fs/mdadm/files/mdadm-3.3.1-mdmon-ensure-Unix-domain-socket-is-created-with-safe.patch
new file mode 100644
index 000000000000..9780196e28cd
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm-3.3.1-mdmon-ensure-Unix-domain-socket-is-created-with-safe.patch
@@ -0,0 +1,34 @@
+From 120ec6f7b96455e42bdfa9131c0c9026c57eaf19 Mon Sep 17 00:00:00 2001
+From: NeilBrown <neilb@suse.de>
+Date: Thu, 3 Jul 2014 17:06:45 +1000
+Subject: [PATCH 09/14] mdmon: ensure Unix domain socket is created with safe
+ permissions.
+
+In the unlikely case that mdmon is started with an overly
+permissive umask, we don't want to risk giving away world acccess.
+
+All other "mkdir" and "O_CREAT" calls in mdmon and mdadm set
+a suitably restrictive permission mask. 'bind' don't take an
+explicit mask so it needs an implicit one.
+
+Reported-by: Vincent Berg <vberg@ioactive.com>
+Signed-off-by: NeilBrown <neilb@suse.de>
+---
+ mdmon.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/mdmon.c b/mdmon.c
+index b84d4d9..21221cd 100644
+--- a/mdmon.c
++++ b/mdmon.c
+@@ -232,6 +232,7 @@ static int make_control_sock(char *devname)
+
+ addr.sun_family = PF_LOCAL;
+ strcpy(addr.sun_path, path);
++ umask(077); /* ensure no world write access */
+ if (bind(sfd, &addr, sizeof(addr)) < 0) {
+ close(sfd);
+ return -1;
+--
+2.0.0
+
diff --git a/sys-fs/mdadm/files/mdadm-3.4-sysmacros.patch b/sys-fs/mdadm/files/mdadm-3.4-sysmacros.patch
new file mode 100644
index 000000000000..22a393447632
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm-3.4-sysmacros.patch
@@ -0,0 +1,31 @@
+https://bugs.gentoo.org/580188
+
+From 5c97e465b33bf8fefb17da7f553a1c3812e508d5 Mon Sep 17 00:00:00 2001
+From: Mike Frysinger <vapier@gentoo.org>
+Date: Tue, 19 Apr 2016 18:10:54 -0400
+Subject: [PATCH] include sys/sysmacros.h for major/minor/makedev prototypes
+
+These funcs are defined in sys/sysmacros.h, so include it for them.
+It works today due to an implicit include by sys/types.h, but the
+various Linux C libraries are moving away from that.
+
+Signed-off-by: Mike Frysinger <vapier@gentoo.org>
+---
+ mdadm.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/mdadm.h b/mdadm.h
+index d209488..b8767a7 100755
+--- a/mdadm.h
++++ b/mdadm.h
+@@ -33,6 +33,7 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
+ # endif
+ #endif
+
++#include <sys/sysmacros.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <stdint.h>
+--
+2.7.4
+
diff --git a/sys-fs/mdadm/files/mdadm.confd b/sys-fs/mdadm/files/mdadm.confd
new file mode 100644
index 000000000000..a4ead14dc34e
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm.confd
@@ -0,0 +1,7 @@
+# /etc/conf.d/mdadm: config file for /etc/init.d/mdadm
+
+# Misc options to pass to mdadm in monitor mode.
+# For more info, run `mdadm --monitor --help` or see
+# the mdadm(8) manpage.
+
+MDADM_OPTS="--syslog"
diff --git a/sys-fs/mdadm/files/mdadm.rc b/sys-fs/mdadm/files/mdadm.rc
new file mode 100644
index 000000000000..c5bd38b13a14
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm.rc
@@ -0,0 +1,25 @@
+#!/sbin/openrc-run
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ use logger dns net
+}
+
+start() {
+ ebegin "Starting mdadm monitor"
+ mdadm --monitor --scan \
+ --daemonise \
+ --pid-file /var/run/mdadm.pid \
+ ${MDADM_OPTS}
+ eend $?
+}
+
+stop() {
+ local ret
+ ebegin "Stopping mdadm monitor"
+ start-stop-daemon --stop --pidfile /var/run/mdadm.pid
+ ret=$?
+ rm -f /var/run/mdadm.pid
+ eend ${ret}
+}
diff --git a/sys-fs/mdadm/files/mdadm.weekly b/sys-fs/mdadm/files/mdadm.weekly
new file mode 100644
index 000000000000..e2b35b550fce
--- /dev/null
+++ b/sys-fs/mdadm/files/mdadm.weekly
@@ -0,0 +1,5 @@
+#!/bin/sh
+# This requires that AUTOCHECK is true in /etc/default/mdadm
+if [ -x /usr/sbin/checkarray ] && [ $(date +\%d) -le 7 ]; then
+ /usr/sbin/checkarray --cron --all --idle --quiet
+fi
diff --git a/sys-fs/mdadm/files/mdraid.confd b/sys-fs/mdadm/files/mdraid.confd
new file mode 100644
index 000000000000..5694d732d006
--- /dev/null
+++ b/sys-fs/mdadm/files/mdraid.confd
@@ -0,0 +1,11 @@
+# /etc/conf.d/mdraid: config file for /etc/init.d/mdraid
+
+# For people who run raid on top of some other layer (like
+# dmcrypt), use rc_need to specify that requirement. See
+# the runscript(8) man page for more information.
+
+# Most configuration happens in /etc/mdadm.conf.
+
+# Pass additional options when assembling raids.
+# Note: This applies to all raids.
+MDADM_ASSEMBLE_OPTS=""
diff --git a/sys-fs/mdadm/files/mdraid.rc b/sys-fs/mdadm/files/mdraid.rc
new file mode 100644
index 000000000000..a30035dbbba2
--- /dev/null
+++ b/sys-fs/mdadm/files/mdraid.rc
@@ -0,0 +1,39 @@
+#!/sbin/openrc-run
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ before checkfs fsck
+ after modules
+}
+
+start() {
+ local output
+
+ ebegin "Starting up RAID devices"
+ output=$(mdadm -As ${MDADM_ASSEMBLE_OPTS} 2>&1)
+ eend $? "${output}"
+
+ local pat="/dev/md_d*"
+ set -- ${pat}
+ if [ "$*" != "${pat}" ] ; then
+ ebegin "Creating RAID device partitions"
+ blockdev "$@"
+ eend $?
+ # wait because vgscan runs next, and we want udev to fire
+ sleep 1
+ fi
+
+ return 0
+}
+
+stop() {
+ local output
+
+ # XXX: Maybe drop this check ?
+ [ ! -e /etc/mdadm/mdadm.conf ] && [ ! -e /etc/mdadm.conf ] && return 0
+
+ ebegin "Shutting down RAID devices (mdadm)"
+ output=$(mdadm -Ss 2>&1)
+ eend $? "${output}"
+}
diff --git a/sys-fs/mdadm/mdadm-3.3.1-r2.ebuild b/sys-fs/mdadm/mdadm-3.3.1-r2.ebuild
new file mode 100644
index 000000000000..32cbe91c6a73
--- /dev/null
+++ b/sys-fs/mdadm/mdadm-3.3.1-r2.ebuild
@@ -0,0 +1,95 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=4
+inherit eutils flag-o-matic multilib systemd toolchain-funcs udev
+
+DESCRIPTION="A useful tool for running RAID systems - it can be used as a replacement for the raidtools"
+HOMEPAGE="http://neil.brown.name/blog/mdadm"
+DEB_PR=2
+SRC_URI="mirror://kernel/linux/utils/raid/mdadm/${P}.tar.xz
+ mirror://debian/pool/main/m/mdadm/${PN}_3.3-${DEB_PR}.debian.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 sparc x86"
+IUSE="static"
+
+DEPEND="virtual/pkgconfig
+ app-arch/xz-utils"
+RDEPEND=">=sys-apps/util-linux-2.16"
+
+# The tests edit values in /proc and run tests on software raid devices.
+# Thus, they shouldn't be run on systems with active software RAID devices.
+RESTRICT="test"
+
+mdadm_emake() {
+ emake \
+ PKG_CONFIG="$(tc-getPKG_CONFIG)" \
+ CC="$(tc-getCC)" \
+ CWFLAGS="-Wall" \
+ CXFLAGS="${CFLAGS}" \
+ UDEVDIR="$(get_udevdir)" \
+ SYSTEMD_DIR="$(systemd_get_unitdir)" \
+ "$@"
+}
+
+src_prepare() {
+ # These are important bugfixes from upstream git after 3.3.1 release,
+ # and before and including 17 Jul 2014:
+ epatch \
+ "${FILESDIR}"/${P}-Makefile-install-mdadm-grow-continue-.service.patch \
+ "${FILESDIR}"/${P}-Grow-fix-removal-of-line-in-wrong-case.patch \
+ "${FILESDIR}"/${P}-IMSM-use-strcpy-rather-than-pointless-strncpy.patch \
+ "${FILESDIR}"/${P}-mdmon-ensure-Unix-domain-socket-is-created-with-safe.patch \
+ "${FILESDIR}"/${P}-mdmon-allow-prepare_update-to-report-failure.patch \
+ "${FILESDIR}"/${P}-DDF-validate-metadata_update-size-before-using-it.patch \
+ "${FILESDIR}"/${P}-IMSM-validate-metadata_update-size-before-using-it.patch \
+ "${FILESDIR}"/${P}-Grow-Do-not-try-to-restart-if-reshape-is-running.patch
+}
+
+src_compile() {
+ use static && append-ldflags -static
+ mdadm_emake all mdassemble
+}
+
+src_test() {
+ mdadm_emake test
+
+ sh ./test || die
+}
+
+src_install() {
+ # Use split lines because of bug #517218
+ mdadm_emake DESTDIR="${D}" install
+ mdadm_emake DESTDIR="${D}" install-systemd
+ into /
+ dosbin mdassemble
+ dodoc ChangeLog INSTALL TODO README* ANNOUNCE-${PV}
+
+ insinto /etc
+ newins mdadm.conf-example mdadm.conf
+ newinitd "${FILESDIR}"/mdadm.rc mdadm
+ newconfd "${FILESDIR}"/mdadm.confd mdadm
+ newinitd "${FILESDIR}"/mdraid.rc mdraid
+ newconfd "${FILESDIR}"/mdraid.confd mdraid
+
+ # From the Debian patchset
+ into /usr
+ dodoc "${WORKDIR}"/debian/README.checkarray
+ dosbin "${WORKDIR}"/debian/checkarray
+
+ insinto /etc/cron.weekly
+ newins "${FILESDIR}"/mdadm.weekly mdadm
+}
+
+pkg_postinst() {
+ if ! systemd_is_booted; then
+ if [[ -z ${REPLACING_VERSIONS} ]] ; then
+ # Only inform people the first time they install.
+ elog "If you're not relying on kernel auto-detect of your RAID"
+ elog "devices, you need to add 'mdraid' to your 'boot' runlevel:"
+ elog " rc-update add mdraid boot"
+ fi
+ fi
+}
diff --git a/sys-fs/mdadm/mdadm-3.4.ebuild b/sys-fs/mdadm/mdadm-3.4.ebuild
new file mode 100644
index 000000000000..433f455c17b8
--- /dev/null
+++ b/sys-fs/mdadm/mdadm-3.4.ebuild
@@ -0,0 +1,88 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+inherit eutils flag-o-matic multilib systemd toolchain-funcs udev
+
+DESCRIPTION="A useful tool for running RAID systems - it can be used as a replacement for the raidtools"
+HOMEPAGE="http://neil.brown.name/blog/mdadm"
+DEB_PR=1.1
+SRC_URI="mirror://kernel/linux/utils/raid/mdadm/${P}.tar.xz
+ mirror://debian/pool/main/m/mdadm/${PN}_3.3.4-${DEB_PR}.debian.tar.xz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 sparc x86"
+IUSE="static"
+
+DEPEND="virtual/pkgconfig
+ app-arch/xz-utils"
+RDEPEND=">=sys-apps/util-linux-2.16"
+
+# The tests edit values in /proc and run tests on software raid devices.
+# Thus, they shouldn't be run on systems with active software RAID devices.
+RESTRICT="test"
+
+src_prepare() {
+ epatch "${FILESDIR}"/${PN}-3.4-sysmacros.patch #580188
+}
+
+mdadm_emake() {
+ # We should probably make corosync & libdlm into USE flags. #573782
+ emake \
+ PKG_CONFIG="$(tc-getPKG_CONFIG)" \
+ CC="$(tc-getCC)" \
+ CWFLAGS="-Wall" \
+ CXFLAGS="${CFLAGS}" \
+ UDEVDIR="$(get_udevdir)" \
+ SYSTEMD_DIR="$(systemd_get_unitdir)" \
+ COROSYNC="-DNO_COROSYNC" \
+ DLM="-DNO_DLM" \
+ "$@"
+}
+
+src_compile() {
+ use static && append-ldflags -static
+ mdadm_emake all mdassemble
+}
+
+src_test() {
+ mdadm_emake test
+
+ sh ./test || die
+}
+
+src_install() {
+ mdadm_emake DESTDIR="${D}" install install-systemd
+ into /
+ dosbin mdassemble
+ dodoc ChangeLog INSTALL TODO README* ANNOUNCE-${PV}
+
+ insinto /etc
+ newins mdadm.conf-example mdadm.conf
+ newinitd "${FILESDIR}"/mdadm.rc mdadm
+ newconfd "${FILESDIR}"/mdadm.confd mdadm
+ newinitd "${FILESDIR}"/mdraid.rc mdraid
+ newconfd "${FILESDIR}"/mdraid.confd mdraid
+
+ # From the Debian patchset
+ into /usr
+ dodoc "${WORKDIR}"/debian/README.checkarray
+ dosbin "${WORKDIR}"/debian/checkarray
+ insinto /etc/default
+ newins "${FILESDIR}"/etc-default-mdadm mdadm
+
+ exeinto /etc/cron.weekly
+ newexe "${FILESDIR}"/mdadm.weekly mdadm
+}
+
+pkg_postinst() {
+ if ! systemd_is_booted; then
+ if [[ -z ${REPLACING_VERSIONS} ]] ; then
+ # Only inform people the first time they install.
+ elog "If you're not relying on kernel auto-detect of your RAID"
+ elog "devices, you need to add 'mdraid' to your 'boot' runlevel:"
+ elog " rc-update add mdraid boot"
+ fi
+ fi
+}
diff --git a/sys-fs/mdadm/mdadm-4.0.ebuild b/sys-fs/mdadm/mdadm-4.0.ebuild
new file mode 100644
index 000000000000..048ba5dc9d00
--- /dev/null
+++ b/sys-fs/mdadm/mdadm-4.0.ebuild
@@ -0,0 +1,88 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=5
+inherit eutils flag-o-matic multilib systemd toolchain-funcs udev
+
+DESCRIPTION="A useful tool for running RAID systems - it can be used as a replacement for the raidtools"
+HOMEPAGE="http://neil.brown.name/blog/mdadm"
+DEB_PR=4
+SRC_URI="mirror://kernel/linux/utils/raid/mdadm/${P}.tar.xz
+ mirror://debian/pool/main/m/mdadm/${PN}_3.4-${DEB_PR}.debian.tar.xz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86"
+IUSE="static"
+
+DEPEND="virtual/pkgconfig
+ app-arch/xz-utils"
+RDEPEND=">=sys-apps/util-linux-2.16"
+
+# The tests edit values in /proc and run tests on software raid devices.
+# Thus, they shouldn't be run on systems with active software RAID devices.
+RESTRICT="test"
+
+src_prepare() {
+ epatch "${FILESDIR}"/${PN}-3.4-sysmacros.patch #580188
+}
+
+mdadm_emake() {
+ # We should probably make corosync & libdlm into USE flags. #573782
+ emake \
+ PKG_CONFIG="$(tc-getPKG_CONFIG)" \
+ CC="$(tc-getCC)" \
+ CWFLAGS="-Wall" \
+ CXFLAGS="${CFLAGS}" \
+ UDEVDIR="$(get_udevdir)" \
+ SYSTEMD_DIR="$(systemd_get_unitdir)" \
+ COROSYNC="-DNO_COROSYNC" \
+ DLM="-DNO_DLM" \
+ "$@"
+}
+
+src_compile() {
+ use static && append-ldflags -static
+ mdadm_emake all mdassemble
+}
+
+src_test() {
+ mdadm_emake test
+
+ sh ./test || die
+}
+
+src_install() {
+ mdadm_emake DESTDIR="${D}" install install-systemd
+ into /
+ dosbin mdassemble
+ dodoc ChangeLog INSTALL TODO README* ANNOUNCE-${PV}
+
+ insinto /etc
+ newins mdadm.conf-example mdadm.conf
+ newinitd "${FILESDIR}"/mdadm.rc mdadm
+ newconfd "${FILESDIR}"/mdadm.confd mdadm
+ newinitd "${FILESDIR}"/mdraid.rc mdraid
+ newconfd "${FILESDIR}"/mdraid.confd mdraid
+
+ # From the Debian patchset
+ into /usr
+ dodoc "${WORKDIR}"/debian/README.checkarray
+ dosbin "${WORKDIR}"/debian/checkarray
+ insinto /etc/default
+ newins "${FILESDIR}"/etc-default-mdadm mdadm
+
+ exeinto /etc/cron.weekly
+ newexe "${FILESDIR}"/mdadm.weekly mdadm
+}
+
+pkg_postinst() {
+ if ! systemd_is_booted; then
+ if [[ -z ${REPLACING_VERSIONS} ]] ; then
+ # Only inform people the first time they install.
+ elog "If you're not relying on kernel auto-detect of your RAID"
+ elog "devices, you need to add 'mdraid' to your 'boot' runlevel:"
+ elog " rc-update add mdraid boot"
+ fi
+ fi
+}
diff --git a/sys-fs/mdadm/metadata.xml b/sys-fs/mdadm/metadata.xml
new file mode 100644
index 000000000000..56c124413057
--- /dev/null
+++ b/sys-fs/mdadm/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<maintainer type="project">
+ <email>base-system@gentoo.org</email>
+ <name>Gentoo Base System</name>
+</maintainer>
+</pkgmetadata>