aboutsummaryrefslogtreecommitdiffstats
path: root/linux
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-09-14 15:22:29 +0100
committerMatt Fleming <matt.fleming@intel.com>2012-09-19 10:46:41 +0100
commitbda54cb680676bffa731394096956f5d10fbcfaf (patch)
treeeccf1b93b239c19ace4ed72a0ec79c382c4cf8ba /linux
parent040f273035ca84fc963d0d0c0b39794f7a5fc7d4 (diff)
downloadsyslinux-bda54cb680676bffa731394096956f5d10fbcfaf.tar.gz
syslinux-bda54cb680676bffa731394096956f5d10fbcfaf.tar.xz
syslinux-bda54cb680676bffa731394096956f5d10fbcfaf.zip
installers: Install ldlinux.c32 automaticallysyslinux-5.00-pre8
Because ldlinux.c32 is required for Syslinux to function correctly, we should be installing it automatically much like ldlinux.sys. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'linux')
-rw-r--r--linux/Makefile1
-rwxr-xr-xlinux/syslinux.c55
2 files changed, 46 insertions, 10 deletions
diff --git a/linux/Makefile b/linux/Makefile
index 08a3ed49..d7facaf4 100644
--- a/linux/Makefile
+++ b/linux/Makefile
@@ -31,6 +31,7 @@ SRCS = syslinux.c \
../libinstaller/fs.c \
../libinstaller/syslxmod.c \
../libinstaller/bootsect_bin.c \
+ ../libinstaller/ldlinuxc32_bin.c \
../libinstaller/ldlinux_bin.c
OBJS = $(patsubst %.c,%.o,$(notdir $(SRCS)))
diff --git a/linux/syslinux.c b/linux/syslinux.c
index 4b13b7fe..f4749ead 100755
--- a/linux/syslinux.c
+++ b/linux/syslinux.c
@@ -238,6 +238,24 @@ int modify_existing_adv(const char *path)
return 0;
}
+int do_open_file(char *name)
+{
+ int fd;
+
+ if ((fd = open(name, O_RDONLY)) >= 0) {
+ uint32_t zero_attr = 0;
+ ioctl(fd, FAT_IOCTL_SET_ATTRIBUTES, &zero_attr);
+ close(fd);
+ }
+
+ unlink(name);
+ fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0444);
+ if (fd < 0)
+ perror(opt.device);
+
+ return fd;
+}
+
int main(int argc, char *argv[])
{
static unsigned char sectbuf[SECTOR_SIZE];
@@ -253,7 +271,7 @@ int main(int argc, char *argv[])
const char *errmsg;
int mnt_cookie;
int patch_sectors;
- int i;
+ int i, rv;
mypid = getpid();
umask(077);
@@ -408,16 +426,8 @@ int main(int argc, char *argv[])
if (modify_adv() < 0)
exit(1);
- if ((fd = open(ldlinux_name, O_RDONLY)) >= 0) {
- uint32_t zero_attr = 0;
- ioctl(fd, FAT_IOCTL_SET_ATTRIBUTES, &zero_attr);
- close(fd);
- }
-
- unlink(ldlinux_name);
- fd = open(ldlinux_name, O_WRONLY | O_CREAT | O_TRUNC, 0444);
+ fd = do_open_file(ldlinux_name);
if (fd < 0) {
- perror(opt.device);
err = 1;
goto umount;
}
@@ -451,6 +461,31 @@ int main(int argc, char *argv[])
close(fd);
sync();
+ sprintf(ldlinux_name, "%sldlinux.c32", ldlinux_path);
+ fd = do_open_file(ldlinux_name);
+ if (fd < 0) {
+ err = 1;
+ goto umount;
+ }
+
+ rv = xpwrite(fd, syslinux_ldlinuxc32, syslinux_ldlinuxc32_len, 0);
+ if (rv != (int)syslinux_ldlinuxc32_len) {
+ fprintf(stderr, "%s: write failure on %s\n", program, ldlinux_name);
+ exit(1);
+ }
+
+ fsync(fd);
+ /*
+ * Set the attributes
+ */
+ {
+ uint32_t attr = 0x07; /* Hidden+System+Readonly */
+ ioctl(fd, FAT_IOCTL_SET_ATTRIBUTES, &attr);
+ }
+
+ close(fd);
+ sync();
+
umount:
do_umount(mntpath, mnt_cookie);
sync();