open_subarray: pass subarray name as explicit arg.
Rather than hiding this arg in the 'st' structure, pass it explicitly. This is a first step to getting rid of 'subarray' from 'supertype'. The strcpy in open_subarray should have better error checking, but it will disappear soon so there is little point. Signed-off-by: NeilBrown <neilb@suse.de.
This commit is contained in:
parent
8d86ffefdf
commit
feab51f8f7
11
Kill.c
11
Kill.c
|
@ -96,16 +96,7 @@ int Kill_subarray(char *dev, char *subarray, int quiet)
|
|||
|
||||
memset(st, 0, sizeof(*st));
|
||||
|
||||
if (snprintf(st->subarray, sizeof(st->subarray), "%s", subarray) >=
|
||||
(int)sizeof(st->subarray)) {
|
||||
if (!quiet)
|
||||
fprintf(stderr,
|
||||
Name ": Input overflow for subarray '%s' > %zu bytes\n",
|
||||
subarray, sizeof(st->subarray) - 1);
|
||||
return 2;
|
||||
}
|
||||
|
||||
fd = open_subarray(dev, st, quiet);
|
||||
fd = open_subarray(dev, subarray, st, quiet);
|
||||
if (fd < 0)
|
||||
return 2;
|
||||
|
||||
|
|
10
Manage.c
10
Manage.c
|
@ -1037,16 +1037,8 @@ int Update_subarray(char *dev, char *subarray, char *update, mddev_ident_t ident
|
|||
int fd, rv = 2;
|
||||
|
||||
memset(st, 0, sizeof(*st));
|
||||
if (snprintf(st->subarray, sizeof(st->subarray), "%s", subarray) >=
|
||||
(signed)sizeof(st->subarray)) {
|
||||
if (!quiet)
|
||||
fprintf(stderr,
|
||||
Name ": Input overflow for subarray '%s' > %zu bytes\n",
|
||||
subarray, sizeof(st->subarray) - 1);
|
||||
return 2;
|
||||
}
|
||||
|
||||
fd = open_subarray(dev, st, quiet);
|
||||
fd = open_subarray(dev, subarray, st, quiet);
|
||||
if (fd < 0)
|
||||
return 2;
|
||||
|
||||
|
|
2
mdadm.h
2
mdadm.h
|
@ -1032,7 +1032,7 @@ extern int open_container(int fd);
|
|||
extern int is_container_member(struct mdstat_ent *ent, char *devname);
|
||||
extern int is_subarray_active(char *subarray, char *devname);
|
||||
int is_container_active(char *devname);
|
||||
extern int open_subarray(char *dev, struct supertype *st, int quiet);
|
||||
extern int open_subarray(char *dev, char *subarray, struct supertype *st, int quiet);
|
||||
extern struct superswitch *version_to_superswitch(char *vers);
|
||||
|
||||
extern int mdmon_running(int devnum);
|
||||
|
|
6
util.c
6
util.c
|
@ -1441,12 +1441,12 @@ int is_container_active(char *container)
|
|||
|
||||
/* open_subarray - opens a subarray in a container
|
||||
* @dev: container device name
|
||||
* @st: supertype with only ->subarray set
|
||||
* @st: empty supertype
|
||||
* @quiet: block reporting errors flag
|
||||
*
|
||||
* On success returns an fd to a container and fills in *st
|
||||
*/
|
||||
int open_subarray(char *dev, struct supertype *st, int quiet)
|
||||
int open_subarray(char *dev, char *subarray, struct supertype *st, int quiet)
|
||||
{
|
||||
struct mdinfo *mdi;
|
||||
int fd, err = 1;
|
||||
|
@ -1498,6 +1498,8 @@ int open_subarray(char *dev, struct supertype *st, int quiet)
|
|||
goto free_sysfs;
|
||||
}
|
||||
|
||||
strncpy(st->subarray, subarray, sizeof(st->subarray)-1);
|
||||
|
||||
if (st->ss->load_super(st, fd, NULL)) {
|
||||
if (!quiet)
|
||||
fprintf(stderr, Name ": Failed to find subarray-%s in %s\n",
|
||||
|
|
Loading…
Reference in New Issue