[syslinux] Upgraded to Syslinux 5.00 - Failed to load ldlinux.c32

Matt Fleming matt at console-pimps.org
Wed Jan 9 13:00:01 PST 2013


On Wed, 2013-01-02 at 15:39 +0000, Matt Fleming wrote:
> On Thu, 2012-12-20 at 20:53 -0800, H. Peter Anvin wrote:
> > On 12/19/2012 04:44 AM, Paulo Alcantara wrote:
> > >
> > > The ldlinux.c32 could be installed in any path, however Syslinux won't
> > > be able to find it in paths other than those in search_directories
> > > array.
> > >
> > 
> > The real issue is that the install directory should be automatically 
> > added to the array... not sure why that isn't happening.
> 
> Me neither. I was pretty certain that this worked because CurrentDirName
> should be set to the installation directory on boot.
> 
> I'll take a look at this.

Interestingly, this feature was broken with the following commit,

commit a126f17f663c438ef264a459fa130951dbac780d
Author: Paulo Alcantara <pcacjr at zytor.com>
Date:   Fri Jun 8 16:20:15 2012 -0300

    EXTLINUX: Initial XFS filesystem support
    
.. because of this...

+
+    sscanf(filename, "%s%cldlinux.sys", path, &slash);
+
+    /* Map the file, and patch the initial sector accordingly */
+    modbytes = patch_file_and_bootblock(fd, path, devfd);

that sscanf() doesn't work, 'path' contains the *full* path, not the
installation subdir. I fixed it with the patch below. Does it look OK?

-- 
Matt Fleming, Intel Open Source Technology Center

---

diff --git a/extlinux/main.c b/extlinux/main.c
index f90ca11..7f2d6db 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 mailing list