aboutsummaryrefslogtreecommitdiffstats
path: root/extlinux/main.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2010-06-24 13:08:46 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2010-06-24 13:08:46 -0700
commit06b5bd5a470cf4aad212aa81a26c8a5e03a48b2c (patch)
tree9927ef3ce16f886ef511cfe04cfc92cfc840a909 /extlinux/main.c
parentd52b620e4f296cd1cb48afdcead64fc1b040e0dc (diff)
downloadsyslinux-06b5bd5a470cf4aad212aa81a26c8a5e03a48b2c.tar.gz
syslinux-06b5bd5a470cf4aad212aa81a26c8a5e03a48b2c.tar.xz
syslinux-06b5bd5a470cf4aad212aa81a26c8a5e03a48b2c.zip
extlinux: fix ADV handling, so extlinux.sys -> ldlinux.sys actually works
Do the appropriate thing for various error cases, so that the migration code actually does the right thing. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'extlinux/main.c')
-rw-r--r--extlinux/main.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/extlinux/main.c b/extlinux/main.c
index a7716435..1ecb39c0 100644
--- a/extlinux/main.c
+++ b/extlinux/main.c
@@ -711,13 +711,21 @@ static int btrfs_read_adv(int devfd)
return syslinux_validate_adv(syslinux_adv) ? 1 : 0;
}
-static int ext_read_adv(const char *path, const char *cfg, int devfd)
+static int ext_read_adv(const char *path, int devfd, const char **namep)
{
+ int err;
+ const char *name;
+
if (fs_type == BTRFS) {
/* btrfs "ldlinux.sys" is in 64k blank area */
return btrfs_read_adv(devfd);
- } else {
- return read_adv(path, cfg);
+ } else {
+ err = read_adv(path, name = "ldlinux.sys");
+ if (err == 2) /* ldlinux.sys does not exist */
+ err = read_adv(path, name = "extlinux.sys");
+ if (namep)
+ *namep = name;
+ return err;
}
}
@@ -752,11 +760,11 @@ int install_loader(const char *path, int update_only)
}
/* Read a pre-existing ADV, if already installed */
- if (opt.reset_adv ||
- !already_installed(devfd) ||
- (ext_read_adv(path, "ldlinux.sys", devfd) < 0 &&
- ext_read_adv(path, "extlinux.sys", devfd) < 0)) {
+ if (opt.reset_adv) {
syslinux_reset_adv(syslinux_adv);
+ } else if (ext_read_adv(path, devfd, NULL) < 0) {
+ close(devfd);
+ return 1;
}
if (modify_adv() < 0) {
@@ -798,8 +806,7 @@ int modify_existing_adv(const char *path)
if (opt.reset_adv)
syslinux_reset_adv(syslinux_adv);
- else if (ext_read_adv(path, filename = "ldlinux.sys", devfd) < 0 &&
- ext_read_adv(path, filename = "extlinux.sys", devfd) < 0) {
+ else if (ext_read_adv(path, devfd, &filename) < 0) {
close(devfd);
return 1;
}