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.
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;
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;
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);
/* 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;
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",