diff options
author | Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> | 2023-06-01 09:27:47 +0200 |
---|---|---|
committer | Jes Sorensen <jes@trained-monkey.org> | 2023-10-26 23:28:23 +0200 |
commit | 330c07f8e4d26f4f2d068e11f09c9df8a3380087 (patch) | |
tree | 939d37ec88cc9eeb43a47064f47307a93d691874 /Build.c | |
parent | tests: create 00confnames (diff) | |
download | mdadm-330c07f8e4d26f4f2d068e11f09c9df8a3380087.tar.xz mdadm-330c07f8e4d26f4f2d068e11f09c9df8a3380087.zip |
mdadm: set ident.devname if applicable
This patch tries to propagate the usage of struct mddev_ident for cmdline
where it is applicable. To avoid regression, this value is derived
from devlist->devname for applicable modes only.
As a result, the whole structure is passed to some functions. It produces
some changes for Build, Create and Assemble.
No functional changes intended.
The goal of the change is to unify devname validation which is done in
next patches.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
Diffstat (limited to 'Build.c')
-rw-r--r-- | Build.c | 21 |
1 files changed, 9 insertions, 12 deletions
@@ -24,8 +24,8 @@ #include "mdadm.h" -int Build(char *mddev, struct mddev_dev *devlist, - struct shape *s, struct context *c) +int Build(struct mddev_ident *ident, struct mddev_dev *devlist, struct shape *s, + struct context *c) { /* Build a linear or raid0 arrays without superblocks * We cannot really do any checks, we just do it. @@ -75,13 +75,12 @@ int Build(char *mddev, struct mddev_dev *devlist, /* We need to create the device. It can have no name. */ map_lock(&map); - mdfd = create_mddev(mddev, NULL, c->autof, LOCAL, + mdfd = create_mddev(ident->devname, NULL, c->autof, LOCAL, chosen_name, 0); if (mdfd < 0) { map_unlock(&map); return 1; } - mddev = chosen_name; map_update(&map, fd2devnm(mdfd), "none", uuid, chosen_name); map_unlock(&map); @@ -93,7 +92,7 @@ int Build(char *mddev, struct mddev_dev *devlist, array.nr_disks = s->raiddisks; array.raid_disks = s->raiddisks; array.md_minor = 0; - if (fstat_is_blkdev(mdfd, mddev, &rdev)) + if (fstat_is_blkdev(mdfd, chosen_name, &rdev)) array.md_minor = minor(rdev); array.not_persistent = 1; array.state = 0; /* not clean, but no errors */ @@ -108,8 +107,7 @@ int Build(char *mddev, struct mddev_dev *devlist, array.chunk_size = s->chunk*1024; array.layout = s->layout; if (md_set_array_info(mdfd, &array)) { - pr_err("md_set_array_info() failed for %s: %s\n", - mddev, strerror(errno)); + pr_err("md_set_array_info() failed for %s: %s\n", chosen_name, strerror(errno)); goto abort; } @@ -178,8 +176,8 @@ int Build(char *mddev, struct mddev_dev *devlist, } if (bitmap_fd >= 0) { if (ioctl(mdfd, SET_BITMAP_FILE, bitmap_fd) < 0) { - pr_err("Cannot set bitmap file for %s: %s\n", - mddev, strerror(errno)); + pr_err("Cannot set bitmap file for %s: %s\n", chosen_name, + strerror(errno)); goto abort; } } @@ -193,9 +191,8 @@ int Build(char *mddev, struct mddev_dev *devlist, } if (c->verbose >= 0) - pr_err("array %s built and started.\n", - mddev); - wait_for(mddev, mdfd); + pr_err("array %s built and started.\n", chosen_name); + wait_for(chosen_name, mdfd); close(mdfd); return 0; |