--- geometry.c Fri Jun 20 08:24:52 1997 +++ ../geometry.c Thu Aug 13 00:19:02 1998 @@ -2,7 +2,9 @@ /* Copyright 1992-1997 Werner Almesberger. See file COPYING for details. */ +/* modified by mrs.brisby@nimh.org to support MD devices */ +#include #include #include #include @@ -257,6 +259,58 @@ #endif } +/* mrs.brisby@nimh.org */ +static void geo_query_dev(GEOMETRY *geo,int device,int all); +static int geo_lookup_mtab_loop(GEOMETRY *geo, int device, int all) +{ + static int displayed_warning = 0; + FILE *fp; + struct stat st; + char line[256], *a, *b, *c; + + if (device & 0x0900) { + fp = fopen("/etc/mdtab", "r"); + while (fgets(line, 255, fp)) { + a = line; + b = strpbrk(a, " \t"); + if (b) { + *b = 0; + b++; + while (isspace(*b)) b++; + } else + continue; + c = strpbrk(b, " \t"); + if (c) { + *c = 0; + c++; + while (isspace(*c)) c++; + } else + continue; + if (stat(a, &st)) + continue; + if (strncmp(b, "raid1", 5) == 0 && st.st_rdev == device) { + b = strpbrk(c, " \t"); + if (b) + *b = 0; + if (stat(c, &st)) + continue; + fclose(fp); + geo_query_dev(geo, st.st_rdev, all); + if (!displayed_warning) + fprintf(stderr, "Warning: you should run /sbin/ckraid immediatly.\n"); + displayed_warning = 1; + return 1; + } else if (st.st_rdev == device) { + c = strchr(b, ','); + if (c) + *c = 0; + die("MD personality `%s' unsupported", b); + } + } + fclose(fp); + } + return 0; +} static void geo_query_dev(GEOMETRY *geo,int device,int all) { @@ -320,7 +374,9 @@ geo->start = hdprm.start; break; default: - die("Sorry, don't know how to handle device 0x%04x",device); + /* mrs.brisby@nimh.org */ + if (!geo_lookup_mtab_loop(geo, device, all)) + die("Sorry, don't know how to handle device 0x%04x",device); } if (get_all) dev_close(&dev); if (!nowarn && (geo->device & 0x7f) >= BIOS_MAX_DEVS)