diff options
Diffstat (limited to 'contrib/syslinux-4.02/com32/gpllib/disk/bootloaders.c')
-rw-r--r-- | contrib/syslinux-4.02/com32/gpllib/disk/bootloaders.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/contrib/syslinux-4.02/com32/gpllib/disk/bootloaders.c b/contrib/syslinux-4.02/com32/gpllib/disk/bootloaders.c new file mode 100644 index 0000000..e034011 --- /dev/null +++ b/contrib/syslinux-4.02/com32/gpllib/disk/bootloaders.c @@ -0,0 +1,46 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2009 Pierre-Alexandre Meyer + * + * This file is part of Syslinux, and is made available under + * the terms of the GNU General Public License version 2. + * + * ----------------------------------------------------------------------- */ + +#include <disk/bootloaders.h> +#include <disk/common.h> +#include <disk/geom.h> +#include <disk/read.h> +#include <stdlib.h> +#include <string.h> + +/** + * get_bootloader_string - return a string describing the boot code in a + * bootsector + * @d: driveinfo struct describing the drive + * @p: partition to scan (usually the active one) + * @buffer: pre-allocated buffer + * @buffer_size: @buffer size + **/ +int get_bootloader_string(struct driveinfo *d, const struct part_entry *p, + char *buffer, const int buffer_size) +{ + char boot_sector[SECTOR * sizeof(char)]; + + if (read_sectors(d, &boot_sector, p->start_lba, 1) == -1) + return -1; + else { + if (!strncmp(boot_sector + 3, "SYSLINUX", 8)) + strlcpy(buffer, "SYSLINUX", buffer_size - 1); + else if (!strncmp(boot_sector + 3, "EXTLINUX", 8)) + strlcpy(buffer, "EXTLINUX", buffer_size - 1); + else if (!strncmp(boot_sector + 3, "MSWIN4.1", 8)) + strlcpy(buffer, "MSWIN4.1", buffer_size - 1); + else + return -1; + /* Add more... */ + + buffer[buffer_size - 1] = '\0'; + return 0; + } +} |