From 0ac822d2744359de5e3bd6f19d9e33fb523a01ec Mon Sep 17 00:00:00 2001 From: Paulo Alcantara Date: Fri, 15 Apr 2011 14:55:29 -0300 Subject: [PATCH] libinstaller: implement syslinux_already_installed syslinux_already_installed function will be used in both extlinux and syslinux for checking if the boot sector has either the string "SYSLINUX" or "EXTLINUX" in the OEMID field. Signed-off-by: Paulo Alcantara --- libinstaller/syslxcom.c | 13 +++++++++++++ libinstaller/syslxcom.h | 1 + 2 files changed, 14 insertions(+) diff --git a/libinstaller/syslxcom.c b/libinstaller/syslxcom.c index b176f6d..1de85aa 100644 --- a/libinstaller/syslxcom.c +++ b/libinstaller/syslxcom.c @@ -284,3 +284,16 @@ int sectmap(int fd, sector_t *sectors, int nsectors) return sectmap_fib(fd, sectors, nsectors); } + +/* + * SYSLINUX installs the string 'SYSLINUX' at offset 3 in the boot + * sector; this is consistent with FAT filesystems. Earlier versions + * would install the string "EXTLINUX" instead, handle both. + */ +int syslinux_already_installed(int dev_fd) +{ + char buffer[8]; + + xpread(dev_fd, buffer, 8, 3); + return !memcmp(buffer, "SYSLINUX", 8) || !memcmp(buffer, "EXTLINUX", 8); +} diff --git a/libinstaller/syslxcom.h b/libinstaller/syslxcom.h index 39ca09d..bf186ca 100644 --- a/libinstaller/syslxcom.h +++ b/libinstaller/syslxcom.h @@ -18,5 +18,6 @@ ssize_t xpwrite(int fd, const void *buf, size_t count, off_t offset); void clear_attributes(int fd); void set_attributes(int fd); int sectmap(int fd, sector_t *sectors, int nsectors); +int syslinux_already_installed(int dev_fd); #endif -- 2.7.4