From 4bf7873b3b5e7cce19fe3aa52ad7476658efa885 Mon Sep 17 00:00:00 2001 From: hpa Date: Mon, 18 Feb 2002 23:43:43 +0000 Subject: Actually make the -o option work properly. --- syslinux.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/syslinux.c b/syslinux.c index fb82fc54..8728a31c 100644 --- a/syslinux.c +++ b/syslinux.c @@ -101,7 +101,7 @@ static u_int32_t get_32(unsigned char *p) void usage(void) { - fprintf(stderr, "Usage: %s [-sf] device\n", program); + fprintf(stderr, "Usage: %s [-sf] [-o offset] device\n", program); exit(1); } @@ -139,7 +139,7 @@ int main(int argc, char *argv[]) } else if ( *opt == 'f' ) { force = 1; /* Force install */ } else if ( *opt == 'o' && argp[1] ) { - offset = atol(*++argp); /* Byte offset */ + offset = strtoul(*++argp, NULL, 0); /* Byte offset */ } else { usage(); } @@ -421,6 +421,13 @@ umount: exit(1); } + if ( lseek(dev_fd, offset, SEEK_SET) != offset ) { + if ( !(force && errno == EBADF) ) { + fprintf(stderr, "%s: seek error", device); + exit(1); + } + } + /* Copy the old superblock into the new boot sector */ memcpy(bootsect+bsCopyStart, sectbuf+bsCopyStart, bsCopyLen); -- cgit v1.2.1