1 |
/* device.c - Some helper functions for OS devices and BIOS drives */ |
/* device.c - Some helper functions for OS devices and BIOS drives */ |
2 |
/* |
/* |
3 |
* GRUB -- GRand Unified Bootloader |
* GRUB -- GRand Unified Bootloader |
4 |
* Copyright (C) 1999, 2000 Free Software Foundation, Inc. |
* Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. |
5 |
* |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
267 |
#endif |
#endif |
268 |
} |
} |
269 |
|
|
270 |
|
#ifdef __linux__ |
271 |
|
static void |
272 |
|
get_dac960_disk_name (char *name, int controller, int drive) |
273 |
|
{ |
274 |
|
sprintf (name, "/dev/rd/c%dd%d", controller, drive); |
275 |
|
} |
276 |
|
#endif |
277 |
|
|
278 |
/* Check if DEVICE can be read. If an error occurs, return zero, |
/* Check if DEVICE can be read. If an error occurs, return zero, |
279 |
otherwise return non-zero. */ |
otherwise return non-zero. */ |
280 |
int |
int |
585 |
} |
} |
586 |
} |
} |
587 |
|
|
588 |
|
#ifdef __linux__ |
589 |
|
/* This is for DAC960 - we have |
590 |
|
/dev/rd/c<controller>d<logical drive>p<partition>. |
591 |
|
|
592 |
|
DAC960 driver currently supports up to 8 controllers, 32 logical |
593 |
|
drives, and 7 partitions. */ |
594 |
|
{ |
595 |
|
int controller, drive; |
596 |
|
|
597 |
|
for (controller = 0; controller < 8; controller++) |
598 |
|
{ |
599 |
|
for (drive = 0; drive < 15; drive++) |
600 |
|
{ |
601 |
|
char name[24]; |
602 |
|
|
603 |
|
get_dac960_disk_name (name, controller, drive); |
604 |
|
if (check_device (name)) |
605 |
|
{ |
606 |
|
(*map)[num_hd + 0x80] = strdup (name); |
607 |
|
assert ((*map)[num_hd + 0x80]); |
608 |
|
|
609 |
|
/* If the device map file is opened, write the map. */ |
610 |
|
if (fp) |
611 |
|
fprintf (fp, "(hd%d)\t%s\n", num_hd, name); |
612 |
|
|
613 |
|
num_hd++; |
614 |
|
} |
615 |
|
} |
616 |
|
} |
617 |
|
} |
618 |
|
#endif /* __linux__ */ |
619 |
|
|
620 |
/* OK, close the device map file if opened. */ |
/* OK, close the device map file if opened. */ |
621 |
if (fp) |
if (fp) |
622 |
fclose (fp); |
fclose (fp); |