summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhpa <hpa>2002-02-18 23:43:43 +0000
committerhpa <hpa>2002-02-18 23:43:43 +0000
commit4bf7873b3b5e7cce19fe3aa52ad7476658efa885 (patch)
treef41d6290f28c39edfed60fa93f1ee72ac23d886e
parentb0fd00bbef2eb6b08857e1dcc52341f29b073c88 (diff)
downloadsyslinux-1.6x-merge-2.tar.gz
Actually make the -o option work properly.syslinux-1.6x-merge-2
-rw-r--r--syslinux.c11
1 files 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);