From: Martin Wilck Date: Wed, 30 Apr 2025 19:18:36 +0000 (+0200) Subject: mdadm: allow any valid minor number in md device name X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e270c8f99e90cf89e0c1a0534547e7b4bf285041;p=thirdparty%2Fmdadm.git mdadm: allow any valid minor number in md device name Since 25aa732 ("mdadm: numbered names verification"), it is not possible any more to create arrays /dev/md${N} with N >= 127. The limit has later been increased to 1024, which is also artificial. The error message printed by mdadm is misleading, as the problem is not POSIX compatibility here. # mdadm -C -v /dev/md9999 --name=foo -l1 -n2 /dev/loop0 /dev/loop1 mdadm: Value "/dev/md9999" cannot be set as devname. Reason: Not POSIX compatible. Given that mdadm creates an array with minor number ${N} if the argument is /dev/md${N}, the natural limit for the number is the highest minor number available, which is (1 << MINORBITS) with MINORBITS=20 on Linux. Fixes: 25aa732 ("mdadm: numbered names verification") Fixes: f786072 ("mdadm: Increase number limit in md device name to 1024.") Signed-off-by: Martin Wilck --- diff --git a/util.c b/util.c index 9fe2d227..0f775211 100644 --- a/util.c +++ b/util.c @@ -972,7 +972,8 @@ static bool is_devname_numbered(const char *devname, const char *pref, const int if (parse_num(&val, devname + pref_len) != 0) return false; - if (val > 1024) + /* Allow any number that represents a valid minor number */ + if (val >= (1 << 20)) return false; return true;