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>
18 * get_bootloader_string - return a string describing the boot code in a
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
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)
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);
43 buffer
[buffer_size
- 1] = '\0';