aboutsummaryrefslogtreecommitdiffstats
path: root/extlinux
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2013-01-29 14:01:07 +0000
committerMatt Fleming <matt.fleming@intel.com>2013-01-29 15:11:28 +0000
commitbf20364b582c383b4927f898de213b1cc0981a80 (patch)
tree5412e0c14cf74df0d7ea29ff182e23d3281aac3e /extlinux
parentafd985f6eec18a0f66a8fc55f9c5e3431128310f (diff)
parenta2d79191b501276026a0a16ec2fa664630a20476 (diff)
downloadsyslinux-bf20364b582c383b4927f898de213b1cc0981a80.tar.gz
syslinux-bf20364b582c383b4927f898de213b1cc0981a80.tar.xz
syslinux-bf20364b582c383b4927f898de213b1cc0981a80.zip
Merge tag 'syslinux-5.01' into firmwaresyslinux-6.00-pre4
Conflicts: Makefile NEWS com32/cmenu/Makefile com32/elflink/ldlinux/Makefile com32/gfxboot/Makefile com32/gpllib/Makefile com32/include/sys/module.h com32/lib/Makefile com32/lib/sys/module/elf_module.c com32/menu/Makefile com32/rosh/Makefile com32/samples/Makefile core/init.c mk/elf.mk Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'extlinux')
-rw-r--r--extlinux/main.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/extlinux/main.c b/extlinux/main.c
index e925a1d8..9ee9abb4 100644
--- a/extlinux/main.c
+++ b/extlinux/main.c
@@ -440,13 +440,11 @@ int install_bootblock(int fd, const char *device)
return 0;
}
-static int rewrite_boot_image(int devfd, const char *filename)
+static int rewrite_boot_image(int devfd, const char *path, const char *filename)
{
int fd;
int ret;
int modbytes;
- char path[PATH_MAX];
- char slash;
/* Let's create LDLINUX.SYS file again (if it already exists, of course) */
fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT | O_SYNC,
@@ -470,8 +468,6 @@ static int rewrite_boot_image(int devfd, const char *filename)
goto error;
}
- sscanf(filename, "%s%cldlinux.sys", path, &slash);
-
/* Map the file, and patch the initial sector accordingly */
modbytes = patch_file_and_bootblock(fd, path, devfd);
@@ -525,7 +521,7 @@ int ext2_fat_install_file(const char *path, int devfd, struct stat *rst)
}
close(fd);
- fd = rewrite_boot_image(devfd, file);
+ fd = rewrite_boot_image(devfd, path, file);
if (fd < 0)
goto bail;
@@ -648,12 +644,16 @@ int btrfs_install_file(const char *path, int devfd, struct stat *rst)
*/
static int xfs_install_file(const char *path, int devfd, struct stat *rst)
{
- static char file[PATH_MAX];
+ static char file[PATH_MAX + 1];
+ static char c32file[PATH_MAX + 1];
int dirfd = -1;
int fd = -1;
+ int retval;
- snprintf(file, PATH_MAX, "%s%sldlinux.sys",
- path, path[0] && path[strlen(path) - 1] == '/' ? "" : "/");
+ snprintf(file, PATH_MAX + 1, "%s%sldlinux.sys", path,
+ path[0] && path[strlen(path) - 1] == '/' ? "" : "/");
+ snprintf(c32file, PATH_MAX + 1, "%s%sldlinux.c32", path,
+ path[0] && path[strlen(path) - 1] == '/' ? "" : "/");
dirfd = open(path, O_RDONLY | O_DIRECTORY);
if (dirfd < 0) {
@@ -673,7 +673,7 @@ static int xfs_install_file(const char *path, int devfd, struct stat *rst)
close(fd);
- fd = rewrite_boot_image(devfd, file);
+ fd = rewrite_boot_image(devfd, path, file);
if (fd < 0)
goto bail;
@@ -689,6 +689,26 @@ static int xfs_install_file(const char *path, int devfd, struct stat *rst)
close(dirfd);
close(fd);
+ dirfd = -1;
+ fd = -1;
+
+ fd = open(c32file, O_WRONLY | O_TRUNC | O_CREAT | O_SYNC,
+ S_IRUSR | S_IRGRP | S_IROTH);
+ if (fd < 0) {
+ perror(c32file);
+ goto bail;
+ }
+
+ retval = xpwrite(fd, syslinux_ldlinuxc32, syslinux_ldlinuxc32_len, 0);
+ if (retval != (int)syslinux_ldlinuxc32_len) {
+ fprintf(stderr, "%s: write failure on %s\n", program, file);
+ goto bail;
+ }
+
+ close(fd);
+
+ sync();
+
return 0;
bail: