summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/generator.c9
-rw-r--r--src/shared/util.c27
-rw-r--r--src/shared/util.h2
3 files changed, 28 insertions, 10 deletions
diff --git a/src/shared/generator.c b/src/shared/generator.c
index 49647c1ab6..61103031db 100644
--- a/src/shared/generator.c
+++ b/src/shared/generator.c
@@ -32,20 +32,23 @@ int generator_write_fsck_deps(
const char *dest,
const char *what,
const char *where,
- const char *type) {
+ const char *fstype) {
assert(f);
+ assert(dest);
+ assert(what);
+ assert(where);
if (!is_device_path(what)) {
log_warning("Checking was requested for \"%s\", but it is not a device.", what);
return 0;
}
- if (type && !streq(type, "auto")) {
+ if (!isempty(fstype) && !streq(fstype, "auto")) {
const char *checker;
int r;
- checker = strappenda("/sbin/fsck.", type);
+ checker = strappenda("/sbin/fsck.", fstype);
r = access(checker, X_OK);
if (r < 0) {
log_warning("Checking was requested for %s, but %s cannot be used: %m", what, checker);
diff --git a/src/shared/util.c b/src/shared/util.c
index cffa1abb30..d28caae6c2 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -3519,25 +3519,21 @@ int signal_from_string_try_harder(const char *s) {
static char *tag_to_udev_node(const char *tagvalue, const char *by) {
_cleanup_free_ char *t = NULL, *u = NULL;
- char *dn;
size_t enc_len;
u = unquote(tagvalue, "\"\'");
- if (u == NULL)
+ if (!u)
return NULL;
enc_len = strlen(u) * 4 + 1;
t = new(char, enc_len);
- if (t == NULL)
+ if (!t)
return NULL;
if (encode_devnode_name(u, t, enc_len) < 0)
return NULL;
- if (asprintf(&dn, "/dev/disk/by-%s/%s", by, t) < 0)
- return NULL;
-
- return dn;
+ return strjoin("/dev/disk/by-", by, "/", t, NULL);
}
char *fstab_node_to_udev_node(const char *p) {
@@ -6339,3 +6335,20 @@ uint64_t physical_memory(void) {
return (uint64_t) mem * (uint64_t) page_size();
}
+
+char* mount_test_option(const char *haystack, const char *needle) {
+
+ struct mntent me = {
+ .mnt_opts = (char*) haystack
+ };
+
+ assert(needle);
+
+ /* Like glibc's hasmntopt(), but works on a string, not a
+ * struct mntent */
+
+ if (!haystack)
+ return NULL;
+
+ return hasmntopt(&me, needle);
+}
diff --git a/src/shared/util.h b/src/shared/util.h
index cd166f6637..c2bc9771b9 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -893,3 +893,5 @@ unsigned long personality_from_string(const char *p);
const char *personality_to_string(unsigned long);
uint64_t physical_memory(void);
+
+char* mount_test_option(const char *haystack, const char *needle);