chiark / gitweb /
core,nspawn: unify code that moves the root dir
[elogind.git] / src / shared / util.h
index 1b3015115b4dc53e63a9e7829e031354bf66a655..4cea627580fd86586acdb5bee5f966e3dde32b0a 100644 (file)
@@ -352,10 +352,7 @@ char* dirname_malloc(const char *path);
 void sigset_add_many(sigset_t *ss, ...);
 int sigprocmask_many(int how, ...);
 
-bool hostname_is_set(void);
-
 char* lookup_uid(uid_t uid);
-char* gethostname_malloc(void);
 char* getlogname_malloc(void);
 char* getusername_malloc(void);
 
@@ -398,9 +395,6 @@ bool nulstr_contains(const char*nulstr, const char *needle);
 
 bool plymouth_running(void);
 
-bool hostname_is_valid(const char *s) _pure_;
-char* hostname_cleanup(char *s, bool lowercase);
-
 bool machine_name_is_valid(const char *s) _pure_;
 
 char* strshorten(char *s, size_t l);
@@ -788,6 +782,21 @@ static inline void qsort_safe(void *base, size_t nmemb, size_t size, comparison_
         qsort(base, nmemb, size, compar);
 }
 
+/* Normal memmem() requires haystack to be nonnull, which is annoying for zero-length buffers */
+static inline void *memmem_safe(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen) {
+
+        if (needlelen <= 0)
+                return (void*) haystack;
+
+        if (haystacklen < needlelen)
+                return NULL;
+
+        assert(haystack);
+        assert(needle);
+
+        return memmem(haystack, haystacklen, needle, needlelen);
+}
+
 int proc_cmdline(char **ret);
 int parse_proc_cmdline(int (*parse_word)(const char *key, const char *value));
 int get_proc_cmdline_key(const char *parameter, char **value);
@@ -832,12 +841,11 @@ int tempfn_xxxxxx(const char *p, char **ret);
 int tempfn_random(const char *p, char **ret);
 int tempfn_random_child(const char *p, char **ret);
 
-bool is_localhost(const char *hostname);
-
 int take_password_lock(const char *root);
 
 int is_symlink(const char *path);
 int is_dir(const char *path, bool follow);
+int is_device_node(const char *path);
 
 typedef enum UnquoteFlags {
         UNQUOTE_RELAX     = 1,
@@ -849,8 +857,6 @@ int unquote_many_words(const char **p, UnquoteFlags flags, ...) _sentinel_;
 
 int free_and_strdup(char **p, const char *s);
 
-int sethostname_idempotent(const char *s);
-
 #define INOTIFY_EVENT_MAX (sizeof(struct inotify_event) + NAME_MAX + 1)
 
 #define FOREACH_INOTIFY_EVENT(e, buffer, sz) \
@@ -898,3 +904,5 @@ int rename_noreplace(int olddirfd, const char *oldpath, int newdirfd, const char
 char *shell_maybe_quote(const char *s);
 
 int parse_mode(const char *s, mode_t *ret);
+
+int mount_move_root(const char *path);