X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fmdadm.git;a=blobdiff_plain;f=mdassemble.c;h=d0d0707e123412b6233fad96285ad6eb8114c137;hp=231754800112b6bfd5bce5c0e1803a0e700290f2;hb=df0d4ea04e34fc5d499056b00fa1e0a25f21453e;hpb=d1f1011b94caa3506c63fb3d1d1a99dd282c7bc5 diff --git a/mdassemble.c b/mdassemble.c index 23175480..d0d0707e 100644 --- a/mdassemble.c +++ b/mdassemble.c @@ -1,7 +1,7 @@ /* * mdassemble - assemble Linux "md" devices aka RAID arrays. * - * Copyright (C) 2001-2006 Neil Brown + * Copyright (C) 2001-2009 Neil Brown * Copyright (C) 2003 Luca Berra * * @@ -20,12 +20,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Author: Neil Brown - * Email: - * Paper: Neil Brown - * School of Computer Science and Engineering - * The University of New South Wales - * Sydney, 2052 - * Australia + * Email: */ #include "mdadm.h" @@ -33,7 +28,7 @@ /* from readme.c */ mapping_t pers[] = { - { "linear", -1}, + { "linear", LEVEL_LINEAR}, { "raid0", 0}, { "0", 0}, { "stripe", 0}, @@ -44,8 +39,8 @@ mapping_t pers[] = { { "4", 4}, { "raid5", 5}, { "5", 5}, - { "multipath", -4}, - { "mp", -4}, + { "multipath", LEVEL_MULTIPATH}, + { "mp", LEVEL_MULTIPATH}, { "raid6", 6}, { "6", 6}, { "raid10", 10}, @@ -54,10 +49,10 @@ mapping_t pers[] = { }; #ifndef MDASSEMBLE_AUTO -/* from mdadm.c */ -int open_mddev(char *dev, int autof/*unused */) +/* from mdopen.c */ +int open_mddev(char *dev, int report_errors/*unused*/) { - int mdfd = open(dev, O_RDWR, 0); + int mdfd = open(dev, O_RDWR); if (mdfd < 0) fprintf(stderr, Name ": error opening %s: %s\n", dev, strerror(errno)); @@ -69,9 +64,22 @@ int open_mddev(char *dev, int autof/*unused */) } return mdfd; } +int create_mddev(char *dev, char *name, int autof/*unused*/, int trustworthy, + char *chosen) +{ + return open_mddev(dev, 0); +} #endif +int map_update(struct map_ent **mpp, int devnum, char *metadata, + int *uuid, char *path) +{ + return 0; +} +struct map_ent *map_by_name(struct map_ent **mpp, char *name) +{ + return NULL; +} -char *configfile = NULL; int rv; int mdfd = -1; int runstop = 0; @@ -79,25 +87,27 @@ int readonly = 0; int verbose = 0; int force = 0; -int main() { - mddev_ident_t array_list = conf_get_ident(configfile, NULL); +int main(int argc, char *argv[]) { + mddev_ident_t array_list = conf_get_ident(NULL); if (!array_list) { fprintf(stderr, Name ": No arrays found in config file\n"); rv = 1; } else for (; array_list; array_list = array_list->next) { mdu_array_info_t array; - mdfd = open_mddev(array_list->devname, array_list->autof); - if (mdfd < 0) { - rv |= 1; + if (strcasecmp(array_list->devname, "") == 0) continue; - } - if (ioctl(mdfd, GET_ARRAY_INFO, &array)>=0) - /* already assembled, skip */ + mdfd = open_mddev(array_list->devname, 0); + if (mdfd >= 0 && ioctl(mdfd, GET_ARRAY_INFO, &array) == 0) { + rv |= Manage_ro(array_list->devname, mdfd, -1); /* make it readwrite */ continue; - rv |= Assemble(array_list->st, array_list->devname, mdfd, - array_list, configfile, - NULL, NULL, - readonly, runstop, NULL, NULL, verbose, force); + } + if (mdfd >= 0) + close(mdfd); + rv |= Assemble(array_list->st, array_list->devname, + array_list, NULL, NULL, + readonly, runstop, NULL, NULL, 0, + verbose, force); } + return rv; }