summaryrefslogtreecommitdiffstats
path: root/mdadm.c
diff options
context:
space:
mode:
authorMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>2023-06-01 09:27:48 +0200
committerJes Sorensen <jes@trained-monkey.org>2023-10-26 23:28:23 +0200
commit67417d9222c505103357191bb0e0ae300892e8a9 (patch)
treeec4990547c9556b08af0b7a098f44d4b9622eeae /mdadm.c
parentmdadm: set ident.devname if applicable (diff)
downloadmdadm-67417d9222c505103357191bb0e0ae300892e8a9.tar.xz
mdadm-67417d9222c505103357191bb0e0ae300892e8a9.zip
mdadm: refactor ident->name handling
Create dedicated setter for name in mddev_ident and propagate it. Following changes are made: - move duplicated code from config.c and mdadm.c into new function. - Add error enum in mdadm.h. - Use MD_NAME_MAX instead of hardcoded value in mddev_ident. - Use secure functions. - Add more detailed verification of the name. - make error messages reusable for cmdline and config: - for cmdline, these are errors so use pr_err(). - for config, these are just warnings, so use pr_info(). Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
Diffstat (limited to 'mdadm.c')
-rw-r--r--mdadm.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/mdadm.c b/mdadm.c
index 0a56ed26..8bc9304e 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -690,20 +690,14 @@ int main(int argc, char *argv[])
case O(CREATE,'N'):
case O(ASSEMBLE,'N'):
case O(MISC,'N'):
- if (ident.name[0]) {
- pr_err("name cannot be set twice. Second value %s.\n", optarg);
- exit(2);
- }
if (mode == MISC && !c.subarray) {
pr_err("-N/--name only valid with --update-subarray in misc mode\n");
exit(2);
}
- if (strlen(optarg) > 32) {
- pr_err("name '%s' is too long, 32 chars max.\n",
- optarg);
+
+ if (ident_set_name(&ident, optarg) != MDADM_STATUS_SUCCESS)
exit(2);
- }
- strcpy(ident.name, optarg);
+
continue;
case O(ASSEMBLE,'m'): /* super-minor for array */