block: remove mount target file if it's a link
[project/fstools.git] / block.c
diff --git a/block.c b/block.c
index 50d877fbeb08e1d2b445549224f0565eecd56791..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) {