Releasing debian version 4.06+dfsg-2.
[syslinux-debian/hramrach.git] / com32 / gpllib / disk / bootloaders.c
blobe0340112f1d20231cb811c90b6ef8f9d8894c45e
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2009 Pierre-Alexandre Meyer
5 * This file is part of Syslinux, and is made available under
6 * the terms of the GNU General Public License version 2.
8 * ----------------------------------------------------------------------- */
10 #include <disk/bootloaders.h>
11 #include <disk/common.h>
12 #include <disk/geom.h>
13 #include <disk/read.h>
14 #include <stdlib.h>
15 #include <string.h>
17 /**
18 * get_bootloader_string - return a string describing the boot code in a
19 * bootsector
20 * @d: driveinfo struct describing the drive
21 * @p: partition to scan (usually the active one)
22 * @buffer: pre-allocated buffer
23 * @buffer_size: @buffer size
24 **/
25 int get_bootloader_string(struct driveinfo *d, const struct part_entry *p,
26 char *buffer, const int buffer_size)
28 char boot_sector[SECTOR * sizeof(char)];
30 if (read_sectors(d, &boot_sector, p->start_lba, 1) == -1)
31 return -1;
32 else {
33 if (!strncmp(boot_sector + 3, "SYSLINUX", 8))
34 strlcpy(buffer, "SYSLINUX", buffer_size - 1);
35 else if (!strncmp(boot_sector + 3, "EXTLINUX", 8))
36 strlcpy(buffer, "EXTLINUX", buffer_size - 1);
37 else if (!strncmp(boot_sector + 3, "MSWIN4.1", 8))
38 strlcpy(buffer, "MSWIN4.1", buffer_size - 1);
39 else
40 return -1;
41 /* Add more... */
43 buffer[buffer_size - 1] = '\0';
44 return 0;