summaryrefslogtreecommitdiffstats
path: root/dos
diff options
context:
space:
mode:
Diffstat (limited to 'dos')
-rw-r--r--dos/Makefile3
-rw-r--r--dos/argv.c2
-rw-r--r--dos/syslinux.c26
3 files changed, 20 insertions, 11 deletions
diff --git a/dos/Makefile b/dos/Makefile
index 5b58af0a..c423ded7 100644
--- a/dos/Makefile
+++ b/dos/Makefile
@@ -7,6 +7,7 @@ CFLAGS = -W -Wall -ffreestanding -msoft-float $(OPTFLAGS) $(INCLUDES)
LDFLAGS = -T com16.ld
AR = ar
RANLIB = ranlib
+LIBGCC := $(shell $(CC) --print-libgcc)
SRCS = syslinux.c \
../syslxmod.c ../bootsect_bin.c ../ldlinux_bin.c \
@@ -33,7 +34,7 @@ spotless: clean
installer: syslinux.com
syslinux.elf: $(OBJS) libcom.a
- $(LD) $(LDFLAGS) -o $@ $^
+ $(LD) $(LDFLAGS) -o $@ $^ $(LIBGCC)
libcom.a: $(LIBOBJS)
-rm -f $@
diff --git a/dos/argv.c b/dos/argv.c
index 5535331a..4c835896 100644
--- a/dos/argv.c
+++ b/dos/argv.c
@@ -73,13 +73,13 @@ int __parse_argv(char ***argv, const char *str)
if ( ! *p )
break;
}
- q--; /* Point to final null */
/* Now create argv */
arg = ALIGN_UP(q,char *);
*argv = arg;
*arg++ = mem; /* argv[0] */
+ q--; /* Point q to final null */
for ( r = mem ; r < q ; r++ ) {
if ( *r == '\0' ) {
*arg++ = r+1;
diff --git a/dos/syslinux.c b/dos/syslinux.c
index cc611c48..3c58edd1 100644
--- a/dos/syslinux.c
+++ b/dos/syslinux.c
@@ -37,7 +37,7 @@ uint16_t dos_version;
void __attribute__((noreturn)) usage(void)
{
- puts("Usage: syslinux [-sf] drive:\n");
+ puts("Usage: syslinux [-sf] drive: [bootsecfile]\n");
exit(1);
}
@@ -250,7 +250,7 @@ int main(int argc, char *argv[])
libfat_sector_t s, *secp, sectors[65]; /* 65 is maximum possible */
int32_t ldlinux_cluster;
int nsectors;
- char *device = NULL;
+ const char *device = NULL, *bootsecfile = NULL;
const char *errmsg;
int i;
@@ -279,8 +279,11 @@ int main(int argc, char *argv[])
opt++;
}
} else {
- if ( device )
+ if ( bootsecfile )
usage();
+ else if ( device )
+ bootsecfile = *argp;
+ else
device = *argp;
}
}
@@ -304,7 +307,7 @@ int main(int argc, char *argv[])
/*
* Check to see that what we got was indeed an MS-DOS boot sector/superblock
*/
- if(!syslinux_check_bootsect(sectbuf,&errmsg)) {
+ if( (errmsg = syslinux_check_bootsect(sectbuf)) ) {
unlock_device(0);
puts(errmsg);
putchar('\n');
@@ -314,7 +317,7 @@ int main(int argc, char *argv[])
ldlinux_name[0] = dev_fd | 0x40;
set_attributes(ldlinux_name, 0);
- fd = creat(ldlinux_name, 0x27); /* ARCHIVE SYSTEM HIDDEN READONLY */
+ fd = creat(ldlinux_name, 0x07); /* SYSTEM HIDDEN READONLY */
write_file(fd, syslinux_ldlinux, syslinux_ldlinux_len);
close(fd);
@@ -359,10 +362,15 @@ int main(int argc, char *argv[])
syslinux_make_bootsect(sectbuf);
/* Write new boot sector */
- write_device(dev_fd, sectbuf, 1, 0);
-
- /* Release device lock */
- unlock_device(0);
+ if ( bootsecfile ) {
+ unlock_device(0);
+ fd = creat(bootsecfile, 0x20); /* ARCHIVE */
+ write_file(fd, sectbuf, 512);
+ close(fd);
+ } else {
+ write_device(dev_fd, sectbuf, 1, 0);
+ unlock_device(0);
+ }
/* Done! */