summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--NEWS3
-rw-r--r--extlinux/extlinux.c41
3 files changed, 40 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 9c66779c..dffe44c1 100644
--- a/Makefile
+++ b/Makefile
@@ -255,7 +255,7 @@ depend: local-depend
# Shortcut to build unix/syslinux using klibc
klibc:
$(MAKE) clean
- $(MAKE) CC=klcc ITARGET= ISUBDIRS=unix BSUBDIRS=
+ $(MAKE) CC=klcc ITARGET= ISUBDIRS='unix extlinux' BSUBDIRS=
# Hook to add private Makefile targets for the maintainer.
-include Makefile.private
diff --git a/NEWS b/NEWS
index 96a06381..a01b7d6a 100644
--- a/NEWS
+++ b/NEWS
@@ -10,7 +10,8 @@ Changes in 3.20:
* New library functions to load and place files in memory.
* mboot.c32 bug fixes.
* Remove 8 MB kernel size restriction.
- * Add "klibc" target for building unix/syslinux with klcc.
+ * Add "klibc" target for building unix/syslinux and
+ extlinux/extlinux with klcc (klibc-1.4.25 or later.)
* PXELINUX: Fail (and eventually reboot) if no configuration
file was found.
* COM32 module by Erwan Velu to make decisions based on DMI
diff --git a/extlinux/extlinux.c b/extlinux/extlinux.c
index 485c3373..be0e296d 100644
--- a/extlinux/extlinux.c
+++ b/extlinux/extlinux.c
@@ -25,7 +25,9 @@ typedef uint64_t u64;
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
+#ifndef __KLIBC__
#include <mntent.h>
+#endif
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
@@ -646,11 +648,14 @@ already_installed(int devfd)
int
install_loader(const char *path, int update_only)
{
- struct stat st, dst, fst;
- struct mntent *mnt = NULL;
+ struct stat st, fst;
int devfd, rv;
- FILE *mtab;
const char *devname = NULL;
+#ifndef __KLIBC__
+ struct mntent *mnt = NULL;
+ struct stat dst;
+ FILE *mtab;
+#endif
if ( stat(path, &st) || !S_ISDIR(st.st_mode) ) {
fprintf(stderr, "%s: Not a directory: %s\n", program, path);
@@ -659,6 +664,27 @@ install_loader(const char *path, int update_only)
devfd = -1;
+#ifdef __KLIBC__
+
+ /* klibc doesn't have getmntent and friends; instead, just create
+ a new device with the appropriate device type */
+
+ {
+ static char devname_buf[64];
+
+ snprintf(devname_buf, sizeof devname_buf, "/tmp/dev-%u:%u",
+ major(st.st_dev), minor(st.st_dev));
+
+ if (mknod(devname_buf, 0600, st.st_dev)) {
+ fprintf(stderr, "%s: cannot create device %s\n", program, devname);
+ return 1;
+ }
+
+ devname = devname_buf;
+ }
+
+#else
+
if ( (mtab = setmntent("/proc/mounts", "r")) ) {
while ( (mnt = getmntent(mtab)) ) {
if ( (!strcmp(mnt->mnt_type, "ext2") ||
@@ -687,6 +713,9 @@ install_loader(const char *path, int update_only)
}
fprintf(stderr, "%s is device %s\n", path, devname);
+
+#endif
+
if ( (devfd = open(devname, O_RDWR|O_SYNC)) < 0 ) {
fprintf(stderr, "%s: cannot open device %s\n", program, devname);
return 1;
@@ -706,11 +735,15 @@ install_loader(const char *path, int update_only)
}
sync();
- rv = install_bootblock(devfd, mnt->mnt_fsname);
+ rv = install_bootblock(devfd, devname);
close(devfd);
sync();
+#ifdef __KLIBC__
+ unlink(devname);
+#else
endmntent(mtab);
+#endif
if ( rv ) return rv;