[syslinux] extlinux and install script

Hiro Yoshioka hyoshiok at miraclelinux.com
Wed Jul 2 18:35:14 PDT 2008


Hi,

I'm new the syslinux and found some bug.

For example, when I install a boot file system into /mnt/boot during
usb booted system, the extlinux reports the following error.

/usr/bin/extlinux -i /mnt/boot
/mnt/boot is device proc
/usr/bin/extlinux: cannot open device proc 

But /mnt/boot is mounted on /dev/sda1 and ext3 file system.

I read the source code and found the following code in
install_loader()

  if ( (mtab = setmntent("/proc/mounts", "r")) ) {
    while ( (mnt = getmntent(mtab)) ) {
      if ( (!strcmp(mnt->mnt_type, "ext2") ||
            !strcmp(mnt->mnt_type, "ext3")) &&
           !stat(mnt->mnt_fsname, &dst) &&
           dst.st_rdev == st.st_dev ) {
        devname = mnt->mnt_fsname;
        break;
      }
    }
  }

  if ( !devname ) {
    /* Didn't find it in /proc/mounts, try /etc/mtab */
    if ( (mtab = setmntent("/etc/mtab", "r")) ) {
      while ( (mnt = getmntent(mtab)) ) {
        devname = mnt->mnt_fsname;
        break;
      }
    }
  }

-----------------
The extlinux could not find the entry in the /proc/mounts then try
/etc/mtab. But it didn't check if the file type is ext2 or ext3.

I think it should check if it is ext2 or ext3. So I wrote the
following patch and it fix the above issue. (I'm using ubuntu, the
syslinux is 3.36-4ubuntu)

--- extlinux.c.orig	2007-02-10 20:47:08.000000000 +0000
+++ extlinux.c	2008-07-02 15:20:20.000000000 +0000
@@ -708,8 +708,13 @@
     /* Didn't find it in /proc/mounts, try /etc/mtab */
     if ( (mtab = setmntent("/etc/mtab", "r")) ) {
       while ( (mnt = getmntent(mtab)) ) {
-	devname = mnt->mnt_fsname;
-	break;
+        if ( (!strcmp(mnt->mnt_type, "ext2") ||
+              !strcmp(mnt->mnt_type, "ext3")) &&
+             !stat(mnt->mnt_fsname, &dst) &&
+             dst.st_rdev == st.st_dev ) {
+ 	  devname = mnt->mnt_fsname;
+	  break;
+	}
       }
     }
   }

I have read the latest source code and the above issue is still
remained.

Could you fix it?

Thanks in advance,
  Hiro




More information about the Syslinux mailing list