mirror of
https://git.yoctoproject.org/poky
synced 2026-02-22 09:29:40 +01:00
syslinux: support ext2/3/4 device
* Support ext2/3/4 deivce. * The open_ext2_fs() checks whether it is an ext2/3/4 device, do the ext2/3/4 installation (install_to_ext2()) if yes, otherwise go on to the fat/ntfs. * The ext2/3/4 support doesn't require root privileges since it doesn't need mount (but write permission is required). Next: * Get rid of fat filesystem from the boot image. These patches have been sent to upstream, we may adjust them (maybe put the extX support to syslinux-mtools), I will go on working with the upstream. (From OE-Core rev: d5af8539c0a1718a7254bcdcfa973e3c887dfbd6) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
06ff3c420c
commit
a2bfd4b1fb
@@ -0,0 +1,116 @@
|
||||
From 64d856b243812907068776b204a003a3a8fa122a Mon Sep 17 00:00:00 2001
|
||||
From: Robert Yang <liezhi.yang@windriver.com>
|
||||
Date: Wed, 31 Dec 2014 16:17:42 +0800
|
||||
Subject: [PATCH 3/9] linux/syslinux: implement install_to_ext2()
|
||||
|
||||
* The handle_adv_on_ext() checks whether we only need update adv.
|
||||
* The write_to_ext() installs files (ldlinux.sys or ldlinux.c32) to the
|
||||
device.
|
||||
* The install_bootblock() installs the boot block.
|
||||
|
||||
Upstream-Status: Submitted
|
||||
|
||||
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
|
||||
Tested-by: Du Dolpher <dolpher.du@intel.com>
|
||||
---
|
||||
linux/syslinux.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 79 insertions(+)
|
||||
|
||||
diff --git a/linux/syslinux.c b/linux/syslinux.c
|
||||
index cc4e7da..45f080d 100755
|
||||
--- a/linux/syslinux.c
|
||||
+++ b/linux/syslinux.c
|
||||
@@ -346,11 +346,90 @@ static int open_ext2_fs(const char *device, const char *subdir)
|
||||
fail:
|
||||
(void) ext2fs_close(e2fs);
|
||||
return -1;
|
||||
+
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Install the boot block on the specified device.
|
||||
+ * Must be run AFTER file installed.
|
||||
+ */
|
||||
+int install_bootblock(int fd, const char *device)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+static int handle_adv_on_ext(void)
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+/* Write files, adv, boot sector */
|
||||
+static int write_to_ext(const char *filename, const char *str, int length,
|
||||
+ int i_flags, int dev_fd, const char *subdir)
|
||||
+{
|
||||
}
|
||||
|
||||
/* The install func for ext2, ext3 and ext4 */
|
||||
static int install_to_ext2(const char *device, int dev_fd, const char *subdir)
|
||||
{
|
||||
+ int retval;
|
||||
+ ext2_ino_t oldino;
|
||||
+
|
||||
+ const char *file = "ldlinux.sys";
|
||||
+ const char *oldfile = "extlinux.sys";
|
||||
+ const char *c32file = "ldlinux.c32";
|
||||
+
|
||||
+ /* Handle the adv */
|
||||
+ if (handle_adv_on_ext() < 0) {
|
||||
+ fprintf(stderr, "%s: error while handling ADV on %s\n",
|
||||
+ program, device);
|
||||
+ retval = 1;
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
+ /* Return if only need update the adv */
|
||||
+ if (opt.update_only == -1) {
|
||||
+ return ext2fs_close(e2fs);
|
||||
+ }
|
||||
+
|
||||
+ /* Write ldlinux.sys, adv, boot sector */
|
||||
+ retval = write_to_ext(file, (const char _force *)boot_image,
|
||||
+ boot_image_len, EXT2_IMMUTABLE_FL, dev_fd, subdir);
|
||||
+ if (retval) {
|
||||
+ fprintf(stderr, "%s: ERROR: while writing: %s.\n",
|
||||
+ program, file);
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
+ /* Write ldlinux.c32 */
|
||||
+ retval = write_to_ext(c32file,
|
||||
+ (const char _force *)syslinux_ldlinuxc32,
|
||||
+ syslinux_ldlinuxc32_len, 0, dev_fd, subdir);
|
||||
+ if (retval) {
|
||||
+ fprintf(stderr, "%s: ERROR: while writing: %s.\n",
|
||||
+ program, c32file);
|
||||
+ goto fail;
|
||||
+ }
|
||||
+
|
||||
+ /* Look if we have the extlinux.sys and remove it*/
|
||||
+ retval = ext2fs_namei(e2fs, root, cwd, oldfile, &oldino);
|
||||
+ if (retval == 0) {
|
||||
+ retval = ext2fs_unlink(e2fs, cwd, oldfile, oldino, 0);
|
||||
+ if (retval) {
|
||||
+ fprintf(stderr, "%s: ERROR: failed to unlink: %s\n",
|
||||
+ program, oldfile);
|
||||
+ goto fail;
|
||||
+ }
|
||||
+ } else {
|
||||
+ retval = 0;
|
||||
+ }
|
||||
+
|
||||
+ sync();
|
||||
+ retval = install_bootblock(dev_fd, device);
|
||||
+ close(dev_fd);
|
||||
+ sync();
|
||||
+
|
||||
+fail:
|
||||
+ (void) ext2fs_close(e2fs);
|
||||
+ return retval;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
--
|
||||
1.9.1
|
||||
|
||||
Reference in New Issue
Block a user