From b5e9efd3db5b596ae9b48b41de1a833c235c389a Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Fri, 25 Jan 2002 20:17:44 +0000 Subject: [PATCH] Only remove symbolic links when deactivating. (if this code didn't create it, don't delete it) --- lib/activate/fs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/activate/fs.c b/lib/activate/fs.c index aacc0664e..883935349 100644 --- a/lib/activate/fs.c +++ b/lib/activate/fs.c @@ -98,6 +98,7 @@ static int _mk_link(struct logical_volume *lv) static int _rm_link(struct logical_volume *lv, const char *lv_name) { + struct stat buf; char link_path[PATH_MAX]; if (!lv_name) @@ -111,6 +112,11 @@ static int _rm_link(struct logical_volume *lv, const char *lv_name) } log_very_verbose("Removing link %s", link_path); + if (lstat(link_path, &buf) || !S_ISLNK(buf.st_mode)) { + log_error("%s not symbolic link - not removing", + link_path); + return 0; + } if (unlink(link_path) < 0) { log_sys_error("unlink", link_path); return 0; -- 2.43.5