Am Montag, den 18.08.2008, 17:05 +0200 schrieb Felix Zielcke: > Am Donnerstag, den 14.08.2008, 23:15 +0200 schrieb Felix Zielcke: > > So I made now the getroot.diff new without indenting the whole switch > > block by 2 spaces. > > Thanks to Marco and Emacs, I know now that the `case' on `switch' is a > special case :) > GCS isn't talking about this and I just assumed on seeing it that it's > wrong without bothering to look at other code :) > > Thanks to Robert for the idea to make one of the variables a macro. > > So the difference between this and last are: > > I used Emacs instead of vi :D > j and k are swapped > new k is now #define > l is const > > Changelog (in attached file) is still the same
/me screams load. I even open the file again to put the changelog in it and then don't notice that it's the old one :( Well attached is now the right one.
2008-08-14 Felix Zielcke <[EMAIL PROTECTED]> * util/getroot.c: Include <config.h>. (grub_util_get_grub_dev): Rewritten to use asprintf for mdraid devices, added support for /dev/md/N devices and handles LVM double dash escaping. Index: util/getroot.c =================================================================== --- util/getroot.c (Revision 1820) +++ util/getroot.c (Arbeitskopie) @@ -17,6 +17,7 @@ * along with GRUB. If not, see <http://www.gnu.org/licenses/>. */ +#include <config.h> #include <sys/stat.h> #include <unistd.h> #include <string.h> @@ -407,58 +408,47 @@ grub_util_get_grub_dev (const char *os_d switch (grub_util_get_dev_abstraction (os_dev)) { case GRUB_DEV_ABSTRACTION_LVM: - grub_dev = xmalloc (strlen (os_dev) - 12 + 1); - strcpy (grub_dev, os_dev + 12); + { +#define k sizeof ("/dev/mapper/") - 1 - break; + unsigned char i, j; + const unsigend char l = strlen (os_dev) - j + 1; - case GRUB_DEV_ABSTRACTION_RAID: - grub_dev = xmalloc (20); + grub_dev = xmalloc (strlen (os_dev) - strlen ("/dev/mapper/") + 1); + + for (i = 0, j = 0; i < l; i++) + { + grub_dev[j] = os_dev[k + i]; + j++; + if (os_dev[k + i] == '-' && os_dev[k + i + 1] == '-') + i++; + } + } + + break; + case GRUB_DEV_ABSTRACTION_RAID: + if (os_dev[7] == '_' && os_dev[8] == 'd') { - const char *p; - /* This a partitionable RAID device of the form /dev/md_dNNpMM. */ - int i; - - grub_dev[0] = 'm'; - grub_dev[1] = 'd'; - i = 2; - p = os_dev + 9; - while (*p >= '0' && *p <= '9') - { - grub_dev[i] = *p; - i++; - p++; - } - - if (*p == '\0') - grub_dev[i] = '\0'; - else if (*p == 'p') - { - p++; - grub_dev[i] = ','; - i++; - - while (*p >= '0' && *p <= '9') - { - grub_dev[i] = *p; - i++; - p++; - } + char *p; + + p = strchr (os_dev, 'p'); + if (p) + *p = ','; - grub_dev[i] = '\0'; - } - else - grub_util_error ("Unknown kind of RAID device `%s'", os_dev); + asprintf (&grub_dev, "md%s", os_dev + sizeof ("/dev/md_d") - 1); } else if (os_dev[7] >= '0' && os_dev[7] <= '9') { - memcpy (grub_dev, os_dev + 5, 7); - grub_dev[7] = '\0'; + asprintf (&grub_dev, "md%s", os_dev + sizeof ("/dev/md") - 1); + } + else if (os_dev[7] == '/' && os_dev[8] >= '0' && os_dev[8] <= '9') + { + asprintf (&grub_dev, "md%s", os_dev + sizeof ("/dev/md/") - 1); } else grub_util_error ("Unknown kind of RAID device `%s'", os_dev);
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel