mountpoint-util: rename mount_propagation_flags_to_string() and friends as singular

This commit is contained in:
Yu Watanabe
2022-12-15 14:15:55 +09:00
parent 6c6eb219d5
commit b205e59ad4
7 changed files with 22 additions and 22 deletions
+2 -2
View File
@@ -568,7 +568,7 @@ int mount_nofollow(
return mount_fd(source, fd, filesystemtype, mountflags, data);
}
const char *mount_propagation_flags_to_string(unsigned long flags) {
const char *mount_propagation_flag_to_string(unsigned long flags) {
switch (flags & (MS_SHARED|MS_SLAVE|MS_PRIVATE)) {
case 0:
@@ -584,7 +584,7 @@ const char *mount_propagation_flags_to_string(unsigned long flags) {
return NULL;
}
int mount_propagation_flags_from_string(const char *name, unsigned long *ret) {
int mount_propagation_flag_from_string(const char *name, unsigned long *ret) {
if (isempty(name))
*ret = 0;
+2 -2
View File
@@ -55,5 +55,5 @@ int dev_is_devtmpfs(void);
int mount_fd(const char *source, int target_fd, const char *filesystemtype, unsigned long mountflags, const void *data);
int mount_nofollow(const char *source, const char *target, const char *filesystemtype, unsigned long mountflags, const void *data);
const char *mount_propagation_flags_to_string(unsigned long flags);
int mount_propagation_flags_from_string(const char *name, unsigned long *ret);
const char *mount_propagation_flag_to_string(unsigned long flags);
int mount_propagation_flag_from_string(const char *name, unsigned long *ret);
+3 -3
View File
@@ -1599,11 +1599,11 @@ static int parse_personality(const char *s, unsigned long *p) {
return 0;
}
static const char* mount_propagation_flags_to_string_with_check(unsigned long n) {
static const char* mount_propagation_flag_to_string_with_check(unsigned long n) {
if (!IN_SET(n, 0, MS_SHARED, MS_PRIVATE, MS_SLAVE))
return NULL;
return mount_propagation_flags_to_string(n);
return mount_propagation_flag_to_string(n);
}
static BUS_DEFINE_SET_TRANSIENT(nsec, "t", uint64_t, nsec_t, NSEC_FMT);
@@ -1624,7 +1624,7 @@ static BUS_DEFINE_SET_TRANSIENT_PARSE_PTR(personality, unsigned long, parse_pers
static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(secure_bits, "i", int32_t, int, "%" PRIi32, secure_bits_to_string_alloc_with_check);
static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(capability, "t", uint64_t, uint64_t, "%" PRIu64, capability_set_to_string_alloc);
static BUS_DEFINE_SET_TRANSIENT_TO_STRING_ALLOC(namespace_flag, "t", uint64_t, unsigned long, "%" PRIu64, namespace_flags_to_string);
static BUS_DEFINE_SET_TRANSIENT_TO_STRING(mount_flags, "t", uint64_t, unsigned long, "%" PRIu64, mount_propagation_flags_to_string_with_check);
static BUS_DEFINE_SET_TRANSIENT_TO_STRING(mount_flags, "t", uint64_t, unsigned long, "%" PRIu64, mount_propagation_flag_to_string_with_check);
int bus_exec_context_set_transient_property(
Unit *u,
+1 -1
View File
@@ -149,7 +149,7 @@ DEFINE_CONFIG_PARSE_PTR(config_parse_blockio_weight, cg_blkio_weight_parse, uint
DEFINE_CONFIG_PARSE_PTR(config_parse_cg_weight, cg_weight_parse, uint64_t, "Invalid weight");
DEFINE_CONFIG_PARSE_PTR(config_parse_cg_cpu_weight, cg_cpu_weight_parse, uint64_t, "Invalid CPU weight");
static DEFINE_CONFIG_PARSE_PTR(config_parse_cpu_shares_internal, cg_cpu_shares_parse, uint64_t, "Invalid CPU shares");
DEFINE_CONFIG_PARSE_PTR(config_parse_exec_mount_flags, mount_propagation_flags_from_string, unsigned long, "Failed to parse mount flag");
DEFINE_CONFIG_PARSE_PTR(config_parse_exec_mount_flags, mount_propagation_flag_from_string, unsigned long, "Failed to parse mount flag");
DEFINE_CONFIG_PARSE_ENUM_WITH_DEFAULT(config_parse_numa_policy, mpol, int, -1, "Invalid NUMA policy type");
DEFINE_CONFIG_PARSE_ENUM(config_parse_status_unit_format, status_unit_format, StatusUnitFormat, "Failed to parse status unit format");
DEFINE_CONFIG_PARSE_ENUM_FULL(config_parse_socket_timestamping, socket_timestamping_from_string_harder, SocketTimestamping, "Failed to parse timestamping precision");
+1 -1
View File
@@ -136,7 +136,7 @@ static int bus_print_property(const char *name, const char *expected_value, sd_b
} else if (streq(name, "MountFlags")) {
const char *result;
result = mount_propagation_flags_to_string(u);
result = mount_propagation_flag_to_string(u);
if (!result)
return -EINVAL;
+2 -2
View File
@@ -131,7 +131,7 @@ DEFINE_BUS_APPEND_PARSE_PTR("t", uint64_t, uint64_t, cg_blkio_weight_parse);
DEFINE_BUS_APPEND_PARSE_PTR("t", uint64_t, uint64_t, cg_cpu_shares_parse);
DEFINE_BUS_APPEND_PARSE_PTR("t", uint64_t, uint64_t, cg_weight_parse);
DEFINE_BUS_APPEND_PARSE_PTR("t", uint64_t, uint64_t, cg_cpu_weight_parse);
DEFINE_BUS_APPEND_PARSE_PTR("t", uint64_t, unsigned long, mount_propagation_flags_from_string);
DEFINE_BUS_APPEND_PARSE_PTR("t", uint64_t, unsigned long, mount_propagation_flag_from_string);
DEFINE_BUS_APPEND_PARSE_PTR("t", uint64_t, uint64_t, safe_atou64);
DEFINE_BUS_APPEND_PARSE_PTR("u", uint32_t, mode_t, parse_mode);
DEFINE_BUS_APPEND_PARSE_PTR("u", uint32_t, unsigned, safe_atou);
@@ -1035,7 +1035,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
return bus_append_safe_atou(m, field, eq);
if (streq(field, "MountFlags"))
return bus_append_mount_propagation_flags_from_string(m, field, eq);
return bus_append_mount_propagation_flag_from_string(m, field, eq);
if (STR_IN_SET(field, "Environment",
"UnsetEnvironment",
+11 -11
View File
@@ -17,19 +17,19 @@
#include "tests.h"
#include "tmpfile-util.h"
static void test_mount_propagation_flags_one(const char *name, int ret, unsigned long expected) {
static void test_mount_propagation_flag_one(const char *name, int ret, unsigned long expected) {
unsigned long flags;
log_info("/* %s(%s) */", __func__, strnull(name));
assert_se(mount_propagation_flags_from_string(name, &flags) == ret);
assert_se(mount_propagation_flag_from_string(name, &flags) == ret);
if (ret >= 0) {
const char *c;
assert_se(flags == expected);
c = mount_propagation_flags_to_string(flags);
c = mount_propagation_flag_to_string(flags);
if (isempty(name))
assert_se(isempty(c));
else
@@ -37,14 +37,14 @@ static void test_mount_propagation_flags_one(const char *name, int ret, unsigned
}
}
TEST(mount_propagation_flags) {
test_mount_propagation_flags_one("shared", 0, MS_SHARED);
test_mount_propagation_flags_one("slave", 0, MS_SLAVE);
test_mount_propagation_flags_one("private", 0, MS_PRIVATE);
test_mount_propagation_flags_one(NULL, 0, 0);
test_mount_propagation_flags_one("", 0, 0);
test_mount_propagation_flags_one("xxxx", -EINVAL, 0);
test_mount_propagation_flags_one(" ", -EINVAL, 0);
TEST(mount_propagation_flag) {
test_mount_propagation_flag_one("shared", 0, MS_SHARED);
test_mount_propagation_flag_one("slave", 0, MS_SLAVE);
test_mount_propagation_flag_one("private", 0, MS_PRIVATE);
test_mount_propagation_flag_one(NULL, 0, 0);
test_mount_propagation_flag_one("", 0, 0);
test_mount_propagation_flag_one("xxxx", -EINVAL, 0);
test_mount_propagation_flag_one(" ", -EINVAL, 0);
}
TEST(mnt_id) {