summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-10-27 14:25:58 +0100
committerLennart Poettering <lennart@poettering.net>2015-10-27 14:25:58 +0100
commit3f2c0becc3dcb1acb9d2a1816dcfe4e3de8877d4 (patch)
treead082a4cb0a9f6112af9826db523505b080a4fb4 /src/basic
parent7b3e062cb6872e28ef5a2e069810070e28bbe0cd (diff)
automount: move generically userful call repeat_mount() into mount-util.[ch]
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/mount-util.c21
-rw-r--r--src/basic/mount-util.h2
2 files changed, 23 insertions, 0 deletions
diff --git a/src/basic/mount-util.c b/src/basic/mount-util.c
index d04e7492e5..29997b1ce7 100644
--- a/src/basic/mount-util.c
+++ b/src/basic/mount-util.c
@@ -506,3 +506,24 @@ bool fstype_is_network(const char *fstype) {
return nulstr_contains(table, fstype);
}
+
+int repeat_unmount(const char *path, int flags) {
+ bool done = false;
+
+ assert(path);
+
+ /* If there are multiple mounts on a mount point, this
+ * removes them all */
+
+ for (;;) {
+ if (umount2(path, flags) < 0) {
+
+ if (errno == EINVAL)
+ return done;
+
+ return -errno;
+ }
+
+ done = true;
+ }
+}
diff --git a/src/basic/mount-util.h b/src/basic/mount-util.h
index c87ae93e55..48954c2d67 100644
--- a/src/basic/mount-util.h
+++ b/src/basic/mount-util.h
@@ -32,6 +32,8 @@
int fd_is_mount_point(int fd, const char *filename, int flags);
int path_is_mount_point(const char *path, int flags);
+int repeat_unmount(const char *path, int flags);
+
int umount_recursive(const char *target, int flags);
int bind_remount_recursive(const char *prefix, bool ro);