From: H. Peter Anvin Date: Fri, 25 Aug 2006 04:04:27 +0000 (-0700) Subject: Support building extlinux with klibc X-Git-Tag: syslinux-3.20-pre20~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3c6c02ff57e3f2fd72a7ec41d8bfbf14290a7adc;p=profile%2Fivi%2Fsyslinux.git Support building extlinux with klibc --- diff --git a/Makefile b/Makefile index 9c66779..dffe44c 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 96a0638..a01b7d6 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 485c337..be0e296 100644 --- a/extlinux/extlinux.c +++ b/extlinux/extlinux.c @@ -25,7 +25,9 @@ typedef uint64_t u64; #include #include #include +#ifndef __KLIBC__ #include +#endif #include #include #include @@ -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;