block: remove mount target file if it's a link
[project/fstools.git] / block.c
diff --git a/block.c b/block.c
index b6d49a8543117bb91fa53bd7c8b1fad5f1e2dbdb..9e530f1a93b8e729cf9aeadfd508bd261928070a 100644 (file)
--- a/block.c
+++ b/block.c
@@ -1072,6 +1072,7 @@ static int mount_device(struct device *dev, int type)
 {
        struct mount *m;
        struct probe_info *pr;
+       struct stat st;
        char _target[32];
        char *target;
        char *device;
@@ -1154,6 +1155,8 @@ static int mount_device(struct device *dev, int type)
                check_filesystem(pr);
 
        mkdir_p(target);
+       if (!lstat(target, &st) && S_ISLNK(st.st_mode))
+               unlink(target);
 
        err = handle_mount(pr->dev, target, pr->type, m);
        if (err) {
@@ -1543,7 +1546,7 @@ static int mount_extroot(char *cfg)
                ULOG_INFO("extroot: device not present, retrying in %u seconds\n", delay_root);
                sleep(delay_root);
                make_devs();
-               cache_load(0);
+               cache_load(1);
                dev = find_block_device(m->uuid, m->label, m->device);
        }
        if (dev) {