diff options
author | Matt Fleming <matt.fleming@intel.com> | 2012-11-05 13:13:25 +0000 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2012-11-05 13:21:04 +0000 |
commit | 0b26e59c8f5dc7a8a124a033a78e08c7a2028bcd (patch) | |
tree | 9a892c852fabd0a75d10c856105b4488cc87f66c /mtools | |
parent | cdeba8ac82f529a3a4a544c4e8346887ef81cb74 (diff) | |
parent | b210bd5bfd0d7182b0a65f507c7557eeb90d5b16 (diff) | |
download | syslinux-0b26e59c8f5dc7a8a124a033a78e08c7a2028bcd.tar.gz |
Merge tag 'syslinux-5.00-pre9' into for-hpa/elflink/firmware
This merge also includes the Syslinux-4.06 release.
Conflicts:
Makefile
com32/hdt/Makefile
com32/modules/Makefile
com32/samples/hello.c
mtools/Makefile
Diffstat (limited to 'mtools')
-rwxr-xr-x | mtools/Makefile | 1 | ||||
-rwxr-xr-x | mtools/syslinux.c | 129 |
2 files changed, 82 insertions, 48 deletions
diff --git a/mtools/Makefile b/mtools/Makefile index 3544388e..3f9c42b3 100755 --- a/mtools/Makefile +++ b/mtools/Makefile @@ -12,6 +12,7 @@ SRCS = syslinux.c \ ../libinstaller/setadv.c \ ../libinstaller/bootsect_bin.c \ ../libinstaller/ldlinux_bin.c \ + ../libinstaller/ldlinuxc32_bin.c \ $(wildcard $(SRC)/../libfat/*.c) OBJS = $(patsubst %.c,%.o,$(notdir $(SRCS))) diff --git a/mtools/syslinux.c b/mtools/syslinux.c index c65021bb..f43b5a5e 100755 --- a/mtools/syslinux.c +++ b/mtools/syslinux.c @@ -125,6 +125,64 @@ int libfat_xpread(intptr_t pp, void *buf, size_t secsize, return xpread(pp, buf, secsize, offset); } +static int move_file(char *filename) +{ + char target_file[4096], command[5120]; + char *cp = target_file, *ep = target_file + sizeof target_file - 16; + const char *sd; + int slash = 1; + int status; + + cp += sprintf(cp, "'s:/"); + for (sd = opt.directory; *sd; sd++) { + if (*sd == '/' || *sd == '\\') { + if (slash) + continue; /* Remove duplicated slashes */ + slash = 1; + } else if (*sd == '\'' || *sd == '!') { + slash = 0; + if (cp < ep) + *cp++ = '\''; + if (cp < ep) + *cp++ = '\\'; + if (cp < ep) + *cp++ = *sd; + if (cp < ep) + *cp++ = '\''; + continue; + } else { + slash = 0; + } + + if (cp < ep) + *cp++ = *sd; + } + if (!slash) + *cp++ = '/'; + sprintf(cp, "%s'", filename); + + /* This command may fail legitimately */ + sprintf(command, "mattrib -h -r -s %s 2>/dev/null", target_file); + status = system(command); + (void)status; /* Keep _FORTIFY_SOURCE happy */ + + sprintf(command, "mmove -D o -D O s:/%s %s", filename, target_file); + status = system(command); + + if (!WIFEXITED(status) || WEXITSTATUS(status)) { + fprintf(stderr, + "%s: warning: unable to move %s\n", program, filename); + + sprintf(command, "mattrib +r +h +s s:/%s", filename); + status = system(command); + } else { + sprintf(command, "mattrib +r +h +s %s", target_file); + status = system(command); + } + + return status; +} + int main(int argc, char *argv[]) { static unsigned char sectbuf[SECTOR_SIZE]; @@ -284,63 +342,38 @@ int main(int argc, char *argv[]) /* Move ldlinux.sys to the desired location */ if (opt.directory) { - char target_file[4096], command[5120]; - char *cp = target_file, *ep = target_file + sizeof target_file - 16; - const char *sd; - int slash = 1; - - cp += sprintf(cp, "'s:/"); - for (sd = opt.directory; *sd; sd++) { - if (*sd == '/' || *sd == '\\') { - if (slash) - continue; /* Remove duplicated slashes */ - slash = 1; - } else if (*sd == '\'' || *sd == '!') { - slash = 0; - if (cp < ep) - *cp++ = '\''; - if (cp < ep) - *cp++ = '\\'; - if (cp < ep) - *cp++ = *sd; - if (cp < ep) - *cp++ = '\''; - continue; - } else { - slash = 0; - } - - if (cp < ep) - *cp++ = *sd; - } - if (!slash) - *cp++ = '/'; - strcpy(cp, "ldlinux.sys'"); + status = move_file("ldlinux.sys"); + } else { + status = system("mattrib +r +h +s s:/ldlinux.sys"); + } - /* This command may fail legitimately */ - sprintf(command, "mattrib -h -r -s %s 2>/dev/null", target_file); - status = system(command); - (void)status; /* Keep _FORTIFY_SOURCE happy */ + if (!WIFEXITED(status) || WEXITSTATUS(status)) { + fprintf(stderr, + "%s: warning: failed to set system bit on ldlinux.sys\n", + program); + } - sprintf(command, "mmove -D o -D O s:/ldlinux.sys %s", target_file); - status = system(command); + /* This command may fail legitimately */ + status = system("mattrib -h -r -s s:/ldlinux.c32 2>/dev/null"); + (void)status; /* Keep _FORTIFY_SOURCE happy */ - if (!WIFEXITED(status) || WEXITSTATUS(status)) { - fprintf(stderr, - "%s: warning: unable to move ldlinux.sys\n", program); + mtp = popen("mcopy -D o -D O -o - s:/ldlinux.c32", "w"); + if (!mtp || fwrite(syslinux_ldlinuxc32, 1, syslinux_ldlinuxc32_len, mtp) + != syslinux_ldlinuxc32_len || + (status = pclose(mtp), !WIFEXITED(status) || WEXITSTATUS(status))) { + die("failed to create ldlinux.c32"); + } - status = system("mattrib +r +h +s s:/ldlinux.sys"); - } else { - sprintf(command, "mattrib +r +h +s %s", target_file); - status = system(command); - } + /* Move ldlinux.c32 to the desired location */ + if (opt.directory) { + status = move_file("ldlinux.c32"); } else { - status = system("mattrib +r +h +s s:/ldlinux.sys"); + status = system("mattrib +r +h +s s:/ldlinux.c32"); } if (!WIFEXITED(status) || WEXITSTATUS(status)) { fprintf(stderr, - "%s: warning: failed to set system bit on ldlinux.sys\n", + "%s: warning: failed to set system bit on ldlinux.c32\n", program); } |