Should the geometry validation fail, mdadm exits with error code 2 if the style of metadata is not explicitly set to imsm. Prior to that however it attempts to exclusively open a device block file. If it succeeds it says that the device is not suitable for any kind of array, otherwise it just says that the device is busy. The file opened is not closed afterwards. Signed-off-by: Lukasz Orlowski <lukasz.orlowski@xxxxxxxxx> --- Create.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Create.c b/Create.c index 8d88aa1..47e5fc8 100644 --- a/Create.c +++ b/Create.c @@ -346,15 +346,15 @@ int Create(struct supertype *st, char *mddev, if (!st) { int dfd = open(dname, O_RDONLY|O_EXCL); - if (dfd < 0) { - fprintf(stderr, Name ": cannot open %s: %s\n", - dname, strerror(errno)); - exit(2); + if (dfd >= 0) { + fprintf(stderr, + Name ": device %s not suitable" + " for any style of array\n", + dname); + close(dfd); } - fprintf(stderr, Name ": device %s not suitable " - "for any style of array\n", - dname); - exit(2); + fail = 1; + break; } if (st->ss != &super0 || st->minor_version != 90) @@ -443,7 +443,7 @@ int Create(struct supertype *st, char *mddev, close(fd); } } - if (raiddisks + sparedisks > st->max_devs) { + if (st && raiddisks + sparedisks > st->max_devs) { fprintf(stderr, Name ": Too many devices:" " %s metadata only supports %d\n", st->ss->name, st->max_devs); --------------------------------------------------------------------- Intel Technology Poland sp. z o.o. z siedziba w Gdansku ul. Slowackiego 173 80-298 Gdansk Sad Rejonowy Gdansk Polnoc w Gdansku, VII Wydzial Gospodarczy Krajowego Rejestru Sadowego, numer KRS 101882 NIP 957-07-52-316 Kapital zakladowy 200.000 zl This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. ��.n��������+%������w��{.n�����{����w��ܨ}���Ơz�j:+v�����w����ޙ��&�)ߡ�a����z�ޗ���ݢj��w�f