[syslinux:elflink] extlinux: Fix installation subdirectory patching

syslinux-bot for Matt Fleming matt.fleming at intel.com
Fri Jan 11 01:36:03 PST 2013


Commit-ID:  15d85f991bb2609aedce06c0e01d89b31c6dc008
Gitweb:     http://www.syslinux.org/commit/15d85f991bb2609aedce06c0e01d89b31c6dc008
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Thu, 10 Jan 2013 11:47:33 +0000
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Thu, 10 Jan 2013 11:47:33 +0000

extlinux: Fix installation subdirectory patching

Commit a126f17f663c ("EXTLINUX: Initial XFS filesystem support") broke
the code that inserts the installation subdirectory into the Extended
Patch Area (EPA). The EPA entry is used to set the initial working
directory on boot.

This caused boot failures for users that chose an install directory
other than /boot/syslinux (technically, it failed for any path not in
'search_directories' in load_env32()) due to ldlinux.c32 failing to
load because the initial working directory was not set correctly.

Cc: Paulo Alcantara <pcacjr at zytor.com>
Signed-off-by: Matt Fleming <matt.fleming at intel.com>

---
 extlinux/main.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/extlinux/main.c b/extlinux/main.c
index fa54152..01bfc9c 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;
 
@@ -673,7 +669,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;
 


More information about the Syslinux-commits mailing list