Re: [LIP] how to find boot loader installed on m/c ? - LILO/grub?
Binand Sethumadhavan <[email protected]>
| Newsgroups | gmane.user-groups.linux.india.programmers |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Nov 06, 2003 at 05:39:51PM +0530, Ritesh Bharati wrote:
> hi,
> On my m/c (fedora test3) i have both rpm packages installed, so rpm -qa
> witll not help. But yes i have /etc/lilo.conf.anaconda file and my
> bootloader is grub.
> This test might do. Is any other way?? Any entry in MBR ..:).
Sigh. On a programming list, a program solution.
This program seems to detect all LILO installations for me. I don't have
a GRUB installation to check, however.
Usage:
1. Save the code into bootloader.c
2. Compile it - make bootloader
3. Run it - ./bootloader /dev/hda (use your disk here)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char **argv) {
char *dev = argv[1];
char buf[4];
int fd;
fd = open (dev, O_RDONLY);
if (fd < 0) {
perror ("open");
exit (1);
}
if (lseek (fd, 6, SEEK_SET) < 0) {
perror ("lseek");
exit (1);
}
if (read (fd, buf, 4) != 4) {
perror ("read");
exit (1);
}
if (buf[0] == 0x4c && buf[1] == 0x49 && buf[2] == 0x4c && buf[3] == 0x4f) {
printf ("Boot Loader is LILO\n");
} else {
printf ("Other Boot Loader - Possibly Grub\n");
}
close(fd);
return 0;
}
Binand
PS: How did I know? I ran xxd /dev/hda and looked for tell-tale signs.
--
Russian Roulette with Unix:
while :; do kill $RANDOM &> /dev/null && break || sleep 1; done
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/