diff options
author | Matt Fleming <matt.fleming@intel.com> | 2012-11-05 13:13:25 +0000 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2012-11-05 13:21:04 +0000 |
commit | 0b26e59c8f5dc7a8a124a033a78e08c7a2028bcd (patch) | |
tree | 9a892c852fabd0a75d10c856105b4488cc87f66c /linux | |
parent | cdeba8ac82f529a3a4a544c4e8346887ef81cb74 (diff) | |
parent | b210bd5bfd0d7182b0a65f507c7557eeb90d5b16 (diff) | |
download | syslinux-0b26e59c8f5dc7a8a124a033a78e08c7a2028bcd.tar.gz |
Merge tag 'syslinux-5.00-pre9' into for-hpa/elflink/firmware
This merge also includes the Syslinux-4.06 release.
Conflicts:
Makefile
com32/hdt/Makefile
com32/modules/Makefile
com32/samples/hello.c
mtools/Makefile
Diffstat (limited to 'linux')
-rw-r--r-- | linux/Makefile | 1 | ||||
-rwxr-xr-x | linux/syslinux.c | 55 |
2 files changed, 46 insertions, 10 deletions
diff --git a/linux/Makefile b/linux/Makefile index d63306af..f88a6cb3 100644 --- a/linux/Makefile +++ b/linux/Makefile @@ -29,6 +29,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(); |