summaryrefslogtreecommitdiff
path: root/src/basic/mount-util.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-12-03 13:57:42 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-12-17 13:57:04 -0500
commitc73838280cb107a10e0d8d45227d5471db56368f (patch)
treef8e57c6d966b36f9ae8bc5301d36f3c27869ae3c /src/basic/mount-util.c
parent117d5a27a3480fd9729cfadd98d135d21732a88d (diff)
Modify mount_propagation_flags_from_string to return a normal int code
This means that callers can distiguish an error from flags==0, and don't have to special-case the empty string.
Diffstat (limited to 'src/basic/mount-util.c')
-rw-r--r--src/basic/mount-util.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/basic/mount-util.c b/src/basic/mount-util.c
index 8970050408..840e94a553 100644
--- a/src/basic/mount-util.c
+++ b/src/basic/mount-util.c
@@ -693,13 +693,12 @@ int umount_verbose(const char *what) {
const char *mount_propagation_flags_to_string(unsigned long flags) {
switch (flags & (MS_SHARED|MS_SLAVE|MS_PRIVATE)) {
-
+ case 0:
+ return "";
case MS_SHARED:
return "shared";
-
case MS_SLAVE:
return "slave";
-
case MS_PRIVATE:
return "private";
}
@@ -707,17 +706,18 @@ const char *mount_propagation_flags_to_string(unsigned long flags) {
return NULL;
}
-unsigned long mount_propagation_flags_from_string(const char *name) {
- if (isempty(name))
- return 0;
-
- if (streq(name, "shared"))
- return MS_SHARED;
- if (streq(name, "slave"))
- return MS_SLAVE;
- if (streq(name, "private"))
- return MS_PRIVATE;
+int mount_propagation_flags_from_string(const char *name, unsigned long *ret) {
+ if (isempty(name))
+ *ret = 0;
+ else if (streq(name, "shared"))
+ *ret = MS_SHARED;
+ else if (streq(name, "slave"))
+ *ret = MS_SLAVE;
+ else if (streq(name, "private"))
+ *ret = MS_PRIVATE;
+ else
+ return -EINVAL;
return 0;
}