summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYousong Zhou <yszhou4tech@gmail.com>2019-10-29 12:39:46 +0000
committerJohn Crispin <john@phrozen.org>2019-11-02 19:21:56 +0100
commit1212b5b94454e6805e1104e740b8cd0c71c34941 (patch)
tree21e2a27ca527ef4012e63419f5bff3451ad55ea6
parenteda8b3fbcc0eb0752c4d02276950c3b977eac259 (diff)
downloadfstools-1212b5b94454e6805e1104e740b8cd0c71c34941.tar.gz
block: umount: skip / unless -a is given
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
-rw-r--r--block.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/block.c b/block.c
index a849500..99672fb 100644
--- a/block.c
+++ b/block.c
@@ -1118,7 +1118,7 @@ static int mount_device(struct probe_info *pr, int type)
return 0;
}
-static int umount_device(char *path, int type)
+static int umount_device(char *path, int type, bool all)
{
char *mp;
int err;
@@ -1126,6 +1126,8 @@ static int umount_device(char *path, int type)
mp = find_mount_point(path);
if (!mp)
return -1;
+ if (!strcmp(mp, "/") && !all)
+ return 0;
if (type != TYPE_AUTOFS)
hotplug_call_mount("remove", basename(path));
@@ -1155,7 +1157,7 @@ static int mount_action(char *action, char *device, int type)
if (type == TYPE_HOTPLUG)
blockd_notify(device, NULL, NULL);
- umount_device(path, type);
+ umount_device(path, type, true);
return 0;
} else if (strcmp(action, "add")) {
@@ -1607,6 +1609,7 @@ static int main_mount(int argc, char **argv)
static int main_umount(int argc, char **argv)
{
struct probe_info *pr;
+ bool all = false;
if (config_load(NULL))
return -1;
@@ -1614,6 +1617,10 @@ static int main_umount(int argc, char **argv)
handle_swapfiles(false);
cache_load(0);
+
+ if (argc == 3)
+ all = !strcmp(argv[2], "-a");
+
list_for_each_entry(pr, &devices, list) {
struct mount *m;
@@ -1624,7 +1631,7 @@ static int main_umount(int argc, char **argv)
if (m && m->extroot)
continue;
- umount_device(pr->dev, TYPE_DEV);
+ umount_device(pr->dev, TYPE_DEV, all);
}
return 0;
@@ -1735,7 +1742,6 @@ static int main_swapon(int argc, char **argv)
default:
return swapon_usage();
}
-
}
if (optind != (argc - 1))