# Main Makefile for SYSLINUX
#
+OSTYPE = $(shell uname -msr)
CC = gcc
INCLUDE =
-CFLAGS = -Wall -O2 -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
+CFLAGS = -Wall -O2 -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
PIC = -fPIC
-LDFLAGS = -O2 -s
+LDFLAGS = -O2 -s
AR = ar
RANLIB = ranlib
NASMSRC = ldlinux.asm syslinux.asm copybs.asm \
pxelinux.asm mbr.asm isolinux.asm isolinux-debug.asm
SOURCES = $(CSRC) *.h $(NASMSRC) *.inc
+# syslinux.exe is BTARGET so as to not require everyone to have the
+# mingw suite installed
BTARGET = kwdhash.gen version.gen ldlinux.bss ldlinux.sys ldlinux.bin \
pxelinux.0 mbr.bin isolinux.bin isolinux-debug.bin \
- libsyslinux.a $(LIB_SO)
+ libsyslinux.a syslinux.exe $(LIB_SO)
ITARGET = syslinux.com syslinux syslinux-nomtools copybs.com gethostip \
mkdiskimage
DOCS = COPYING NEWS README TODO *.doc sample com32
INSTALL_BIN = syslinux gethostip ppmtolss16 lss16toppm
# Things to install in /usr/lib/syslinux
INSTALL_AUX = pxelinux.0 isolinux.bin isolinux-debug.bin \
- syslinux.com copybs.com memdisk/memdisk
+ syslinux.com syslinux.exe copybs.com memdisk/memdisk
# Things to install in /usr/lib
INSTALL_LIB = $(LIB_SO) libsyslinux.a
# Things to install in /usr/include
$(CC) $(INCLUDE) $(CFLAGS) $(PIC) -DPATCH_OFFSET=`cat patch.offset` \
-c -o $@ $<
+syslinux.exe: win32/syslinux-mingw.c libsyslinux.a
+ $(MAKE) -C win32 all
+
gethostip.o: gethostip.c
gethostip: gethostip.o
tidy: local-tidy
$(MAKE) -C memdisk tidy
+ $(MAKE) -C win32 tidy
local-clean:
rm -f $(ITARGET)
clean: local-tidy local-clean
$(MAKE) -C sample clean
$(MAKE) -C memdisk clean
+ $(MAKE) -C win32 clean
dist: tidy
for dir in . sample memdisk ; do \
spotless: local-clean dist local-spotless
$(MAKE) -C sample spotless
$(MAKE) -C memdisk spotless
+ $(MAKE) -C win32 spotless
.depend:
rm -f .depend
example, the Ethernet (type 1) address 88:99:AA:BB:CC:DD
would query the file pxelinux.cfg/01-88-99-aa-bb-cc-dd.
* PXELINUX: Fix bug involving non-IP-based config file names.
+ * SYSLINUX: New installer for WinNT-based systems, from Lars Munch.
Changes in 2.04:
* ALL: Reclaim even more low memory by observing that
uid_t euid; /* Initial euid */
pid_t mypid;
-enum bs_offsets {
- bsJump = 0x00,
- bsOemName = 0x03,
- bsBytesPerSec = 0x0b,
- bsSecPerClust = 0x0d,
- bsResSectors = 0x0e,
- bsFATs = 0x10,
- bsRootDirEnts = 0x11,
- bsSectors = 0x13,
- bsMedia = 0x15,
- bsFATsecs = 0x16,
- bsSecPerTrack = 0x18,
- bsHeads = 0x1a,
- bsHiddenSecs = 0x1c,
- bsHugeSectors = 0x20,
- bsDriveNumber = 0x24,
- bsReserved1 = 0x25,
- bsBootSignature = 0x26,
- bsVolumeID = 0x27,
- bsVolumeLabel = 0x2b,
- bsFileSysType = 0x36,
- bsCode = 0x3e,
- bsSignature = 0x1fe
-};
-
-/*
- * Access functions for littleendian numbers, possibly misaligned.
- */
-static u_int16_t get_16(unsigned char *p)
-{
- return (u_int16_t)p[0] + ((u_int16_t)p[1] << 8);
-}
-
-static u_int32_t get_32(unsigned char *p)
-{
- return (u_int32_t)p[0] + ((u_int32_t)p[1] << 8) +
- ((u_int32_t)p[2] << 16) + ((u_int32_t)p[3] << 24);
-}
-
-#if 0 /* Not needed */
-static void set_16(unsigned char *p, u_int16_t v)
-{
- p[0] = (v & 0xff);
- p[1] = ((v >> 8) & 0xff);
-}
-
-static void set_32(unsigned char *p, u_int32_t v)
-{
- p[0] = (v & 0xff);
- p[1] = ((v >> 8) & 0xff);
- p[2] = ((v >> 16) & 0xff);
- p[3] = ((v >> 24) & 0xff);
-}
-#endif
-
void usage(void)
{
fprintf(stderr, "Usage: %s [-sf] [-o offset] device\n", program);
const unsigned char *cdp;
int dev_fd, fd;
struct stat st;
- int nb, left, veryold;
- unsigned int sectors, clusters;
+ int nb, left;
int err = 0;
pid_t f, w;
int status;
xpread(dev_fd, sectbuf, 512, offset);
fsync(dev_fd);
-
+
/*
* Check to see that what we got was indeed an MS-DOS boot sector/superblock
*/
-
- if ( sectbuf[bsBootSignature] == 0x29 ) {
- /* It's DOS, and it has all the new nice fields */
-
- veryold = 0;
-
- sectors = get_16(sectbuf+bsSectors);
- sectors = sectors ? sectors : get_32(sectbuf+bsHugeSectors);
- clusters = sectors / sectbuf[bsSecPerClust];
-
- if ( !memcmp(sectbuf+bsFileSysType, "FAT12 ", 8) ) {
- if ( clusters > 4086 ) {
- fprintf(stderr, "%s: ERROR: FAT12 but claims more than 4086 clusters\n",
- device);
- exit(1);
- }
- } else if ( !memcmp(sectbuf+bsFileSysType, "FAT16 ", 8) ) {
- if ( clusters <= 4086 ) {
- fprintf(stderr, "%s: ERROR: FAT16 but claims less than 4086 clusters\n",
- device);
- exit(1);
- }
- } else if ( !memcmp(sectbuf+bsFileSysType, "FAT ", 8) ) {
- /* OS/2 sets up the filesystem as just `FAT'. */
- } else {
- fprintf(stderr, "%s: filesystem type \"%8.8s\" not supported\n",
- device, sectbuf+bsFileSysType);
- exit(1);
- }
- } else {
- veryold = 1;
-
- if ( sectbuf[bsSecPerClust] & (sectbuf[bsSecPerClust] - 1) ||
- sectbuf[bsSecPerClust] == 0 ) {
- fprintf(stderr, "%s: This doesn't look like a FAT filesystem\n",
- device);
- }
-
- sectors = get_16(sectbuf+bsSectors);
- sectors = sectors ? sectors : get_32(sectbuf+bsHugeSectors);
- clusters = sectors / sectbuf[bsSecPerClust];
- }
-
- if ( get_16(sectbuf+bsBytesPerSec) != 512 ) {
- fprintf(stderr, "%s: Sector sizes other than 512 not supported\n",
- device);
+ if(!syslinux_check_bootsect(sectbuf,device)) {
exit(1);
}
- if ( sectbuf[bsSecPerClust] > 32 ) {
- fprintf(stderr, "%s: Cluster sizes larger than 16K not supported\n",
- device);
- }
/*
* Now mount the device.
char *device; /* Device to install to */
pid_t mypid;
-enum bs_offsets {
- bsJump = 0x00,
- bsOemName = 0x03,
- bsBytesPerSec = 0x0b,
- bsSecPerClust = 0x0d,
- bsResSectors = 0x0e,
- bsFATs = 0x10,
- bsRootDirEnts = 0x11,
- bsSectors = 0x13,
- bsMedia = 0x15,
- bsFATsecs = 0x16,
- bsSecPerTrack = 0x18,
- bsHeads = 0x1a,
- bsHiddenSecs = 0x1c,
- bsHugeSectors = 0x20,
- bsDriveNumber = 0x24,
- bsReserved1 = 0x25,
- bsBootSignature = 0x26,
- bsVolumeID = 0x27,
- bsVolumeLabel = 0x2b,
- bsFileSysType = 0x36,
- bsCode = 0x3e,
- bsSignature = 0x1fe
-};
-
-/*
- * Access functions for littleendian numbers, possibly misaligned.
- */
-static u_int16_t get_16(unsigned char *p)
-{
- return (u_int16_t)p[0] + ((u_int16_t)p[1] << 8);
-}
-
-static u_int32_t get_32(unsigned char *p)
-{
- return (u_int32_t)p[0] + ((u_int32_t)p[1] << 8) +
- ((u_int32_t)p[2] << 16) + ((u_int32_t)p[3] << 24);
-}
-
-#if 0 /* Not needed */
-static void set_16(unsigned char *p, u_int16_t v)
-{
- p[0] = (v & 0xff);
- p[1] = ((v >> 8) & 0xff);
-}
-
-static void set_32(unsigned char *p, u_int32_t v)
-{
- p[0] = (v & 0xff);
- p[1] = ((v >> 8) & 0xff);
- p[2] = ((v >> 16) & 0xff);
- p[3] = ((v >> 24) & 0xff);
-}
-#endif
-
void usage(void)
{
fprintf(stderr, "Usage: %s [-sf] [-o offset] device\n", program);
static unsigned char sectbuf[512];
int dev_fd;
struct stat st;
- int veryold;
- unsigned int sectors, clusters;
int status;
char **argp, *opt;
int force = 0; /* -f (force) option */
/*
* Check to see that what we got was indeed an MS-DOS boot sector/superblock
*/
-
- if ( sectbuf[bsBootSignature] == 0x29 ) {
- /* It's DOS, and it has all the new nice fields */
-
- veryold = 0;
-
- sectors = get_16(sectbuf+bsSectors);
- sectors = sectors ? sectors : get_32(sectbuf+bsHugeSectors);
- clusters = sectors / sectbuf[bsSecPerClust];
-
- if ( !memcmp(sectbuf+bsFileSysType, "FAT12 ", 8) ) {
- if ( clusters > 4086 ) {
- fprintf(stderr, "%s: ERROR: FAT12 but claims more than 4086 clusters\n",
- device);
- exit(1);
- }
- } else if ( !memcmp(sectbuf+bsFileSysType, "FAT16 ", 8) ) {
- if ( clusters <= 4086 ) {
- fprintf(stderr, "%s: ERROR: FAT16 but claims less than 4086 clusters\n",
- device);
- exit(1);
- }
- } else if ( !memcmp(sectbuf+bsFileSysType, "FAT ", 8) ) {
- /* OS/2 sets up the filesystem as just `FAT'. */
- } else {
- fprintf(stderr, "%s: filesystem type \"%8.8s\" not supported\n",
- device, sectbuf+bsFileSysType);
- exit(1);
- }
- } else {
- veryold = 1;
-
- if ( sectbuf[bsSecPerClust] & (sectbuf[bsSecPerClust] - 1) ||
- sectbuf[bsSecPerClust] == 0 ) {
- fprintf(stderr, "%s: This doesn't look like a FAT filesystem\n",
- device);
- }
-
- sectors = get_16(sectbuf+bsSectors);
- sectors = sectors ? sectors : get_32(sectbuf+bsHugeSectors);
- clusters = sectors / sectbuf[bsSecPerClust];
- }
-
- if ( get_16(sectbuf+bsBytesPerSec) != 512 ) {
- fprintf(stderr, "%s: Sector sizes other than 512 not supported\n",
- device);
+ if(!syslinux_check_bootsect(sectbuf,device)) {
exit(1);
}
- if ( sectbuf[bsSecPerClust] > 32 ) {
- fprintf(stderr, "%s: Cluster sizes larger than 16K not supported\n",
- device);
- }
/*
* Create an mtools configuration file
umount /mnt
- ---- DOS procedure ----
+ ---- DOS/Windows procedure ----
To make this installation in DOS only, you need the utility copybs.com
-(included with SYSLINUX) as well as the syslinux.com installer.
+(included with SYSLINUX) as well as the syslinux.com installer. If
+you are on an WinNT-based system (WinNT, Win2k, WinXP or later), use
+syslinux.exe instead.
1. Make a DOS bootable disk. This can be done either by specifying
the /s option when formatting the disk in DOS, or by running the
3. Run SYSLINUX on the disk:
- [lock a: if you're running under Win95/98/ME]
syslinux a:
4. Copy the Linux kernel image(s), initrd(s), etc to the disk, and
/* This takes a boot sector and merges in the syslinux fields */
void syslinux_make_bootsect(void *);
+/* Check to see that what we got was indeed an MS-DOS boot sector/superblock */
+int syslinux_check_bootsect(void *bs, char* device);
+
#endif
#define _XOPEN_SOURCE 500 /* Required on glibc 2.x */
#define _BSD_SOURCE
-#include <alloca.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <mntent.h>
-#include <paths.h>
#include <stdio.h>
+#include <inttypes.h>
#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/wait.h>
#include "syslinux.h"
/*
* Access functions for littleendian numbers, possibly misaligned.
*/
-static inline u_int16_t get_16(unsigned char *p)
+static inline uint16_t get_16(unsigned char *p)
{
- return (u_int16_t)p[0] + ((u_int16_t)p[1] << 8);
+ return (uint16_t)p[0] + ((uint16_t)p[1] << 8);
}
-static inline u_int32_t get_32(unsigned char *p)
+static inline uint32_t get_32(unsigned char *p)
{
- return (u_int32_t)p[0] + ((u_int32_t)p[1] << 8) +
- ((u_int32_t)p[2] << 16) + ((u_int32_t)p[3] << 24);
+ return (uint32_t)p[0] + ((uint32_t)p[1] << 8) +
+ ((uint32_t)p[2] << 16) + ((uint32_t)p[3] << 24);
}
-static inline void set_16(unsigned char *p, u_int16_t v)
+static inline void set_16(unsigned char *p, uint16_t v)
{
p[0] = (v & 0xff);
p[1] = ((v >> 8) & 0xff);
}
#if 0 /* Not needed */
-static inline void set_32(unsigned char *p, u_int32_t v)
+static inline void set_32(unsigned char *p, uint32_t v)
{
p[0] = (v & 0xff);
p[1] = ((v >> 8) & 0xff);
memcpy(bootsect+bsHead, syslinux_bootsect+bsHead, bsHeadLen);
memcpy(bootsect+bsCode, syslinux_bootsect+bsCode, bsCodeLen);
}
+
+/*
+ * Check to see that what we got was indeed an MS-DOS boot sector/superblock
+ */
+int syslinux_check_bootsect(void *bs, char* device)
+{
+ int veryold;
+ unsigned int sectors, clusters;
+ unsigned char *sectbuf = bs;
+
+ if ( sectbuf[bsBootSignature] == 0x29 ) {
+ /* It's DOS, and it has all the new nice fields */
+
+ veryold = 0;
+
+ sectors = get_16(sectbuf+bsSectors);
+ sectors = sectors ? sectors : get_32(sectbuf+bsHugeSectors);
+ clusters = sectors / sectbuf[bsSecPerClust];
+
+ if ( !memcmp(sectbuf+bsFileSysType, "FAT12 ", 8) ) {
+ if ( clusters > 4086 ) {
+ fprintf(stderr, "%s: ERROR: FAT12 but claims more than 4086 clusters\n",
+ device);
+ return 0;
+ }
+ } else if ( !memcmp(sectbuf+bsFileSysType, "FAT16 ", 8) ) {
+ if ( clusters <= 4086 ) {
+ fprintf(stderr, "%s: ERROR: FAT16 but claims less than 4086 clusters\n",
+ device);
+ return 0;
+ }
+ } else if ( !memcmp(sectbuf+bsFileSysType, "FAT ", 8) ) {
+ /* OS/2 sets up the filesystem as just `FAT'. */
+ } else {
+ fprintf(stderr, "%s: filesystem type \"%8.8s\" not supported\n",
+ device, sectbuf+bsFileSysType);
+ return 0;
+ }
+ } else {
+ veryold = 1;
+
+ if ( sectbuf[bsSecPerClust] & (sectbuf[bsSecPerClust] - 1) ||
+ sectbuf[bsSecPerClust] == 0 ) {
+ fprintf(stderr, "%s: This doesn't look like a FAT filesystem\n",
+ device);
+ }
+
+ sectors = get_16(sectbuf+bsSectors);
+ sectors = sectors ? sectors : get_32(sectbuf+bsHugeSectors);
+ clusters = sectors / sectbuf[bsSecPerClust];
+ }
+
+ if ( get_16(sectbuf+bsBytesPerSec) != 512 ) {
+ fprintf(stderr, "%s: Sector sizes other than 512 not supported\n",
+ device);
+ return 0;
+ }
+
+ if ( sectbuf[bsSecPerClust] > 32 ) {
+ fprintf(stderr, "%s: Cluster sizes larger than 16K not supported\n",
+ device);
+ return 0;
+ }
+
+ return 1;
+}
clean: tidy
-spotless:
- rm -f ../syslinux.exe
+spotless: clean
+ rm -f ../syslinux.exe *~
+